mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-10-22 07:38:08 +00:00
c6fc094c93
The Perl tests of the OpenEmbedded Genesis image ran its shell scripts
and C programs through system(), qx, pipes and fork, wrote fake
commands through copied read_file and write_file helpers, and matched
regexes against shell and C source. Many rejections checked only a
non-zero exit, so an earlier, unrelated failure also passed. The
quality gate judged 91% of their 762 checks bad.
The shell and C checks move to bats in xCAT-test/bats. The C programs
are compiled there and run: the plain console, test drivers for the
shared status view and the shell launcher, and genesis-udp-send against
a loopback listener. Each rejection now matches the message of its own
guard. The .t files keep the artifact checks (kas, recipes, kernel
fragments, units, README), read with XCAT::Test::File. Test files left
with no checks are deleted.
Claim map (file -> where its claims went):
- go_xcat_uninstall_installed_only.t -> go_xcat_uninstall_installed_only.bats
- genesis_readme_paths.t, genesis_base_sources_staged.t -> kept in the
.t (README read by slurp_repo_file, tarball read by Archive::Tar)
- genesis_openembedded_{export,hardware,runtime}.t -> the bats file of
the same name
- genesis_openembedded_{bmcsetup,metrics,extensions,qeth,actions,
discovery}.t -> scripts to the bats file of the same name, recipes
and units kept in the .t
- genesis_openembedded_console.t -> built and run checks, state.c,
plain_ui.c and shell.c to genesis_openembedded_console.bats; Newt
source checks kept in the .t
- genesis_openembedded.t -> oe/build to genesis_openembedded_build.bats;
shell matches to the runtime, hardware and extensions bats; console
matches to the console bats or the console .t; artifacts kept
Red proof: every moved or new test was run against a mutated copy of
the code it covers and went red, for example: rpm -q not checked,
tar without --mtime, VEX report not exported, support dir after PATH,
digest check off, layer2 forced, wildcard device allowed, arguments
eval'd, tcp probe skipped, SOURCE_PORT 302, AF_INET only, stage timer
compared, launch error ignored, kas run twice, status written in place.
One mutation stayed green: tar without --owner=0 when the test runs as
root.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
146 lines
5.5 KiB
Bash
146 lines
5.5 KiB
Bash
#!/usr/bin/env bats
|
|
#
|
|
# genesis-qeth runs in the s390x Genesis image before NetworkManager. It groups the qeth
|
|
# channels named by rd.znet=qeth on the kernel command line, or found by znetconf -u, and
|
|
# publishes the result. znetconf, genesis-status and logger are scratch scripts that log
|
|
# their arguments; znetconf answers -c and -u from files.
|
|
|
|
load 'helpers/shell_source'
|
|
|
|
QETH='xCAT-genesis-base/oe/meta-xcat-genesis/recipes-connectivity/xcat-genesis-qeth/files/genesis-qeth'
|
|
|
|
setup()
|
|
{
|
|
QETH_SCRIPT="$(require_repo_file "$QETH")"
|
|
bin="$BATS_TEST_TMPDIR/bin"
|
|
mkdir -p "$bin"
|
|
cat >"$bin/znetconf" <<'SH'
|
|
#!/bin/sh
|
|
printf 'znetconf %s\n' "$*" >>"$XCAT_TEST_LOG"
|
|
case "$1" in
|
|
-c)
|
|
cat "$XCAT_TEST_CONFIGURED"
|
|
exit "${XCAT_TEST_CONFIGURED_STATUS:-0}"
|
|
;;
|
|
-u)
|
|
cat "$XCAT_TEST_UNCONFIGURED"
|
|
exit "${XCAT_TEST_UNCONFIGURED_STATUS:-0}"
|
|
;;
|
|
-a)
|
|
[ "${XCAT_TEST_FAIL_CHANNELS:-}" != "$2" ]
|
|
;;
|
|
esac
|
|
SH
|
|
printf '#!/bin/sh\nprintf "status %%s\\n" "$*" >>"$XCAT_TEST_LOG"\n' >"$bin/genesis-status"
|
|
printf '#!/bin/sh\nprintf "logger %%s\\n" "$*" >>"$XCAT_TEST_LOG"\n' >"$bin/logger"
|
|
chmod 0755 "$bin"/*
|
|
|
|
export PATH="$bin:$PATH"
|
|
export XCAT_CIO_SETTLE_FILE="$BATS_TEST_TMPDIR/cio_settle"
|
|
export XCAT_CMDLINE_FILE="$BATS_TEST_TMPDIR/cmdline"
|
|
export XCAT_STATUS_COMMAND="$bin/genesis-status"
|
|
export XCAT_ZNETCONF_COMMAND="$bin/znetconf"
|
|
export XCAT_TEST_CONFIGURED="$BATS_TEST_TMPDIR/configured"
|
|
export XCAT_TEST_UNCONFIGURED="$BATS_TEST_TMPDIR/unconfigured"
|
|
export XCAT_TEST_LOG="$BATS_TEST_TMPDIR/commands.log"
|
|
: >"$XCAT_CIO_SETTLE_FILE"
|
|
: >"$XCAT_TEST_CONFIGURED"
|
|
: >"$XCAT_TEST_UNCONFIGURED"
|
|
: >"$XCAT_TEST_LOG"
|
|
}
|
|
|
|
# Run genesis-qeth with a kernel command line. $status is its exit status.
|
|
run_qeth()
|
|
{
|
|
printf '%s\n' "$1" >"$XCAT_CMDLINE_FILE"
|
|
run /bin/bash "$QETH_SCRIPT"
|
|
}
|
|
|
|
activations()
|
|
{
|
|
grep '^znetconf -a ' "$XCAT_TEST_LOG" || true
|
|
}
|
|
|
|
@test "a system without ccwgroup devices needs no qeth setup, after CIO work settles" {
|
|
XCAT_TEST_UNCONFIGURED_STATUS=31 run_qeth 'console=ttysclp0 xcatd=192.0.2.1'
|
|
[ "$status" -eq 0 ]
|
|
[ -z "$(activations)" ]
|
|
[ "$(cat "$XCAT_CIO_SETTLE_FILE")" = 1 ]
|
|
}
|
|
|
|
@test "configured qeth devices need no activation" {
|
|
printf '0.0.0500,0.0.0501,0.0.0502 1731/01 OSA 10 qeth enc500 online\n' >"$XCAT_TEST_CONFIGURED"
|
|
run_qeth 'console=ttysclp0 xcatd=192.0.2.1'
|
|
[ "$status" -eq 0 ]
|
|
[ -z "$(activations)" ]
|
|
}
|
|
|
|
@test "an explicit qeth triplet is normalized, defaults to layer 2, and is published" {
|
|
run_qeth 'rd.znet=qeth,0600,0.0.0601,0.0.0602,portno=1 xcatd=192.0.2.1'
|
|
[ "$status" -eq 0 ]
|
|
[ "$(activations)" = 'znetconf -a 0.0.0600,0.0.0601,0.0.0602 -d qeth -o portno=1 -o layer2=1' ]
|
|
grep -qx 'status network CONFIGURING_NETWORK qeth devices are ready' "$XCAT_TEST_LOG"
|
|
}
|
|
|
|
@test "a duplicate qeth triplet is grouped once" {
|
|
run_qeth 'rd.znet=qeth,0.0.0600,0.0.0601,0.0.0602 rd.znet=qeth,0.0.0600,0.0.0601,0.0.0602 xcatd=192.0.2.1'
|
|
[ "$status" -eq 0 ]
|
|
[ "$(activations | grep -c '^znetconf -a 0\.0\.0600,0\.0\.0601,0\.0\.0602 ')" -eq 1 ]
|
|
}
|
|
|
|
@test "explicit qeth options are accepted, and an explicit layer is not overridden" {
|
|
run_qeth 'rd.znet=qeth,0.0.0610,0.0.0611,0.0.0612,layer2=0,portname=test xcatd=192.0.2.1'
|
|
[ "$status" -eq 0 ]
|
|
[ "$(activations)" = 'znetconf -a 0.0.0610,0.0.0611,0.0.0612 -d qeth -o layer2=0 -o portname=test' ]
|
|
}
|
|
|
|
@test "an already configured triplet is left unchanged" {
|
|
printf '0.0.0620,0.0.0621,0.0.0622 1731/01 OSA 10 qeth enc600 online\n' >"$XCAT_TEST_CONFIGURED"
|
|
run_qeth 'rd.znet=qeth,0.0.0620,0.0.0621,0.0.0622 xcatd=192.0.2.1'
|
|
[ "$status" -eq 0 ]
|
|
[ -z "$(activations)" ]
|
|
}
|
|
|
|
@test "unconfigured qeth devices are discovered and activated for DHCP, other types are not" {
|
|
printf '%s\n' 'Scanning for network devices...' \
|
|
'Device IDs Type Card Type CHPID Drv.' \
|
|
'0.0.0710,0.0.0711 3088/60 LCS OSA 20 lcs' \
|
|
'0.0.0700,0.0.0701,0.0.0702 1731/01 OSA (QDIO) 10 qeth' >"$XCAT_TEST_UNCONFIGURED"
|
|
run_qeth 'xcatd=192.0.2.1'
|
|
[ "$status" -eq 0 ]
|
|
[ "$(activations)" = 'znetconf -a 0.0.0700,0.0.0701,0.0.0702 -d qeth -o layer2=1' ]
|
|
}
|
|
|
|
@test "a qeth discovery error is returned and published" {
|
|
XCAT_TEST_UNCONFIGURED_STATUS=9 run_qeth 'xcatd=192.0.2.1'
|
|
[ "$status" -eq 9 ]
|
|
grep -q '^status network DEGRADED Unable to inspect qeth devices' "$XCAT_TEST_LOG"
|
|
}
|
|
|
|
@test "a non-qeth rd.znet entry disables qeth discovery and activates nothing" {
|
|
printf '0.0.0700,0.0.0701,0.0.0702 1731/01 OSA 10 qeth\n' >"$XCAT_TEST_UNCONFIGURED"
|
|
run_qeth 'rd.znet=ctc,0.0.0800,0.0.0801 xcatd=192.0.2.1'
|
|
[ "$status" -eq 0 ]
|
|
refute_grep -qx 'znetconf -u' "$XCAT_TEST_LOG"
|
|
[ -z "$(activations)" ]
|
|
}
|
|
|
|
@test "an incomplete qeth triplet fails with a degraded status" {
|
|
run_qeth 'rd.znet=qeth,0.0.0900,0.0.0901 xcatd=192.0.2.1'
|
|
[ "$status" -eq 1 ]
|
|
grep -q '^status network DEGRADED One or more qeth devices' "$XCAT_TEST_LOG"
|
|
}
|
|
|
|
@test "an invalid qeth option fails before activation" {
|
|
run_qeth 'rd.znet=qeth,0.0.0910,0.0.0911,0.0.0912,bad?=1 xcatd=192.0.2.1'
|
|
[ "$status" -eq 1 ]
|
|
[ -z "$(activations)" ]
|
|
}
|
|
|
|
@test "failure of one qeth triplet is reported, and the others are still attempted" {
|
|
XCAT_TEST_FAIL_CHANNELS=0.0.0a00,0.0.0a01,0.0.0a02 \
|
|
run_qeth 'rd.znet=qeth,0.0.0a00,0.0.0a01,0.0.0a02 rd.znet=qeth,0.0.0b00,0.0.0b01,0.0.0b02 xcatd=192.0.2.1'
|
|
[ "$status" -eq 1 ]
|
|
activations | grep -q '^znetconf -a 0\.0\.0b00,0\.0\.0b01,0\.0\.0b02 '
|
|
}
|