diff --git a/test/client_test.go b/test/client_test.go index 0360e570..4b0d8873 100644 --- a/test/client_test.go +++ b/test/client_test.go @@ -54,6 +54,16 @@ var ( runPProfServerOnce sync.Once ) +func skipOnK8S(t *testing.T) { + if isK8S() { + t.Skip("Skipping on k8s") + } +} + +func isK8S() bool { + return os.Getenv("TEST_MODE") == "k8s" +} + // skipBetweenVersion skips the test if the current server version is less than // the min version or higher/equal max version func skipBetweenVersion(c driver.Client, minVersion, maxVersion driver.Version, t *testing.T) driver.VersionInfo { @@ -245,7 +255,7 @@ func createClientFromEnv(t testEnv, waitUntilReady bool) driver.Client { // waitUntilServerAvailable keeps waiting until the server/cluster that the client is addressing is available. func waitUntilServerAvailable(ctx context.Context, c driver.Client, t testEnv) error { return driverErrorCheck(ctx, c, func(ctx context.Context, client driver.Client) error { - if getTestMode() != testModeSingle { + if getTestMode() != testModeSingle && !isK8S() { // Refresh endpoints if err := client.SynchronizeEndpoints2(ctx, "_system"); err != nil { return err @@ -322,6 +332,10 @@ func waitUntilClusterHealthy(c driver.Client) error { // waitUntilEndpointSynchronized keeps waiting until the endpoints are synchronized. leadership might be ongoing. func waitUntilEndpointSynchronized(ctx context.Context, c driver.Client, dbname string, t testEnv) error { + if isK8S() { + return nil + } + return driverErrorCheck(ctx, c, func(ctx context.Context, client driver.Client) error { callCtx, cancel := context.WithTimeout(ctx, time.Second*5) defer cancel() diff --git a/test/server_mode_test.go b/test/server_mode_test.go index ccdc4863..977d5773 100644 --- a/test/server_mode_test.go +++ b/test/server_mode_test.go @@ -24,10 +24,11 @@ package test import ( "context" - "os" "testing" driver "github.com/arangodb/go-driver" + "os" + "strings" ) // TestServerMode creates a database and checks the various server modes. @@ -35,7 +36,7 @@ func TestServerMode(t *testing.T) { c := createClientFromEnv(t, true) ctx := context.Background() - if os.Getenv("TEST_AUTHENTICATION") == "super:testing" { + if strings.HasPrefix(os.Getenv("TEST_AUTHENTICATION"), "super:") { t.Skip("Skipping read only test because of superuser access.") } version, err := c.Version(nil) diff --git a/test/server_statistics_test.go b/test/server_statistics_test.go index 0e433acf..8e514bcb 100644 --- a/test/server_statistics_test.go +++ b/test/server_statistics_test.go @@ -30,6 +30,7 @@ import ( "time" driver "github.com/arangodb/go-driver" + "strings" ) func checkEnabled(t *testing.T, c driver.Client, ctx context.Context) { @@ -193,16 +194,15 @@ func TestServerStatisticsTraffic(t *testing.T) { // Now check if user only stats are there and see if they should have increased: if statsBefore.ClientUser.BytesReceived.Counts != nil { t.Logf("New user only statistics API is present, testing...") - auth := os.Getenv("TEST_AUTHENTICATION") - if auth == "super:testing" { - t.Logf("Authentication %s is jwt superuser, expecting no user traffic...", auth) + if strings.HasPrefix(os.Getenv("TEST_AUTHENTICATION"), "super:") { + t.Logf("Authentication %s is jwt superuser, expecting no user traffic...", os.Getenv("TEST_AUTHENTICATION")) // Traffic is superuser, so nothing should be counted in ClientUser, // not even the statistics calls. checkTrafficAtMost(t, &statsBefore, &statsAfter, user, &limits{Sent: 0.1, Recv: 0.1, SentCount: 0, RecvCount: 0}, "Cherry") } else { - t.Logf("Authentication %s is not jwt superuser, expecting to see user traffic...", auth) + t.Logf("Authentication %s is not jwt superuser, expecting to see user traffic...", os.Getenv("TEST_AUTHENTICATION")) // Traffic is either unauthenticated or with password, so there should // be traffic in ClientUser checkTrafficAtLeast(t, &statsBefore, &statsAfter, user, @@ -246,7 +246,7 @@ func TestServerStatisticsForwarding(t *testing.T) { endpoints := conn.Endpoints() if len(endpoints) < 2 { - t.Fatalf("Did not have at least two endpoints. Giving up.") + t.Skipf("Did not have at least two endpoints. Giving up.") } // Do a preliminary test to see if we can do some traffic on one coordinator @@ -348,8 +348,7 @@ func TestServerStatisticsForwarding(t *testing.T) { // However, first coordinator should have counted the user traffic, // note: it was just a single request with nearly no upload but quite // some download: - auth := os.Getenv("TEST_AUTHENTICATION") - if auth != "super:testing" { + if !strings.HasPrefix(os.Getenv("TEST_AUTHENTICATION"), "super:") { t.Logf("Checking user traffic on coordinator1...") t.Logf("statsBefore1: %v\nstatsAfter1: %v", statsBefore1.ClientUser.BytesSent, statsAfter1.ClientUser.BytesSent) checkTrafficAtLeast(t, &statsBefore1, &statsAfter1, user,