diff --git a/e2e/e2e_test.go b/e2e/e2e_test.go index a07c97e2..63bbbb2f 100644 --- a/e2e/e2e_test.go +++ b/e2e/e2e_test.go @@ -38,11 +38,13 @@ var _ = Describe("E2e", func() { BeforeEach(func() { deleteMySQLUserIfExist(ctx) deleteMySQLIfExist(ctx) + deleteMySQLSecretIfExist(ctx) }) AfterEach(func() { deleteMySQLUserIfExist(ctx) deleteMySQLIfExist(ctx) + deleteMySQLSecretIfExist(ctx) }) Describe("Creating and deleting MySQL/MySQLUser object", func() { @@ -183,6 +185,15 @@ func checkMySQLHasUser(mysqluser string) (int, error) { } } +func deleteMySQLSecretIfExist(ctx context.Context) { + secret := &corev1.Secret{} + err := k8sClient.Get(ctx, client.ObjectKey{Namespace: mysqlNamespace, Name: secretName}, secret) + if err != nil { + return + } + Expect(k8sClient.Delete(ctx, secret)).Should(Succeed()) +} + func deleteMySQLServiceIfExist(ctx context.Context) { svcNames := []string{"mysql", "mysql-nodeport"} for _, svcName := range svcNames {