Skip to content

Commit 4a66b60

Browse files
committed
Evan's suggestions
Here are my suggested changes: * Remove the readme. We are not good at keeping things like this in sync. When this becomes more user-facing we can revisit how we want to inform users of what is required. * Move runner back to test definitions. It does not make sense to separate this, expecially given that this is docker-specific. * Cleanup environment variable handling. Signed-off-by: Evan Lezar <[email protected]>
1 parent ee97f6c commit 4a66b60

File tree

6 files changed

+86
-215
lines changed

6 files changed

+86
-215
lines changed

.github/workflows/e2e.yaml

+5-6
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,14 @@ jobs:
7070

7171
- name: Run e2e tests
7272
env:
73-
E2E_IMAGE_REPO: ghcr.io/nvidia/container-toolkit
73+
E2E_INSTALL_CTK: "true"
74+
E2E_IMAGE_NAME: ghcr.io/nvidia/container-toolkit
7475
E2E_IMAGE_TAG: ${{ inputs.version }}-ubuntu20.04
75-
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 }}
78-
E2E_INSTALL_CTK: "true"
7978
run: |
8079
e2e_ssh_key=$(mktemp)
81-
echo "$SSH_KEY" > "$e2e_ssh_key"
80+
echo "${{ secrets.AWS_SSH_KEY }}" > "$e2e_ssh_key"
8281
chmod 600 "$e2e_ssh_key"
8382
export E2E_SSH_KEY="$e2e_ssh_key"
8483
@@ -90,7 +89,7 @@ jobs:
9089
name: ginkgo-logs
9190
path: ginkgo.json
9291
retention-days: 15
93-
92+
9493
- name: Send Slack alert notification
9594
if: ${{ failure() }}
9695
uses: slackapi/[email protected]
@@ -101,5 +100,5 @@ jobs:
101100
channel: ${{ secrets.SLACK_CHANNEL_ID }}
102101
text: |
103102
:x: On repository ${{ github.repository }}, the Workflow *${{ github.workflow }}* has failed.
104-
103+
105104
Details: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}

tests/e2e/README.md

-124
This file was deleted.

tests/e2e/e2e_test.go

+31-59
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
/*
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.
15-
*/
1+
/**
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.
16+
**/
1617

1718
package e2e
1819

@@ -33,16 +34,13 @@ var (
3334

3435
installCTK bool
3536

36-
ImageRepo string
37-
ImageTag string
37+
imageName string
38+
imageTag string
3839

3940
sshKey string
4041
sshUser string
4142
sshHost string
4243
sshPort string
43-
cwd string
44-
45-
runner Runner
4644
)
4745

4846
func TestMain(t *testing.T) {
@@ -58,57 +56,31 @@ func TestMain(t *testing.T) {
5856
)
5957
}
6058

61-
// BeforeSuite runs before the test suite
62-
var _ = BeforeSuite(func() {
63-
runner = NewRunner(
64-
WithHost(sshHost),
65-
WithPort(sshPort),
66-
WithSshKey(sshKey),
67-
WithSshUser(sshUser),
68-
)
69-
70-
if installCTK {
71-
installer, err := NewToolkitInstaller(
72-
WithRunner(runner),
73-
WithImage(ImageRepo+":"+ImageTag),
74-
WithTemplate(dockerInstallTemplate),
75-
)
76-
Expect(err).ToNot(HaveOccurred())
77-
78-
err = installer.Install()
79-
Expect(err).ToNot(HaveOccurred())
80-
}
81-
})
82-
8359
// getTestEnv gets the test environment variables
8460
func getTestEnv() {
8561
defer GinkgoRecover()
86-
var err error
8762

88-
installCTK = getEnvVarOrDefault("E2E_INSTALL_CTK", true)
63+
installCTK = getEnvVarOrDefault("E2E_INSTALL_CTK", false)
8964

9065
if installCTK {
91-
ImageRepo = os.Getenv("E2E_IMAGE_REPO")
92-
Expect(ImageRepo).NotTo(BeEmpty(), "E2E_IMAGE_REPO environment variable must be set")
93-
94-
ImageTag = os.Getenv("E2E_IMAGE_TAG")
95-
Expect(ImageTag).NotTo(BeEmpty(), "E2E_IMAGE_TAG environment variable must be set")
96-
}
66+
imageName = getRequiredEnvvar[string]("E2E_IMAGE_NAME")
9767

98-
sshKey = os.Getenv("E2E_SSH_KEY")
99-
Expect(sshKey).NotTo(BeEmpty(), "E2E_SSH_KEY environment variable must be set")
68+
imageTag = getRequiredEnvvar[string]("E2E_IMAGE_TAG")
10069

101-
sshUser = os.Getenv("E2E_SSH_USER")
102-
Expect(sshUser).NotTo(BeEmpty(), "E2E_SSH_USER environment variable must be set")
70+
}
10371

104-
sshHost = os.Getenv("E2E_SSH_HOST")
105-
Expect(sshHost).NotTo(BeEmpty(), "E2E_SSH_HOST environment variable must be set")
72+
sshKey = getRequiredEnvvar[string]("E2E_SSH_KEY")
73+
sshUser = getRequiredEnvvar[string]("E2E_SSH_USER")
74+
sshHost = getRequiredEnvvar[string]("E2E_SSH_HOST")
10675

10776
sshPort = getEnvVarOrDefault("E2E_SSH_PORT", "22")
77+
}
10878

109-
// Get current working directory
110-
cwd, err = os.Getwd()
111-
Expect(err).NotTo(HaveOccurred())
79+
// getRequiredEnvvar returns the specified envvar if set or raises an error.
80+
func getRequiredEnvvar[T any](key string) T {
81+
v, err := getEnvVarAs[T](key)
82+
Expect(err).To(BeNil(), "required environement variable not set", key)
83+
return v
11284
}
11385

11486
func getEnvVarAs[T any](key string) (T, error) {

tests/e2e/installer.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
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+
* 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.
1515
*/
1616

1717
package e2e

tests/e2e/nvidia-container-toolkit_test.go

+24
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,30 @@ import (
2727

2828
// Integration tests for Docker runtime
2929
var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
30+
var runner Runner
31+
32+
// Install the NVIDIA Container Toolkit
33+
BeforeAll(func(ctx context.Context) {
34+
runner = NewRunner(
35+
WithHost(sshHost),
36+
WithPort(sshPort),
37+
WithSshKey(sshKey),
38+
WithSshUser(sshUser),
39+
)
40+
41+
if installCTK {
42+
installer, err := NewToolkitInstaller(
43+
WithRunner(runner),
44+
WithImage(ImageRepo+":"+ImageTag),
45+
WithTemplate(dockerInstallTemplate),
46+
)
47+
Expect(err).ToNot(HaveOccurred())
48+
49+
err = installer.Install()
50+
Expect(err).ToNot(HaveOccurred())
51+
}
52+
})
53+
3054
// GPUs are accessible in a container: Running nvidia-smi -L inside the
3155
// container shows the same output inside the container as outside the
3256
// container. This means that the following commands must all produce

tests/e2e/runner.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
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+
* 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.
1515
*/
1616

1717
package e2e

0 commit comments

Comments
 (0)