Skip to content

Commit

Permalink
improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sbueringer committed May 23, 2024
1 parent 2746d6b commit 68c5302
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions controllers/vmware/test/controllers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,19 +281,19 @@ func initManagerAndBuildClient(networkProvider string) (client.Client, context.C
func waitForWebhooks() {
port := testEnv.WebhookInstallOptions.LocalServingPort

klog.V(2).Infof("Waiting for webhook port %d to be open prior to running tests", port)
klog.Infof("Waiting for webhook port %d to be open prior to running tests", port)
timeout := 1 * time.Second
for {
time.Sleep(1 * time.Second)
conn, err := net.DialTimeout("tcp", net.JoinHostPort("127.0.0.1", strconv.Itoa(port)), timeout)
if err != nil {
klog.V(2).Infof("Webhook port is not ready, will retry in %v: %s", timeout, err)
klog.Infof("Webhook port is not ready, will retry in %v: %s", timeout, err)
continue
}
if err := conn.Close(); err != nil {
klog.V(2).Info("Connection to webhook port could not be closed. Continuing with tests...")
klog.Info("Connection to webhook port could not be closed. Continuing with tests...")
}
klog.V(2).Info("Webhook port is now open. Continuing with tests...")
klog.Info("Webhook port is now open. Continuing with tests...")
return
}
}
Expand Down
8 changes: 4 additions & 4 deletions internal/test/helpers/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,19 @@ func InitializeWebhookInEnvironment(e *envtest.Environment, configPath string) {
func (t *TestEnvironment) WaitForWebhooks() {
port := env.WebhookInstallOptions.LocalServingPort

klog.V(2).Infof("Waiting for webhook port %d to be open prior to running tests", port)
klog.Infof("Waiting for webhook port %d to be open prior to running tests", port)
timeout := 1 * time.Second
for {
time.Sleep(1 * time.Second)
conn, err := net.DialTimeout("tcp", net.JoinHostPort("127.0.0.1", strconv.Itoa(port)), timeout)
if err != nil {
klog.V(2).Infof("Webhook port is not ready, will retry in %v: %s", timeout, err)
klog.Infof("Webhook port is not ready, will retry in %v: %s", timeout, err)
continue
}
if err := conn.Close(); err != nil {
klog.V(2).Info("Connection to webhook port could not be closed. Continuing with tests...")
klog.Info("Connection to webhook port could not be closed. Continuing with tests...")
}
klog.V(2).Info("Webhook port is now open. Continuing with tests...")
klog.Info("Webhook port is now open. Continuing with tests...")
return
}
}

0 comments on commit 68c5302

Please sign in to comment.