Merge lp:~1chb1n/charms/trusty/cinder-ceph/next-amulet-relation-settle into lp:~openstack-charmers-archive/charms/trusty/cinder-ceph/next

Proposed by Ryan Beisner on 2015-07-02
Status: Work in progress
Proposed branch: lp:~1chb1n/charms/trusty/cinder-ceph/next-amulet-relation-settle
Merge into: lp:~openstack-charmers-archive/charms/trusty/cinder-ceph/next
Diff against target: 88 lines (+48/-5)
2 files modified
tests/basic_deployment.py (+2/-5)
tests/charmhelpers/contrib/amulet/utils.py (+46/-0)
To merge this branch: bzr merge lp:~1chb1n/charms/trusty/cinder-ceph/next-amulet-relation-settle
Reviewer Review Type Date Requested Status
Ryan Beisner Disapprove on 2015-07-13
Corey Bryant 2015-07-02 Pending
Review via email: mp+263716@code.launchpad.net

Description of the Change

Amulet tests (in general) are sometimes racey when the test rig is under higher load, as the relations may not have settled before tests begin.

Instead of an arbitary sleep time after deployment is "complete," use the same logic we use in openstack-mojo-testing (a juju run -all XYZ check) before proceeding.

Ex. http://paste.ubuntu.com/11812413/ ... unexpected relation data in cinder cinder-ceph storage-backend - key 'broker_rsp' does not exist

This MP is dependent on c-h changes @ https://code.launchpad.net/~1chb1n/charm-helpers/amulet-relations-settled/+merge/263724

To post a comment you must log in.

charm_lint_check #5729 cinder-ceph-next for 1chb1n mp263716
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/5729/

charm_unit_test #5361 cinder-ceph-next for 1chb1n mp263716
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/5361/

36. By Ryan Beisner on 2015-07-02

use juju run all (a la openstack-mojo-specs) instead of arbitrary sleep; resync tests/charmhelpers

charm_lint_check #5730 cinder-ceph-next for 1chb1n mp263716
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/5730/

charm_unit_test #5362 cinder-ceph-next for 1chb1n mp263716
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/5362/

charm_amulet_test #4923 cinder-ceph-next for 1chb1n mp263716
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/4923/

charm_amulet_test #4928 cinder-ceph-next for 1chb1n mp263716
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/11813598/
Build: http://10.245.162.77:8080/job/charm_amulet_test/4928/

charm_amulet_test #4925 cinder-ceph-next for 1chb1n mp263716
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/4925/

charm_amulet_test #4927 cinder-ceph-next for 1chb1n mp263716
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/4927/

charm_amulet_test #4926 cinder-ceph-next for 1chb1n mp263716
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/4926/

charm_amulet_test #4924 cinder-ceph-next for 1chb1n mp263716
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/4924/

charm_amulet_test #4993 cinder-ceph-next for 1chb1n mp263716
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/4993/

charm_amulet_test #4996 cinder-ceph-next for 1chb1n mp263716
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/4996/

charm_amulet_test #4995 cinder-ceph-next for 1chb1n mp263716
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/4995/

charm_amulet_test #4994 cinder-ceph-next for 1chb1n mp263716
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/4994/

charm_amulet_test #4997 cinder-ceph-next for 1chb1n mp263716
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/4997/

Ryan Beisner (1chb1n) wrote :

Before these changes, in a looped local test run, appx 1 in 4 tests failed with the relation data issue.

With these changes, 15 of 15 local test runs succeeded.

37. By Ryan Beisner on 2015-07-09

resync tests/charmhelpers

charm_lint_check #5901 cinder-ceph-next for 1chb1n mp263716
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/5901/

charm_unit_test #5533 cinder-ceph-next for 1chb1n mp263716
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/5533/

charm_amulet_test #5014 cinder-ceph-next for 1chb1n mp263716
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/5014/

Corey Bryant (corey.bryant) wrote :

Looks good, I'll approve once the c-h portion lands.

charm_amulet_test #5025 cinder-ceph-next for 1chb1n mp263716
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/11852192/
Build: http://10.245.162.77:8080/job/charm_amulet_test/5025/

charm_amulet_test #5026 cinder-ceph-next for 1chb1n mp263716
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/11852198/
Build: http://10.245.162.77:8080/job/charm_amulet_test/5026/

charm_amulet_test #5028 cinder-ceph-next for 1chb1n mp263716
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/11852202/
Build: http://10.245.162.77:8080/job/charm_amulet_test/5028/

charm_amulet_test #5029 cinder-ceph-next for 1chb1n mp263716
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/11852210/
Build: http://10.245.162.77:8080/job/charm_amulet_test/5029/

charm_amulet_test #5027 cinder-ceph-next for 1chb1n mp263716
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
Timeout occurred (2700s), printing juju status...environment: osci-sv05
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/11852211/
Build: http://10.245.162.77:8080/job/charm_amulet_test/5027/

Ryan Beisner (1chb1n) wrote :

^^ Amulet test builds #5025 - 5029 #undercloud-fail

Will re-run after confirming test rig's undercloud health...

charm_amulet_test #5032 cinder-ceph-next for 1chb1n mp263716
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/11855935/
Build: http://10.245.162.77:8080/job/charm_amulet_test/5032/

charm_amulet_test #5033 cinder-ceph-next for 1chb1n mp263716
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/5033/

charm_amulet_test #5034 cinder-ceph-next for 1chb1n mp263716
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/5034/

Ryan Beisner (1chb1n) wrote :

