Skip to content

Commit ee97f6c

Browse files
ArangoGutierrezelezar
authored andcommitted
[no-relnote] Update Github Actions E2E
Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
1 parent 1ef5824 commit ee97f6c

File tree

9 files changed

+98
-101
lines changed

9 files changed

+98
-101
lines changed

.github/workflows/e2e.yaml

+9-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ jobs:
7070

7171
- name: Run e2e tests
7272
env:
73-
IMAGE_NAME: ghcr.io/nvidia/container-toolkit
74-
VERSION: ${{ inputs.version }}
73+
E2E_IMAGE_REPO: ghcr.io/nvidia/container-toolkit
74+
E2E_IMAGE_TAG: ${{ inputs.version }}-ubuntu20.04
7575
SSH_KEY: ${{ secrets.AWS_SSH_KEY }}
7676
E2E_SSH_USER: ${{ secrets.E2E_SSH_USER }}
7777
E2E_SSH_HOST: ${{ steps.holodeck_public_dns_name.outputs.result }}
@@ -84,6 +84,13 @@ jobs:
8484
8585
make -f tests/e2e/Makefile test
8686
87+
- name: Archive Ginkgo logs
88+
uses: actions/upload-artifact@v4
89+
with:
90+
name: ginkgo-logs
91+
path: ginkgo.json
92+
retention-days: 15
93+
8794
- name: Send Slack alert notification
8895
if: ${{ failure() }}
8996
uses: slackapi/[email protected]

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
/nvidia-ctk
1212
/shared-*
1313
/release-*
14+
/bin

tests/e2e/Makefile

+7-5
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
.PHONY: test-e2e ginkgo
16+
.PHONY: test $(GINKGO_BIN)
1717

1818
GINKGO_ARGS ?=
1919
LOG_ARTIFACTS_DIR ?= $(CURDIR)/e2e_logs
2020

21-
ginkgo:
21+
GINKGO_BIN := $(CURDIR)/bin/ginkgo
22+
23+
test: $(GINKGO_BIN)
24+
$(GINKGO_BIN) $(GINKGO_ARGS) -v --json-report ginkgo.json ./tests/e2e/...
25+
26+
$(GINKGO_BIN):
2227
mkdir -p $(CURDIR)/bin
2328
GOBIN=$(CURDIR)/bin go install github.com/onsi/ginkgo/v2/ginkgo@latest
24-
25-
test-e2e: ginkgo
26-
$(CURDIR)/bin/ginkgo $(GINKGO_ARGS) -v --json-report ginkgo.json ./tests/e2e/...

tests/e2e/README.md

+12-28
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License.
2020
---
2121

2222
## 1 Scope & Goals
23-
This repository contains a **Ginkgo v2 / Gomega** test harness that exercises an
23+
This folder contains a **Ginkgo v2 / Gomega** test harness that exercises an
2424
NVIDIA Container Toolkit (CTK) installation on a **remote GPU‑enabled host** via
2525
SSH. The suite validates that:
2626

@@ -58,12 +58,13 @@ compatibility runs, and pre‑release validation of new CTK builds.
5858

5959
| Variable | Required | Example | Description |
6060
|----------|----------|---------|-------------|
61-
| `INSTALL_CTK` || `true` | When `true` the test installs CTK on the remote host before running the image. When `false` it assumes CTK is already present. |
62-
| `TOOLKIT_IMAGE` || `nvcr.io/nvidia/cuda:12.4.0-runtime-ubi9` | Image that will be pulled & executed. |
63-
| `SSH_KEY` || `/home/ci/.ssh/id_rsa` | Private key used for authentication. |
64-
| `SSH_USER` || `ubuntu` | Username on the remote host. |
65-
| `REMOTE_HOST` || `gpurunner01.corp.local` | Hostname or IP address of the target node. |
66-
| `REMOTE_PORT` || `22` | SSH port of the target node. |
61+
| `E2E_INSTALL_CTK` || `true` | When `true` the test installs CTK on the remote host before running the image. When `false` it assumes CTK is already present. |
62+
| `E2E_IMAGE_REPO` || `ghcr.io/nvidia/container-toolkit` | Container Toolkit Image |
63+
| `E2E_IMAGE_TAG` || `latest` | Image tag |
64+
| `E2E_SSH_KEY` || `/home/ci/.ssh/id_rsa` | Private key used for authentication. |
65+
| `E2E_SSH_USER` || `ubuntu` | Username on the remote host. |
66+
| `E2E_SSH_HOST` || `10.0.0.0` | Hostname or IP address of the target node. |
67+
| `E2E_SSH_PORT` || `22` | SSH port of the target node. |
6768

