Skip to content

Commit 035f7f9

Browse files
CLOUDP-132091: Add TLS and arbiters to operator upgrade test (#1103)
1 parent 6e2270c commit 035f7f9

File tree

7 files changed

+33
-31
lines changed

7 files changed

+33
-31
lines changed

.action_templates/jobs/tests.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,5 @@ tests:
5656
distro: ubi
5757
- test-name: replica_set_mongod_port_change_with_arbiters
5858
distro: ubi
59+
- test-name: replica_set_operator_upgrade
60+
distro: ubi

.github/workflows/e2e-fork.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ jobs:
138138
distro: ubi
139139
- test-name: replica_set_mongod_port_change_with_arbiters
140140
distro: ubi
141+
- test-name: replica_set_operator_upgrade
142+
distro: ubi
141143
steps:
142144
# template: .action_templates/steps/cancel-previous.yaml
143145
- name: Cancel Previous Runs

.github/workflows/e2e.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ jobs:
144144
distro: ubi
145145
- test-name: replica_set_mongod_port_change_with_arbiters
146146
distro: ubi
147+
- test-name: replica_set_operator_upgrade
148+
distro: ubi
147149
steps:
148150
# template: .action_templates/steps/cancel-previous.yaml
149151
- name: Cancel Previous Runs

api/v1/mongodbcommunity_types.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,9 @@ type TLS struct {
505505

506506
// LocalObjectReference is a reference to another Kubernetes object by name.
507507
// TODO: Replace with a type from the K8s API. CoreV1 has an equivalent
508-
// "LocalObjectReference" type but it contains a TODO in its
509-
// description that we don't want in our CRD.
508+
//
509+
// "LocalObjectReference" type but it contains a TODO in its
510+
// description that we don't want in our CRD.
510511
type LocalObjectReference struct {
511512
Name string `json:"name"`
512513
}

cmd/readiness/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func hasDeadlockedSteps(health health.Status) bool {
9999
// there and find the last step which has "Started" non nil
100100
// (indeed this is not the perfect logic as sometimes the agent doesn't update the 'Started' as well - see
101101
// 'health-status-ok.json', but seems it works for finding deadlocks still
102-
//noinspection GoNilness
102+
// noinspection GoNilness
103103
func findCurrentStep(processStatuses map[string]health.MmsDirectorStatus) *health.StepStatus {
104104
var currentPlan *health.PlanStatus
105105
if len(processStatuses) == 0 {

test/e2e/replica_set_operator_upgrade/replica_set_operator_upgrade_test.go

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,18 @@ func TestMain(m *testing.M) {
2121
}
2222

2323
func TestReplicaSetOperatorUpgrade(t *testing.T) {
24-
ctx := setup.SetupWithDefaultOperator(t)
24+
resourceName := "mdb0"
25+
testConfig := setup.LoadTestConfigFromEnv()
26+
ctx := setup.SetupWithTestConfig(t, testConfig, true, true, resourceName)
2527
defer ctx.Teardown()
2628

27-
mdb, user := e2eutil.NewTestMongoDB(ctx, "mdb0", "")
29+
mdb, user := e2eutil.NewTestMongoDB(ctx, resourceName, testConfig.Namespace)
2830
scramUser := mdb.GetScramUsers()[0]
31+
mdb.Spec.Security.TLS = e2eutil.NewTestTLSConfig(false)
32+
mdb.Spec.Arbiters = 1
33+
mdb.Spec.Members = 2
2934

30-
_, err := setup.GeneratePasswordForUser(ctx, user, "")
35+
_, err := setup.GeneratePasswordForUser(ctx, user, testConfig.Namespace)
3136
if err != nil {
3237
t.Fatal(err)
3338
}
@@ -39,19 +44,22 @@ func TestReplicaSetOperatorUpgrade(t *testing.T) {
3944

4045
t.Run("Create MongoDB Resource", mongodbtests.CreateMongoDBResource(&mdb, ctx))
4146
t.Run("Basic tests", mongodbtests.BasicFunctionality(&mdb, true))
42-
t.Run("Keyfile authentication is configured", tester.HasKeyfileAuth(3))
43-
t.Run("Test Basic Connectivity", tester.ConnectivitySucceeds())
44-
t.Run("Test SRV Connectivity", tester.ConnectivitySucceeds(WithURI(mdb.MongoSRVURI("")), WithoutTls(), WithReplicaSet(mdb.Name)))
45-
t.Run("Test Basic Connectivity with generated connection string secret",
46-
tester.ConnectivitySucceeds(WithURI(mongodbtests.GetConnectionStringForUser(mdb, scramUser))))
47-
t.Run("Test SRV Connectivity with generated connection string secret",
48-
tester.ConnectivitySucceeds(WithURI(mongodbtests.GetSrvConnectionStringForUser(mdb, scramUser))))
49-
t.Run("Ensure Authentication", tester.EnsureAuthenticationIsConfigured(3))
5047
t.Run("AutomationConfig has the correct version", mongodbtests.AutomationConfigVersionHasTheExpectedVersion(&mdb, 1))
48+
mongodbtests.SkipTestIfLocal(t, "Ensure MongoDB TLS Configuration", func(t *testing.T) {
49+
t.Run("Has TLS Mode", tester.HasTlsMode("requireSSL", 60, WithTls(mdb)))
50+
t.Run("Basic Connectivity Succeeds", tester.ConnectivitySucceeds(WithTls(mdb)))
51+
t.Run("SRV Connectivity Succeeds", tester.ConnectivitySucceeds(WithURI(mdb.MongoSRVURI("")), WithTls(mdb)))
52+
t.Run("Basic Connectivity With Generated Connection String Secret Succeeds",
53+
tester.ConnectivitySucceeds(WithURI(mongodbtests.GetConnectionStringForUser(mdb, scramUser)), WithTls(mdb)))
54+
t.Run("SRV Connectivity With Generated Connection String Secret Succeeds",
55+
tester.ConnectivitySucceeds(WithURI(mongodbtests.GetSrvConnectionStringForUser(mdb, scramUser)), WithTls(mdb)))
56+
t.Run("Connectivity Fails", tester.ConnectivityFails(WithoutTls()))
57+
t.Run("Ensure authentication is configured", tester.EnsureAuthenticationIsConfigured(3, WithTls(mdb)))
58+
})
5159

5260
// upgrade the operator to master
5361
config := setup.LoadTestConfigFromEnv()
54-
err = setup.DeployOperator(config, "mdb", false, false)
62+
err = setup.DeployOperator(config, resourceName, true, false)
5563
assert.NoError(t, err)
5664

5765
// Perform the basic tests
@@ -71,7 +79,7 @@ func TestReplicaSetOperatorUpgradeFrom0_7_2(t *testing.T) {
7179
testConfig.ReadinessProbeImage = "quay.io/mongodb/mongodb-kubernetes-readinessprobe:1.0.6"
7280
testConfig.AgentImage = "quay.io/mongodb/mongodb-agent:11.0.5.6963-1"
7381

74-
ctx := setup.SetupWithTestConfig(t, testConfig, true, resourceName)
82+
ctx := setup.SetupWithTestConfig(t, testConfig, true, false, resourceName)
7583
defer ctx.Teardown()
7684

7785
mdb, user := e2eutil.NewTestMongoDB(ctx, resourceName, "")

test/e2e/setup/setup.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,6 @@ const (
3636
Pem tlsSecretType = "PEM"
3737
)
3838

39-
func SetupWithDefaultOperator(t *testing.T) *e2eutil.Context {
40-
ctx, err := e2eutil.NewContext(t, envvar.ReadBool(performCleanupEnv))
41-
42-
if err != nil {
43-
t.Fatal(err)
44-
}
45-
config := LoadTestConfigFromEnv()
46-
if err := DeployOperator(config, "mdb", false, true); err != nil {
47-
t.Fatal(err)
48-
}
49-
return ctx
50-
}
51-
5239
func Setup(t *testing.T) *e2eutil.Context {
5340
ctx, err := e2eutil.NewContext(t, envvar.ReadBool(performCleanupEnv))
5441

@@ -83,7 +70,7 @@ func SetupWithTLS(t *testing.T, resourceName string) (*e2eutil.Context, TestConf
8370
return ctx, config
8471
}
8572

86-
func SetupWithTestConfig(t *testing.T, testConfig TestConfig, withTLS bool, resourceName string) *e2eutil.Context {
73+
func SetupWithTestConfig(t *testing.T, testConfig TestConfig, withTLS, defaultOperator bool, resourceName string) *e2eutil.Context {
8774
ctx, err := e2eutil.NewContext(t, envvar.ReadBool(performCleanupEnv))
8875

8976
if err != nil {
@@ -96,7 +83,7 @@ func SetupWithTestConfig(t *testing.T, testConfig TestConfig, withTLS bool, reso
9683
}
9784
}
9885

99-
if err := DeployOperator(testConfig, resourceName, withTLS, false); err != nil {
86+
if err := DeployOperator(testConfig, resourceName, withTLS, defaultOperator); err != nil {
10087
t.Fatal(err)
10188
}
10289

0 commit comments

Comments
 (0)