Skip to content
This repository was archived by the owner on Dec 12, 2025. It is now read-only.

Commit 832e238

Browse files
authored
[e2e] bump sts timeout, logs update, helm update (#1191)
- bump helm-charts: Add License to repo helm-charts#193 - bump overall test limit from 30m to 45m (tests succeeding almost take 30minutes: https://github.com/mongodb/mongodb-kubernetes-operator/actions/runs/3891209152/jobs/6641225437 vs failures: https://github.com/mongodb/mongodb-kubernetes-operator/actions/runs/3894602279/jobs/6648879374). - removes explicit sts timeout usage at they are matching the default opts - bumping sts test timeout from 20 to 25 as this one is one of the longest running checks (https://github.com/mongodb/mongodb-kubernetes-operator/actions/runs/3543640187/jobs/5950896967) - add log for sts elapsed time. This could be done properly but it takes more refactoring. Most of the flaky tests are the sts checks, as they take the most time. If we think it happens for the other functions we can refactor and make it common
1 parent d873cbd commit 832e238

File tree

6 files changed

+13
-17
lines changed

6 files changed

+13
-17
lines changed

helm-charts

scripts/dev/e2e.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def create_test_pod(args: argparse.Namespace, dev_config: DevConfig) -> None:
129129
"go",
130130
"test",
131131
"-v",
132-
"-timeout=30m",
132+
"-timeout=45m",
133133
"-failfast",
134134
f"./test/e2e/{args.test}",
135135
],

test/e2e/feature_compatibility_version/feature_compatibility_version_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import (
66
"testing"
77
"time"
88

9-
"github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/wait"
10-
119
. "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester"
1210

1311
e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e"
@@ -51,7 +49,7 @@ func TestFeatureCompatibilityVersion(t *testing.T) {
5149
t.Run("MongoDB is reachable while version is upgraded", func(t *testing.T) {
5250
defer tester.StartBackgroundConnectivityTest(t, time.Second*20)()
5351
t.Run("Test Version can be upgraded", mongodbtests.ChangeVersion(&mdb, "4.4.11"))
54-
t.Run("Stateful Set Reaches Ready State, after Upgrading", mongodbtests.StatefulSetBecomesReady(&mdb, wait.Timeout(20*time.Minute)))
52+
t.Run("Stateful Set Reaches Ready State, after Upgrading", mongodbtests.StatefulSetBecomesReady(&mdb))
5553
})
5654

5755
t.Run("Test Basic Connectivity after upgrade has completed", tester.ConnectivitySucceeds())
@@ -61,7 +59,7 @@ func TestFeatureCompatibilityVersion(t *testing.T) {
6159
t.Run("MongoDB is reachable while version is downgraded", func(t *testing.T) {
6260
defer tester.StartBackgroundConnectivityTest(t, time.Second*10)()
6361
t.Run("Test Version can be downgraded", mongodbtests.ChangeVersion(&mdb, "4.2.23"))
64-
t.Run("Stateful Set Reaches Ready State, after Upgrading", mongodbtests.StatefulSetBecomesReady(&mdb, wait.Timeout(20*time.Minute)))
62+
t.Run("Stateful Set Reaches Ready State, after Upgrading", mongodbtests.StatefulSetBecomesReady(&mdb))
6563
})
6664

6765
t.Run("Test FeatureCompatibilityVersion, after downgrade, is 4.2", tester.HasFCV("4.2", 3))

test/e2e/feature_compatibility_version_upgrade/feature_compatibility_version_upgrade_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import (
66
"testing"
77
"time"
88

9-
"github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/wait"
10-
119
"github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester"
1210

1311
mdbv1 "github.com/mongodb/mongodb-kubernetes-operator/api/v1"
@@ -53,7 +51,7 @@ func TestFeatureCompatibilityVersionUpgrade(t *testing.T) {
5351
t.Run("MongoDB is reachable", func(t *testing.T) {
5452
defer tester.StartBackgroundConnectivityTest(t, time.Second*10)()
5553
t.Run("Test Version can be upgraded", mongodbtests.ChangeVersion(&mdb, "4.2.6"))
56-
t.Run("Stateful Set Reaches Ready State, after Upgrading", mongodbtests.StatefulSetBecomesReady(&mdb, wait.Timeout(20*time.Minute)))
54+
t.Run("Stateful Set Reaches Ready State, after Upgrading", mongodbtests.StatefulSetBecomesReady(&mdb))
5755
t.Run("Test Basic Connectivity after upgrade has completed", tester.ConnectivitySucceeds())
5856
})
5957

@@ -66,7 +64,7 @@ func TestFeatureCompatibilityVersionUpgrade(t *testing.T) {
6664
})
6765
assert.NoError(t, err)
6866
})
69-
t.Run("Stateful Set Reaches Ready State", mongodbtests.StatefulSetBecomesReady(&mdb, wait.Timeout(20*time.Minute)))
67+
t.Run("Stateful Set Reaches Ready State", mongodbtests.StatefulSetBecomesReady(&mdb))
7068
t.Run("MongoDB Reaches Running Phase", mongodbtests.MongoDBReachesRunningPhase(&mdb))
7169
})
7270
t.Run("Test FeatureCompatibilityVersion, after upgrade, is 4.2", tester.HasFCV("4.2", 3))

