Skip to content

Commit 9091340

Browse files
committed
fix scenarios
1 parent 290f219 commit 9091340

File tree

9 files changed

+17
-13
lines changed

9 files changed

+17
-13
lines changed

src/services/dns_seed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def __init__(self, docker_network, templates, config_dir):
1414
self.docker_network = docker_network
1515
self.templates = templates
1616
self.service = {
17-
"container_name": DNS_SEED_NAME,
17+
"container_name": f"{self.docker_network}_{DNS_SEED_NAME}",
1818
"ports": [f"{PORT}:53/udp", f"{PORT}:53/tcp"],
1919
"build": {
2020
"context": ".",

src/services/fork_observer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def __init__(self, docker_network, fork_observer_config):
99
self.fork_observer_config = fork_observer_config
1010
self.service = {
1111
"image": "b10c/fork-observer:latest",
12-
"container_name": "fork-observer",
12+
"container_name": f"{self.docker_network}_fork-observer",
1313
"ports": [f"{PORT}:2323"],
1414
"volumes": [f"{self.fork_observer_config}:/app/config.toml"],
1515
"networks": [self.docker_network],

src/services/grafana.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def __init__(self, docker_network):
88
super().__init__(docker_network)
99
self.service = {
1010
"image": "grafana/grafana:latest",
11-
"container_name": "grafana",
11+
"container_name": f"{self.docker_network}_grafana",
1212
"ports": [f"3000:{PORT}"],
1313
"volumes": ["grafana-storage:/var/lib/grafana"],
1414
"networks": [self.docker_network],

src/services/node_exporter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def __init__(self, docker_network):
66
super().__init__(docker_network)
77
self.service = {
88
"image": "prom/node-exporter:latest",
9-
"container_name": "node-exporter",
9+
"container_name": f"{self.docker_network}_node-exporter",
1010
"volumes": ["/proc:/host/proc:ro", "/sys:/host/sys:ro", "/:/rootfs:ro"],
1111
"command": ["--path.procfs=/host/proc", "--path.sysfs=/host/sys"],
1212
"networks": [self.docker_network],

src/services/prometheus.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import docker
12
from .base_service import BaseService
23

34
PORT = 9090
@@ -8,7 +9,7 @@ def __init__(self, docker_network, config_dir):
89
super().__init__(docker_network, config_dir)
910
self.service = {
1011
"image": "prom/prometheus:latest",
11-
"container_name": "prometheus",
12+
"container_name": f"{self.docker_network}_prometheus",
1213
"ports": [f"{PORT}:9090"],
1314
"volumes": [
1415
f"{self.config_dir / 'prometheus.yml'}:/etc/prometheus/prometheus.yml"

src/services/tor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def __init__(self, docker_network, templates):
1313
"context": str(self.templates),
1414
"dockerfile": DOCKERFILE,
1515
},
16-
"container_name": "tor",
16+
"container_name": f"{self.docker_network}_tor",
1717
"networks": {
1818
self.docker_network: {
1919
"ipv4_address": DIRECTORY_AUTHORITY_IP,

src/warnet/cli.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,17 @@ def list():
176176
print(f"Error listing scenarios: {e}")
177177

178178

179-
@scenarios.command()
179+
@scenarios.command(context_settings={"ignore_unknown_options": True})
180180
@click.argument("scenario", type=str)
181-
def run(scenario):
181+
@click.argument("additional_args", nargs=-1, type=click.UNPROCESSED)
182+
@click.option("--network", default="warnet", show_default=True)
183+
def run(scenario, network, additional_args):
182184
"""
183185
Run <scenario> from the Warnet Test Framework
184186
"""
185187
try:
186-
res = rpc_call("run", {"scenario": scenario})
188+
params = {"scenario": scenario, "additional_args": additional_args, "network": network}
189+
res = rpc_call("run", params)
187190
print(res)
188191
except Exception as e:
189192
print(f"Error running scenario: {e}")

src/warnet/tank.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def container_name(self):
129129
@property
130130
def exporter_name(self):
131131
if self._exporter_name is None:
132-
self._exporter_name = f"{CONTAINER_PREFIX_PROMETHEUS}_{self.suffix}"
132+
self._exporter_name = f"{self.docker_network}_{CONTAINER_PREFIX_PROMETHEUS}_{self.suffix}"
133133
return self._exporter_name
134134

135135
@property

src/warnet/warnetd.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import threading
1010
from datetime import datetime
1111
from logging.handlers import RotatingFileHandler
12-
12+
from typing import List
1313
from flask import Flask
1414
from flask_jsonrpc.app import JSONRPC
1515

@@ -129,7 +129,7 @@ def list() -> list[str]:
129129

130130

131131
@jsonrpc.method("run")
132-
def run(scenario: str, network: str = "warnet") -> str:
132+
def run(scenario: str, additional_args: List[str], network: str = "warnet") -> str:
133133
"""
134134
Run <scenario> from the Warnet Test Framework
135135
"""
@@ -140,7 +140,7 @@ def run(scenario: str, network: str = "warnet") -> str:
140140
return f"Scenario {scenario} not found at {scenario_path}."
141141

142142
try:
143-
run_cmd = [sys.executable, scenario_path] + [f"--network={network}"]
143+
run_cmd = [sys.executable, scenario_path] + additional_args + [f"--network={network}"]
144144
logger.debug(f"Running {run_cmd}")
145145
subprocess.Popen(run_cmd, shell=False)
146146
return f"Running scenario {scenario} in the background..."

0 commit comments

Comments
 (0)