Skip to content

Commit 4a1e2c4

Browse files
author
jvd10
committed
fix(local-ci): harden sandbox startup/seeding and reduce flaky integration failures
This commit groups local CI stability fixes discovered while running make ci on macOS/arm64 and in environments without host-side Vault CLI tools. Changes included: 1) scripts/up.sh - Gate the ipmi profile on actual image availability. - If SBX_IPMI_SIM_IMAGE is neither present locally nor pullable, continue without COMPOSE_PROFILES=ipmi instead of failing up/ci. - Emit heartbeat + stderr warning to make the fallback explicit. 2) fixtures/vault-seed.sh - Remove dependency on a host-installed vault binary. - Add a shell function that executes vault commands inside sandbox-vault via docker exec, forwarding VAULT_ADDR and VAULT_TOKEN. - Keeps seeding self-contained and consistent with the running stack. 3) tests/bats/cli-smoke.bats - Same portability fix as seed script: run vault commands inside sandbox-vault instead of requiring host vault CLI. - Eliminates command-not-found failures in bats smoke tests on fresh machines. 4) compose/bmc-sim.yaml - Escape HOSTNAME in the openssl subject from to 18386{HOSTNAME}. - Prevents docker compose host-side interpolation warning and preserves container runtime expansion. 5) compose/core.yaml - power-control: set platform: linux/amd64 to avoid manifest/platform resolution failures on arm64 hosts. - fru-tracker: tune sqlite DSN with _busy_timeout=5000 and _journal_mode=WAL to reduce write-lock contention during reconcile-heavy UC7 runs. 6) tests/integration/uc4_tokensmith_smd_test.go - Add jwt.WithLeeway(30*time.Second) to token parsing. - Reduces false negatives caused by minor clock skew where freshly minted tokens can briefly appear 'not valid yet'. Net effect: - Sandbox startup is more resilient when optional/local images are missing. - Vault seed + bats smoke no longer require host vault installation. - Compose warning noise is removed. - UC4 claim validation is less flaky across hosts. - Host architecture and sqlite contention edge cases are handled better for local CI iteration. Signed-off-by: jvd10 <jay.depasse@hpe.com>
1 parent dc5dc62 commit 4a1e2c4

6 files changed

Lines changed: 32 additions & 6 deletions

File tree

compose/bmc-sim.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ x-redfish-bmc: &redfish-bmc
4141
mkdir -p /tmp/tls
4242
openssl req -x509 -newkey rsa:2048 -nodes \
4343
-keyout /tmp/tls/key.pem -out /tmp/tls/cert.pem \
44-
-days 365 -subj "/CN=${HOSTNAME}" 2>/dev/null
44+
-days 365 -subj "/CN=$${HOSTNAME}" 2>/dev/null
4545
exec sushy-emulator --fake -i :: -p 443 \
4646
--ssl-certificate /tmp/tls/cert.pem \
4747
--ssl-key /tmp/tls/key.pem

compose/core.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ services:
118118
command:
119119
- "serve"
120120
- "--port=27793"
121-
- "--database-url=file:/data/fru.db?cache=shared&_fk=1"
121+
- "--database-url=file:/data/fru.db?cache=shared&_fk=1&_busy_timeout=5000&_journal_mode=WAL"
122122
tmpfs:
123123
- /data:mode=1777
124124
ports:
@@ -127,6 +127,7 @@ services:
127127

128128
power-control:
129129
image: ${SBX_POWER_IMAGE:-ghcr.io/openchami/pcs:pr-68}
130+
platform: linux/amd64
130131
container_name: sandbox-power
131132
# power-control's Vault credstore (HMS hms-securestorage) only authenticates
132133
# to Vault via the K8s service-account JWT flow — VAULT_TOKEN is ignored.

fixtures/vault-seed.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,19 @@ set -euo pipefail
88
VAULT_ADDR="${VAULT_ADDR:-http://127.0.0.1:8200}"
99
VAULT_TOKEN="${VAULT_TOKEN:-dev-root-token}"
1010
CLUSTER="${CLUSTER:-sandbox}"
11+
CONTAINER="${VAULT_CONTAINER:-sandbox-vault}"
1112