test/e2e/mongodbtests/mongodbtests.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func SkipTestIfLocal(t *testing.T, msg string, f func(t *testing.T)) {
3636
func StatefulSetBecomesReady(mdb *mdbv1.MongoDBCommunity, opts ...wait.Configuration) func(t *testing.T) {
3737
defaultOpts := []wait.Configuration{
3838
wait.RetryInterval(time.Second * 15),
39-
wait.Timeout(time.Minute * 20),
39+
wait.Timeout(time.Minute * 25),
4040
}
4141
defaultOpts = append(defaultOpts, opts...)
4242
return statefulSetIsReady(mdb, defaultOpts...)
@@ -81,11 +81,13 @@ func StatefulSetIsReadyAfterScaleDown(mdb *mdbv1.MongoDBCommunity) func(t *testi
8181
// reaches the running state.
8282
func statefulSetIsReady(mdb *mdbv1.MongoDBCommunity, opts ...wait.Configuration) func(t *testing.T) {
8383
return func(t *testing.T) {
84+
start := time.Now()
8485
err := wait.ForStatefulSetToBeReady(t, mdb, opts...)
8586
if err != nil {
8687
t.Fatal(err)
8788
}
88-
t.Logf("StatefulSet %s/%s is ready!", mdb.Namespace, mdb.Name)
89+
elapsed := time.Since(start).Seconds()
90+
t.Logf("StatefulSet %s/%s is ready! It took %f seconds", mdb.Namespace, mdb.Name, elapsed)
8991
}
9092
}
9193

@@ -350,7 +352,7 @@ func GetConnectionStringForUser(mdb mdbv1.MongoDBCommunity, user scram.User) str
350352
return string(GetConnectionStringSecret(mdb, user).Data["connectionString.standard"])
351353
}
352354

353-
// GetConnectionStringForUser returns the mongodb service connection string for a user
355+
// GetSrvConnectionStringForUser returns the mongodb service connection string for a user
354356
func GetSrvConnectionStringForUser(mdb mdbv1.MongoDBCommunity, user scram.User) string {
355357
return string(GetConnectionStringSecret(mdb, user).Data["connectionString.standardSrv"])
356358
}
@@ -531,7 +533,7 @@ func StatefulSetContainerConditionIsTrue(mdb *mdbv1.MongoDBCommunity, containerN
531533
}
532534
}
533535

534-
// PodContainerBecomesReady waits until the container with 'containerName' in the pod #podNum becomes not ready.
536+
// PodContainerBecomesNotReady waits until the container with 'containerName' in the pod #podNum becomes not ready.
535537
func PodContainerBecomesNotReady(mdb *mdbv1.MongoDBCommunity, podNum int, containerName string) func(*testing.T) {
536538
return func(t *testing.T) {
537539
pod := podFromMongoDBCommunity(mdb, podNum)

test/e2e/replica_set_arbiter/replica_set_arbiter_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ import (
66
"github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests"
77
setup "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup"
88
"github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester"
9-
"github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/wait"
109
"github.com/stretchr/testify/assert"
1110
"os"
1211
"testing"
13-
"time"
1412
)
1513

1614
func TestMain(m *testing.M) {
@@ -82,7 +80,7 @@ func TestReplicaSetArbiter(t *testing.T) {
8280
if len(testConfig.expectedErrorMessage) > 0 {
8381
t.Run("Check status", mongodbtests.StatefulSetMessageIsReceived(&mdb, ctx, testConfig.expectedErrorMessage))
8482
} else {
85-
t.Run("Check that the stateful set becomes ready", mongodbtests.StatefulSetBecomesReady(&mdb, wait.Timeout(20*time.Minute)))
83+
t.Run("Check that the stateful set becomes ready", mongodbtests.StatefulSetBecomesReady(&mdb))
8684
t.Run("Check the number of arbiters", mongodbtests.AutomationConfigReplicaSetsHaveExpectedArbiters(&mdb, testConfig.numberOfArbiters))
8785

8886
if testConfig.numberOfArbiters != testConfig.scaleArbitersTo {

0 commit comments

Comments
 (0)