Skip to content

Commit a4b5265

Browse files
authored
Merge branch 'staging' into feat/roman/crv-3-for-fast-block-too
2 parents 6e002ff + f48125c commit a4b5265

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

tests/e2e_tests/conftest.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
)
2121

2222
LOCALNET_IMAGE_NAME = "ghcr.io/opentensor/subtensor-localnet:devnet-ready"
23+
CONTAINER_NAME_PREFIX = "test_local_chain_"
2324

2425

2526
def wait_for_node_start(process, timestamp=None):
@@ -163,7 +164,32 @@ def try_start_docker():
163164
print("Docker wasn't run. Manual start may be required.")
164165
return False
165166

166-
container_name = f"test_local_chain_{str(time.time()).replace('.', '_')}"
167+
def stop_existing_test_containers():
168+
"""Stop running Docker containers with names starting with 'test_local_chain_'."""
169+
try:
170+
existing_container_result = subprocess.run(
171+
[
172+
"docker",
173+
"ps",
174+
"--filter",
175+
f"name={CONTAINER_NAME_PREFIX}",
176+
"--format",
177+
"{{.ID}}",
178+
],
179+
stdout=subprocess.PIPE,
180+
stderr=subprocess.PIPE,
181+
text=True,
182+
check=True,
183+
)
184+
container_ids = existing_container_result.stdout.strip().splitlines()
185+
for cid in container_ids:
186+
if cid:
187+
print(f"Stopping existing container: {cid}")
188+
subprocess.run(["docker", "stop", cid], check=True)
189+
except subprocess.CalledProcessError as e:
190+
print(f"Failed to stop existing containers: {e}")
191+
192+
container_name = f"{CONTAINER_NAME_PREFIX}{str(time.time()).replace('.', '_')}"
167193

168194
# Command to start container
169195
cmds = [
@@ -182,6 +208,8 @@ def try_start_docker():
182208

183209
try_start_docker()
184210

211+
stop_existing_test_containers()
212+
185213
# Start container
186214
with subprocess.Popen(
187215
cmds,

0 commit comments

Comments
 (0)