Skip to content
This repository
Browse code

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

  • Loading branch information...
commit b84024dc7887f9c6dbeb7cb643832430417678e8 1 parent fc7a4e7
Patrick Armstrong authored July 14, 2011
2  src/python/epumgmt/defaults/svc_adapter.py
@@ -372,7 +372,7 @@ def _intake_query_result_from_file(self, local_filename):
372 372
                 iaas_state_time = info['instances'][nodeid]['iaas_state_time']
373 373
                 wis.iaas_state_time = int(iaas_state_time)
374 374
 
375  
-                wis.hearbeat_state = info['instances'][nodeid]['heartbeat_state']
  375
+                wis.heartbeat_state = info['instances'][nodeid]['heartbeat_state']
376 376
                 heartbeat_time = info['instances'][nodeid]['heartbeat_time']
377 377
                 wis.heartbeat_time = int(heartbeat_time)
378 378
 
45  src/python/tests/test_epumgmt_defaults_svc_adapter.py
@@ -172,6 +172,51 @@ def test_reconcile_relative_conf(self):
172 172
         got_path = self.svc_adapter._reconcile_relative_conf(relative_dir, user, "")
173 173
         assert got_path == "/home/%s/%s" % (user, relative_dir)
174 174
 
  175
+    def test_intake_query_result_from_file(self):
  176
+
  177
+        controller_name = "test-controller"
  178
+        de_state = "STABLE_DE"
  179
+        de_conf_report = "balala"
  180
+        last_queuelen_size = 5
  181
+        last_queuelen_time = 1234
  182
+        instance_0 = "fashfjsahfjksa"
  183
+        instance_0_state = "600-RUNNING"
  184
+        iaas_state_time = 12312142
  185
+        heartbeat_state = "SOMETHING"
  186
+        heartbeat_time = 5
  187
+
  188
+
  189
+        (json_file, json_filename) = tempfile.mkstemp()
  190
+        os.close(json_file)
  191
+        test_json = """
  192
+        {"%s": {"de_state":"%s", "de_conf_report":"%s", "last_queuelen_size":%s,
  193
+         "last_queuelen_time": %s,
  194
+         "instances": {
  195
+           "%s": {"iaas_state":"%s", "iaas_state_time": %s,
  196
+                  "heartbeat_state":"%s", "heartbeat_time": %s}}}}
  197
+        """ % (controller_name, de_state, de_conf_report, last_queuelen_size,
  198
+              last_queuelen_time, instance_0, instance_0_state, iaas_state_time,
  199
+              heartbeat_state, heartbeat_time)
  200
+
  201
+        with open(json_filename, "w") as j_file:
  202
+            j_file.write(test_json)
  203
+
  204
+        map = self.svc_adapter._intake_query_result_from_file(json_filename)
  205
+
  206
+        # Test that all our values are correct
  207
+        assert map.has_key(controller_name)
  208
+        controller = map[controller_name]
  209
+        assert controller.de_state == de_state
  210
+        assert controller.de_conf_report == de_conf_report
  211
+        assert controller.last_queuelen_size == last_queuelen_size
  212
+        assert controller.last_queuelen_time == last_queuelen_time
  213
+        assert len(controller.instances) == 1
  214
+        instance = controller.instances[0]
  215
+        assert instance.nodeid == instance_0
  216
+        assert instance.iaas_state == instance_0_state
  217
+        assert instance.iaas_state_time == iaas_state_time
  218
+        assert instance.heartbeat_state == heartbeat_state
  219
+        assert instance.heartbeat_time == heartbeat_time
175 220
 
176 221
 def make_fake_run_one_cmd(target, real_run_one_cmd):
177 222
     def fake_run_one_cmd(target, cmd):

0 notes on commit b84024d

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