Skip to content

Commit 81d0297

Browse files
authored
Merge pull request #622 from pinheadmz/splitconf
charts: split off defaultConfig from [node] config
2 parents 6299243 + 76f3387 commit 81d0297

File tree

10 files changed

+66
-46
lines changed

10 files changed

+66
-46
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
test:
3939
- conf_test.py
4040
- dag_connection_test.py
41+
- graph_test.py
4142
- logging_test.py
4243
- rpc_test.py
4344
- services_test.py
@@ -87,24 +88,3 @@ jobs:
8788
name: kubernetes-logs-${{ matrix.test }}
8889
path: ./k8s-logs
8990
retention-days: 5
90-
test-without-mk:
91-
runs-on: ubuntu-latest
92-
strategy:
93-
matrix:
94-
test:
95-
- graph_test.py
96-
steps:
97-
- uses: actions/checkout@v4
98-
- name: Install the latest version of uv
99-
uses: astral-sh/setup-uv@v2
100-
with:
101-
version: "latest"
102-
enable-cache: true
103-
- name: Install Python
104-
run: uv python install $PYTHON_VERSION
105-
- name: Install project
106-
run: uv sync --all-extras --dev
107-
- name: Run tests
108-
run: |
109-
source .venv/bin/activate
110-
./test/${{matrix.test}}

resources/charts/bitcoincore/templates/configmap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ data:
1313
rpcport={{ index .Values .Values.chain "RPCPort" }}
1414
zmqpubrawblock=tcp://0.0.0.0:{{ .Values.ZMQBlockPort }}
1515
zmqpubrawtx=tcp://0.0.0.0:{{ .Values.ZMQTxPort }}
16+
{{- .Values.defaultConfig | nindent 4 }}
1617
{{- .Values.config | nindent 4 }}
1718
{{- range .Values.connect }}
1819
{{- print "connect=" . | nindent 4}}

resources/charts/bitcoincore/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ baseConfig: |
133133
134134
config: ""
135135

136+
defaultConfig: ""
137+
136138
connect: []
137139
loadSnapshot:
138140
enabled: false

resources/networks/6_node_bitcoin/network.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
nodes:
22
- name: tank-0001
3+
config: uacomment=tank0001
34
image:
45
tag: "26.0"
56
connect:
67
- tank-0002
78
- tank-0003
89
- name: tank-0002
10+
config: uacomment=tank0002
911
resources:
1012
limits:
1113
cpu: 100m
@@ -17,14 +19,17 @@ nodes:
1719
- tank-0003
1820
- tank-0004
1921
- name: tank-0003
22+
config: uacomment=tank0003
2023
connect:
2124
- tank-0004
2225
- tank-0005
2326
- name: tank-0004
27+
config: uacomment=tank0004
2428
connect:
2529
- tank-0005
2630
- tank-0006
2731
- name: tank-0005
32+
config: uacomment=tank0005
2833
connect:
2934
- tank-0006
3035
- name: tank-0006

resources/networks/6_node_bitcoin/node-defaults.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ image:
2121
# Overrides the image tag whose default is the chart appVersion.
2222
tag: "27.0"
2323

24-
config: |
24+
defaultConfig: |
2525
dns=1
2626
debug=rpc

resources/networks/fork_observer/node-defaults.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ image:
2121
# Overrides the image tag whose default is the chart appVersion.
2222
tag: "27.0"
2323

24-
config: |
24+
defaultConfig: |
2525
dns=1
2626
debug=rpc
2727
rpcauth=forkobserver:1418183465eecbd407010cf60811c6a0$d4e5f0647a63429c218da1302d7f19fe627302aeb0a71a74de55346a25d8057c

src/warnet/bitcoin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import re
3+
import subprocess
34
import sys
45
from datetime import datetime
56
from io import BytesIO
@@ -181,7 +182,6 @@ def get_messages(tank_a: str, tank_b: str, chain: str):
181182
file_path = f"{base_dir}/{dir_name}/{file}"
182183
# Fetch the file contents from the container
183184
cmd = f"kubectl exec {tank_a} -- cat {file_path}"
184-
import subprocess
185185

