~celebdor/charms/trusty/neutron-api/plugin_pkg_fix

« back to all changes in this revision

Viewing changes to tests/charmhelpers/contrib/openstack/amulet/deployment.py

  • Committer: Liam Young
  • Date: 2015-10-19 06:36:41 UTC
  • mfrom: (152.1.5 neutron-api)
  • Revision ID: liam.young@canonical.com-20151019063641-leixdk02j0dnv2g0
Tags: 15.10
[1chb1n, r=gnuoy] Update amulet tests for Trusty-Liberty, Wily-Liberty.

Sync charmhelpers.

Add service and relations to satisfy workload status ready state.

Add new logic to wait for extended status message to confirm deploy is ready, before testing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# You should have received a copy of the GNU Lesser General Public License
15
15
# along with charm-helpers.  If not, see <http://www.gnu.org/licenses/>.
16
16
 
 
17
import re
17
18
import six
18
19
from collections import OrderedDict
19
20
from charmhelpers.contrib.amulet.deployment import (
114
115
        for service, config in six.iteritems(configs):
115
116
            self.d.configure(service, config)
116
117
 
 
118
    def _auto_wait_for_status(self, message=None, exclude_services=None,
 
119
                              timeout=1800):
 
120
        """Wait for all units to have a specific extended status, except
 
121
        for any defined as excluded.  Unless specified via message, any
 
122
        status containing any case of 'ready' will be considered a match.
 
123
 
 
124
        Examples of message usage:
 
125
 
 
126
          Wait for all unit status to CONTAIN any case of 'ready' or 'ok':
 
127
              message = re.compile('.*ready.*|.*ok.*', re.IGNORECASE)
 
128
 
 
129
          Wait for all units to reach this status (exact match):
 
130
              message = 'Unit is ready'
 
131
 
 
132
          Wait for all units to reach any one of these (exact match):
 
133
              message = re.compile('Unit is ready|OK|Ready')
 
134
 
 
135
          Wait for at least one unit to reach this status (exact match):
 
136
              message = {'ready'}
 
137
 
 
138
        See Amulet's sentry.wait_for_messages() for message usage detail.
 
139
        https://github.com/juju/amulet/blob/master/amulet/sentry.py
 
140
 
 
141
        :param message: Expected status match
 
142
        :param exclude_services: List of juju service names to ignore
 
143
        :param timeout: Maximum time in seconds to wait for status match
 
144
        :returns: None.  Raises if timeout is hit.
 
145
        """
 
146
 
 
147
        if not message:
 
148
            message = re.compile('.*ready.*', re.IGNORECASE)
 
149
 
 
150
        if not exclude_services:
 
151
            exclude_services = []
 
152
 
 
153
        services = list(set(self.d.services.keys()) - set(exclude_services))
 
154
        service_messages = {service: message for service in services}
 
155
        self.d.sentry.wait_for_messages(service_messages, timeout=timeout)
 
156
 
117
157
    def _get_openstack_release(self):
118
158
        """Get openstack release.
119
159