Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ cover.out
k8test
bin/
image.tar
venv/
7 changes: 1 addition & 6 deletions pkg/internal/integration/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"testing"
"time"

cloudscale "github.com/cloudscale-ch/cloudscale-go-sdk/v6"
"github.com/cloudscale-ch/cloudscale-go-sdk/v6"
"github.com/stretchr/testify/suite"
"golang.org/x/oauth2"
v1 "k8s.io/api/core/v1"
Expand All @@ -23,11 +23,6 @@ import (
"k8s.io/client-go/tools/clientcmd"
)

func TestMain(m *testing.M) {
exitStatus := m.Run()
os.Exit(exitStatus)
}

func TestIntegration(t *testing.T) {
suite.Run(t, new(IntegrationTestSuite))
}
Expand Down
37 changes: 28 additions & 9 deletions pkg/internal/integration/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,16 +470,35 @@ func (s *IntegrationTestSuite) verifyLBAvailability(name string, start time.Time
s.Require().Len(service.Status.LoadBalancer.Ingress, 2)
addr := service.Status.LoadBalancer.Ingress[0].IP

response, err := testkit.HelloNginx(addr, 80)
if reachable {
s.Assert().NoError(err, "request failed")
if s.Assert().NotNil(response, "response is empty") {
s.Assert().NotEmpty(response.ServerName)
pollInterval := 500 * time.Millisecond
pollTimeout := 10 * time.Second

err := wait.PollUntilContextTimeout(s.T().Context(), pollInterval, pollTimeout, true, func(ctx context.Context) (bool, error) {
response, err := testkit.HelloNginx(addr, 80)

if reachable {
if err != nil {
s.T().Logf("waiting for connectivity: %s", err)
return false, nil
}
if response == nil || response.ServerName == "" {
s.T().Log("waiting for valid response body", "response", response)
return false, nil
}
return true, nil
}
} else {
s.Assert().Error(err, "request successful")
s.Assert().Nil(response, "response is empty")
}

if err == nil {
s.T().Log("waiting for service to be unreachable, but got no error")
return false, nil
}
if response != nil {
s.T().Log("waiting for service to be unreachable, but got a response")
return false, nil
}
return true, nil
})
s.Assert().NoError(err, "polling failed")

// we expect no warnings. Errors can happen for a short time when setting to 0 nodes reachable.
s.T().Log("Checking log output for errors/warnings")
Expand Down
Loading