Skip to content

Commit 18ad1ac

Browse files
[no-relnote] Update E2E suite
Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
1 parent de3d736 commit 18ad1ac

File tree

7 files changed

+209
-160
lines changed

7 files changed

+209
-160
lines changed

tests/e2e/Makefile

+10-29
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
23
#
34
# Licensed under the Apache License, Version 2.0 (the "License");
45
# you may not use this file except in compliance with the License.
@@ -12,34 +13,14 @@
1213
# See the License for the specific language governing permissions and
1314
# limitations under the License.
1415

15-
GO_CMD ?= go
16+
.PHONY: test-e2e ginkgo
1617

17-
include $(CURDIR)/versions.mk
18+
GINKGO_ARGS ?=
19+
LOG_ARTIFACTS_DIR ?= $(CURDIR)/e2e_logs
1820

19-
E2E_RUNTIME ?= docker
21+
ginkgo:
22+
mkdir -p $(CURDIR)/bin
23+
GOBIN=$(CURDIR)/bin go install github.com/onsi/ginkgo/v2/ginkgo@latest
2024

21-
E2E_INSTALL_CTK ?= false
22-
23-
ifeq ($($(DIST)),)
24-
DIST ?= ubuntu20.04
25-
endif
26-
IMAGE_TAG ?= $(VERSION)-$(DIST)
27-
IMAGE = $(IMAGE_NAME):$(IMAGE_TAG)
28-
29-
E2E_SSH_KEY ?=
30-
E2E_SSH_USER ?=
31-
E2E_SSH_HOST ?=
32-
E2E_SSH_PORT ?= 22
33-
34-
.PHONY: test
35-
test:
36-
cd $(CURDIR)/tests/e2e && $(GO_CMD) test -v . -args \
37-
-ginkgo.focus="$(E2E_RUNTIME)" \
38-
-test.timeout=1h \
39-
-ginkgo.v \
40-
-install-ctk=$(E2E_INSTALL_CTK) \
41-
-toolkit-image=$(IMAGE) \
42-
-ssh-key=$(E2E_SSH_KEY) \
43-
-ssh-user=$(E2E_SSH_USER) \
44-
-remote-host=$(E2E_SSH_HOST) \
45-
-remote-port=$(E2E_SSH_PORT)
25+
test-e2e: ginkgo
26+
$(CURDIR)/bin/ginkgo $(GINKGO_ARGS) -v --json-report ginkgo.json ./tests/e2e/...

tests/e2e/e2e_test.go

+106-30
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
/*
2-
* Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
2+
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
1516
*/
1617

1718
package e2e
1819

1920
import (
2021
"context"
21-
"flag"
22+
"os"
23+
"path/filepath"
24+
"runtime"
25+
"strconv"
2226
"testing"
2327

2428
. "github.com/onsi/ginkgo/v2"
@@ -31,33 +35,105 @@ var (
3135

3236
installCTK bool
3337

34-
image string
38+
ImageRepo string
39+
ImageTag string
3540

36-
sshKey string
37-
sshUser string
38-
host string
39-
sshPort string
40-
)
41+
sshKey string
42+
sshUser string
43+
host string
44+
sshPort string
45+
cwd string
46+
packagePath string
4147

42-
func init() {
43-
flag.BoolVar(&installCTK, "install-ctk", false, "Install the NVIDIA Container Toolkit")
44-
flag.StringVar(&image, "toolkit-image", "", "Repository of the image to test")
45-
flag.StringVar(&sshKey, "ssh-key", "", "SSH key to use for remote login")
46-
flag.StringVar(&sshUser, "ssh-user", "", "SSH user to use for remote login")
47-
flag.StringVar(&host, "remote-host", "", "Hostname of the remote machine")
48-
flag.StringVar(&sshPort, "remote-port", "22", "SSH port to use for remote login")
49-
}
48+
runner Runner
49+
)
5050

5151
func TestMain(t *testing.T) {
52-
suiteName := "NVIDIA Container Toolkit E2E"
52+
suiteName := "E2E NVIDIA Container Toolkit"
5353

5454
RegisterFailHandler(Fail)
55+
56+
ctx = context.Background()
57+
getTestEnv()
58+
5559
RunSpecs(t,
5660
suiteName,
5761
)
5862
}
5963

6064
// BeforeSuite runs before the test suite
6165
var _ = BeforeSuite(func() {
62-
ctx = context.Background()
66+
runner = NewRunner(
67+
WithHost(host),
68+
WithPort(sshPort),
69+
WithSshKey(sshKey),
70+
WithSshUser(sshUser),
71+
)
72+
73+
if installCTK {
74+
installer, err := NewToolkitInstaller(
75+
WithRunner(runner),
76+
WithImage(ImageRepo+":"+ImageTag),
77+
WithTemplate(dockerInstallTemplate),
78+
)
79+
Expect(err).ToNot(HaveOccurred())
80+
81+
err = installer.Install()
82+
Expect(err).ToNot(HaveOccurred())
83+
}
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())
6393
})
94+
95+
// getTestEnv gets the test environment variables
96+
func getTestEnv() {
97+
defer GinkgoRecover()
98+
var err error
99+
100+
_, thisFile, _, _ := runtime.Caller(0)
101+
packagePath = filepath.Dir(thisFile)
102+
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")
107+
108+
ImageTag = os.Getenv("E2E_IMAGE_TAG")
109+
Expect(ImageTag).NotTo(BeEmpty(), "E2E_IMAGE_TAG environment variable must be set")
110+
111+
sshKey = os.Getenv("SSH_KEY")
112+
Expect(sshKey).NotTo(BeEmpty(), "SSH_KEY environment variable must be set")
113+
114+
sshUser = os.Getenv("SSH_USER")
115+
Expect(sshUser).NotTo(BeEmpty(), "SSH_USER environment variable must be set")
116+
117+
host = os.Getenv("REMOTE_HOST")
118+
Expect(host).NotTo(BeEmpty(), "REMOTE_HOST environment variable must be set")
119+
120+
sshPort = os.Getenv("REMOTE_PORT")
121+
Expect(sshPort).NotTo(BeEmpty(), "REMOTE_PORT environment variable must be set")
122+
123+
// Get current working directory
124+
cwd, err = os.Getwd()
125+
Expect(err).NotTo(HaveOccurred())
126+
}
127+
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 {
130+
value := os.Getenv(key)
131+
if value == "" {
132+
return defaultValue
133+
}
134+
boolValue, err := strconv.ParseBool(value)
135+
if err != nil {
136+
return defaultValue
137+
}
138+
return boolValue
139+
}

tests/e2e/installer.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
/*
2-
* Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
2+
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
1516
*/
16-
1717
package e2e
1818

1919
import (

0 commit comments

Comments
 (0)