Skip to content
Browse files

Add some more tests for svc_adapter, fix typo bug in same.

  • Loading branch information...
1 parent fc7a4e7 commit b84024dc7887f9c6dbeb7cb643832430417678e8 @oldpatricka oldpatricka committed Jul 14, 2011
View
2 src/python/epumgmt/defaults/svc_adapter.py
@@ -372,7 +372,7 @@ def _intake_query_result_from_file(self, local_filename):
iaas_state_time = info['instances'][nodeid]['iaas_state_time']
wis.iaas_state_time = int(iaas_state_time)
- wis.hearbeat_state = info['instances'][nodeid]['heartbeat_state']
+ wis.heartbeat_state = info['instances'][nodeid]['heartbeat_state']
heartbeat_time = info['instances'][nodeid]['heartbeat_time']
wis.heartbeat_time = int(heartbeat_time)
View
45 src/python/tests/test_epumgmt_defaults_svc_adapter.py
@@ -172,6 +172,51 @@ def test_reconcile_relative_conf(self):
got_path = self.svc_adapter._reconcile_relative_conf(relative_dir, user, "")
assert got_path == "/home/%s/%s" % (user, relative_dir)
+ def test_intake_query_result_from_file(self):
+
+ controller_name = "test-controller"
+ de_state = "STABLE_DE"
+ de_conf_report = "balala"
+ last_queuelen_size = 5
+ last_queuelen_time = 1234
+ instance_0 = "fashfjsahfjksa"
+ instance_0_state = "600-RUNNING"
+ iaas_state_time = 12312142
+ heartbeat_state = "SOMETHING"
+ heartbeat_time = 5
+
+
+ (json_file, json_filename) = tempfile.mkstemp()
+ os.close(json_file)
+ test_json = """
+ {"%s": {"de_state":"%s", "de_conf_report":"%s", "last_queuelen_size":%s,
+ "last_queuelen_time": %s,
+ "instances": {
+ "%s": {"iaas_state":"%s", "iaas_state_time": %s,
+ "heartbeat_state":"%s", "heartbeat_time": %s}}}}
+ """ % (controller_name, de_state, de_conf_report, last_queuelen_size,
+ last_queuelen_time, instance_0, instance_0_state, iaas_state_time,
+ heartbeat_state, heartbeat_time)
+
+ with open(json_filename, "w") as j_file:
+ j_file.write(test_json)
+
+ map = self.svc_adapter._intake_query_result_from_file(json_filename)
+
+ # Test that all our values are correct
+ assert map.has_key(controller_name)
+ controller = map[controller_name]
+ assert controller.de_state == de_state
+ assert controller.de_conf_report == de_conf_report
+ assert controller.last_queuelen_size == last_queuelen_size
+ assert controller.last_queuelen_time == last_queuelen_time
+ assert len(controller.instances) == 1
+ instance = controller.instances[0]
+ assert instance.nodeid == instance_0
+ assert instance.iaas_state == instance_0_state
+ assert instance.iaas_state_time == iaas_state_time
+ assert instance.heartbeat_state == heartbeat_state
+ assert instance.heartbeat_time == heartbeat_time
def make_fake_run_one_cmd(target, real_run_one_cmd):
def fake_run_one_cmd(target, cmd):

0 comments on commit b84024d

Please sign in to comment.
Something went wrong with that request. Please try again.