Skip to content

Commit 4111810

Browse files
committed
status: rename scenarios_active to more accurate scenarios_deployed
1 parent 1dfa773 commit 4111810

File tree

5 files changed

+18
-43
lines changed

5 files changed

+18
-43
lines changed

src/warnet/control.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,11 @@
2727

2828
console = Console()
2929

30-
31-
def get_active_scenarios():
32-
"""Get list of active scenarios"""
33-
commanders = get_mission("commander")
34-
return [c.metadata.name for c in commanders]
35-
36-
3730
@click.command()
3831
@click.argument("scenario_name", required=False)
3932
def stop(scenario_name):
4033
"""Stop a running scenario or all scenarios"""
41-
active_scenarios = get_active_scenarios()
34+
active_scenarios = [sc.metadata.name for sc in get_mission("commander")]
4235

4336
if not active_scenarios:
4437
console.print("[bold red]No active scenarios found.[/bold red]")
@@ -108,24 +101,6 @@ def stop_all_scenarios(scenarios):
108101
console.print("[bold green]All scenarios have been stopped.[/bold green]")
109102

110103

111-
def list_active_scenarios():
112-
"""List all active scenarios"""
113-
active_scenarios = get_active_scenarios()
114-
if not active_scenarios:
115-
print("No active scenarios found.")
116-
return
117-
118-
console = Console()
119-
table = Table(title="Active Scenarios", show_header=True, header_style="bold magenta")
120-
table.add_column("Name", style="cyan")
121-
table.add_column("Status", style="green")
122-
123-
for scenario in active_scenarios:
124-
table.add_row(scenario, "deployed")
125-
126-
console.print(table)
127-
128-
129104
@click.command()
130105
def down():
131106
"""Bring down a running warnet quickly"""

src/warnet/status.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def status():
1414
console = Console()
1515

1616
tanks = _get_tank_status()
17-
scenarios = _get_active_scenarios()
17+
scenarios = _get_deployed_scenarios()
1818

1919
# Create a unified table
2020
table = Table(title="Warnet Status", show_header=True, header_style="bold magenta")
@@ -62,6 +62,6 @@ def _get_tank_status():
6262
return [{"name": tank.metadata.name, "status": tank.status.phase.lower()} for tank in tanks]
6363

6464

65-
def _get_active_scenarios():
65+
def _get_deployed_scenarios():
6666
commanders = get_mission("commander")
6767
return [{"name": c.metadata.name, "status": c.status.phase.lower()} for c in commanders]

test/scenarios_test.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from warnet.control import stop_scenario
99
from warnet.process import run_command
10-
from warnet.status import _get_active_scenarios as scenarios_active
10+
from warnet.status import _get_deployed_scenarios as scenarios_deployed
1111

1212

1313
class ScenariosTest(TestBase):
@@ -32,22 +32,22 @@ def setup_network(self):
3232

3333
def scenario_running(self, scenario_name: str):
3434
"""Check that we are only running a single scenario of the correct name"""
35-
active = scenarios_active()
36-
assert len(active) == 1
37-
return scenario_name in active[0]["name"]
35+
deployed = scenarios_deployed()
36+
assert len(deployed) == 1
37+
return scenario_name in deployed[0]["name"]
3838

3939
def check_scenario_stopped(self):
40-
running = scenarios_active()
40+
running = scenarios_deployed()
4141
self.log.debug(f"Checking if scenario stopped. Running scenarios: {len(running)}")
4242
return len(running) == 0
4343

4444
def check_scenario_clean_exit(self):
45-
active = scenarios_active()
46-
return all(scenario["status"] == "succeeded" for scenario in active)
45+
deployed = scenarios_deployed()
46+
return all(scenario["status"] == "succeeded" for scenario in deployed)
4747

4848
def stop_scenario(self):
4949
self.log.info("Stopping running scenario")
50-
running = scenarios_active()
50+
running = scenarios_deployed()
5151
assert len(running) == 1, f"Expected one running scenario, got {len(running)}"
5252
assert running[0]["status"] == "running", "Scenario should be running"
5353
stop_scenario(running[0]["name"])
@@ -58,8 +58,8 @@ def check_blocks(self, target_blocks, start: int = 0):
5858
self.log.debug(f"Current block count: {count}, target: {start + target_blocks}")
5959

6060
try:
61-
active = scenarios_active()
62-
commander = active[0]["commander"]
61+
deployed = scenarios_deployed()
62+
commander = deployed[0]["commander"]
6363
command = f"kubectl logs {commander}"
6464
print("\ncommander output:")
6565
print(run_command(command))

test/signet_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from test_base import TestBase
88

9-
from warnet.status import _get_active_scenarios as scenarios_active
9+
from warnet.status import _get_deployed_scenarios as scenarios_deployed
1010

1111

1212
class SignetTest(TestBase):
@@ -55,8 +55,8 @@ def check_signet_recon(self):
5555
self.warnet(f"run {scenario_file}")
5656

5757
def check_scenario_clean_exit():
58-
active = scenarios_active()
59-
return all(scenario["status"] == "succeeded" for scenario in active)
58+
deployed = scenarios_deployed()
59+
return all(scenario["status"] == "succeeded" for scenario in deployed)
6060

6161
self.wait_for_predicate(check_scenario_clean_exit)
6262

test/test_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
from time import sleep
1111

1212
from warnet import SRC_DIR
13-
from warnet.control import get_active_scenarios
1413
from warnet.k8s import get_pod_exit_status
1514
from warnet.network import _connected as network_connected
1615
from warnet.status import _get_tank_status as network_status
16+
from warnet.status import _get_deployed_scenarios as scenarios_deployed
1717

1818

1919
class TestBase:
@@ -126,7 +126,7 @@ def wait_for_all_edges(self, timeout=20 * 60, interval=5):
126126

127127
def wait_for_all_scenarios(self):
128128
def check_scenarios():
129-
scns = get_active_scenarios()
129+
scns = scenarios_deployed()
130130
if len(scns) == 0:
131131
return True
132132
for s in scns:

0 commit comments

Comments
 (0)