Skip to content

Commit 4f60062

Browse files
jluhrsenMeina-rh
authored andcommitted
Add CI lane for e2e tests
Signed-off-by: Jamo Luhrsen <jluhrsen@gmail.com>
1 parent 8d6db36 commit 4f60062

File tree

4 files changed

+110
-2
lines changed

4 files changed

+110
-2
lines changed

.github/workflows/e2e.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: E2E Tests
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
push:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: e2e-${{ github.head_ref || github.run_id }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
e2e:
19+
name: E2E Test Suite
20+
runs-on: ubuntu-24.04
21+
timeout-minutes: 20
22+
strategy:
23+
matrix:
24+
include:
25+
- {mode: "live-mode"}
26+
- {mode: "offline-mode"}
27+
env:
28+
JOB_NAME: "${{ matrix.mode }}"
29+
steps:
30+
- name: Check out code into the Go module directory
31+
uses: actions/checkout@v4
32+
33+
- name: Set up Go
34+
uses: actions/setup-go@v5
35+
with:
36+
go-version-file: go.mod
37+
cache: false
38+
id: go
39+
40+
- name: Install dependencies
41+
run: |
42+
set -x
43+
# Check if jinjanator is already available
44+
if ! command -v jinjanate &> /dev/null; then
45+
echo "jinjanator not found, installing..."
46+
sudo apt-get update
47+
sudo apt-get install -y pipx
48+
pipx install jinjanator
49+
pipx ensurepath
50+
echo "$HOME/.local/bin" >> $GITHUB_PATH
51+
else
52+
echo "jinjanator already installed"
53+
fi
54+
55+
- name: Verify jinjanator installation
56+
run: |
57+
set -x
58+
which jinjanate
59+
jinjanate --version
60+
61+
- name: Build
62+
run: make build
63+
64+
- name: Deploy KIND
65+
if: matrix.mode == 'live-mode'
66+
run: make deploy-kind-ovnk
67+
68+
- name: Run E2E tests
69+
run: |
70+
if [ "${{ matrix.mode }}" == "live-mode" ]; then
71+
make run-e2e MCP_MODE="Live Mode"
72+
else
73+
make run-e2e MCP_MODE="Offline Mode"
74+
fi
75+
76+
- name: Export kind logs
77+
if: always() && matrix.mode == 'live-mode'
78+
run: |
79+
set -x
80+
# Only export logs if kind CLI exists and cluster is running
81+
if command -v kind &> /dev/null && kind get clusters 2>/dev/null | grep -q '^ovn$'; then
82+
mkdir -p /tmp/kind/logs
83+
kind export logs --name ovn --verbosity 4 /tmp/kind/logs
84+
else
85+
echo "KIND cluster 'ovn' not found or kind CLI not available, skipping log export"
86+
fi
87+
88+
- name: Upload kind logs
89+
if: always() && matrix.mode == 'live-mode'
90+
uses: actions/upload-artifact@v4
91+
with:
92+
name: kind-logs-e2e-${{ github.run_id }}
93+
path: /tmp/kind/logs
94+
if-no-files-found: ignore
95+
96+
- name: Cleanup KIND cluster
97+
if: always() && matrix.mode == 'live-mode'
98+
run: |
99+
set -x
100+
kind delete cluster --name ovn || true

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ NPM_VERSION := 11.6.1
4545

4646
.PHONY: run-e2e
4747
run-e2e:
48-
./hack/run-e2e.sh $(NVM_VERSION) $(NODE_VERSION) $(NPM_VERSION)
48+
./hack/run-e2e.sh $(NVM_VERSION) $(NODE_VERSION) $(NPM_VERSION) "$(MCP_MODE)"
4949

5050
.PHONY: test-e2e
5151
test-e2e: build deploy-kind-ovnk run-e2e undeploy-kind-ovnk

hack/run-e2e.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
NVM_VERSION=$1
66
NODE_VERSION=$2
77
NPM_VERSION=$3
8+
MCP_MODE=$4
89

910
if [[ -z "${NVM_VERSION}" ]] || [[ -z "${NODE_VERSION}" ]] || [[ -z "${NPM_VERSION}" ]]; then
1011
echo "NVM_VERSION, NODE_VERSION and NPM_VERSION are required"
@@ -40,4 +41,10 @@ echo "Dependencies installed"
4041

4142
# Run e2e tests
4243
echo "Running e2e tests"
43-
ginkgo -vv test/e2e
44+
if [[ "${MCP_MODE}" == "Offline Mode" ]]; then
45+
echo "Running offline mode tests (sosreport and must-gather)"
46+
ginkgo -vv --focus="Sosreport Tools" --skip-file="e2e_suite_test.go" test/e2e
47+
else
48+
echo "Running online mode tests (excluding offline tests)"
49+
ginkgo -vv --skip="Sosreport Tools" test/e2e
50+
fi

test/e2e/e2e_suite_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ func TestE2e(t *testing.T) {
9090
var _ = BeforeSuite(func() {
9191
mcpServerPath := os.Getenv(mcpServerPathEnvVar)
9292
Expect(mcpServerPath).NotTo(BeEmpty())
93+
9394
kubeconfig := os.Getenv(kubeconfigEnvVar)
9495
Expect(kubeconfig).NotTo(BeEmpty())
9596

0 commit comments

Comments
 (0)