6869
> All variables are validated at start‑up; the suite aborts early with a clear
6970
> message if any are missing or ill‑formed.
@@ -87,24 +88,7 @@ bin/ginkgo:
8788

8889
---
8990

90-
## 6 Running the suite
91-
92-
### 6.1 Basic invocation
93-
```bash
94-
INSTALL_CTK=true \
95-
TOOLKIT_IMAGE=nvcr.io/nvidia/cuda:12.4.0-runtime-ubi9 \
96-
SSH_KEY=$HOME/.ssh/id_rsa \
97-
SSH_USER=ubuntu \
98-
REMOTE_HOST=10.0.0.15 \
99-
REMOTE_PORT=22 \
100-
make test-e2e
101-
```
102-
This downloads the image on the remote host, installs CTK (if requested), and
103-
executes a minimal CUDA‑based workload.
104-
105-
---
106-
107-
## 7 Internal test flow
91+
## 6 Internal test flow
10892

10993
| Phase | Key function(s) | Notes |
11094
|-------|-----------------|-------|
@@ -116,7 +100,7 @@ executes a minimal CUDA‑based workload.
116100

117101
---
118102

119-
## 8 Extending the suite
103+
## 7 Extending the suite
120104

121105
1. Create a new `_test.go` file under `tests/e2e`.
122106
2. Use the Ginkgo DSL (`Describe`, `When`, `It` …). Each leaf node receives a
@@ -127,14 +111,14 @@ executes a minimal CUDA‑based workload.
127111

128112
---
129113

130-
## 9 Common issues & fixes
114+
## 8 Common issues & fixes
131115

132116
| Symptom | Likely cause | Fix |
133117
|---------|--------------|-----|
134118
| `Permission denied (publickey)` | Wrong `SSH_KEY` or `SSH_USER` | Check variables; ensure key is readable by the CI user. |
135119
| `docker: Error response from daemon: could not select device driver` | CTK not installed or wrong runtime class | Verify `INSTALL_CTK=true` or confirm CTK installation on the host. |
136120
| Test hangs at image pull | No outbound internet on remote host | Pre‑load the image or use a local registry mirror. |
137121

138-
## 10 License
122+
## 9 License
139123
Distributed under the terms of the **Apache License 2.0** (see header).
140124

tests/e2e/e2e_test.go

+49-41
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3-
* SPDX-License-Identifier: Apache-2.0
2+
* Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
43
*
54
* Licensed under the Apache License, Version 2.0 (the "License");
65
* you may not use this file except in compliance with the License.
@@ -19,9 +18,8 @@ package e2e
1918

