Skip to content

Commit 59475aa

Browse files
authored
ci(kubernetes): add kube gateway e2e tests and gated CI workflow (ai-openshell#1251)
* test(helm): Add kube gateway e2e tests Signed-off-by: Taylor Mutch <taylormutch@gmail.com> * ci(helm): add Branch Helm E2E workflow gated on test:e2e-helm Adds a label-gated GitHub Actions workflow that exercises the Helm chart end-to-end against the Rust e2e suite via `mise run e2e:helm`. Pipeline: - pr_metadata gates on the `test:e2e-helm` label via the pr-gate action. - build-gateway / build-supervisor build and push Docker images using the reusable docker-build.yml workflow. - helm-e2e (bare runner): apt-installs z3 build deps so cargo can compile the openshell-policy crate's z3-sys backend, creates a kind cluster via helm/kind-action, materializes the kind kubeconfig at the path mise's [env] block expects, side-loads the freshly built gateway/supervisor images, applies deploy/kube/manifests/agent-sandbox.yaml so the sandboxes.agents.x-k8s.io CRD and reconciling StatefulSet are in place, and finally runs `mise run e2e:helm`. Also expands the `e2e:helm` task to run the full Rust e2e suite (matching `e2e:podman`) instead of only the smoke test, with OPENSHELL_E2E_KUBE_TEST as an opt-in single-test override for local debugging. Extends the e2e-label-help workflow so applying `test:e2e-helm` posts the next-step hint pointing at this workflow. Signed-off-by: Taylor Mutch <taylormutch@gmail.com> * test(helm-e2e): run host-gateway tests on the kube driver Six tests previously skipped on the kubernetes driver — three in host_gateway_alias.rs plus the forward_proxy_l7 + graphql_l7 cases — relied on `host.openshell.internal` reaching either a host process or a sibling docker container. The Helm chart already supports this via `server.hostGatewayIP`, but the e2e wrapper never set it. - with-kube-gateway.sh: auto-detect the host-routable IP (CoreDNS `host.k3d.internal` first to handle Docker Desktop, docker network gateway as a fallback for kind on Linux CI) and pass it to helm install. Also import locally-built images into existing k3d clusters and wait for namespace deletion to complete before exit. - e2e/rust/Cargo.toml + e2e-helm.sh: add an `e2e-host-gateway` feature that gates the three test files; docker and podman runs imply it, helm runs opt in by default (overridable via OPENSHELL_E2E_HELM_FEATURES for remote clusters where the test host is unreachable from pods). - Drop the `skip_if_kube` helper and its callers — feature gating now decides whether the tests compile in. Verified against a local k3d cluster: all six previously-skipped tests pass, smoke regression intact. * refactor(e2e): rename e2e:helm to e2e:kubernetes The runner exercises the gateway on Kubernetes; helm is just the deployment mechanism. Names now describe the target environment. - mise task: `e2e:helm` -> `e2e:kubernetes` - script: e2e/rust/e2e-helm.sh -> e2e/rust/e2e-kubernetes.sh - env var: OPENSHELL_E2E_HELM_FEATURES -> OPENSHELL_E2E_KUBERNETES_FEATURES - workflow: branch-helm-e2e.yml -> branch-kubernetes-e2e.yml (display name "Branch Kubernetes E2E", job "kubernetes-e2e") - PR gate label: test:e2e-helm -> test:e2e-kubernetes (e2e-label-help hint workflow updated to match) PR ai-openshell#1251 needs the new label applied; the old label can be removed. * fix(e2e): prefer IPv4 host-gateway IP from dual-stack docker networks kind dual-stacks its network; the wrapper's awk picked the first non-empty gateway, which was the IPv6 entry (fc00:...). Sandbox pods can't reach the test host's IPv4 listener through that, so the L7 and host-gateway-alias tests failed in CI even though they passed locally against k3d (where host.k3d.internal in CoreDNS short-circuits the docker-network fallback). Restrict the awk filter to IPv4 octets. --------- Signed-off-by: Taylor Mutch <taylormutch@gmail.com>
1 parent 6184d24 commit 59475aa

6 files changed

Lines changed: 492 additions & 3 deletions

File tree

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: Branch Kubernetes E2E
5+
6+
on:
7+
push:
8+
branches:
9+
- "pull-request/[0-9]+"
10+
workflow_dispatch: {}
11+
12+
permissions: {}
13+
14+
jobs:
15+
pr_metadata:
16+
name: Resolve PR metadata
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
pull-requests: read
21+
outputs:
22+
should_run: ${{ steps.gate.outputs.should_run }}
23+
steps:
24+
- uses: actions/checkout@v6
25+
26+
- id: gate
27+
uses: ./.github/actions/pr-gate
28+
with:
29+
required_label: test:e2e-kubernetes
30+
31+
build-gateway:
32+
needs: [pr_metadata]
33+
if: needs.pr_metadata.outputs.should_run == 'true'
34+
permissions:
35+
contents: read
36+
packages: write
37+
uses: ./.github/workflows/docker-build.yml
38+
with:
39+
component: gateway
40+
platform: linux/amd64
41+
42+
build-supervisor:
43+
needs: [pr_metadata]
44+
if: needs.pr_metadata.outputs.should_run == 'true'
45+
permissions:
46+
contents: read
47+
packages: write
48+
uses: ./.github/workflows/docker-build.yml
49+
with:
50+
component: supervisor
51+
platform: linux/amd64
52+
53+
kubernetes-e2e:
54+
name: Kubernetes E2E (Rust smoke)
55+
needs: [pr_metadata, build-gateway, build-supervisor]
56+
if: needs.pr_metadata.outputs.should_run == 'true'
57+
# Bare runner: running kind-in-container hits nested-Docker / kubeconfig
58+
# complications. The runner has Docker; mise installs helm, kubectl, and
59+
# the Rust toolchain.
60+
runs-on: linux-amd64-cpu8
61+
timeout-minutes: 60
62+
permissions:
63+
contents: read
64+
packages: read
65+
env:
66+
MISE_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
KIND_CLUSTER_NAME: kube-e2e-${{ github.run_id }}
68+
steps:
69+
- uses: actions/checkout@v6
70+
71+
- name: Install mise
72+
run: |
73+
curl https://mise.run | sh
74+
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
75+
echo "$HOME/.local/share/mise/shims" >> "$GITHUB_PATH"
76+
77+
- name: Install tools
78+
run: mise install --locked
79+
80+
# The openshell-policy crate transitively pulls in z3-sys, whose
81+
# build script needs the z3 C/C++ headers and clang/bindgen to
82+
# compile. The bare runner doesn't ship them; the CI container
83+
# image used by other Rust e2e jobs does, but we can't run this job
84+
# there (the runner's container handler injects its own --network
85+
# bridge, which conflicts with the --network host we need so kind's
86+
# API server is reachable from the test process).
87+
- name: Install z3 build deps
88+
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libz3-dev clang
89+
90+
- name: Log in to GHCR
91+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
92+
93+
- name: Create kind cluster
94+
uses: helm/kind-action@v1
95+
with:
96+
cluster_name: ${{ env.KIND_CLUSTER_NAME }}
97+
wait: 120s
98+
99+
# mise.toml sets KUBECONFIG="{{config_root}}/kubeconfig"; helm/kind-action
100+
# writes to ~/.kube/config. Materialize the kind context at the mise path
101+
# so `mise run e2e:kubernetes` (and the wrapper's `kubectl --context=…`)
102+
# finds the kind cluster.
103+
- name: Export kind kubeconfig to mise path
104+
run: |
105+
set -euo pipefail
106+
kind get kubeconfig --name "$KIND_CLUSTER_NAME" > "$GITHUB_WORKSPACE/kubeconfig"
107+
chmod 600 "$GITHUB_WORKSPACE/kubeconfig"
108+
109+
# Pre-pull and side-load: kind nodes don't have ghcr credentials, and
110+
# tagging IMAGE_TAG to a SHA means the chart's IfNotPresent pull policy
111+
# is satisfied once the image is loaded into the node's containerd.
112+
- name: Load gateway and supervisor images into kind
113+
run: |
114+
set -euo pipefail
115+
for component in gateway supervisor; do
116+
image="ghcr.io/nvidia/openshell/${component}:${{ github.sha }}"
117+
docker pull "$image"
118+
kind load docker-image "$image" --name "$KIND_CLUSTER_NAME"
119+
done
120+
121+
- name: Run Kubernetes E2E (Rust smoke)
122+
env:
123+
OPENSHELL_E2E_KUBE_CONTEXT: kind-${{ env.KIND_CLUSTER_NAME }}
124+
IMAGE_TAG: ${{ github.sha }}
125+
OPENSHELL_REGISTRY: ghcr.io/nvidia/openshell
126+
run: mise run --no-deps --skip-deps e2e:kubernetes

‎.github/workflows/e2e-label-help.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ permissions: {}
1919
jobs:
2020
hint:
2121
name: Post next-step hint for E2E label
22-
if: github.event.label.name == 'test:e2e' || github.event.label.name == 'test:e2e-gpu'
22+
if: github.event.label.name == 'test:e2e' || github.event.label.name == 'test:e2e-gpu' || github.event.label.name == 'test:e2e-kubernetes'
2323
runs-on: ubuntu-latest
2424
permissions:
2525
pull-requests: write
@@ -40,6 +40,7 @@ jobs:
4040
case "$LABEL_NAME" in
4141
test:e2e) workflow_file=branch-e2e.yml; workflow_name="Branch E2E Checks" ;;
4242
test:e2e-gpu) workflow_file=test-gpu.yml; workflow_name="GPU Test" ;;
43+
test:e2e-kubernetes) workflow_file=branch-kubernetes-e2e.yml; workflow_name="Branch Kubernetes E2E" ;;
4344
*) echo "Unrecognized label $LABEL_NAME"; exit 1 ;;
4445
esac
4546

