Skip to content

Commit

Permalink
initialize clients for vcsim once
Browse files Browse the repository at this point in the history
  • Loading branch information
chrischdi committed Aug 27, 2024
1 parent e5fbbf2 commit d745cf3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/e2e/e2e_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,23 @@ func addVCSimTestVariables(managementClusterProxy framework.ClusterProxy, specNa

testSpecificVariables[k] = v
}

vsphereClientsInitialized.Do(func() {
for k, v := range envVar.Status.Variables {
switch k {
case "VSPHERE_USERNAME":
vsphereUsername = v
case "VSPHERE_PASSWORD":
vspherePassword = v
case "VSPHERE_SERVER":
vsphereServer = v
case "VSPHERE_DATACENTER":
vsphereDatacenter = v
}
}

By("Initializing the vSphere session to ensure credentials are working", initVSphereSession)
})
}

func setupNamespaceWithVMOperatorDependenciesVCSim(managementClusterProxy framework.ClusterProxy, workloadClusterNamespace string) {
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/govmomi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"flag"
"net/url"
"os"
"sync"
"time"

. "github.com/onsi/ginkgo/v2"
Expand All @@ -42,6 +43,8 @@ var (
vsphereClient *govmomi.Client
restClient *rest.Client
vsphereFinder *find.Finder

vsphereClientsInitialized sync.Once
)

func init() {
Expand Down

0 comments on commit d745cf3

Please sign in to comment.