mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-10-21 07:08:12 +00:00
test(genesis): preserve status publication failure policies
This commit is contained in:
@@ -54,7 +54,7 @@ tail -n +2 "$XCAT_TEST_NEXTDESTINY_QUEUE" >"$XCAT_TEST_NEXTDESTINY_QUEUE.new"
|
||||
mv "$XCAT_TEST_NEXTDESTINY_QUEUE.new" "$XCAT_TEST_NEXTDESTINY_QUEUE"
|
||||
printf '%s\n' "$response"
|
||||
SH
|
||||
printf '#!/bin/sh\nprintf "logger %%s\\n" "$*" >>"$XCAT_TEST_LOG"\n' >"$bin/logger"
|
||||
printf '#!/bin/sh\nprintf "logger %%s\\n" "$*" >>"$XCAT_TEST_LOG"\n[ -z "${XCAT_TEST_LOGGER_FAIL-}" ]\n' >"$bin/logger"
|
||||
printf '#!/bin/sh\nprintf "%%s\\n" discover >>"$XCAT_TEST_LOG"\n' >"$bin/discover"
|
||||
printf '#!/bin/sh\nprintf "%%s\\n" getcert >>"$XCAT_TEST_LOG"\n: >"$XCAT_TEST_CERTIFICATE_FILE"\n' >"$bin/getcert"
|
||||
printf '#!/bin/sh\nprintf "reboot-control %%s\\n" "$*" >>"$XCAT_TEST_LOG"\n' >"$bin/reboot-control"
|
||||
@@ -269,3 +269,13 @@ has_no_line()
|
||||
[ "$(cat "$destiny_file")" = osimage ]
|
||||
has_line "$record" '^CODE=XCAT_CHAIN_ADVANCE_FAILED$'
|
||||
}
|
||||
|
||||
@test "action status failures use the caller diagnostic and propagate a logging failure" {
|
||||
export XCAT_STATUS_COMMAND=/bin/false
|
||||
run_action standby
|
||||
[ "$status" -eq 0 ]
|
||||
grep -Fx 'logger -t xcat-genesis-action -- unable to publish action status' "$command_log"
|
||||
[ "$(cat "$destiny_file")" = standby ]
|
||||
XCAT_TEST_LOGGER_FAIL=1 run_action standby
|
||||
[ "$status" -eq 1 ]
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ setup()
|
||||
printf '%s\n' XCATDEST=192.0.2.10:3001 XCATMASTER=192.0.2.10 XCATPORT=3001 \
|
||||
XCAT_INTERFACE=eth0 XCAT_SOURCE_ADDRESS=192.0.2.98 >"$state_dir/genesis.env"
|
||||
|
||||
printf '#!/bin/sh\n[ -z "${XCAT_TEST_LOGGER_FAIL-}" ]\n' >"$bin/logger"
|
||||
printf '#!/bin/sh\nprintf "logger %%s\\n" "$*" >>"$XCAT_TEST_LOG"\n[ -z "${XCAT_TEST_LOGGER_FAIL-}" ]\n' >"$bin/logger"
|
||||
printf '#!/bin/sh\n[ "$1" = "-m" ] && printf "%%s\\n" "${XCAT_TEST_ARCH-x86_64}"\n' >"$bin/uname"
|
||||
cat >"$bin/ipmitool" <<'SH'
|
||||
#!/bin/sh
|
||||
@@ -292,12 +292,17 @@ not_in_packet()
|
||||
[ "$status" -ne 0 ]
|
||||
}
|
||||
|
||||
@test "the certificate client installs only the PEM certificate from a signed x509 request" {
|
||||
printf '%s\n' 'XCATDEST=[2001:db8::10]:3001' XCATMASTER=2001:db8::10 XCATPORT=3001 \
|
||||
XCAT_INTERFACE=eth0 XCAT_SOURCE_ADDRESS=2001:db8::98 >"$state_dir/genesis.env"
|
||||
credential_response()
|
||||
{
|
||||
printf '%s\n' XCAT_NODE_NAME=node042 XCAT_DESTINY=standby >"$XCAT_METADATA_FILE"
|
||||
printf '%s\n' '<xcatresponse>' '<data><content>' '-----BEGIN CERTIFICATE-----' 'Q0VSVA==' \
|
||||
'-----END CERTIFICATE-----' '</content></data>' '</xcatresponse>' >"$XCAT_TEST_CREDENTIAL_RESPONSE"
|
||||
}
|
||||
|
||||
@test "the certificate client installs only the PEM certificate from a signed x509 request" {
|
||||
printf '%s\n' 'XCATDEST=[2001:db8::10]:3001' XCATMASTER=2001:db8::10 XCATPORT=3001 \
|
||||
XCAT_INTERFACE=eth0 XCAT_SOURCE_ADDRESS=2001:db8::98 >"$state_dir/genesis.env"
|
||||
credential_response
|
||||
run /bin/bash "$GETCERT"
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$(cat "$XCAT_KEY_DIR/cert.pem")" = '-----BEGIN CERTIFICATE-----
|
||||
@@ -312,6 +317,27 @@ Q0VSVA==
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "discovery status failures use the caller diagnostic and propagate a logging failure" {
|
||||
export XCAT_STATUS_COMMAND=/bin/false
|
||||
discover
|
||||
[ "$status" -eq 0 ]
|
||||
[ -s "$packet" ]
|
||||
grep -Fx 'logger -t xcat-genesis-discover -- unable to publish discovery status' "$XCAT_TEST_LOG"
|
||||
XCAT_TEST_LOGGER_FAIL=1 discover
|
||||
[ "$status" -eq 1 ]
|
||||
}
|
||||
|
||||
@test "credential status failures keep the singular diagnostic and propagate a logging failure" {
|
||||
export XCAT_STATUS_COMMAND=/bin/false
|
||||
credential_response
|
||||
run /bin/bash "$GETCERT"
|
||||
[ "$status" -eq 0 ]
|
||||
[ -s "$XCAT_KEY_DIR/cert.pem" ]
|
||||
grep -Fx 'logger -t xcat-genesis-getcert -- unable to publish credential status' "$XCAT_TEST_LOG"
|
||||
XCAT_TEST_LOGGER_FAIL=1 run /bin/bash "$GETCERT"
|
||||
[ "$status" -eq 1 ]
|
||||
}
|
||||
|
||||
@test "the certificate client rejects an unsafe node name with a specific code" {
|
||||
printf '%s\n' XCAT_NODE_NAME=invalid/name >"$XCAT_METADATA_FILE"
|
||||
run /bin/bash "$GETCERT"
|
||||
|
||||
@@ -395,6 +395,17 @@ VERIFIED_SECONDS=123' ]
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "network status failures use the caller diagnostic and propagate a logging failure" {
|
||||
export XCAT_STATUS_COMMAND=/bin/false
|
||||
printf 'xcatd=127.0.0.1:%s BOOTIF=01-52-54-00-00-00-35\n' "$port" >"$XCAT_CMDLINE_FILE"
|
||||
network_state
|
||||
[ "$status" -eq 0 ]
|
||||
grep -Fx 'logger -t xcat-genesis-network-state -- unable to publish network status' "$XCAT_TEST_LOG"
|
||||
[ -s "$state_dir/genesis.env" ]
|
||||
XCAT_TEST_LOGGER_FAIL=1 network_state
|
||||
[ "$status" -eq 1 ]
|
||||
}
|
||||
|
||||
@test "unsafe network data is rejected, never evaluated, and does not replace the prior state" {
|
||||
printf 'xcatd=127.0.0.1:%s BOOTIF=01-52-54-00-00-00-35\n' "$port" >"$XCAT_CMDLINE_FILE"
|
||||
network_state
|
||||
@@ -476,6 +487,17 @@ with_network_state()
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "registration status failures use the caller diagnostic and propagate a logging failure" {
|
||||
export XCATDEST=192.0.2.213:3001 XCAT_STATUS_COMMAND=/bin/false
|
||||
printf 'xcatd=192.0.2.213:3001 destiny=shell\n' >"$XCAT_CMDLINE_FILE"
|
||||
run /bin/bash "$REGISTER_SCRIPT"
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$(cat "$state_dir/destiny")" = shell ]
|
||||
grep -Fx 'logger -t xcat-genesis-register -- unable to publish registration status' "$XCAT_TEST_LOG"
|
||||
XCAT_TEST_LOGGER_FAIL=1 run /bin/bash "$REGISTER_SCRIPT"
|
||||
[ "$status" -eq 1 ]
|
||||
}
|
||||
|
||||
@test "registration requests a missing destiny, and rejects an empty one without replacing state" {
|
||||
export XCATDEST=192.0.2.213:3001
|
||||
printf 'xcatd=192.0.2.213:3001\n' >"$XCAT_CMDLINE_FILE"
|
||||
|
||||
@@ -302,8 +302,12 @@ class GenesisMetadata(unittest.TestCase):
|
||||
library_owner = "xcat-genesis-init"
|
||||
if "xcat-genesis-common" in self.dependencies(library_owner):
|
||||
library_owner = "xcat-genesis-common"
|
||||
self.assertIn(library_owner, self.dependencies("xcat-genesis-discovery"))
|
||||
self.assertEqual(self.dependencies(library_owner), {"bash", "util-linux-logger"})
|
||||
library_data, library_root = self.install(library_owner)
|
||||
self.installed(library_data, library_root, "libexecdir", "xcat/genesis-functions", 0o644)
|
||||
library = self.installed(library_data, library_root, "libexecdir", "xcat/genesis-functions", 0o644)
|
||||
self.assertEqual(library.read_bytes(),
|
||||
(LAYER / "recipes-core/xcat-genesis-init/files/genesis-functions").read_bytes())
|
||||
for name in ("genesis-status", "genesis-maintenance-shell"):
|
||||
self.installed(data, root, "libexecdir", "xcat/" + name, 0o755)
|
||||
self.assertFalse(list(root.rglob("*debug-shell*")))
|
||||
|
||||
Reference in New Issue
Block a user