2019
import (
2120
"context"
21+
"errors"
2222
"os"
23-
"path/filepath"
24-
"runtime"
2523
"strconv"
2624
"testing"
2725

@@ -38,12 +36,11 @@ var (
3836
ImageRepo string
3937
ImageTag string
4038

41-
sshKey string
42-
sshUser string
43-
host string
44-
sshPort string
45-
cwd string
46-
packagePath string
39+
sshKey string
40+
sshUser string
41+
sshHost string
42+
sshPort string
43+
cwd string
4744

4845
runner Runner
4946
)
@@ -64,7 +61,7 @@ func TestMain(t *testing.T) {
6461
// BeforeSuite runs before the test suite
6562
var _ = BeforeSuite(func() {
6663
runner = NewRunner(
67-
WithHost(host),
64+
WithHost(sshHost),
6865
WithPort(sshPort),
6966
WithSshKey(sshKey),
7067
WithSshUser(sshUser),
@@ -81,59 +78,70 @@ var _ = BeforeSuite(func() {
8178
err = installer.Install()
8279
Expect(err).ToNot(HaveOccurred())
8380
}
84-
85-
_, _, err := runner.Run("docker pull ubuntu")
86-
Expect(err).ToNot(HaveOccurred())
87-
88-
_, _, err = runner.Run("docker pull nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda12.5.0")
89-
Expect(err).ToNot(HaveOccurred())
90-
91-
_, _, err = runner.Run("docker pull nvcr.io/nvidia/cuda:12.8.0-base-ubi8")
92-
Expect(err).ToNot(HaveOccurred())
9381
})
9482

9583
// getTestEnv gets the test environment variables
9684
func getTestEnv() {
9785
defer GinkgoRecover()
9886
var err error
9987

100-
_, thisFile, _, _ := runtime.Caller(0)
101-
packagePath = filepath.Dir(thisFile)
88+
installCTK = getEnvVarOrDefault("E2E_INSTALL_CTK", true)
10289

103-
installCTK = getBoolEnvVar("INSTALL_CTK", false)
104-
105-
ImageRepo = os.Getenv("E2E_IMAGE_REPO")
106-
Expect(ImageRepo).NotTo(BeEmpty(), "E2E_IMAGE_REPO environment variable must be set")
90+
if installCTK {
91+
ImageRepo = os.Getenv("E2E_IMAGE_REPO")
92+
Expect(ImageRepo).NotTo(BeEmpty(), "E2E_IMAGE_REPO environment variable must be set")
10793

108-
ImageTag = os.Getenv("E2E_IMAGE_TAG")
109-
Expect(ImageTag).NotTo(BeEmpty(), "E2E_IMAGE_TAG environment variable must be set")
94+
ImageTag = os.Getenv("E2E_IMAGE_TAG")
95+
Expect(ImageTag).NotTo(BeEmpty(), "E2E_IMAGE_TAG environment variable must be set")
96+
}
11097

111-
sshKey = os.Getenv("SSH_KEY")
112-
Expect(sshKey).NotTo(BeEmpty(), "SSH_KEY environment variable must be set")
98+
sshKey = os.Getenv("E2E_SSH_KEY")
99+
Expect(sshKey).NotTo(BeEmpty(), "E2E_SSH_KEY environment variable must be set")
113100

114-
sshUser = os.Getenv("SSH_USER")
115-
Expect(sshUser).NotTo(BeEmpty(), "SSH_USER environment variable must be set")
101+
sshUser = os.Getenv("E2E_SSH_USER")
102+
Expect(sshUser).NotTo(BeEmpty(), "E2E_SSH_USER environment variable must be set")
116103

117-
host = os.Getenv("REMOTE_HOST")
118-
Expect(host).NotTo(BeEmpty(), "REMOTE_HOST environment variable must be set")
104+
sshHost = os.Getenv("E2E_SSH_HOST")
105+
Expect(sshHost).NotTo(BeEmpty(), "E2E_SSH_HOST environment variable must be set")
119106

120-
sshPort = os.Getenv("REMOTE_PORT")
121-
Expect(sshPort).NotTo(BeEmpty(), "REMOTE_PORT environment variable must be set")
107+
sshPort = getEnvVarOrDefault("E2E_SSH_PORT", "22")
122108

123109
// Get current working directory
124110
cwd, err = os.Getwd()
125111
Expect(err).NotTo(HaveOccurred())
126112
}
127113

128-
// getBoolEnvVar returns the boolean value of the environment variable or the default value if not set.
129-
func getBoolEnvVar(key string, defaultValue bool) bool {
114+
func getEnvVarAs[T any](key string) (T, error) {
115+
var zero T
130116
value := os.Getenv(key)
131117
if value == "" {
132-
return defaultValue
118+
return zero, errors.New("env var not set")
119+
}
120+
121+
switch any(zero).(type) {
122+
case bool:
123+
v, err := strconv.ParseBool(value)
124+
if err != nil {
125+
return zero, err
126+
}
127+
return any(v).(T), nil
128+
case int:
129+
v, err := strconv.Atoi(value)
130+
if err != nil {
131+
return zero, err
132+
}
133+
return any(v).(T), nil
134+
case string:
135+
return any(value).(T), nil
136+
default:
137+
return zero, errors.New("unsupported type")
133138
}
134-
boolValue, err := strconv.ParseBool(value)
139+
}
140+
141+
func getEnvVarOrDefault[T any](key string, defaultValue T) T {
142+
val, err := getEnvVarAs[T](key)
135143
if err != nil {
136144
return defaultValue
137145
}
138-
return boolValue
146+
return val
139147
}

tests/e2e/installer.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3-
* SPDX-License-Identifier: Apache-2.0
2+
* Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
43
*
54
* Licensed under the Apache License, Version 2.0 (the "License");
65
* you may not use this file except in compliance with the License.
@@ -14,6 +13,7 @@
1413
* See the License for the specific language governing permissions and
1514
* limitations under the License.
1615
*/
16+
1717
package e2e
1818

1919
import (

0 commit comments

Comments
 (0)