186186
blob = subprocess.run(
187187
cmd, shell=True, capture_output=True, executable="bash"

test/data/signet/node-defaults.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ chain: signet
88
spec:
99
restartPolicy: Always
1010

11-
config: |
11+
defaultConfig: |
1212
debug=rpc
1313
debug=net
1414
signetchallenge=0014d33b6e11ca95c4edccd8e986434358d79e919730

test/graph_test.py

Lines changed: 52 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22

3+
import json
34
import os
4-
import shutil
55

66
import pexpect
77
from test_base import TestBase
@@ -15,34 +15,65 @@ def __init__(self):
1515

1616
def run_test(self):
1717
try:
18+
# cwd out of the git repo for remainder of script
19+
os.chdir(self.tmpdir)
1820
self.directory_not_exist()
1921
os.mkdir(NETWORKS_DIR)
2022
self.directory_exists()
21-
23+
self.run_created_network()
2224
finally:
23-
shutil.rmtree(NETWORKS_DIR) if os.path.exists(NETWORKS_DIR) else None
25+
self.cleanup()
2426

2527
def directory_not_exist(self):
26-
self.sut = pexpect.spawn("warnet create")
27-
self.sut.expect("init", timeout=50)
28+
try:
29+
self.log.info("testing warnet create, dir doesn't exist")
30+
self.sut = pexpect.spawn("warnet create")
31+
self.sut.expect("init", timeout=10)
32+
except Exception as e:
33+
print(f"\nReceived prompt text:\n {self.sut.before.decode('utf-8')}\n")
34+
raise e
2835

2936
def directory_exists(self):
30-
self.sut = pexpect.spawn("warnet create")
31-
self.sut.expect("name", timeout=10)
32-
self.sut.sendline("ANewNetwork")
33-
self.sut.expect("many", timeout=10)
34-
self.sut.sendline("")
35-
self.sut.expect("connections", timeout=10)
36-
self.sut.sendline("")
37-
self.sut.expect("version", timeout=10)
38-
self.sut.sendline("")
39-
self.sut.expect("enable fork-observer", timeout=10)
40-
self.sut.sendline("")
41-
self.sut.expect("seconds", timeout=10)
42-
self.sut.sendline("")
43-
self.sut.expect("enable grafana", timeout=10)
44-
self.sut.sendline("")
45-
self.sut.expect("successfully", timeout=50)
37+
try:
38+
self.log.info("testing warnet create, dir does exist")
39+
self.sut = pexpect.spawn("warnet create")
40+
self.sut.expect("name", timeout=10)
41+
self.sut.sendline("ANewNetwork")
42+
self.sut.expect("many", timeout=10)
43+
self.sut.sendline("")
44+
self.sut.expect("connections", timeout=10)
45+
self.sut.sendline("")
46+
self.sut.expect("version", timeout=10)
47+
self.sut.sendline("")
48+
self.sut.expect("enable fork-observer", timeout=10)
49+
self.sut.sendline("")
50+
self.sut.expect("seconds", timeout=10)
51+
self.sut.sendline("")
52+
self.sut.expect("enable grafana", timeout=10)
53+
self.sut.sendline("")
54+
self.sut.expect("successfully", timeout=50)
55+
except Exception as e:
56+
print(f"\nReceived prompt text:\n {self.sut.before.decode('utf-8')}\n")
57+
raise e
58+
59+
def run_created_network(self):
60+
self.log.info("adding custom config to one tank")
61+
with open("networks/ANewNetwork/network.yaml") as f:
62+
s = f.read()
63+
s = s.replace(" name: tank-0000\n", " name: tank-0000\n config: debug=mempool\n")
64+
with open("networks/ANewNetwork/network.yaml", "w") as f:
65+
f.write(s)
66+
67+
self.log.info("deploying new network")
68+
self.warnet("deploy networks/ANewNetwork")
69+
self.wait_for_all_tanks_status(target="running")
70+
debugs = json.loads(self.warnet("bitcoin rpc tank-0000 logging"))
71+
# set in defaultConfig
72+
assert debugs["rpc"]
73+
# set in config just for this tank
74+
assert debugs["mempool"]
75+
# santy check
76+
assert not debugs["zmq"]
4677

4778

4879
if __name__ == "__main__":

test/test_base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def setup_logging(self):
3939
logging.config.dictConfig(logging_config)
4040
self.log = logging.getLogger("test")
4141
self.log.info("Logging started")
42+
self.log.info(f"Testdir: {self.tmpdir}")
4243

4344
def cleanup(self, signum=None, frame=None):
4445
try:

0 commit comments

Comments
 (0)