Skip to content

Commit 6c43182

Browse files
committed
allow simln to declare its constants
1 parent cd81f4f commit 6c43182

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

resources/plugins/simln/simln.py

+17-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
# When we want to select pods based on their role in Warnet, we use "mission" tags. The "mission"
1212
# tag for "lightning" nodes is stored in LIGHTNING_MISSION.
13-
from warnet.constants import LIGHTNING_MISSION, PLUGIN_DIR_TAG
13+
from warnet.constants import LIGHTNING_MISSION
1414
from warnet.k8s import (
1515
download,
1616
get_default_namespace,
@@ -30,7 +30,9 @@
3030
# explicit here using the variable name CONTAINER which Warnet uses internally in its log and status
3131
# systems.
3232
# Again, this should match the container name provided in the associated helm file.
33-
CONTAINER = MISSION
33+
PRIMARY_CONTAINER = MISSION
34+
35+
PLUGIN_DIR_TAG = "plugin_dir"
3436

3537

3638
class SimLNError(Exception):
@@ -173,7 +175,7 @@ def _sh(pod, method: str, params: tuple[str, ...]) -> str:
173175
sclient.connect_get_namespaced_pod_exec,
174176
pod,
175177
namespace,
176-
container=CONTAINER,
178+
container=PRIMARY_CONTAINER,
177179
command=cmd,
178180
stderr=True,
179181
stdin=False,
@@ -205,5 +207,17 @@ def sh(pod: str, method: str, params: tuple[str, ...]):
205207
print(_sh(pod, method, params))
206208

207209

210+
@simln.command()
211+
def mission():
212+
"""Return the SimLN mission name"""
213+
click.secho(MISSION)
214+
215+
216+
@simln.command()
217+
def primary_container():
218+
"""Return the SimLN primary container name."""
219+
click.secho(PRIMARY_CONTAINER)
220+
221+
208222
if __name__ == "__main__":
209223
simln()

test/simln_test.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
from ln_test import LNTest
1212
from test_base import TestBase
1313

14-
from warnet.k8s import download, get_pods_with_label, pod_log, wait_for_pod
14+
from warnet.constants import LIGHTNING_MISSION
15+
from warnet.k8s import download, get_mission, pod_log, wait_for_pod
1516
from warnet.process import run_command
1617

17-
lightning_selector = "mission=lightning"
18-
1918

2019
class SimLNTest(LNTest, TestBase):
2120
def __init__(self):
@@ -49,11 +48,11 @@ def init_directory(self):
4948

5049
def copy_results(self):
5150
self.log.info("Copying results")
52-
pod = get_pods_with_label("mission=simln")[0]
51+
pod = get_mission(f"{self.simln_exec} mission")[0]
5352
self.wait_for_gossip_sync(2)
5453
wait_for_pod(pod.metadata.name, 60)
5554

56-
log_resp = pod_log(pod.metadata.name, "simln")
55+
log_resp = pod_log(pod.metadata.name, f"{self.simln_exec} primary-container")
5756
self.log.info(log_resp.data.decode("utf-8"))
5857

5958
partial_func = partial(self.found_results_remotely, pod.metadata.name)
@@ -78,7 +77,7 @@ def wait_for_gossip_sync(self, expected: int):
7877
current = 0
7978
while current < expected:
8079
current = 0
81-
pods = get_pods_with_label(lightning_selector)
80+
pods = get_mission(LIGHTNING_MISSION)
8281
for v1_pod in pods:
8382
node = v1_pod.metadata.name
8483
chs = json.loads(run_command(f"warnet ln rpc {node} describegraph"))["edges"]

0 commit comments

Comments
 (0)