Skip to content

Commit 427cd08

Browse files
committed
lint
1 parent a24f048 commit 427cd08

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

resources/plugins/tor/plugin.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
#!/usr/bin/env python3
22

33
from pathlib import Path
4-
from warnet.process import run_command
54

5+
from warnet.process import run_command
66

77
if __name__ == "__main__":
8-
command = (
9-
f"helm upgrade --install torda {Path(__file__).parent / 'charts' / 'torda'}"
10-
)
8+
command = f"helm upgrade --install torda {Path(__file__).parent / 'charts' / 'torda'}"
119
run_command(command)
12-

src/warnet/k8s.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,9 @@ def get_ingress_ip_or_host():
347347
return None
348348

349349

350-
def pod_log(pod_name, container_name=None, follow=False, namespace: Optional[str] = None, tail_lines=None):
350+
def pod_log(
351+
pod_name, container_name=None, follow=False, namespace: Optional[str] = None, tail_lines=None
352+
):
351353
namespace = get_default_namespace_or(namespace)
352354
sclient = get_static_client()
353355

@@ -358,7 +360,7 @@ def pod_log(pod_name, container_name=None, follow=False, namespace: Optional[str
358360
container=container_name,
359361
follow=follow,
360362
_preload_content=False,
361-
tail_lines=tail_lines
363+
tail_lines=tail_lines,
362364
)
363365
except ApiException as e:
364366
raise Exception(json.loads(e.body.decode("utf-8"))["message"]) from None

test/onion_test.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from pathlib import Path
66

77
from test_base import TestBase
8+
89
from warnet.k8s import pod_log
910

1011

@@ -26,10 +27,7 @@ def setup_network(self):
2627
self.wait_for_all_tanks_status(target="running")
2728

2829
def check_tor(self):
29-
onions = {
30-
"tank-0001": None,
31-
"tank-0002": None
32-
}
30+
onions = {"tank-0001": None, "tank-0002": None}
3331

3432
def get_onions():
3533
peers = ["tank-0001", "tank-0002"]
@@ -41,10 +39,8 @@ def get_onions():
4139
if "onion" in addr["address"]:
4240
onions[tank] = addr["address"]
4341
self.log.info(f" ... got: {addr['address']}")
44-
for tank in peers:
45-
if not onions[tank]:
46-
return False
47-
return True
42+
return all(onions[tank] for tank in peers)
43+
4844
self.wait_for_predicate(get_onions)
4945

5046
self.log.info("Adding 1 block")
@@ -67,15 +63,18 @@ def onion_connect():
6763
else:
6864
self.log.info("tank-0001 tor log tail:")
6965
stream = pod_log(
70-
pod_name="tank-0001", container_name="tor", namespace="default", follow=False, tail_lines=5
66+
pod_name="tank-0001",
67+
container_name="tor",
68+
namespace="default",
69+
follow=False,
70+
tail_lines=5,
7171
)
7272
for line in stream:
7373
msg = line.decode("utf-8").rstrip()
7474
msg = msg.split("]")
7575
self.log.info(msg[-1])
7676

77-
self.wait_for_predicate(onion_connect, timeout=20*60)
78-
77+
self.wait_for_predicate(onion_connect, timeout=20 * 60)
7978

8079

8180
if __name__ == "__main__":

0 commit comments

Comments
 (0)