mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-22 01:13:00 +02:00
test: Add new sanity check tests
One to verify it is the correct version on the duts and one that check that it is the correct bootorder.
This commit is contained in:
@@ -6,12 +6,26 @@
|
||||
infamy:
|
||||
specification: False
|
||||
|
||||
- case: meta/bootorder.py
|
||||
infamy:
|
||||
specification: False
|
||||
|
||||
- case: meta/check-version.py
|
||||
infamy:
|
||||
specification: False
|
||||
|
||||
|
||||
- name: Misc tests
|
||||
suite: misc/misc.yaml
|
||||
|
||||
- name: ietf-system
|
||||
suite: ietf_system/ietf_system.yaml
|
||||
|
||||
# Upgrade may leave wrong boot order
|
||||
- case: meta/bootorder.py
|
||||
infamy:
|
||||
specification: False
|
||||
|
||||
- name: ietf-syslog
|
||||
suite: ietf_syslog/ietf_syslog.yaml
|
||||
|
||||
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python3
|
||||
import infamy
|
||||
|
||||
with infamy.Test() as test:
|
||||
with test.step("Discover topology and attach to available DUTs"):
|
||||
env = infamy.Env(False)
|
||||
ctrl = env.ptop.get_ctrl()
|
||||
duts = {}
|
||||
duts_state = {}
|
||||
for ix in env.ptop.get_infixen():
|
||||
cport, ixport = env.ptop.get_mgmt_link(ctrl, ix)
|
||||
print(f"Attaching to {ix}:{ixport} via {ctrl}:{cport}")
|
||||
duts[ix] = env.attach(ix, ixport)
|
||||
|
||||
with test.step("Verify bootorder"):
|
||||
for name, tgt in duts.items():
|
||||
expected = env.ptop.get_expected_boot(name)
|
||||
running = tgt.get_data("/ietf-system:system-state")
|
||||
running = running['system-state']['software']['booted']
|
||||
print(f"{name}: booted: {running} expected: {expected}")
|
||||
|
||||
if running != expected:
|
||||
test.fail()
|
||||
test.succeed()
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python3
|
||||
import infamy
|
||||
import os
|
||||
|
||||
with infamy.Test() as test:
|
||||
with test.step("Discover topology and attach to available DUTs"):
|
||||
env = infamy.Env(False)
|
||||
ctrl = env.ptop.get_ctrl()
|
||||
duts = {}
|
||||
duts_state = {}
|
||||
for ix in env.ptop.get_infixen():
|
||||
cport, ixport = env.ptop.get_mgmt_link(ctrl, ix)
|
||||
print(f"Attaching to {ix}:{ixport} via {ctrl}:{cport}")
|
||||
duts[ix] = env.attach(ix, ixport)
|
||||
|
||||
with test.step("Verify software version"):
|
||||
expected=os.environ.get("VERSION")
|
||||
for name, tgt in duts.items():
|
||||
running = tgt.get_data("/ietf-system:system-state")
|
||||
running = running['system-state']['platform']['os-version']
|
||||
print(f"{name}: booted: {running} expected {expected}")
|
||||
if running != expected:
|
||||
test.fail()
|
||||
test.succeed()
|
||||
@@ -13,27 +13,4 @@ with infamy.Test() as test:
|
||||
else:
|
||||
print(f"Specify PYTHONHASHSEED={seed} to reproduce this test environment")
|
||||
|
||||
with test.step("Discover topology and attach to available DUTs"):
|
||||
env = infamy.Env(False)
|
||||
ctrl = env.ptop.get_ctrl()
|
||||
|
||||
duts = {}
|
||||
for ix in env.ptop.get_infixen():
|
||||
cport, ixport = env.ptop.get_mgmt_link(ctrl, ix)
|
||||
print(f"Attaching to {ix}:{ixport} via {ctrl}:{cport}")
|
||||
duts[ix] = env.attach(ix, ixport)
|
||||
|
||||
with test.step("Log running software versions"):
|
||||
for name, tgt in duts.items():
|
||||
sys = tgt.get_data("/ietf-system:system-state")
|
||||
sw = sys["system-state"]["software"]
|
||||
plt = sys["system-state"]["platform"]
|
||||
|
||||
print(f"{name}:")
|
||||
for k,v in plt.items():
|
||||
print(f" {k:<16s} {v}")
|
||||
|
||||
for k in ("compatible", "booted"):
|
||||
print(f" {k:<16s} {sw[k]}")
|
||||
|
||||
test.succeed()
|
||||
|
||||
@@ -184,6 +184,7 @@ while getopts "b:cCDf:hiKp:q:rt:" opt; do
|
||||
kvm=
|
||||
;;
|
||||
p)
|
||||
version=$(unsquashfs -cat $OPTARG manifest.raucm | awk -F'=' '/^version=/ {print $2}')
|
||||
INFAMY_ARGS="$INFAMY_ARGS -p $OPTARG"
|
||||
;;
|
||||
q)
|
||||
@@ -234,6 +235,7 @@ if [ "$containerize" ]; then
|
||||
--env NINEPM_PROJ_CONFIG="$NINEPM_PROJ_CONFIG" \
|
||||
--env QENETH_PATH="$testdir/templates:$testdir" \
|
||||
--env PS1="$(build_ps1)" \
|
||||
--env VERSION="$version" \
|
||||
$extra_env \
|
||||
--expose 9001-9010 --publish-all \
|
||||
-v "$HOME/.infix/.ash_history":/root/.ash_history \
|
||||
|
||||
@@ -131,6 +131,13 @@ class Topology:
|
||||
|
||||
return qstrip(password) if password is not None else "admin"
|
||||
|
||||
def get_expected_boot(self, node):
|
||||
n = self.dotg.get_node(node)
|
||||
b = n[0] if n else {}
|
||||
boot = b.get("expected_boot")
|
||||
|
||||
return _qstrip(boot)
|
||||
|
||||
def get_link(self, src, dst, flt=lambda _: True):
|
||||
es = self.g.get_edge_data(src, dst)
|
||||
for e in es.values():
|
||||
@@ -150,7 +157,6 @@ class Topology:
|
||||
def get_infixen(self):
|
||||
return self.get_nodes(lambda _, attrs: compatible(attrs, {"requires": {"infix"}}))
|
||||
|
||||
|
||||
def get_attr(self, name, default=None):
|
||||
return _qstrip(self.dotg.get_attributes().get(name, default))
|
||||
|
||||
|
||||
+1
-2
@@ -14,8 +14,7 @@ mode-qeneth := -q $(test-dir)/virt/quad
|
||||
mode-host := -t $(or $(TOPOLOGY),/etc/infamy.dot)
|
||||
mode-run := -t $(BINARIES_DIR)/qemu.dot
|
||||
mode := $(mode-$(TEST_MODE))
|
||||
|
||||
INFIX_IMAGE_ID := $(call qstrip,$(INFIX_IMAGE_ID))
|
||||
INFIX_IMAGE_ID := $(call qstrip,$(INFIX_IMAGE_ID))
|
||||
binaries-$(ARCH) := $(addprefix $(INFIX_IMAGE_ID),.img -disk.qcow2)
|
||||
pkg-$(ARCH) := -p $(O)/images/$(addprefix $(INFIX_IMAGE_ID),.pkg)
|
||||
binaries-x86_64 += OVMF.fd
|
||||
|
||||
@@ -25,6 +25,7 @@ graph "dual" {
|
||||
label="{ <e1> e1 | <e2> e2 | <e3> e3 } | dut1 | { <e4> e4 | <e5> e5 | <e6> e6 }",
|
||||
pos="10,18!",
|
||||
provides="infix",
|
||||
expected_boot="primary",
|
||||
qn_console=9001,
|
||||
qn_mem="384M",
|
||||
qn_usb="dut1.usb"
|
||||
@@ -33,6 +34,7 @@ graph "dual" {
|
||||
label="{ <e1> e1 | <e2> e2 | <e3> e3 } | dut2 | { <e4> e4 | <e5> e5 | <e6> e6 }",
|
||||
pos="10,12!",
|
||||
provides="infix",
|
||||
expected_boot="primary",
|
||||
qn_console=9002,
|
||||
qn_mem="384M",
|
||||
qn_usb="dut2.usb"
|
||||
|
||||
@@ -24,6 +24,7 @@ graph "quad" {
|
||||
label="{ <e1> e1 | <e2> e2 | <e3> e3 | <e4> e4 } | dut1 | { <e5> e5 | <e6> e6 | <e7> e7 | <e8> e8}",
|
||||
pos="10,30!",
|
||||
provides="infix",
|
||||
expected_boot="primary",
|
||||
qn_console=9001,
|
||||
qn_mem="384M",
|
||||
qn_usb="dut1.usb"
|
||||
@@ -32,6 +33,7 @@ graph "quad" {
|
||||
label="{ <e1> e1 | <e2> e2 | <e3> e3 | <e4> e4 } | dut2 | { <e5> e5 | <e6> e6 | <e7> e7 | <e8> e8}",
|
||||
pos="0,20!",
|
||||
provides="infix",
|
||||
expected_boot="primary",
|
||||
qn_console=9002,
|
||||
qn_mem="384M",
|
||||
qn_usb="dut2.usb"
|
||||
@@ -40,6 +42,7 @@ graph "quad" {
|
||||
label="{ <e1> e1 | <e2> e2 | <e3> e3 | <e4> e4 } | dut3 | { <e5> e5 | <e6> e6 | <e7> e7 | <e8> e8}",
|
||||
pos="0,10!",
|
||||
provides="infix",
|
||||
expected_boot="primary",
|
||||
qn_console=9003,
|
||||
qn_mem="384M",
|
||||
qn_usb="dut3.usb"
|
||||
@@ -49,6 +52,7 @@ graph "quad" {
|
||||
label="{ <e1> e1 | <e2> e2 | <e3> e3 | <e4> e4 } | dut4 | { <e5> e5 | <e6> e6 | <e7> e7 | <e8> e8}",
|
||||
pos="10,0!",
|
||||
provides="infix",
|
||||
expected_boot="primary",
|
||||
qn_console=9004,
|
||||
qn_mem="384M",
|
||||
qn_usb="dut4.usb"
|
||||
|
||||
Reference in New Issue
Block a user