‎e2e/rust/Cargo.toml‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,17 @@ publish = false
1717

1818
[features]
1919
e2e = []
20-
e2e-docker = ["e2e"]
20+
# Selects tests that rely on `host.openshell.internal` (the sandbox's stable
21+
# alias to the host running test fixtures). docker and podman wire the alias
22+
# unconditionally; the kube driver only does so when the chart's
23+
# `server.hostGatewayIP` is set, so `e2e-kubernetes` does NOT imply this and
24+
# the helm wrapper opts in explicitly when it has resolved an IP.
25+
e2e-host-gateway = ["e2e"]
26+
e2e-docker = ["e2e", "e2e-host-gateway"]
2127
e2e-gpu = ["e2e"]
2228
e2e-docker-gpu = ["e2e-docker", "e2e-gpu"]
2329
e2e-kubernetes = ["e2e"]
24-
e2e-podman = ["e2e"]
30+
e2e-podman = ["e2e", "e2e-host-gateway"]
2531
e2e-podman-gpu = ["e2e-podman", "e2e-gpu"]
2632

2733
[[test]]
@@ -44,6 +50,21 @@ name = "user_namespaces"
4450
path = "tests/user_namespaces.rs"
4551
required-features = ["e2e-kubernetes"]
4652

53+
[[test]]
54+
name = "host_gateway_alias"
55+
path = "tests/host_gateway_alias.rs"
56+
required-features = ["e2e-host-gateway"]
57+
58+
[[test]]
59+
name = "forward_proxy_l7_bypass"
60+
path = "tests/forward_proxy_l7_bypass.rs"
61+
required-features = ["e2e-host-gateway"]
62+
63+
[[test]]
64+
name = "forward_proxy_graphql_l7"
65+
path = "tests/forward_proxy_graphql_l7.rs"
66+
required-features = ["e2e-host-gateway"]
67+
4768
[[test]]
4869
name = "gpu_device_selection"
4970
path = "tests/gpu_device_selection.rs"

