Skip to content

Commit

Permalink
NBSDUTY-57: fix test_add_host_with_legacy_local_ssd (#1805)
Browse files Browse the repository at this point in the history
  • Loading branch information
sharpeye authored Aug 17, 2024
1 parent f2f7971 commit 64c058d
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions cloud/blockstore/tests/local_ssd/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ def _wait_for_devices_to_be_cleared(client, expected_dirty_count=0):
time.sleep(1)


def _wait_agent_state(client, agent_id, desired_state):
while True:
bkp = _backup(client)
agent = [x for x in bkp["Agents"] if x['AgentId'] == agent_id]
assert len(agent) == 1

if agent[0].get("State") == desired_state:
break
time.sleep(1)


@pytest.fixture(name='ydb')
def start_ydb_cluster():

Expand Down Expand Up @@ -282,15 +293,14 @@ def test_add_host_with_legacy_local_ssd(
assert not disk_agent.is_alive()

# wait for DR to mark the agent as unavailable
while True:
bkp = _backup(client)
if bkp["Agents"][0].get("State") == 'AGENT_STATE_UNAVAILABLE':
break
time.sleep(1)
_wait_agent_state(client, agent_id, 'AGENT_STATE_UNAVAILABLE')

disk_agent = start_disk_agent(disk_agent_config, name='disk-agent.2')
assert disk_agent.wait_for_registration()

# wait for DR to mark the agent as warning (back from unavailable)
_wait_agent_state(client, agent_id, 'AGENT_STATE_WARNING')

bkp = _backup(client)
assert bkp["Agents"][0]["State"] == 'AGENT_STATE_WARNING', json.dumps(bkp)
assert len(bkp.get("SuspendedDevices", [])) == 4
Expand Down Expand Up @@ -423,15 +433,14 @@ def test_add_host(
assert not disk_agent.is_alive()

# wait for DR to mark the agent as unavailable
while True:
bkp = _backup(client)
if bkp["Agents"][0].get("State") == 'AGENT_STATE_UNAVAILABLE':
break
time.sleep(1)
_wait_agent_state(client, agent_id, 'AGENT_STATE_UNAVAILABLE')

disk_agent = start_disk_agent(disk_agent_config, name='disk-agent.2')
assert disk_agent.wait_for_registration()

# wait for DR to mark the agent as warning (back from unavailable)
_wait_agent_state(client, agent_id, 'AGENT_STATE_WARNING')

bkp = _backup(client)
assert bkp["Agents"][0]["State"] == 'AGENT_STATE_WARNING', json.dumps(bkp)
assert len(bkp.get("SuspendedDevices", [])) == 4
Expand Down

0 comments on commit 64c058d

Please sign in to comment.