^ 1 of 3 failed with the relation settling race, with the 2nd remote run check removed, the test race condition re-appeared. So I added it back, which also keeps the approach in line with the same in openstack mojo specs.

38. By Ryan Beisner on 2015-07-13

resync tests/charmhelpers

charm_lint_check #6111 cinder-ceph-next for 1chb1n mp263716
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/6111/

charm_unit_test #5743 cinder-ceph-next for 1chb1n mp263716
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/5743/

charm_amulet_test #5097 cinder-ceph-next for 1chb1n mp263716
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/11872749/
Build: http://10.245.162.77:8080/job/charm_amulet_test/5097/

charm_amulet_test #5099 cinder-ceph-next for 1chb1n mp263716
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/11873035/
Build: http://10.245.162.77:8080/job/charm_amulet_test/5099/

Ryan Beisner (1chb1n) wrote :

Abandoning this as the juju run twice approach appears to no longer be effective.

I disapprove. ;-)

review: Disapprove

charm_amulet_test #5100 cinder-ceph-next for 1chb1n mp263716
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/5100/

charm_amulet_test #5098 cinder-ceph-next for 1chb1n mp263716
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/5098/

Unmerged revisions

38. By Ryan Beisner on 2015-07-13

resync tests/charmhelpers

37. By Ryan Beisner on 2015-07-09

resync tests/charmhelpers

36. By Ryan Beisner on 2015-07-02

use juju run all (a la openstack-mojo-specs) instead of arbitrary sleep; resync tests/charmhelpers

35. By Ryan Beisner on 2015-07-02

increase initial wait

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/basic_deployment.py'
2--- tests/basic_deployment.py 2015-06-30 20:40:06 +0000
3+++ tests/basic_deployment.py 2015-07-13 14:04:38 +0000
4@@ -103,9 +103,6 @@
5 def _initialize_tests(self):
6 """Perform final initialization before tests get run."""
7 # Access the sentries for inspecting service units
8- u.log.debug('!!!!!')
9- u.log.debug(dir(self.d.sentry))
10-
11 self.mysql_sentry = self.d.sentry.unit['mysql/0']
12 self.keystone_sentry = self.d.sentry.unit['keystone/0']
13 self.rabbitmq_sentry = self.d.sentry.unit['rabbitmq-server/0']
14@@ -119,8 +116,8 @@
15 u.log.debug('openstack release str: {}'.format(
16 self._get_openstack_release_string()))
17
18- # Let things settle a bit original moving forward
19- time.sleep(30)
20+ # Make sure relations have settled, raise exception if not
21+ u.check_hooks_are_settled()
22
23 # Authenticate admin with keystone
24 self.keystone = u.authenticate_keystone_admin(self.keystone_sentry,
25
26=== modified file 'tests/charmhelpers/contrib/amulet/utils.py'
27--- tests/charmhelpers/contrib/amulet/utils.py 2015-06-29 14:33:37 +0000
28+++ tests/charmhelpers/contrib/amulet/utils.py 2015-07-13 14:04:38 +0000
29@@ -22,9 +22,11 @@
30 import os
31 import re
32 import six
33+import subprocess
34 import sys
35 import time
36 import urlparse
37+import yaml
38
39
40 class AmuletUtils(object):
41@@ -531,3 +533,47 @@
42 return 'Dicts within list are not identical'
43
44 return None
45+
46+ def _remote_shell_check(self, unit, timeout='2m0s'):
47+ """Check that a juju run shell command succeeds on a juju unit."""
48+ cmd = ['juju', 'run', '--timeout', timeout,
49+ '--unit', unit, 'uname -a']
50+ fnull = open(os.devnull, 'w')
51+ return not subprocess.call(cmd, stdout=fnull, stderr=subprocess.STDOUT)
52+
53+ def _remote_runs(self, units, timeout='2m0s'):
54+ """Check that juju run succeeds against a list of units."""
55+ self.log.debug('Checking juju run command completion on '
56+ 'units: {}'.format(units))
57+ for unit in units:
58+ if not self._remote_shell_check(unit, timeout):
59+ msg = 'Juju run failed or timed out on {}'.format(unit)
60+ amulet.raise_status(amulet.FAIL, msg=msg)
61+ self.log.debug('Units completed juju run command checks OK.')
62+
63+ def get_juju_status(self):
64+ """Get juju status yaml data, return as dictionary."""
65+ self.log.debug('Getting juju status yaml data...')
66+ cmd = ['juju', 'status', '--format', 'yaml']
67+ status_file = subprocess.Popen(cmd, stdout=subprocess.PIPE).stdout
68+ return yaml.load(status_file)
69+
70+ def get_juju_units(self):
71+ """Get a list of juju units from juju status output."""
72+ self.log.debug('Getting juju unit list from juju status data...')
73+ juju_status = self.get_juju_status()
74+ units = []
75+ services = [svc for svc in juju_status['services']]
76+ for svc in services:
77+ if 'units' in juju_status['services'][svc]:
78+ for unit in juju_status['services'][svc]['units']:
79+ units.append(unit)
80+ return units
81+
82+ def check_hooks_are_settled(self, timeout='2m0s'):
83+ """Use juju run (twice) against all units as an indicator that
84+ hooks are done. Raise exception if any unit fails or times out."""
85+ self.log.info('Checking that juju hooks appear to be complete...')
86+ juju_units = self.get_juju_units()
87+ self._remote_runs(juju_units, timeout)
88+ self._remote_runs(juju_units, timeout)

Subscribers

People subscribed via source and target branches