Skip to content

Commit

Permalink
HM: integtest are more and they pass
Browse files Browse the repository at this point in the history
  • Loading branch information
mhasself committed Sep 14, 2023
1 parent 44101ac commit 0304a81
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
3 changes: 3 additions & 0 deletions tests/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@ hosts:
'arguments': []},
{'agent-class': 'FakeDataAgent',
'instance-id': 'fake-data-local',
'manage': 'host/down',
'arguments': [['--mode', 'idle'],
['--num-channels', '16'],
['--sample-rate', '5'],
['--frame-length', '10']]},
{'agent-class': 'RegistryAgent',
'instance-id': 'registry',
'manage': 'host/up',
'arguments': []},
{'agent-class': 'AggregatorAgent',
'instance-id': 'aggregator-local',
'manage': 'ignore',
'arguments': [['--initial-state', 'idle'],
['--time-per-file', '30'],
['--data-dir', '/tmp/data/']]},
Expand Down
30 changes: 26 additions & 4 deletions tests/integration/test_host_manager_agent_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,35 @@ def find_child(resp, instance_id):
return v
raise ValueError

target = 'fake-data-local'
# Check whether managed agents are getting to their requested
# initial state. The expectations here are matched to manage:
# settings in default.yaml. We check the "up" ones first, because
# once we've waited for those to come up we've probably waited
# long enough to ensure the 'down' ones aren't going to also come
# up unexpectedly.

state = find_child(resp, target)
assert (state['target_state'] == 'down')
assert (state['next_action'] == 'down')
timeout = time.time() + 10
for target, is_managed, init_state in [
('registry', True, 'up'),
('influxagent-local', True, 'up'),
('fake-data-local', True, 'down'),
('aggregator-local', False, None),
]:
print(f'Waiting for {target} ...')
if is_managed:
while time.time() < timeout:
resp = client.manager.status()
state = find_child(resp, target)
if state['next_action'] == init_state:
break
time.sleep(.5)
assert state['target_state'] == init_state
else:
with pytest.raises(ValueError):
state = find_child(resp, target)

# Start it up
target = 'fake-data-local'
resp = client.update(requests=[(target, 'up')])
print(resp)

Expand Down

0 comments on commit 0304a81

Please sign in to comment.