From 1ae3efae2c88392fc7615f3193966e54e5f8f816 Mon Sep 17 00:00:00 2001 From: Amit Lichtenberg Date: Sun, 23 Jun 2024 12:18:12 +0300 Subject: [PATCH] Input custom operator tags to database integration e2e tests --- .github/workflows/e2e-test.yaml | 15 ++++++++- tests/azureiam/azureiam_test.go | 26 ++++++-------- tests/base_suite.go | 41 +++++++++++++++++++++++ tests/databases/postgres/postgres_test.go | 16 +-------- 4 files changed, 66 insertions(+), 32 deletions(-) diff --git a/.github/workflows/e2e-test.yaml b/.github/workflows/e2e-test.yaml index b3cfe0dd..24744c30 100644 --- a/.github/workflows/e2e-test.yaml +++ b/.github/workflows/e2e-test.yaml @@ -133,8 +133,21 @@ jobs: docker pull ${{ inputs.gcr-registry }}/intents-operator:${{ inputs.credentials-operator-tag }} minikube image load ${{ inputs.gcr-registry }}/intents-operator:${{ inputs.credentials-operator-tag }} + - name: Set intents operator image env vars + if: "${{ inputs.gcr-registry != '' && inputs.intents-operator-tag != ''}}" + run: | + echo "INTENTS_OPERATOR_REPOSITORY=${{ inputs.gcr-registry }}" >> $GITHUB_ENV + echo "INTENTS_OPERATOR_IMAGE=intents-operator" >> $GITHUB_ENV + echo "INTENTS_OPERATOR_TAG=${{ inputs.intents-operator-tag }}" >> $GITHUB_ENV + + - name: Set credentials operator image env vars + if: "${{ inputs.gcr-registry != '' && inputs.credentials-operator-tag != ''}}" + run: | + echo "CREDENTIALS_OPERATOR_REPOSITORY=${{ inputs.gcr-registry }}" >> $GITHUB_ENV + echo "CREDENTIALS_OPERATOR_IMAGE=credentials-operator" >> $GITHUB_ENV + echo "CREDENTIALS_OPERATOR_TAG=${{ inputs.credentials-operator-tag }}" >> $GITHUB_ENV + - name: Run E2E tests - database integrations - # TODO: provide registry & image tags as arguments run: | cd tests go test -v -json ./databases/... | tee gotest.log | gotestfmt diff --git a/tests/azureiam/azureiam_test.go b/tests/azureiam/azureiam_test.go index 90cd5015..fd46e9e1 100644 --- a/tests/azureiam/azureiam_test.go +++ b/tests/azureiam/azureiam_test.go @@ -129,22 +129,16 @@ func (s *AzureIAMTestSuite) initAzureAgent() { } func (s *AzureIAMTestSuite) installOtterizeForAzureIAM() { - values := map[string]any{ - "global": map[string]any{ - "azure": map[string]any{ - "enabled": true, - "subscriptionID": s.conf.SubscriptionID, - "resourceGroup": s.conf.ResourceGroup, - "aksClusterName": s.conf.AKSClusterName, - "userAssignedIdentityID": s.conf.OtterizeOperatorUserAssignedIdentityClientID, - }, - "deployment": map[string]any{ - "networkMapper": false, - }, - "telemetry": map[string]interface{}{ - "enabled": false, - }, - }, + values := s.GetDefaultValues() + if _, ok := values["global"]; !ok { + values["global"] = map[string]any{} + } + values["global"].(map[string]any)["azure"] = map[string]any{ + "enabled": true, + "subscriptionID": s.conf.SubscriptionID, + "resourceGroup": s.conf.ResourceGroup, + "aksClusterName": s.conf.AKSClusterName, + "userAssignedIdentityID": s.conf.OtterizeOperatorUserAssignedIdentityClientID, } s.InstallOtterizeHelmChart(values) diff --git a/tests/base_suite.go b/tests/base_suite.go index ec861b9a..fdb8b401 100644 --- a/tests/base_suite.go +++ b/tests/base_suite.go @@ -89,6 +89,47 @@ func (s *BaseSuite) SetupSuite() { }) } +func (s *BaseSuite) GetDefaultValues() map[string]any { + defaultValues := map[string]any{ + "global": map[string]any{ + "deployment": map[string]any{ + "networkMapper": false, + }, + "telemetry": map[string]any{ + "enabled": false, + }, + }, + } + + intentsOperatorRepository := os.Getenv("INTENTS_OPERATOR_REPOSITORY") + intentsOperatorImage := os.Getenv("INTENTS_OPERATOR_IMAGE") + intentsOperatorTag := os.Getenv("INTENTS_OPERATOR_TAG") + + if intentsOperatorTag != "" { + defaultValues["intentsOperator"].(map[string]any)["operator"] = map[string]any{ + "tag": intentsOperatorTag, + "image": intentsOperatorImage, + "repository": intentsOperatorRepository, + "pullPolicy": "Never", + } + } + + credentialsOperatorRepository := os.Getenv("CREDENTIALS_OPERATOR_REPOSITORY") + credentialsOperatorImage := os.Getenv("CREDENTIALS_OPERATOR_IMAGE") + credentialsOperatorTag := os.Getenv("CREDENTIALS_OPERATOR_TAG") + + if credentialsOperatorTag != "" { + defaultValues["credentialsOperator"].(map[string]any)["operator"] = map[string]any{ + "tag": credentialsOperatorTag, + "image": credentialsOperatorImage, + "repository": credentialsOperatorRepository, + "pullPolicy": "Never", + } + } + + return defaultValues +} + func (s *BaseSuite) InstallOtterizeHelmChart(values map[string]any) { // Load Chart.yaml chart, err := loader.Load(OtterizeKubernetesChartPath) diff --git a/tests/databases/postgres/postgres_test.go b/tests/databases/postgres/postgres_test.go index 8d0b3647..2e44d0c8 100644 --- a/tests/databases/postgres/postgres_test.go +++ b/tests/databases/postgres/postgres_test.go @@ -39,7 +39,7 @@ type PostgresTestSuite struct { func (s *PostgresTestSuite) SetupSuite() { s.BaseSuite.SetupSuite() - s.installOtterizeNetworkMapperDisabled() + s.InstallOtterizeHelmChart(s.GetDefaultValues()) s.PGServerConfClient = s.DynamicClient.Resource(schema.GroupVersionResource{ Group: "k8s.otterize.com", @@ -54,20 +54,6 @@ func (s *PostgresTestSuite) TearDownSuite() { s.UninstallOtterizeHelmChart(ctx) } -func (s *PostgresTestSuite) installOtterizeNetworkMapperDisabled() { - values := map[string]interface{}{ - "global": map[string]interface{}{ - "deployment": map[string]interface{}{ - "networkMapper": false, - }, - "telemetry": map[string]interface{}{ - "enabled": false, - }, - }, - } - s.InstallOtterizeHelmChart(values) -} - func (s *PostgresTestSuite) SetupTest() { ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(2*time.Minute)) defer cancel()