File tree Expand file tree Collapse file tree 9 files changed +71
-28
lines changed
Expand file tree Collapse file tree 9 files changed +71
-28
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,7 @@ rm -f "$TARGET_DIR/etc/os-release"
8686 fi
8787} > " $TARGET_DIR /etc/os-release"
8888
89+ cp " $TARGET_DIR /etc/os-release" " $BINARIES_DIR /"
8990echo " $INFIX_TAGLINE $INFIX_VERSION -- $( date +" %b %e %H:%M %Z %Y" ) " > " $TARGET_DIR /etc/version"
9091
9192# In case of ambguities, this is what the image was built from
Original file line number Diff line number Diff line change 66 infamy :
77 specification : False
88
9+ - case : meta/sanity-check.py
10+ infamy :
11+ specification : False
12+
913- name : Misc tests
1014 suite : misc/misc.yaml
1115
1216- name : ietf-system
1317 suite : ietf_system/ietf_system.yaml
1418
19+ # Upgrade may leave wrong boot order
20+ - case : meta/sanity-check.py
21+ infamy :
22+ specification : False
23+
1524- name : ietf-syslog
1625 suite : ietf_syslog/ietf_syslog.yaml
1726
Original file line number Diff line number Diff line change 1313 else :
1414 print (f"Specify PYTHONHASHSEED={ seed } to reproduce this test environment" )
1515
16- with test .step ("Discover topology and attach to available DUTs" ):
17- env = infamy .Env (False )
18- ctrl = env .ptop .get_ctrl ()
19-
20- duts = {}
21- for ix in env .ptop .get_infixen ():
22- cport , ixport = env .ptop .get_mgmt_link (ctrl , ix )
23- print (f"Attaching to { ix } :{ ixport } via { ctrl } :{ cport } " )
24- duts [ix ] = env .attach (ix , ixport )
25-
26- with test .step ("Log running software versions" ):
27- for name , tgt in duts .items ():
28- sys = tgt .get_data ("/ietf-system:system-state" )
29- sw = sys ["system-state" ]["software" ]
30- plt = sys ["system-state" ]["platform" ]
31-
32- print (f"{ name } :" )
33- for k ,v in plt .items ():
34- print (f" { k :<16s} { v } " )
35-
36- for k in ("compatible" , "booted" ):
37- print (f" { k :<16s} { sw [k ]} " )
38-
3916 test .succeed ()
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3
2+ import infamy
3+ import os
4+
5+ with infamy .Test () as test :
6+ with test .step ("Discover topology and attach to available DUTs" ):
7+ env = infamy .Env (False )
8+ ctrl = env .ptop .get_ctrl ()
9+ duts = {}
10+ duts_state = {}
11+ for ix in env .ptop .get_infixen ():
12+ cport , ixport = env .ptop .get_mgmt_link (ctrl , ix )
13+ print (f"Attaching to { ix } :{ ixport } via { ctrl } :{ cport } " )
14+ duts [ix ] = env .attach (ix , ixport )
15+ sys = duts [ix ].get_data ("/ietf-system:system-state" )
16+ sw = sys ["system-state" ]["software" ]
17+ plt = sys ["system-state" ]["platform" ]
18+ duts_state [ix ] = {
19+ "platform" : plt ,
20+ "software" : sw
21+ }
22+ with test .step ("Verify bootorder" ):
23+ for name , tgt in duts .items ():
24+ expected = env .ptop .get_boot (name )
25+ running = duts_state [name ]["software" ]["booted" ]
26+ print (f"{ name } : booted: { running } expected: { expected } " )
27+
28+ if running != expected :
29+ test .fail ()
30+ with test .step ("Verify software version" ):
31+ expected = os .environ .get ("VERSION" )
32+ for name , tgt in duts .items ():
33+ running = duts_state [name ]["platform" ]["os-version" ]
34+ print (f"{ name } : booted: { running } expected { expected } " )
35+ if running != expected :
36+ test .fail ()
37+ test .succeed ()
Original file line number Diff line number Diff line change @@ -67,6 +67,9 @@ usage: test/env [-cDhiKr] -f <IMAGE> -q <QENETH-DIR> <COMMAND> [<ARGS>...]
6767 topology. If the command is containerized, it will be launched
6868 in the host's network namespace
6969
70+ -v <VERSION>
71+ Version of the image under test.
72+
7073EOF
7174}
7275
@@ -154,7 +157,7 @@ containerize=yes
154157files=
155158basedir=" $ixdir "
156159
157- while getopts " b:cCDf:hiKp:q:rt:" opt; do
160+ while getopts " b:cCDf:hiKp:q:rt:v: " opt; do
158161 case ${opt} in
159162 b)
160163 basedir=" $OPTARG "
@@ -198,6 +201,9 @@ while getopts "b:cCDf:hiKp:q:rt:" opt; do
198201 network=" --network host --volume $topology :$topology :ro"
199202 runners=" docker podman"
200203 ;;
204+ v)
205+ version=" $OPTARG "
206+ ;;
201207 * )
202208 >&2 echo " Unknown option -$opt "
203209 usage
@@ -234,6 +240,7 @@ if [ "$containerize" ]; then
234240 --env NINEPM_PROJ_CONFIG=" $NINEPM_PROJ_CONFIG " \
235241 --env QENETH_PATH=" $testdir /templates:$testdir " \
236242 --env PS1=" $( build_ps1) " \
243+ --env VERSION=" $version " \
237244 $extra_env \
238245 --expose 9001-9010 --publish-all \
239246 -v " $HOME /.infix/.ash_history" :/root/.ash_history \
Original file line number Diff line number Diff line change @@ -131,6 +131,13 @@ def get_password(self, node):
131131
132132 return qstrip (password ) if password is not None else "admin"
133133
134+ def get_boot (self , node ):
135+ n = self .dotg .get_node (node )
136+ b = n [0 ] if n else {}
137+ boot = b .get ("boot" )
138+
139+ return _qstrip (boot )
140+
134141 def get_link (self , src , dst , flt = lambda _ : True ):
135142 es = self .g .get_edge_data (src , dst )
136143 for e in es .values ():
@@ -150,7 +157,6 @@ def get_ctrl(self):
150157 def get_infixen (self ):
151158 return self .get_nodes (lambda _ , attrs : compatible (attrs , {"requires" : {"infix" }}))
152159
153-
154160 def get_attr (self , name , default = None ):
155161 return _qstrip (self .dotg .get_attributes ().get (name , default ))
156162
Original file line number Diff line number Diff line change @@ -14,8 +14,8 @@ mode-qeneth := -q $(test-dir)/virt/quad
1414mode-host := -t $(or $(TOPOLOGY ) ,/etc/infamy.dot)
1515mode-run := -t $(BINARIES_DIR ) /qemu.dot
1616mode := $(mode-$(TEST_MODE ) )
17-
18- INFIX_IMAGE_ID := $(call qstrip,$(INFIX_IMAGE_ID ) )
17+ INFIX_VERSION := $( shell sed -n 's/^VERSION="\(. * \) "/\1/p' $( BINARIES_DIR ) /os-release)
18+ INFIX_IMAGE_ID := $(call qstrip,$(INFIX_IMAGE_ID ) )
1919binaries-$(ARCH) := $(addprefix $(INFIX_IMAGE_ID ) ,.img -disk.qcow2)
2020pkg-$(ARCH) := -p $(O ) /images/$(addprefix $(INFIX_IMAGE_ID ) ,.pkg)
2121binaries-x86_64 += OVMF.fd
3030 $(test-dir ) /env -r $(base ) $(mode ) $(binaries ) $(pkg-$(ARCH ) ) $(ninepm ) -v $(TESTS )
3131
3232test-sh :
33- $(test-dir ) /env $(base ) $(mode ) $(binaries ) $(pkg-$(ARCH ) ) -i /bin/sh
33+ $(test-dir ) /env $(base ) $(mode ) $(binaries ) $(pkg-$(ARCH ) ) -v $( INFIX_VERSION ) - i /bin/sh
3434
3535test-spec :
3636 @esc_infix_name=" $( echo $( INFIX_NAME) | sed ' s/\//\\\//g' ) " ; \
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ graph "dual" {
2525 label="{ <e1> e1 | <e2> e2 | <e3> e3 } | dut1 | { <e4> e4 | <e5> e5 | <e6> e6 }",
2626 pos="10,18!",
2727 provides="infix",
28+ boot="primary",
2829 qn_console=9001,
2930 qn_mem="384M",
3031 qn_usb="dut1.usb"
@@ -33,6 +34,7 @@ graph "dual" {
3334 label="{ <e1> e1 | <e2> e2 | <e3> e3 } | dut2 | { <e4> e4 | <e5> e5 | <e6> e6 }",
3435 pos="10,12!",
3536 provides="infix",
37+ boot="primary",
3638 qn_console=9002,
3739 qn_mem="384M",
3840 qn_usb="dut2.usb"
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ graph "quad" {
2424 label="{ <e1> e1 | <e2> e2 | <e3> e3 | <e4> e4 } | dut1 | { <e5> e5 | <e6> e6 | <e7> e7 | <e8> e8}",
2525 pos="10,30!",
2626 provides="infix",
27+ boot="primary",
2728 qn_console=9001,
2829 qn_mem="384M",
2930 qn_usb="dut1.usb"
@@ -32,6 +33,7 @@ graph "quad" {
3233 label="{ <e1> e1 | <e2> e2 | <e3> e3 | <e4> e4 } | dut2 | { <e5> e5 | <e6> e6 | <e7> e7 | <e8> e8}",
3334 pos="0,20!",
3435 provides="infix",
36+ boot="primary",
3537 qn_console=9002,
3638 qn_mem="384M",
3739 qn_usb="dut2.usb"
@@ -40,6 +42,7 @@ graph "quad" {
4042 label="{ <e1> e1 | <e2> e2 | <e3> e3 | <e4> e4 } | dut3 | { <e5> e5 | <e6> e6 | <e7> e7 | <e8> e8}",
4143 pos="0,10!",
4244 provides="infix",
45+ boot="primary",
4346 qn_console=9003,
4447 qn_mem="384M",
4548 qn_usb="dut3.usb"
@@ -49,6 +52,7 @@ graph "quad" {
4952 label="{ <e1> e1 | <e2> e2 | <e3> e3 | <e4> e4 } | dut4 | { <e5> e5 | <e6> e6 | <e7> e7 | <e8> e8}",
5053 pos="10,0!",
5154 provides="infix",
55+ boot="primary",
5256 qn_console=9004,
5357 qn_mem="384M",
5458 qn_usb="dut4.usb"
You can’t perform that action at this time.
0 commit comments