-
Notifications
You must be signed in to change notification settings - Fork 368
[no-relnote] Update E2E test suite #1048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,20 +70,25 @@ jobs: | |
|
||
- name: Run e2e tests | ||
env: | ||
IMAGE_NAME: ghcr.io/nvidia/container-toolkit | ||
VERSION: ${{ inputs.version }} | ||
SSH_KEY: ${{ secrets.AWS_SSH_KEY }} | ||
E2E_INSTALL_CTK: "true" | ||
E2E_IMAGE_NAME: ghcr.io/nvidia/container-toolkit | ||
E2E_IMAGE_TAG: ${{ inputs.version }}-ubuntu20.04 | ||
E2E_SSH_USER: ${{ secrets.E2E_SSH_USER }} | ||
E2E_SSH_HOST: ${{ steps.holodeck_public_dns_name.outputs.result }} | ||
E2E_INSTALL_CTK: "true" | ||
run: | | ||
e2e_ssh_key=$(mktemp) | ||
echo "$SSH_KEY" > "$e2e_ssh_key" | ||
echo "${{ secrets.AWS_SSH_KEY }}" > "$e2e_ssh_key" | ||
chmod 600 "$e2e_ssh_key" | ||
export E2E_SSH_KEY="$e2e_ssh_key" | ||
|
||
make -f tests/e2e/Makefile test | ||
|
||
- name: Archive Ginkgo logs | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ginkgo-logs | ||
path: ginkgo.json | ||
retention-days: 15 | ||
- name: Send Slack alert notification | ||
if: ${{ failure() }} | ||
uses: slackapi/[email protected] | ||
|
@@ -94,5 +99,5 @@ jobs: | |
channel: ${{ secrets.SLACK_CHANNEL_ID }} | ||
text: | | ||
:x: On repository ${{ github.repository }}, the Workflow *${{ github.workflow }}* has failed. | ||
|
||
Details: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ | |
/nvidia-ctk | ||
/shared-* | ||
/release-* | ||
/bin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,27 @@ | ||
/* | ||
* Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
/** | ||
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
**/ | ||
|
||
package e2e | ||
|
||
import ( | ||
"context" | ||
"flag" | ||
"errors" | ||
"os" | ||
"strconv" | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
|
@@ -31,33 +34,86 @@ var ( | |
|
||
installCTK bool | ||
|
||
image string | ||
imageName string | ||
imageTag string | ||
|
||
sshKey string | ||
sshUser string | ||
host string | ||
sshHost string | ||
sshPort string | ||
) | ||
|
||
func init() { | ||
flag.BoolVar(&installCTK, "install-ctk", false, "Install the NVIDIA Container Toolkit") | ||
flag.StringVar(&image, "toolkit-image", "", "Repository of the image to test") | ||
flag.StringVar(&sshKey, "ssh-key", "", "SSH key to use for remote login") | ||
flag.StringVar(&sshUser, "ssh-user", "", "SSH user to use for remote login") | ||
flag.StringVar(&host, "remote-host", "", "Hostname of the remote machine") | ||
flag.StringVar(&sshPort, "remote-port", "22", "SSH port to use for remote login") | ||
} | ||
|
||
func TestMain(t *testing.T) { | ||
suiteName := "NVIDIA Container Toolkit E2E" | ||
suiteName := "E2E NVIDIA Container Toolkit" | ||
|
||
RegisterFailHandler(Fail) | ||
|
||
ctx = context.Background() | ||
getTestEnv() | ||
|
||
RunSpecs(t, | ||
suiteName, | ||
) | ||
} | ||
|
||
// BeforeSuite runs before the test suite | ||
var _ = BeforeSuite(func() { | ||
ctx = context.Background() | ||
}) | ||
// getTestEnv gets the test environment variables | ||
func getTestEnv() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please make sure that the envvars here match the ones in the README (or remove the readme section). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
defer GinkgoRecover() | ||
|
||
installCTK = getEnvVarOrDefault("E2E_INSTALL_CTK", false) | ||
|
||
if installCTK { | ||
imageName = getRequiredEnvvar[string]("E2E_IMAGE_NAME") | ||
|
||
imageTag = getRequiredEnvvar[string]("E2E_IMAGE_TAG") | ||
|
||
} | ||
|
||
sshKey = getRequiredEnvvar[string]("E2E_SSH_KEY") | ||
sshUser = getRequiredEnvvar[string]("E2E_SSH_USER") | ||
sshHost = getRequiredEnvvar[string]("E2E_SSH_HOST") | ||
|
||
sshPort = getEnvVarOrDefault("E2E_SSH_PORT", "22") | ||
} | ||
|
||
// getRequiredEnvvar returns the specified envvar if set or raises an error. | ||
func getRequiredEnvvar[T any](key string) T { | ||
v, err := getEnvVarAs[T](key) | ||
Expect(err).To(BeNil(), "required environement variable not set", key) | ||
return v | ||
} | ||
|
||
func getEnvVarAs[T any](key string) (T, error) { | ||
var zero T | ||
value := os.Getenv(key) | ||
if value == "" { | ||
return zero, errors.New("env var not set") | ||
} | ||
|
||
switch any(zero).(type) { | ||
case bool: | ||
v, err := strconv.ParseBool(value) | ||
if err != nil { | ||
return zero, err | ||
} | ||
return any(v).(T), nil | ||
case int: | ||
v, err := strconv.Atoi(value) | ||
if err != nil { | ||
return zero, err | ||
} | ||
return any(v).(T), nil | ||
case string: | ||
return any(value).(T), nil | ||
default: | ||
return zero, errors.New("unsupported type") | ||
} | ||
} | ||
|
||
func getEnvVarOrDefault[T any](key string, defaultValue T) T { | ||
val, err := getEnvVarAs[T](key) | ||
if err != nil { | ||
tariq1890 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return defaultValue | ||
} | ||
return val | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.