diff --git a/Makefile b/Makefile index acc28cd9..da4bcd67 100644 --- a/Makefile +++ b/Makefile @@ -137,7 +137,7 @@ vet: ## Run go vet against code. .PHONY: test test: manifests generate fmt vet envtest ## Run tests. - KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out + KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... --ginkgo.label-filter=!integration -coverprofile cover.out ##@ Build diff --git a/controllers/dbc_end2end_test.go b/controllers/dbc_end2end_test.go new file mode 100644 index 00000000..d58fd43e --- /dev/null +++ b/controllers/dbc_end2end_test.go @@ -0,0 +1,339 @@ +package controllers + +import ( + "context" + "fmt" + "strings" + "time" + + persistancev1 "github.com/infobloxopen/db-controller/api/v1" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" + "k8s.io/client-go/kubernetes/scheme" + "k8s.io/client-go/tools/clientcmd" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/envtest" + logf "sigs.k8s.io/controller-runtime/pkg/log" +) + +const ( + timeout = time.Minute * 3 + interval = time.Minute * 1 +) + +var ( + falseVal = false + namespace = "bjeevan" + newdbcName = "new-db-test-dbclaim" + newdbcMasterSecretName = "box-3-new-db-test-dbclaim-1ec9b27c-master" + ctx = context.Background() + // dBHostname string +) + +var _ = Describe("db-controller end to end testing", Label("integration"), Ordered, func() { + var _ = BeforeAll(func() { + loadingRules := clientcmd.NewDefaultClientConfigLoadingRules() + kubeConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, &clientcmd.ConfigOverrides{}) + + rawConfig, err := kubeConfig.RawConfig() + if err != nil { + Skip(fmt.Sprintf("This test can only run in %s. Current context is %s", "box-3", "unable to read kubeconfig")) + } + + if !strings.Contains(rawConfig.CurrentContext, "box-4") { + Skip(fmt.Sprintf("This test can only run in %s. Current context is %s", "box-3", rawConfig.CurrentContext)) + } + // integration tests + + By("bootstrapping test environment") + e2e_testEnv = &envtest.Environment{ + UseExistingCluster: &trueVal, + } + + e2e_cfg, err = e2e_testEnv.Start() + Expect(err).ToNot(HaveOccurred()) + Expect(e2e_cfg).ToNot(BeNil()) + + err = persistancev1.AddToScheme(scheme.Scheme) + Expect(err).NotTo(HaveOccurred()) + + // +kubebuilder:scaffold:scheme + + e2e_k8sClient, err = client.New(e2e_cfg, client.Options{Scheme: scheme.Scheme}) + Expect(err).ToNot(HaveOccurred()) + Expect(e2e_k8sClient).ToNot(BeNil()) + }) + + logf.Log.Info("Starting test", "timeout", timeout, "interval", interval) + + Context("Creating a Postgres RDS using a dbclaim ", func() { + It("should create a RDS in AWS", func() { + By("creating a new DB Claim") + createPostgresRDSTest() + }) + }) + Context("Delete RDS", func() { + It("should delete dbinstances.crds", func() { + By("deleting the dbc and associated dbinstances.crd") + deletePostgresRDSTest() + }) + }) + Context("Use Existing RDS", func() { + It("should use Existing RDS", func() { + By("setting up master secret to access existing RDS") + setupMasterSecretForExistingRDS() + By("successfully processing an useExisting dbClaim") + UseExistingPostgresRDSTest() + }) + }) + Context("Migrate Use Existing RDS to a local RDS", func() { + It("should create a new RDS and migrate Existing database", func() { + By("Removing the useExistingFlag in dbclaim") + MigrateUseExistingToNewRDS() + }) + }) + Context("Migrate postgres RDS to Aurora RDS", func() { + It("should create a new RDS and migrate postgres sample_db to new RDS", func() { + MigratePostgresToAuroraRDS() + }) + }) + + var _ = AfterAll(func() { + By("tearing down the test environment") + if e2e_testEnv != nil { + err := e2e_testEnv.Stop() + Expect(err).ToNot(HaveOccurred()) + } + }) +}) + +func MigratePostgresToAuroraRDS() { + key := types.NamespacedName{ + Name: "end2end-test-2-dbclaim", + Namespace: namespace, + } + type testState struct { + DbState persistancev1.DbState + MigrationState string + Type persistancev1.DatabaseType + } + expectedState := testState{ + DbState: persistancev1.Ready, + MigrationState: "completed", + Type: "aurora-postgresql", + } + existingDbClaim := &persistancev1.DatabaseClaim{} + By("Getting the existing dbclaim") + Expect(e2e_k8sClient.Get(ctx, key, existingDbClaim)).Should(Succeed()) + By("Updating type from postgres to aurora-postgresql in the claim") + existingDbClaim.Spec.Type = "aurora-postgresql" + Expect(e2e_k8sClient.Update(ctx, existingDbClaim)).Should(Succeed()) + time.Sleep(time.Minute * 5) + createdDbClaim := &persistancev1.DatabaseClaim{} + By("checking dbclaim status is ready") + By("checking dbclaim status type is aurora-postgresql") + Eventually(func() (testState, error) { + err := e2e_k8sClient.Get(ctx, key, createdDbClaim) + if err != nil { + return testState{}, err + } + currentState := testState{ + DbState: createdDbClaim.Status.ActiveDB.DbState, + MigrationState: createdDbClaim.Status.MigrationState, + Type: createdDbClaim.Status.ActiveDB.Type, + } + return currentState, nil + }, time.Minute*15, interval).Should(Equal(expectedState)) + //check if eventually the secret sample-secret is created + By("checking if the secret is created") + //box-3-end2end-test-2-dbclaim-bb1e7196 + Eventually(func() (string, error) { + secret := &corev1.Secret{} + err := e2e_k8sClient.Get(ctx, types.NamespacedName{Name: "sample-secret", Namespace: namespace}, secret) + if err != nil { + return "", err + } + return string(secret.Data["hostname"]), nil + }, time.Minute*15, interval).Should(ContainSubstring("box-3-end2end-test-2-dbclaim-bb1e7196")) +} + +func MigrateUseExistingToNewRDS() { + key := types.NamespacedName{ + Name: "end2end-test-2-dbclaim", + Namespace: namespace, + } + existingDbClaim := &persistancev1.DatabaseClaim{} + By("Getting the existing dbclaim") + Expect(e2e_k8sClient.Get(ctx, key, existingDbClaim)).Should(Succeed()) + By("Removing the useExistingFlag in dbclaim") + existingDbClaim.Spec.UseExistingSource = &falseVal + existingDbClaim.Spec.SourceDataFrom = nil + Expect(e2e_k8sClient.Update(ctx, existingDbClaim)).Should(Succeed()) + time.Sleep(time.Minute * 5) + createdDbClaim := &persistancev1.DatabaseClaim{} + By("checking dbclaim status is ready") + Eventually(func() (persistancev1.DbState, error) { + err := e2e_k8sClient.Get(ctx, key, createdDbClaim) + if err != nil { + return "", err + } + return createdDbClaim.Status.ActiveDB.DbState, nil + }, time.Minute*15, interval).Should(Equal(persistancev1.Ready)) + //check if eventually the secret sample-secret is created + By("checking if the secret is created and host name contains 1ec9b27c") + //box-3-end2end-test-2-dbclaim-1ec9b27c + Eventually(func() error { + return e2e_k8sClient.Get(ctx, types.NamespacedName{Name: "sample-secret", Namespace: namespace}, &corev1.Secret{}) + }, time.Minute*15, interval).Should(BeNil()) + +} + +func UseExistingPostgresRDSTest() { + key := types.NamespacedName{ + Name: "end2end-test-2-dbclaim", + Namespace: namespace, + } + dbClaim := &persistancev1.DatabaseClaim{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "persistance.atlas.infoblox.com/v1", + Kind: "DatabaseClaim", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: key.Name, + Namespace: key.Namespace, + }, + Spec: persistancev1.DatabaseClaimSpec{ + AppID: "sample-app", + DatabaseName: "sample_db", + SecretName: "sample-secret", + Username: "sample_user", + Type: "postgres", + DSNName: "dsn", + EnableReplicationRole: &falseVal, + UseExistingSource: &trueVal, + DBVersion: "15.3", + SourceDataFrom: &persistancev1.SourceDataFrom{ + Type: persistancev1.SourceDataType("database"), + Database: &persistancev1.Database{ + DSN: "postgres://root@box-3-new-db-test-dbclaim-1ec9b27c.cpwy0kesdxhx.us-east-1.rds.amazonaws.com:5432/sample_db?sslmode=require", + SecretRef: &persistancev1.SecretRef{ + Name: "existing-db-master-secret", + Namespace: namespace, + }, + }, + }, + }, + } + Expect(e2e_k8sClient.Create(ctx, dbClaim)).Should(Succeed()) + // time.Sleep(time.Minute * 5) + createdDbClaim := &persistancev1.DatabaseClaim{} + By("checking dbclaim status is use-existing-db") + Eventually(func() (persistancev1.DbState, error) { + err := e2e_k8sClient.Get(ctx, key, createdDbClaim) + if err != nil { + return "", err + } + return createdDbClaim.Status.ActiveDB.DbState, nil + }, time.Minute*2, time.Second*15).Should(Equal(persistancev1.UsingExistingDB)) + //check if eventually the secret sample-secret is created + By("checking if the secret is created") + Eventually(func() error { + return e2e_k8sClient.Get(ctx, types.NamespacedName{Name: "sample-secret", Namespace: namespace}, &corev1.Secret{}) + }, time.Minute*2, time.Second*15).Should(BeNil()) +} + +func setupMasterSecretForExistingRDS() { + //copy secret from prev dbclaim and use it as master secret for existing rds usecase + key := types.NamespacedName{ + Name: newdbcMasterSecretName, + Namespace: "db-controller", + } + newDBMasterSecret := &corev1.Secret{} + By("Reading the prev secret") + Expect(e2e_k8sClient.Get(ctx, key, newDBMasterSecret)).Should(Succeed()) + Expect(newDBMasterSecret.Data["password"]).NotTo(BeNil()) + By("Creating the master secret") + existingDBMasterSecret := &corev1.Secret{ + ObjectMeta: metav1.ObjectMeta{ + Name: "existing-db-master-secret", + Namespace: namespace, + }, + Data: map[string][]byte{ + "password": []byte(newDBMasterSecret.Data["password"]), + }, + } + + Expect(e2e_k8sClient.Create(ctx, existingDBMasterSecret)).Should(Succeed()) +} + +func deletePostgresRDSTest() { + key := types.NamespacedName{ + Name: newdbcName, + Namespace: namespace, + } + prevDbClaim := &persistancev1.DatabaseClaim{} + By("Getting the prev dbclaim") + Expect(e2e_k8sClient.Get(ctx, key, prevDbClaim)).Should(Succeed()) + By("Deleting the dbclaim") + Expect(e2e_k8sClient.Delete(ctx, prevDbClaim)).Should(Succeed()) + // time.Sleep(time.Minute * 5) + By("checking dbclaim does not exists") + Eventually(func() error { + err := e2e_k8sClient.Get(ctx, key, prevDbClaim) + if err != nil { + if errors.IsNotFound(err) { + return nil + } + return err + } else { + return fmt.Errorf("dbclaim still exists") + } + }, timeout, time.Second*5).Should(Succeed()) +} + +func createPostgresRDSTest() { + key := types.NamespacedName{ + Name: newdbcName, + Namespace: namespace, + } + dbClaim := &persistancev1.DatabaseClaim{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "persistance.atlas.infoblox.com/v1", + Kind: "DatabaseClaim", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: key.Name, + Namespace: key.Namespace, + }, + Spec: persistancev1.DatabaseClaimSpec{ + AppID: "sample-app", + DatabaseName: "sample_db", + SecretName: "newdb-secret", + Username: "sample_user", + Type: "postgres", + DSNName: "dsn", + EnableReplicationRole: &falseVal, + UseExistingSource: &falseVal, + DBVersion: "15.3", + }, + } + Expect(e2e_k8sClient.Create(ctx, dbClaim)).Should(Succeed()) + // time.Sleep(time.Minute * 5) + createdDbClaim := &persistancev1.DatabaseClaim{} + By("checking dbclaim status is ready") + Eventually(func() (persistancev1.DbState, error) { + err := e2e_k8sClient.Get(ctx, key, createdDbClaim) + if err != nil { + return "", err + } + return createdDbClaim.Status.ActiveDB.DbState, nil + }, timeout, interval).Should(Equal(persistancev1.Ready)) + By("checking if the secret is created") + Eventually(func() error { + return e2e_k8sClient.Get(ctx, types.NamespacedName{Name: "newdb-secret", Namespace: namespace}, &corev1.Secret{}) + }, timeout, interval).Should(BeNil()) +} diff --git a/controllers/suite_test.go b/controllers/suite_test.go index 6563edfe..57de7263 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -48,6 +48,11 @@ var cfg *rest.Config var k8sClient client.Client var testEnv *envtest.Environment +var e2e_cfg *rest.Config +var e2e_k8sClient client.Client +var e2e_testEnv *envtest.Environment +var trueVal = true + var controllerConfig = []byte(` authSource: "secret" passwordConfig: diff --git a/go.mod b/go.mod index 5dd6254f..246b3350 100644 --- a/go.mod +++ b/go.mod @@ -5,12 +5,12 @@ go 1.20 require ( github.com/crossplane-contrib/provider-aws v0.42.0 github.com/crossplane/crossplane-runtime v0.20.0-rc.0.0.20230320143010-c424c4aca5b0 - github.com/onsi/gomega v1.27.1 + github.com/onsi/gomega v1.29.0 github.com/ory/dockertest/v3 v3.10.0 github.com/prometheus/client_golang v1.14.0 github.com/sethvargo/go-password v0.2.0 github.com/spf13/viper v1.11.0 - golang.org/x/net v0.11.0 // indirect + golang.org/x/net v0.17.0 // indirect k8s.io/api v0.26.1 k8s.io/apimachinery v0.26.3 k8s.io/client-go v0.26.1 @@ -25,10 +25,10 @@ require ( github.com/aws/aws-sdk-go-v2/config v1.11.1 github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.2.1 github.com/fsnotify/fsnotify v1.6.0 - github.com/go-logr/logr v1.2.3 + github.com/go-logr/logr v1.3.0 github.com/infobloxopen/atlas-app-toolkit v1.1.2 github.com/lib/pq v1.10.5 - github.com/onsi/ginkgo/v2 v2.8.4 + github.com/onsi/ginkgo/v2 v2.13.1 go.uber.org/zap v1.24.0 gopkg.in/yaml.v2 v2.4.0 sigs.k8s.io/yaml v1.3.0 @@ -68,12 +68,12 @@ require ( github.com/go-openapi/jsonpointer v0.19.5 // indirect github.com/go-openapi/jsonreference v0.20.0 // indirect github.com/go-openapi/swag v0.19.14 // indirect - github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect + github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/protobuf v1.5.2 // indirect + github.com/golang/protobuf v1.5.3 // indirect github.com/google/gnostic v0.5.7-v3refs // indirect - github.com/google/go-cmp v0.5.9 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/google/gofuzz v1.1.0 // indirect github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect @@ -117,14 +117,14 @@ require ( github.com/xeipuuv/gojsonschema v1.2.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.6.0 // indirect - golang.org/x/crypto v0.10.0 // indirect - golang.org/x/mod v0.11.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/mod v0.13.0 // indirect golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect - golang.org/x/sys v0.9.0 // indirect - golang.org/x/term v0.9.0 // indirect - golang.org/x/text v0.10.0 // indirect + golang.org/x/sys v0.14.0 // indirect + golang.org/x/term v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.10.0 // indirect + golang.org/x/tools v0.14.0 // indirect gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21 // indirect diff --git a/go.sum b/go.sum index a2d398c1..6505c3c6 100644 --- a/go.sum +++ b/go.sum @@ -179,8 +179,8 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= -github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= +github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/zapr v1.2.3 h1:a9vnzlIBPQBBkeaR9IuMUfmVOrQlkoC4YfPoFkX3T7A= github.com/go-logr/zapr v1.2.3/go.mod h1:eIauM6P8qSvTw5o2ez6UEAfGjQKrxQTl5EoK+Qa2oG4= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= @@ -194,8 +194,8 @@ github.com/go-openapi/swag v0.19.14/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/ github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= @@ -232,8 +232,9 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/gnostic v0.5.7-v3refs h1:FhTMOKj2VhjpouxvWJAV1TL304uMlb9zcDqkl6cEI54= @@ -250,8 +251,8 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g= github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -371,10 +372,10 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/onsi/ginkgo/v2 v2.8.4 h1:gf5mIQ8cLFieruNLAdgijHF1PYfLphKm2dxxcUtcqK0= -github.com/onsi/ginkgo/v2 v2.8.4/go.mod h1:427dEDQZkDKsBvCjc2A/ZPefhKxsTTrsQegMlayL730= -github.com/onsi/gomega v1.27.1 h1:rfztXRbg6nv/5f+Raen9RcGoSecHIFgBBLQK3Wdj754= -github.com/onsi/gomega v1.27.1/go.mod h1:aHX5xOykVYzWOV4WqQy0sy8BQptgukenXpCXfadcIAw= +github.com/onsi/ginkgo/v2 v2.13.1 h1:LNGfMbR2OVGBfXjvRZIZ2YCTQdGKtPLvuI1rMCCj3OU= +github.com/onsi/ginkgo/v2 v2.13.1/go.mod h1:XStQ8QcGwLyF4HdfcZB8SFOS/MWCgDuXMSBe6zrvLgM= +github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg= +github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM= @@ -501,8 +502,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM= -golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -540,8 +541,8 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= -golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY= +golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -584,8 +585,8 @@ golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= -golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -613,7 +614,7 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -669,13 +670,13 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= -golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= +golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.9.0 h1:GRRCnKYhdQrD8kfRAdQ6Zcw1P0OcELxGLKJvtjVMZ28= -golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo= +golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= +golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -686,8 +687,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58= -golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -746,8 +747,8 @@ golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.10.0 h1:tvDr/iQoUqNdohiYm0LmmKcBk+q86lb9EprIUFhHHGg= -golang.org/x/tools v0.10.0/go.mod h1:UJwyiVBsOA2uwvK/e5OY3GTpDUJriEd+/YlqAwLPmyM= +golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc= +golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/pkg/dbclient/client_test.go b/pkg/dbclient/client_test.go index a21389b0..799fd3e6 100644 --- a/pkg/dbclient/client_test.go +++ b/pkg/dbclient/client_test.go @@ -2,6 +2,7 @@ package dbclient import ( "database/sql" + "flag" "fmt" "net/url" "strconv" @@ -18,6 +19,19 @@ const failed = "\u2717" var sqlDB *sql.DB +// The following gingo struct and associted init() is required to run go test with ginkgo related flags +// Since this test is not using ginkgo, this is a hack to get around the issue of go test complaining about +// unknown flags. +var ginkgo struct { + dry_run string + label_filter string +} + +func init() { + flag.StringVar(&ginkgo.dry_run, "ginkgo.dry-run", "", "Ignore this flag") + flag.StringVar(&ginkgo.label_filter, "ginkgo.label-filter", "", "Ignore this flag") +} + type testDB struct { t *testing.T port int diff --git a/pkg/dbuser/dbuser_test.go b/pkg/dbuser/dbuser_test.go index cc76c51c..515f5181 100644 --- a/pkg/dbuser/dbuser_test.go +++ b/pkg/dbuser/dbuser_test.go @@ -1,11 +1,25 @@ package dbuser import ( + "flag" "testing" persistancev1 "github.com/infobloxopen/db-controller/api/v1" ) +// The following gingo struct and associted init() is required to run go test with ginkgo related flags +// Since this test is not using ginkgo, this is a hack to get around the issue of go test complaining about +// unknown flags. +var ginkgo struct { + dry_run string + label_filter string +} + +func init() { + flag.StringVar(&ginkgo.dry_run, "ginkgo.dry-run", "", "Ignore this flag") + flag.StringVar(&ginkgo.label_filter, "ginkgo.label-filter", "", "Ignore this flag") +} + func TestDBUser_IsUserChanged(t *testing.T) { type mockDBUser struct { role string diff --git a/pkg/hostparams/hostparams_test.go b/pkg/hostparams/hostparams_test.go index 13563317..a924852a 100644 --- a/pkg/hostparams/hostparams_test.go +++ b/pkg/hostparams/hostparams_test.go @@ -2,6 +2,7 @@ package hostparams import ( "bytes" + "flag" "reflect" "testing" @@ -10,6 +11,19 @@ import ( "github.com/spf13/viper" ) +// The following gingo struct and associted init() is required to run go test with ginkgo related flags +// Since this test is not using ginkgo, this is a hack to get around the issue of go test complaining about +// unknown flags. +var ginkgo struct { + dry_run string + label_filter string +} + +func init() { + flag.StringVar(&ginkgo.dry_run, "ginkgo.dry-run", "", "Ignore this flag") + flag.StringVar(&ginkgo.label_filter, "ginkgo.label-filter", "", "Ignore this flag") +} + func TestHostParams_Hash(t *testing.T) { type fields struct { Engine string diff --git a/pkg/pgctl/pgctl_test.go b/pkg/pgctl/pgctl_test.go index 699652d4..b85dc4b2 100644 --- a/pkg/pgctl/pgctl_test.go +++ b/pkg/pgctl/pgctl_test.go @@ -2,6 +2,7 @@ package pgctl import ( "database/sql" + "flag" "fmt" "os" "reflect" @@ -15,6 +16,19 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log/zap" ) +// The following gingo struct and associted init() is required to run go test with ginkgo related flags +// Since this test is not using ginkgo, this is a hack to get around the issue of go test complaining about +// unknown flags. +var ginkgo struct { + dry_run string + label_filter string +} + +func init() { + flag.StringVar(&ginkgo.dry_run, "ginkgo.dry-run", "", "Ignore this flag") + flag.StringVar(&ginkgo.label_filter, "ginkgo.label-filter", "", "Ignore this flag") +} + var ( SourceDBAdminDsn string SourceDBUserDsn string diff --git a/pkg/postgres-exporter/render_test.go b/pkg/postgres-exporter/render_test.go index 28266c26..d9649c36 100644 --- a/pkg/postgres-exporter/render_test.go +++ b/pkg/postgres-exporter/render_test.go @@ -3,6 +3,7 @@ package exporter import ( "bytes" "context" + "flag" "io/ioutil" "os" "path" @@ -15,6 +16,19 @@ import ( "sigs.k8s.io/controller-runtime/pkg/envtest" ) +// The following gingo struct and associted init() is required to run go test with ginkgo related flags +// Since this test is not using ginkgo, this is a hack to get around the issue of go test complaining about +// unknown flags. +var ginkgo struct { + dry_run string + label_filter string +} + +func init() { + flag.StringVar(&ginkgo.dry_run, "ginkgo.dry-run", "", "Ignore this flag") + flag.StringVar(&ginkgo.label_filter, "ginkgo.label-filter", "", "Ignore this flag") +} + var testenv = &envtest.Environment{} func TestDefaultConfig(t *testing.T) { diff --git a/pkg/rdsauth/rdsauth_test.go b/pkg/rdsauth/rdsauth_test.go index a3624570..adb57922 100644 --- a/pkg/rdsauth/rdsauth_test.go +++ b/pkg/rdsauth/rdsauth_test.go @@ -1,10 +1,24 @@ package rdsauth import ( + "flag" "testing" "time" ) +// The following gingo struct and associted init() is required to run go test with ginkgo related flags +// Since this test is not using ginkgo, this is a hack to get around the issue of go test complaining about +// unknown flags. +var ginkgo struct { + dry_run string + label_filter string +} + +func init() { + flag.StringVar(&ginkgo.dry_run, "ginkgo.dry-run", "", "Ignore this flag") + flag.StringVar(&ginkgo.label_filter, "ginkgo.label-filter", "", "Ignore this flag") +} + func Test_parseRegion(t *testing.T) { type mockAuth struct { authToken string