Skip to content

Commit

Permalink
Input custom operator tags to database integration e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amitlicht committed Jun 23, 2024
1 parent f4d3c81 commit 1ae3efa
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 32 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/e2e-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 10 additions & 16 deletions tests/azureiam/azureiam_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
41 changes: 41 additions & 0 deletions tests/base_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 1 addition & 15 deletions tests/databases/postgres/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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()
Expand Down

0 comments on commit 1ae3efa

Please sign in to comment.