1213
export VAULT_ADDR VAULT_TOKEN
1314

1415
XNAMES=(x0c0s0b0 x0c0s1b0 x0c0s2b0 x0c0s3b0 x0c0s4b0 x0c0s5b0 x0c0s6b0 x0c0s7b0)
1516

17+
vault() {
18+
docker exec -i \
19+
-e VAULT_ADDR="$VAULT_ADDR" \
20+
-e VAULT_TOKEN="$VAULT_TOKEN" \
21+
"$CONTAINER" vault "$@"
22+
}
23+
1624
# --- KV-v2 namespace for cluster-wide secrets (mirrors openchami-operator) ---
1725
vault secrets enable -path=openchami kv-v2 2>/dev/null || true
1826

scripts/up.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,18 @@ fi
2828
WAIT_PER_TIMEOUT_S=60 bash scripts/wait-for-stack.sh infra
2929

3030
# Gate the ipmi_sim service (compose/bmc-sim.yaml::ipmi-bmc-0 has
31-
# `profiles: ["ipmi"]`) on SKIP_SIM. With SKIP_SIM=true the build is
32-
# skipped and the image won't pull; the profile keeps compose from trying.
31+
# `profiles: ["ipmi"]`) on SKIP_SIM and image availability. If the image
32+
# is missing and cannot be pulled, skip ipmi instead of hard-failing `up`.
3333
if [[ -z "${COMPOSE_PROFILES:-}" ]]; then
3434
if [[ "${SKIP_SIM:-false}" != "true" ]]; then
35-
export COMPOSE_PROFILES="ipmi"
35+
if docker image inspect "$SBX_IPMI_SIM_IMAGE" >/dev/null 2>&1; then
36+
export COMPOSE_PROFILES="ipmi"
37+
elif timeout 30 docker pull --quiet "$SBX_IPMI_SIM_IMAGE" >/dev/null 2>&1; then
38+
export COMPOSE_PROFILES="ipmi"
39+
else
40+
bash scripts/heartbeat.sh up-warning "ipmi image unavailable; continuing with SKIP_SIM=true"
41+
echo "up: WARN: IPMI image unavailable ($SBX_IPMI_SIM_IMAGE); continuing without ipmi profile" >&2
42+
fi
3643
fi
3744
fi
3845

tests/bats/cli-smoke.bats

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ setup() {
77
: "${SBX_VAULT_URL:=http://127.0.0.1:8200}"
88
: "${SBX_SMD_URL:=http://127.0.0.1:27779}"
99
: "${SBX_LOCALSTACK_URL:=http://127.0.0.1:4566}"
10+
: "${VAULT_CONTAINER:=sandbox-vault}"
1011
export VAULT_ADDR="$SBX_VAULT_URL"
1112
export VAULT_TOKEN="${VAULT_TOKEN:-dev-root-token}"
1213
export AWS_ACCESS_KEY_ID=test
@@ -15,6 +16,13 @@ setup() {
1516
export AWS_ENDPOINT_URL="$SBX_LOCALSTACK_URL"
1617
}
1718

19+
vault() {
20+
docker exec -i \
21+
-e VAULT_ADDR="$VAULT_ADDR" \
22+
-e VAULT_TOKEN="$VAULT_TOKEN" \
23+
"$VAULT_CONTAINER" vault "$@"
24+
}
25+
1826
@test "vault status reports unsealed" {
1927
run vault status -format=json
2028
[ "$status" -eq 0 ]

tests/integration/uc4_tokensmith_smd_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ func TestUC4_Tokensmith_SMD(t *testing.T) {
118118
"RS256", "RS384", "RS512",
119119
"PS256", "PS384", "PS512",
120120
"ES256", "ES384", "ES512",
121-
}))
121+
}),
122+
jwt.WithLeeway(30*time.Second),
123+
)
122124
if err != nil {
123125
t.Fatalf("verify JWT against JWKS: %v", err)
124126
}

0 commit comments

Comments
 (0)