Use AmuletUtils.status_get in tests.

This commit is contained in:
Geoffrey J. Teale 2015-09-10 14:30:38 +02:00
parent d51109324c
commit 22c16003e7

View File

@ -3,25 +3,6 @@
import basic_deployment
from charmhelpers.contrib.amulet.utils import AmuletUtils
# from charmhelpers.core.hookenv import status_get
def status_get(unit):
import json
raw_status, return_code = unit.run("status-get --format=json")
status = json.loads(raw_status)
return (status["status"], status.get("message", ""))
# status = json.loads(raw_status.decode("UTF-8"))
# return (status["status"], status["message"])
# import subprocess
# import json
# cmd = ["juju", "run", "--unit", "percona-cluster/0",
# "'status-get'"]
# raw_status = subprocess.check_output(cmd)
# # status = json.loads(raw_status.decode("UTF-8"))
# status = raw_status.decode("UTF-8")
# return (status["status"], "")
utils = AmuletUtils()
@ -33,7 +14,7 @@ class PauseResume(basic_deployment.BasicDeployment):
uid = 'percona-cluster/0'
unit = self.d.sentry.unit[uid]
assert self.is_mysqld_running(unit), 'mysql not running: %s' % uid
assert status_get(unit)[0] == "unknown"
assert utils.status_get(unit)[0] == "unknown"
action_id = utils.run_action(unit, "pause")
assert utils.wait_on_action(action_id), "Pause action failed."
@ -48,10 +29,10 @@ class PauseResume(basic_deployment.BasicDeployment):
assert "mysql.override" in init_contents["files"], \
"Override file not created."
assert status_get(unit)[0] == "maintenance"
assert utils.status_get(unit)[0] == "maintenance"
action_id = utils.run_action(unit, "resume")
assert utils.wait_on_action(action_id), "Resume action failed"
assert status_get(unit)[0] == "active"
assert utils.status_get(unit)[0] == "active"
init_contents = unit.directory_contents("/etc/init/")
assert "mysql.override" not in init_contents["files"], \
"Override file not removed."