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
+ **/
16
17
17
18
package e2e
18
19
@@ -33,16 +34,13 @@ var (
33
34
34
35
installCTK bool
35
36
36
- ImageRepo string
37
- ImageTag string
37
+ imageName string
38
+ imageTag string
38
39
39
40
sshKey string
40
41
sshUser string
41
42
sshHost string
42
43
sshPort string
43
- cwd string
44
-
45
- runner Runner
46
44
)
47
45
48
46
func TestMain (t * testing.T ) {
@@ -58,57 +56,31 @@ func TestMain(t *testing.T) {
58
56
)
59
57
}
60
58
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
-
83
59
// getTestEnv gets the test environment variables
84
60
func getTestEnv () {
85
61
defer GinkgoRecover ()
86
- var err error
87
62
88
- installCTK = getEnvVarOrDefault ("E2E_INSTALL_CTK" , true )
63
+ installCTK = getEnvVarOrDefault ("E2E_INSTALL_CTK" , false )
89
64
90
65
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" )
97
67
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" )
100
69
101
- sshUser = os .Getenv ("E2E_SSH_USER" )
102
- Expect (sshUser ).NotTo (BeEmpty (), "E2E_SSH_USER environment variable must be set" )
70
+ }
103
71
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" )
106
75
107
76
sshPort = getEnvVarOrDefault ("E2E_SSH_PORT" , "22" )
77
+ }
108
78
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
112
84
}
113
85
114
86
func getEnvVarAs [T any ](key string ) (T , error ) {
0 commit comments