88
99from warnet .k8s import get_kubeconfig_value
1010from warnet .process import stream_command
11+ from warnet .status import _get_deployed_scenarios as scenarios_deployed
1112
1213
1314class WargamesTest (TestBase ):
@@ -19,6 +20,7 @@ def __init__(self):
1920 Path (os .path .dirname (__file__ )).parent / "resources" / "scenarios" / "test_scenarios"
2021 )
2122 self .initial_context = get_kubeconfig_value ("{.current-context}" )
23+ self .kconfigdir = self .tmpdir / "kubeconfigs"
2224
2325 def run_test (self ):
2426 try :
@@ -61,8 +63,8 @@ def check_scenario_permissions(self):
6163 assert self .warnet ("bitcoin rpc miner getblockcount" ) == "5"
6264
6365 self .log .info ("Switch to wargames player context" )
64- self .log .info (self .warnet ("admin create-kubeconfigs" ))
65- clicker = pexpect .spawn ("warnet auth kubeconfigs /warnet-user-wargames-red-kubeconfig" )
66+ self .log .info (self .warnet (f "admin create-kubeconfigs --kubeconfig-dir= { self . kconfigdir } " ))
67+ clicker = pexpect .spawn (f "warnet auth { self . kconfigdir } /warnet-user-wargames-red-kubeconfig" )
6668 while clicker .expect (["Overwrite" , "Updated kubeconfig" ]) == 0 :
6769 print (clicker .before , clicker .after )
6870 clicker .sendline ("y" )
@@ -82,16 +84,22 @@ def check_scenario_permissions(self):
8284 # Nothing was accesible
8385 assert self .warnet ("bitcoin rpc armada getblockcount" ) == "6"
8486
87+ self .log .info ("Check pod limit per namespace" )
88+ for i in range (10 ):
89+ stream_command (
90+ f"warnet run { self .scen_test_dir / 'nothing.py' } --source_dir={ self .scen_src_dir } "
91+ )
92+ assert len (scenarios_deployed ()) == 2 , f"Unexpected scenarios deployed:{ scenarios_deployed ()} "
93+
8594 self .log .info ("Restore admin context" )
8695 stream_command (f"kubectl config use-context { self .initial_context } " )
8796 # Sanity check
8897 assert self .warnet ("bitcoin rpc miner getblockcount" ) == "6"
8998
9099 self .log .info ("Re-generate kubeconfigs after a scenario has been run" )
91- self .log .info (self .warnet ("admin create-kubeconfigs" ))
92- kubeconfig_dir = Path ("kubeconfigs/" )
100+ self .log .info (self .warnet (f"admin create-kubeconfigs --kubeconfig-dir={ self .kconfigdir } " ))
93101 count = 0
94- for p in kubeconfig_dir .iterdir ():
102+ for p in self . kconfigdir .iterdir ():
95103 if p .is_file ():
96104 print (p )
97105 assert "warnet-user" in str (p )
0 commit comments