Permalink
Browse files

Make ha test subscribe to events immediately after starting agent

This prevents the test from losing events
  • Loading branch information...
1 parent a857735 commit 3f4b460d2bd01aaf374d1feb036a12b8574b6d3a @oldpatricka oldpatricka committed Oct 1, 2012
Showing with 3 additions and 7 deletions.
  1. +3 −7 ion/agents/cei/test/test_haagent.py
@@ -99,6 +99,7 @@ def setUp(self):
self._haa_pid = self.container_client.spawn_process(name=self._haa_name,
module="ion.agents.cei.high_availability_agent",
cls="HighAvailabilityAgent", config=self._haa_config)
+ self.subscribe_events(None)
# Start a resource agent client to talk with the instrument agent.
self._haa_pyon_client = SimpleResourceAgentClient(self.resource_id, process=FakeProcess())
@@ -153,7 +154,6 @@ def test_features(self):
result = self.haa_client.dump().result
self.assertEqual(result['policy'], new_policy)
- self.subscribe_events(None)
self.await_state_event("test", ProcessStateEnum.SPAWN)
self.assertEqual(len(self.get_running_procs()), 1)
@@ -339,6 +339,7 @@ def setUp(self):
self._haa_pid = self.container_client.spawn_process(name=self._haa_name,
module="ion.agents.cei.high_availability_agent",
cls="HighAvailabilityAgent", config=self._haa_config)
+ self.subscribe_events(None)
# Start a resource agent client to talk with the instrument agent.
self._haa_pyon_client = SimpleResourceAgentClient(self.resource_id, process=FakeProcess())
@@ -396,12 +397,7 @@ def test_sensor_policy(self):
# Ensure HA hasn't already failed
assert status in ('PENDING', 'READY', 'STEADY')
- self.subscribe_events(None)
- try:
- self.await_state_event("test", ProcessStateEnum.SPAWN)
- except (AssertionError, Empty), e:
- if len(self.get_running_procs()) != 1:
- raise e
+ self.await_state_event("test", ProcessStateEnum.SPAWN)
self.assertEqual(len(self.get_running_procs()), 1)

0 comments on commit 3f4b460

Please sign in to comment.