‎e2e/rust/e2e-kubernetes.sh‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
# Run the Rust e2e suite against an OpenShell gateway deployed on Kubernetes
6+
# via Helm. Set OPENSHELL_E2E_KUBE_CONTEXT to target an existing cluster;
7+
# otherwise an ephemeral k3d cluster is created and torn down by
8+
# with-kube-gateway.sh. Set OPENSHELL_E2E_KUBE_TEST to scope to a single
9+
# integration test (e.g. smoke) for local debugging.
10+
#
11+
# Features: the default set includes `e2e-host-gateway` so tests that rely on
12+
# the sandbox-side `host.openshell.internal` alias compile and run. The
13+
# wrapper detects the cluster's host-routable IP and wires it into the chart
14+
# via `server.hostGatewayIP`. Targeting a cluster where the test host is
15+
# unreachable from pods? Set OPENSHELL_E2E_KUBERNETES_FEATURES=e2e to drop the
16+
# alias-dependent tests entirely.
17+
18+
set -euo pipefail
19+
20+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
21+
22+
E2E_FEATURES="${OPENSHELL_E2E_KUBERNETES_FEATURES:-e2e,e2e-host-gateway}"
23+
24+
cargo build -p openshell-cli --features openshell-core/dev-settings
25+
26+
test_filter=()
27+
if [ -n "${OPENSHELL_E2E_KUBE_TEST:-}" ]; then
28+
test_filter+=(--test "${OPENSHELL_E2E_KUBE_TEST}")
29+
fi
30+
31+
exec "${ROOT}/e2e/with-kube-gateway.sh" \
32+
cargo test --manifest-path "${ROOT}/e2e/rust/Cargo.toml" \
33+
--features "${E2E_FEATURES}" \
34+
--no-fail-fast \
35+
${test_filter[@]+"${test_filter[@]}"} \
36+
-- --nocapture

0 commit comments

Comments
 (0)