Merge pull request #1117 from kernelkit/test-stability

Test stability
This commit is contained in:
Tobias Waldekranz
2025-08-27 13:23:15 +02:00
committed by GitHub
6 changed files with 14 additions and 62 deletions
+1 -3
View File
@@ -2,12 +2,10 @@
- settings:
test-spec: Readme.adoc
- case: meta/wait.py
infamy:
specification: False
- case: meta/reproducible.py
infamy:
specification: False
- name: Misc tests
suite: misc/misc.yaml
@@ -75,11 +75,5 @@ nsenter -m/1/ns/mnt -u/1/ns/uts -i/1/ns/ipc -n/1/ns/net hostname {hostname_new}
until(lambda: c.running(cont_name), attempts=10)
with test.step("Verify the new hostname set by the container"):
oper = target.get_data("/ietf-system:system")
name = oper["system"]["hostname"]
if name != hostname_new:
print(f"Expected hostname: {hostname_new}, actual hostname: {name}")
test.fail()
until(lambda: c.running(cont_name) != target.get_data("/ietf-system:system")["system"]["hostname"], attempts=10)
test.succeed()
-49
View File
@@ -1,49 +0,0 @@
#!/usr/bin/env python3
import time
import infamy
import infamy.neigh
TIMEOUT = 300
def ll6ping(node):
cport, nport = env.ptop.get_mgmt_link(ctrl, node)
neigh = infamy.neigh.ll6ping(cport, flags=["-w1", "-c1", "-L", "-n"])
if neigh:
print(f"Found {neigh} on {cport} (connected to {node}:{nport})")
return neigh
return None
def is_reachable(node, env):
neigh = ll6ping(node)
if not neigh:
return False
return infamy.util.is_reachable(neigh, env, env.ptop.get_password(node))
with infamy.Test() as test:
with test.step("Initialize"):
# The test is designed to be run on a physical topology.
env = infamy.Env(ltop=False)
ctrl = env.ptop.get_ctrl()
infixen = env.ptop.get_infixen()
with test.step(f"Reach {infixen}"):
print(f"Waiting for {infixen} to come up, timeout: {TIMEOUT / 60} min")
timeout = time.time() + TIMEOUT
while infixen and time.time() < timeout:
time.sleep(1)
infixen = [node for node in infixen if not is_reachable(node, env)]
if infixen:
print(f"Unable to reach {infixen}")
test.fail()
test.succeed()
+12 -1
View File
@@ -6,7 +6,7 @@ import sys
import random
import inspect
from . import neigh, netconf, restconf, ssh, tap, topology
from . import neigh, netconf, restconf, ssh, tap, topology, util
class NullEnv:
@@ -116,6 +116,13 @@ class Env(object):
def get_password(self, node):
return self.ptop.get_password(node)
def is_reachable(self, node, port):
ip = neigh.ll6ping(port)
if not ip:
return False
return util.is_reachable(ip, self, self.get_password(node))
def attach(self, node, port="mgmt", protocol=None, test_reset=True, username = None, password = None):
"""Attach to node on port using protocol."""
@@ -126,6 +133,7 @@ class Env(object):
else:
mapping = None
# Precedence:
# 1. Caller specifies `protocol`
# 2. User specifies `-t` when executing test
@@ -141,6 +149,9 @@ class Env(object):
ctrl = self.ptop.get_ctrl()
cport, _ = self.ptop.get_mgmt_link(ctrl, node)
print("Waiting for DUTs to become reachable...")
util.parallel(util.until(lambda: self.is_reachable(node, cport), 300))
print(f"Probing {node} on port {cport} for IPv6LL mgmt address ...")
mgmtip = neigh.ll6ping(cport)
if not mgmtip:
-1
View File
@@ -22,7 +22,6 @@ from . import env, netutil
def netconf_syn(addr):
if netutil.tcp_port_is_open(addr, 830):
print(f"{addr} answers to TCP connections on port 830 (NETCONF)")
return True
else:
return False
-1
View File
@@ -101,7 +101,6 @@ def restconf_reachable(neigh, password):
response = requests_workaround_get(url, headers=headers, auth=auth,
verify=False)
if response.status_code == 200:
print(f"{neigh} answers to TCP connections on port 443 (RESTCONF)")
return True
except:
return False