8
8
from typing import Optional
9
9
10
10
import pexpect
11
- from ln_test import LNTest
12
11
from test_base import TestBase
13
12
14
13
from warnet .constants import LIGHTNING_MISSION
15
- from warnet .k8s import download , get_mission , pod_log , wait_for_pod
14
+ from warnet .k8s import download , get_mission , wait_for_pod
16
15
from warnet .process import run_command
17
16
18
17
19
- class SimLNTest (LNTest , TestBase ):
18
+ class SimLNTest (TestBase ):
20
19
def __init__ (self ):
21
20
super ().__init__ ()
22
21
self .network_dir = Path (os .path .dirname (__file__ )) / "data" / "ln"
@@ -27,15 +26,8 @@ def run_test(self):
27
26
try :
28
27
os .chdir (self .tmpdir )
29
28
self .init_directory ()
30
-
31
- self .import_network ()
32
- self .setup_network ()
33
- self .test_channel_policies ()
34
- self .test_payments ()
35
- self .run_simln ()
36
-
29
+ self .deploy_with_plugin ()
37
30
self .copy_results ()
38
- self .run_activity ()
39
31
finally :
40
32
self .cleanup ()
41
33
@@ -46,32 +38,20 @@ def init_directory(self):
46
38
self .sut .sendline ("n" )
47
39
self .sut .close ()
48
40
49
- def copy_results (self ):
50
- self .log .info ("Copying results" )
51
- pod = get_mission (f"{ self .simln_exec } mission" )[0 ]
52
- self .wait_for_gossip_sync (2 )
53
- wait_for_pod (pod .metadata .name , 60 )
54
-
55
- log_resp = pod_log (pod .metadata .name , f"{ self .simln_exec } primary-container" )
56
- self .log .info (log_resp .data .decode ("utf-8" ))
41
+ def deploy_with_plugin (self ):
42
+ self .log .info ("Deploy the ln network with a SimLN plugin" )
43
+ results = self .warnet (f"deploy { self .network_dir } " )
44
+ self .log .info (results )
45
+ wait_for_pod (self .get_first_simln_pod ())
57
46
58
- partial_func = partial (self .found_results_remotely , pod .metadata .name )
47
+ def copy_results (self ):
48
+ pod = self .get_first_simln_pod ()
49
+ partial_func = partial (self .found_results_remotely , pod )
59
50
self .wait_for_predicate (partial_func )
60
51
61
- download (pod . metadata . name , Path ("/working/results" ), Path ("." ), pod . metadata . namespace )
52
+ download (pod , Path ("/working/results" ), Path ("." ))
62
53
self .wait_for_predicate (self .found_results_locally )
63
54
64
- def run_activity (self ):
65
- cmd = f"{ self .simln_exec } get-example-activity"
66
- self .log .info (f"Activity: { cmd } " )
67
- activity_result = run_command (cmd )
68
- activity = json .loads (activity_result )
69
- pod_result = run_command (f"{ self .simln_exec } launch-activity '{ json .dumps (activity )} '" )
70
- self .log .info (f"launched activity: { pod_result } " )
71
- partial_func = partial (self .found_results_remotely , pod_result .strip ())
72
- self .wait_for_predicate (partial_func )
73
- self .log .info ("Successfully ran activity" )
74
-
75
55
def wait_for_gossip_sync (self , expected : int ):
76
56
self .log .info (f"Waiting for sync (expecting { expected } )..." )
77
57
current = 0
@@ -88,9 +68,7 @@ def wait_for_gossip_sync(self, expected: int):
88
68
89
69
def found_results_remotely (self , pod : Optional [str ] = None ) -> bool :
90
70
if pod is None :
91
- pod_names_literal = run_command (f"{ self .simln_exec } list-pod-names" )
92
- pod_names = ast .literal_eval (pod_names_literal )
93
- pod = pod_names [0 ]
71
+ pod = self .get_first_simln_pod ()
94
72
self .log .info (f"Checking for results file in { pod } " )
95
73
results_file = run_command (f"{ self .simln_exec } sh { pod } ls /working/results" ).strip ()
96
74
self .log .info (f"Results file: { results_file } " )
@@ -100,6 +78,13 @@ def found_results_remotely(self, pod: Optional[str] = None) -> bool:
100
78
self .log .info (results )
101
79
return results .find ("Success" ) > 0
102
80
81
+ def get_first_simln_pod (self ):
82
+ command = f"{ self .simln_exec } list-pod-names"
83
+ pod_names_literal = run_command (command )
84
+ self .log .info (f"{ command } : { pod_names_literal } " )
85
+ pod_names = ast .literal_eval (pod_names_literal )
86
+ return pod_names [0 ]
87
+
103
88
def found_results_locally (self ) -> bool :
104
89
directory = "results"
105
90
self .log .info (f"Searching { directory } " )
0 commit comments