107
110
endpoint_type='publicURL')
108
111
self.ceil = ceilclient.Client(endpoint=ep, token=self._get_token)
113
def _run_action(self, unit_id, action, *args):
114
command = ["juju", "action", "do", "--format=json", unit_id, action]
116
print("Running command: %s\n" % " ".join(command))
117
output = subprocess.check_output(command)
118
output_json = output.decode(encoding="UTF-8")
119
data = json.loads(output_json)
120
action_id = data[u'Action queued with id']
123
def _wait_on_action(self, action_id):
124
command = ["juju", "action", "fetch", "--format=json", action_id]
127
output = subprocess.check_output(command)
128
except Exception as e:
131
output_json = output.decode(encoding="UTF-8")
132
data = json.loads(output_json)
133
if data[u"status"] == "completed":
135
elif data[u"status"] == "failed":
110
139
def test_100_services(self):
111
140
"""Verify the expected services are running on the corresponding
112
141
service units."""
571
600
self.d.configure(juju_service, set_default)
602
def test_1000_pause_and_resume(self):
603
"""The services can be paused and resumed. """
604
unit_name = "ceilometer/0"
605
unit = self.d.sentry.unit[unit_name]
607
assert u.status_get(unit)[0] == "unknown"
609
action_id = self._run_action(unit_name, "pause")
610
assert self._wait_on_action(action_id), "Pause action failed."
611
assert u.status_get(unit)[0] == "maintenance"
613
action_id = self._run_action(unit_name, "resume")
614
assert self._wait_on_action(action_id), "Resume action failed."
615
assert u.status_get(unit)[0] == "active"