diff --git a/test/backup_service/backup_service_suite_test.go b/test/backup_service/backup_service_suite_test.go index 2479fb3d..3d8ff23c 100644 --- a/test/backup_service/backup_service_suite_test.go +++ b/test/backup_service/backup_service_suite_test.go @@ -7,16 +7,12 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/gexec" - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" k8Runtime "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - "github.com/aerospike/aerospike-kubernetes-operator/controllers/common" "github.com/aerospike/aerospike-kubernetes-operator/test" ) @@ -40,18 +36,6 @@ var _ = BeforeSuite( var err error testEnv, _, k8sClient, _, err = test.BootStrapTestEnv(scheme) Expect(err).NotTo(HaveOccurred()) - - sa := corev1.ServiceAccount{ - ObjectMeta: metav1.ObjectMeta{ - Name: common.AerospikeBackupService, - Namespace: namespace, - }, - } - - err = k8sClient.Create(testCtx, &sa) - if err != nil && !errors.IsAlreadyExists(err) { - Fail(err.Error()) - } }) var _ = AfterSuite( diff --git a/test/cleanup-test-namespace.sh b/test/cleanup-test-namespace.sh index 6b552f89..97a7bb07 100755 --- a/test/cleanup-test-namespace.sh +++ b/test/cleanup-test-namespace.sh @@ -36,6 +36,7 @@ for namespace in $namespaces; do echo "Removing serviceaccount from namespace: $namespace" kubectl -n "$namespace" delete serviceaccount aerospike-operator-controller-manager --ignore-not-found + kubectl -n "$namespace" delete serviceaccount aerospike-backup-service --ignore-not-found done diff --git a/test/suite_test.go b/test/suite_test.go index 82f3f4f4..06b40afa 100644 --- a/test/suite_test.go +++ b/test/suite_test.go @@ -37,6 +37,7 @@ import ( // +kubebuilder:scaffold:imports asdbv1 "github.com/aerospike/aerospike-kubernetes-operator/api/v1" + "github.com/aerospike/aerospike-kubernetes-operator/controllers/common" ) // These tests use Ginkgo (BDD-style Go testing framework). Refer to @@ -91,6 +92,10 @@ var _ = BeforeSuite( Expect(err).NotTo(HaveOccurred()) Expect(k8sClient).NotTo(BeNil()) + // Create SA for aerospike backup service + err = createServiceAccount(k8sClient, goctx.TODO(), common.AerospikeBackupService, namespace) + Expect(err).ToNot(HaveOccurred()) + // Setup by user function // test creating resource // IN operator namespace