mirror of
https://github.com/NVIDIA/OpenShell.git
synced 2026-10-20 06:00:06 +08:00
* feat(e2e): run kubernetes suite on cargo-nextest with JUnit/HTML reports
Switch e2e:kubernetes (and all its variants) from `cargo test` to
`cargo nextest run` for per-test process isolation and output consistent
with the other nextest-based CI runs.
- Add a dedicated `e2e-kubernetes` nextest profile with a JUnit report and a
generous slow-timeout (60s flag, 5-min terminate) suited to live-cluster
tests; kept separate from `ci` so its JUnit path and timeouts don't affect
the workspace run.
- Pin `--target-dir` for the run so the profile's relative JUnit path resolves
to the repo-root results/ regardless of any inherited CARGO_TARGET_DIR
(nextest ignores absolute JUnit paths).
- Render the JUnit XML to a standalone HTML report via xsltproc and a committed
XSLT stylesheet (best-effort; never masks the test exit code).
- Name each report via `OPENSHELL_E2E_REPORT_NAME` (default `e2e-kubernetes`),
used verbatim for both the `results/<name>.{xml,html}` filenames and the HTML
heading. Tasks that invoke the script multiple times in one run set a distinct
name per invocation so the reports no longer clobber the single fixed path:
the credential-driver runs write results/e2e-kubernetes-secrets.xml and
-vault.xml, and e2e:kubernetes:agent-sandbox-versions writes
results/e2e-kubernetes-agent-sandbox-v1beta1.xml and -v1alpha1.xml.
- Declare cargo-nextest in mise [tools] so the task runs without the Nix shell.
- Ignore the results/ output directory.
The results/ reports do not leak information. They are gitignored and no
workflow uploads them as artifacts, so they stay on the ephemeral CI runner
and are discarded when it is torn down. The HTML template renders only test
names, status, timings, and failure messages (no captured stdout/stderr).
Moving from `cargo test -- --nocapture` to nextest's captured, failure-only
output also reduces what lands in the retained, viewable console logs.
Signed-off-by: Jorge Garcia Oncins <jgarciao@redhat.com>
* chore(e2e): revert per-lane report names for agent-sandbox-versions
The agent-sandbox-versions task runs two lanes sequentially against the
same cluster: v0.5.0 (v1beta1 storage version) then v0.4.6 (v1alpha1).
On a reused cluster the second lane fails when kubectl applies the older
CRD, because Kubernetes refuses to drop v1beta1 from spec.versions while
it remains in status.storedVersions (the storage-version downgrade
guardrail). This is a pre-existing issue with the v0.4.6 lane, unrelated
to the nextest reporting work.
The per-lane OPENSHELL_E2E_REPORT_NAME additions do not address that
downgrade failure, so revert them to keep this PR scoped to the nextest
change. Agent Sandbox 0.4.x is also superseded (1.0.0 is published);
dropping or bumping the v1alpha1 lane is left as a follow-up.
Signed-off-by: Jorge Garcia Oncins <jgarciao@redhat.com>
---------
Signed-off-by: Jorge Garcia Oncins <jgarciao@redhat.com>
120 lines
4.4 KiB
Bash
Executable File
120 lines
4.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
# Run the Rust e2e suite against an OpenShell gateway deployed on Kubernetes
|
|
# via Helm. Set OPENSHELL_E2E_KUBE_CONTEXT to target an existing cluster;
|
|
# otherwise an ephemeral k3d cluster is created and torn down by
|
|
# with-kube-gateway.sh. Set OPENSHELL_E2E_KUBE_TEST to scope to a single
|
|
# integration test for local debugging.
|
|
#
|
|
# Features: the default set includes `e2e-host-gateway` so tests that rely on
|
|
# the sandbox-side `host.openshell.internal` alias compile and run. The
|
|
# wrapper detects the cluster's host-routable IP and wires it into the chart
|
|
# via `server.hostGatewayIP`. Targeting a cluster where the test host is
|
|
# unreachable from pods? Set OPENSHELL_E2E_KUBERNETES_FEATURES=e2e to drop the
|
|
# alias-dependent tests entirely.
|
|
#
|
|
# Results: `run_suite` writes a JUnit + HTML report under `results/`. Set
|
|
# `OPENSHELL_E2E_REPORT_NAME` to name it per run when invoking this script repeatedly.
|
|
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
RUN_WITH_GATEWAY_COMMAND="__openshell_run_kubernetes_e2e"
|
|
# shellcheck source=e2e/support/conformance.sh
|
|
source "${ROOT}/e2e/support/conformance.sh"
|
|
|
|
E2E_FEATURES="${OPENSHELL_E2E_KUBERNETES_FEATURES-e2e,e2e-host-gateway,e2e-kubernetes}"
|
|
|
|
# Fixed output path of the `e2e-kubernetes` nextest profile (`.config/nextest.toml`).
|
|
JUNIT_XML="${ROOT}/results/e2e-kubernetes.xml"
|
|
|
|
# Render a sibling HTML report from a JUnit XML. Best-effort: failures only warn.
|
|
render_html() {
|
|
local xml="${1:-${JUNIT_XML}}"
|
|
local title="${2:-e2e-kubernetes}"
|
|
[ -f "${xml}" ] || return 0
|
|
local html="${xml%.xml}.html"
|
|
if command -v xsltproc >/dev/null 2>&1; then
|
|
xsltproc --stringparam title "${title}" \
|
|
"${ROOT}/scripts/junit-to-html.xsl" "${xml}" >"${html}" \
|
|
&& echo "HTML report: ${html}" \
|
|
|| echo "WARNING: failed to render HTML report from ${xml}" >&2
|
|
else
|
|
echo "WARNING: xsltproc not found; skipping HTML report (${xml} still written)" >&2
|
|
fi
|
|
}
|
|
|
|
# Docker and Podman build their local gateway and CLI together in the shared
|
|
# gateway wrapper. Kubernetes consumes published gateway images, so only its
|
|
# local CLI needs to be built when CI has not supplied a prebuilt one.
|
|
if [ -z "${OPENSHELL_BIN:-}" ]; then
|
|
cargo build -p openshell-cli
|
|
export OPENSHELL_BIN="${ROOT}/target/debug/openshell"
|
|
fi
|
|
|
|
test_filter=()
|
|
if [ -n "${OPENSHELL_E2E_KUBE_TEST:-}" ]; then
|
|
test_filter+=(--test "${OPENSHELL_E2E_KUBE_TEST}")
|
|
fi
|
|
|
|
is_operator_workspace_mode() {
|
|
[[ ",${E2E_FEATURES}," == *",e2e-kubernetes-workspace-operator,"* ]]
|
|
}
|
|
|
|
run_conformance() {
|
|
if is_operator_workspace_mode; then
|
|
echo "note: skipping standalone CLI conformance in Kubernetes operator workspace mode; default workspace is not operator-allowlisted (see #2971)."
|
|
return 0
|
|
fi
|
|
|
|
e2e_run_openshell_conformance "Kubernetes"
|
|
}
|
|
|
|
# `OPENSHELL_E2E_REPORT_NAME` (default `e2e-kubernetes`) names the report
|
|
# `results/<name>.{xml,html}` and its heading, so repeated runs do not clobber.
|
|
run_suite() {
|
|
local name="${OPENSHELL_E2E_REPORT_NAME:-e2e-kubernetes}"
|
|
local report="${ROOT}/results/${name}.xml"
|
|
local status=0
|
|
"${ROOT}/e2e/with-kube-gateway.sh" \
|
|
bash "${BASH_SOURCE[0]}" "${RUN_WITH_GATEWAY_COMMAND}" || status=$?
|
|
if [ "${report}" != "${JUNIT_XML}" ]; then
|
|
mv -f "${JUNIT_XML}" "${report}" 2>/dev/null || true
|
|
fi
|
|
render_html "${report}" "${name}"
|
|
return "${status}"
|
|
}
|
|
|
|
run_e2e() {
|
|
run_conformance
|
|
if [ -z "${E2E_FEATURES}" ]; then
|
|
return 0
|
|
fi
|
|
|
|
# Pin `--target-dir` so the profile `junit.path` resolves regardless of `CARGO_TARGET_DIR`.
|
|
cargo nextest run --profile e2e-kubernetes \
|
|
--config-file "${ROOT}/.config/nextest.toml" \
|
|
--target-dir "${ROOT}/e2e/rust/target" \
|
|
--manifest-path "${ROOT}/e2e/rust/Cargo.toml" \
|
|
--features "${E2E_FEATURES}" \
|
|
${test_filter[@]+"${test_filter[@]}"}
|
|
}
|
|
|
|
if [ "${1:-}" = "${RUN_WITH_GATEWAY_COMMAND}" ]; then
|
|
run_e2e
|
|
exit 0
|
|
fi
|
|
|
|
# Credential-driver mode: run once per storage backend, each with its own report.
|
|
if [ "${OPENSHELL_E2E_CREDENTIAL_DRIVERS:-0}" = "1" ] \
|
|
&& [ -z "${OPENSHELL_E2E_CREDENTIAL_DRIVER:-}" ]; then
|
|
OPENSHELL_E2E_CREDENTIAL_DRIVER=kubernetes-secrets \
|
|
OPENSHELL_E2E_REPORT_NAME=e2e-kubernetes-secrets run_suite
|
|
OPENSHELL_E2E_CREDENTIAL_DRIVER=vault \
|
|
OPENSHELL_E2E_REPORT_NAME=e2e-kubernetes-vault run_suite
|
|
else
|
|
run_suite
|
|
fi
|