Skip to content

Commit d745cf3

Browse files
committed
initialize clients for vcsim once
1 parent e5fbbf2 commit d745cf3

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

test/e2e/e2e_setup_test.go

+17
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,23 @@ func addVCSimTestVariables(managementClusterProxy framework.ClusterProxy, specNa
317317

318318
testSpecificVariables[k] = v
319319
}
320+
321+
vsphereClientsInitialized.Do(func() {
322+
for k, v := range envVar.Status.Variables {
323+
switch k {
324+
case "VSPHERE_USERNAME":
325+
vsphereUsername = v
326+
case "VSPHERE_PASSWORD":
327+
vspherePassword = v
328+
case "VSPHERE_SERVER":
329+
vsphereServer = v
330+
case "VSPHERE_DATACENTER":
331+
vsphereDatacenter = v
332+
}
333+
}
334+
335+
By("Initializing the vSphere session to ensure credentials are working", initVSphereSession)
336+
})
320337
}
321338

322339
func setupNamespaceWithVMOperatorDependenciesVCSim(managementClusterProxy framework.ClusterProxy, workloadClusterNamespace string) {

test/e2e/govmomi_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"flag"
2121
"net/url"
2222
"os"
23+
"sync"
2324
"time"
2425

2526
. "github.com/onsi/ginkgo/v2"
@@ -42,6 +43,8 @@ var (
4243
vsphereClient *govmomi.Client
4344
restClient *rest.Client
4445
vsphereFinder *find.Finder
46+
47+
vsphereClientsInitialized sync.Once
4548
)
4649

4750
func init() {

0 commit comments

Comments
 (0)