Skip to content

Commit ff4ddab

Browse files
committed
set resource requests and limits on tank object
tell k8s up front the min and max CPU, memory we want for a tank. can be overriden from a graph file if a tank needs more/less. since we only get 4cpus for minikube in github actions, trim down the test graphs to run with <= 6 tanks. we dont really need to test large graphs in CI , anyways.
1 parent 485b5e7 commit ff4ddab

File tree

14 files changed

+33
-110
lines changed

14 files changed

+33
-110
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ jobs:
5959
- uses: azure/[email protected]
6060
- uses: medyagh/setup-minikube@master
6161
with:
62+
cpus: max
63+
memory: 10000m
6264
mount-path: ${{ github.workspace }}:/mnt/src
6365
- uses: actions/download-artifact@v4
6466
with:

src/warnet/backend/kubernetes_backend.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,10 @@ def create_bitcoind_container(self, tank: Tank) -> client.V1Container:
406406
privileged=True,
407407
capabilities=client.V1Capabilities(add=["NET_ADMIN", "NET_RAW"]),
408408
),
409+
resources=client.V1ResourceRequirements(
410+
requests=tank.resources["requests"],
411+
limits=tank.resources["limits"],
412+
),
409413
)
410414
self.log.debug(
411415
f"Created bitcoind container for tank {tank.index} using {bitcoind_options=:}"

src/warnet/cli/graph.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def create(number: int, outfile: Path, version: str, bitcoin_conf: Path, random:
2424
Create a cycle graph with <number> nodes, and include 7 extra random outbounds per node.
2525
Returns XML file as string with or without --outfile option
2626
"""
27-
graph = create_cycle_graph(number, version, bitcoin_conf, random)
27+
graph = create_cycle_graph(number, version, bitcoin_conf, random, None)
2828

2929
if outfile:
3030
file_path = Path(outfile)
@@ -52,7 +52,14 @@ def import_json(infile: Path, outfile: Path, cb: str, ln_image: str):
5252

5353
# Start with a connected L1 graph with the right amount of tanks
5454
graph = create_cycle_graph(
55-
len(json_graph["nodes"]), version=DEFAULT_TAG, bitcoin_conf=None, random_version=False
55+
len(json_graph["nodes"]),
56+
version=DEFAULT_TAG,
57+
bitcoin_conf=None,
58+
random_version=False,
59+
resources={
60+
"requests": {"cpu": "250m", "memory": "250Mi"},
61+
"limits": {"cpu": "250m", "limit": "500Mi"},
62+
},
5663
)
5764

5865
# Initialize all the tanks with basic LN node configurations

src/warnet/tank.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ def __init__(self, index: int, warnet):
4646
self.bitcoin_network = warnet.bitcoin_network
4747
self.version: str = ""
4848
self.image: str = ""
49+
self.resources: dict = {
50+
"requests": {"cpu": "500m", "memory": "500Mi"},
51+
"limits": {"cpu": "1000m", "memory": "1500Mi"},
52+
}
4953
self.bitcoin_config = ""
5054
self.netem = None
5155
self.exporter = False

src/warnet/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,9 @@ def set_execute_permission(file_path):
380380
os.chmod(file_path, current_permissions | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
381381

382382

383-
def create_cycle_graph(n: int, version: str, bitcoin_conf: str | None, random_version: bool):
383+
def create_cycle_graph(
384+
n: int, version: str, bitcoin_conf: str | None, random_version: bool, resources: dict | None
385+
):
384386
try:
385387
# Use nx.MultiDiGraph() so we get directed edges (source->target)
386388
# and still allow parallel edges (L1 p2p connections + LN channels)
@@ -435,6 +437,8 @@ def create_cycle_graph(n: int, version: str, bitcoin_conf: str | None, random_ve
435437
graph.nodes[node]["build_args"] = ""
436438
graph.nodes[node]["exporter"] = False
437439
graph.nodes[node]["collect_logs"] = False
440+
if resources is not None:
441+
graph.nodes[node]["resources"] = resources
438442

439443
convert_unsupported_attributes(graph)
440444
return graph

test/dag_connection_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class DAGConnectionTest(TestBase):
1010
def __init__(self):
1111
super().__init__()
1212
self.graph_file_path = (
13-
Path(os.path.dirname(__file__)) / "data" / "ten_semi_unconnected.graphml"
13+
Path(os.path.dirname(__file__)) / "data" / "six_semi_unconnected.graphml"
1414
)
1515

1616
def run_test(self):

test/data/12_node_ring.graphml renamed to test/data/6_node_ring.graphml

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,6 @@
3737
<data key="bitcoin_config">-uacomment=w4</data>
3838
</node>
3939
<node id="5">
40-
<data key="version">27.0</data>
41-
<data key="bitcoin_config">-uacomment=w5</data>
42-
</node>
43-
<node id="6">
44-
<data key="version">27.0</data>
45-
<data key="bitcoin_config">-uacomment=w6</data>
46-
</node>
47-
<node id="7">
48-
<data key="version">27.0</data>
49-
<data key="bitcoin_config">-uacomment=w7</data>
50-
</node>
51-
<node id="8">
52-
<data key="version">27.0</data>
53-
<data key="bitcoin_config">-uacomment=w8</data>
54-
</node>
55-
<node id="9">
56-
<data key="version">27.0</data>
57-
<data key="bitcoin_config">-uacomment=w9</data>
58-
</node>
59-
<node id="10">
60-
<data key="version">27.0</data>
61-
<data key="bitcoin_config">-uacomment=w10</data>
62-
</node>
63-
<node id="11">
6440
<data key="version">27.0</data>
6541
<!-- no bitcoin_config to test unused options -->
6642
</node>
@@ -70,12 +46,6 @@
7046
<edge id="13" source="2" target="3"></edge>
7147
<edge id="14" source="3" target="4"></edge>
7248
<edge id="15" source="4" target="5"></edge>
73-
<edge id="16" source="5" target="6"></edge>
74-
<edge id="17" source="6" target="7"></edge>
75-
<edge id="18" source="7" target="8"></edge>
76-
<edge id="19" source="8" target="9"></edge>
77-
<edge id="20" source="9" target="10"></edge>
78-
<edge id="21" source="10" target="11"></edge>
79-
<edge id="21" source="11" target="0"></edge>
49+
<edge id="16" source="5" target="0"></edge>
8050
</graph>
8151
</graphml>

test/data/permutations.graphml

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,30 +64,12 @@
6464
<data key="exporter">False</data>
6565
<data key="collect_logs">False</data>
6666
</node>
67-
<node id="6">
68-
<data key="version">27.0</data>
69-
<data key="bitcoin_config" />
70-
<data key="tc_netem" />
71-
<data key="build_args" />
72-
<data key="exporter">False</data>
73-
<data key="collect_logs">False</data>
74-
</node>
75-
<node id="7">
76-
<data key="version">27.0</data>
77-
<data key="bitcoin_config" />
78-
<data key="tc_netem" />
79-
<data key="build_args" />
80-
<data key="exporter">False</data>
81-
<data key="collect_logs">False</data>
82-
</node>
8367
<edge source="0" target="2" id="0" />
8468
<edge source="1" target="2" id="0" />
8569
<edge source="1" target="3" id="0" />
8670
<edge source="2" target="3" id="0" />
8771
<edge source="2" target="4" id="0" />
8872
<edge source="3" target="5" id="0" />
8973
<edge source="5" target="4" id="0" />
90-
<edge source="5" target="6" id="0" />
91-
<edge source="6" target="7" id="0" />
9274
</graph>
93-
</graphml>
75+
</graphml>

test/data/scenario_connect_dag.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ConnectionType(Enum):
2020
class ConnectDag(WarnetTestFramework):
2121
def set_test_params(self):
2222
# This is just a minimum
23-
self.num_nodes = 10
23+
self.num_nodes = 6
2424

2525
def add_options(self, parser):
2626
parser.add_argument(
@@ -63,13 +63,6 @@ def run_test(self):
6363
self.connect_nodes(2, 4)
6464
self.connect_nodes(3, 5)
6565
self.connect_nodes(5, 4)
66-
self.connect_nodes(5, 6)
67-
self.connect_nodes(6, 7)
68-
69-
# Nodes 8 & 9 shall come pre-connected. Attempt to connect them anyway to test the handling
70-
# of dns node addresses
71-
self.connect_nodes(8, 9)
72-
self.connect_nodes(9, 8)
7366

7467
self.sync_all()
7568

@@ -79,10 +72,6 @@ def run_test(self):
7972
three_peers = self.nodes[3].getpeerinfo()
8073
four_peers = self.nodes[4].getpeerinfo()
8174
five_peers = self.nodes[5].getpeerinfo()
82-
six_peers = self.nodes[6].getpeerinfo()
83-
seven_peers = self.nodes[7].getpeerinfo()
84-
eight_peers = self.nodes[8].getpeerinfo()
85-
nine_peers = self.nodes[9].getpeerinfo()
8675

8776
for tank in self.warnet.tanks:
8877
self.log.info(
@@ -104,13 +93,6 @@ def run_test(self):
10493
self.assert_connection(four_peers, 5, ConnectionType.IP)
10594
self.assert_connection(five_peers, 3, ConnectionType.IP)
10695
self.assert_connection(five_peers, 4, ConnectionType.DNS)
107-
self.assert_connection(five_peers, 6, ConnectionType.DNS)
108-
self.assert_connection(six_peers, 5, ConnectionType.IP)
109-
self.assert_connection(six_peers, 7, ConnectionType.DNS)
110-
self.assert_connection(seven_peers, 6, ConnectionType.IP)
111-
# Check the pre-connected nodes
112-
self.assert_connection(eight_peers, 9, ConnectionType.DNS)
113-
self.assert_connection(nine_peers, 8, ConnectionType.IP)
11496

11597
self.log.info(
11698
f"Successfully ran the connect_dag.py scenario using a temporary file: "

test/data/ten_semi_unconnected.graphml renamed to test/data/six_semi_unconnected.graphml

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -64,38 +64,6 @@
6464
<data key="exporter">False</data>
6565
<data key="collect_logs">False</data>
6666
</node>
67-
<node id="6">
68-
<data key="version">26.0</data>
69-
<data key="bitcoin_config" />
70-
<data key="tc_netem" />
71-
<data key="build_args" />
72-
<data key="exporter">False</data>
73-
<data key="collect_logs">False</data>
74-
</node>
75-
<node id="7">
76-
<data key="version">26.0</data>
77-
<data key="bitcoin_config" />
78-
<data key="tc_netem" />
79-
<data key="build_args" />
80-
<data key="exporter">False</data>
81-
<data key="collect_logs">False</data>
82-
</node>
83-
<node id="8">
84-
<data key="version">26.0</data>
85-
<data key="bitcoin_config" />
86-
<data key="tc_netem" />
87-
<data key="build_args" />
88-
<data key="exporter">False</data>
89-
<data key="collect_logs">False</data>
90-
</node>
91-
<node id="9">
92-
<data key="version">26.0</data>
93-
<data key="bitcoin_config" />
94-
<data key="tc_netem" />
95-
<data key="build_args" />
96-
<data key="exporter">False</data>
97-
<data key="collect_logs">False</data>
98-
</node>
99-
<edge id="0" source="8" target="9"></edge>
67+
<edge id="0" source="3" target="4"></edge>
10068
</graph>
10169
</graphml>

0 commit comments

Comments
 (0)