This repository was archived by the owner on Dec 12, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 521
CLOUDP-111968: Update automation config when updating TLS #905
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ed1ff7c
Ensure automation config when ensuring TLS secret
mircea-cosbuc 7ad350b
Test TLS config and automation config interaction
mircea-cosbuc bd49124
Wait for resource to reach running state after STS is deleted
mircea-cosbuc 4531af7
Fix e2e test to delete STS
mircea-cosbuc 752c217
Fix e2e role to allow patching webhook configs
mircea-cosbuc 070a527
Fix stale automation config by reverting
mircea-cosbuc 93f5b09
Revert CRD annotation removal
mircea-cosbuc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -134,6 +134,7 @@ rules: | |
| - watch | ||
| - create | ||
| - delete | ||
| - patch | ||
| - update | ||
| - apiGroups: | ||
| - acme.cert-manager.io | ||
|
|
||
65 changes: 65 additions & 0 deletions
65
test/e2e/replica_set_tls_rotate_delete_sts/replica_set_tls_rotate_delete_sts_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| package replica_set_tls_rotate_delete_sts | ||
|
|
||
| import ( | ||
| "os" | ||
| "testing" | ||
|
|
||
| "fmt" | ||
|
|
||
| . "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/util/mongotester" | ||
|
|
||
| e2eutil "github.com/mongodb/mongodb-kubernetes-operator/test/e2e" | ||
| "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/mongodbtests" | ||
| "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/setup" | ||
| "github.com/mongodb/mongodb-kubernetes-operator/test/e2e/tlstests" | ||
| ) | ||
|
|
||
| func TestMain(m *testing.M) { | ||
| code, err := e2eutil.RunTest(m) | ||
| if err != nil { | ||
| fmt.Println(err) | ||
| } | ||
| os.Exit(code) | ||
| } | ||
|
|
||
| func TestReplicaSetTLSRotateDeleteSts(t *testing.T) { | ||
| resourceName := "mdb-tls" | ||
|
|
||
| ctx, testConfig := setup.SetupWithTLS(t, resourceName) | ||
| defer ctx.Teardown() | ||
|
|
||
| mdb, user := e2eutil.NewTestMongoDB(ctx, resourceName, testConfig.Namespace) | ||
| mdb.Spec.Security.TLS = e2eutil.NewTestTLSConfig(false) | ||
|
|
||
| _, err := setup.GeneratePasswordForUser(ctx, user, testConfig.Namespace) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
|
||
| tester, err := FromResource(t, mdb) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
|
||
| clientCert, err := GetClientCert(mdb) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| initialCertSerialNumber := clientCert.SerialNumber | ||
|
|
||
| t.Run("Create MongoDB Resource", mongodbtests.CreateMongoDBResource(&mdb, ctx)) | ||
| t.Run("Basic tests", mongodbtests.BasicFunctionality(&mdb)) | ||
| t.Run("Wait for TLS to be enabled", tester.HasTlsMode("requireSSL", 60, WithTls(mdb))) | ||
| t.Run("Test Basic TLS Connectivity", tester.ConnectivitySucceeds(WithTls(mdb))) | ||
| t.Run("Ensure Authentication", tester.EnsureAuthenticationIsConfigured(3, WithTls(mdb))) | ||
| t.Run("Test TLS required", tester.ConnectivityFails(WithoutTls())) | ||
|
|
||
| t.Run("MongoDB is reachable while certificate is rotated", func(t *testing.T) { | ||
| t.Run("Delete Statefulset", mongodbtests.DeleteStatefulSet(&mdb)) | ||
| t.Run("Update certificate secret", tlstests.RotateCertificate(&mdb)) | ||
| t.Run("Wait for certificate to be rotated", tester.WaitForRotatedCertificate(mdb, initialCertSerialNumber)) | ||
| t.Run("Test Replica Set Recovers", mongodbtests.StatefulSetBecomesReady(&mdb)) | ||
| t.Run("Wait for MongoDB to reach Running Phase", mongodbtests.MongoDBReachesRunningPhase(&mdb)) | ||
| t.Run("Test Basic TLS Connectivity", tester.ConnectivitySucceeds(WithTls(mdb))) | ||
| }) | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.