From 833c63fc5a49f8bc2e4e30b1a299a920ae11953c Mon Sep 17 00:00:00 2001 From: Vishwanath Hiremath Date: Mon, 4 Mar 2024 11:42:42 -0800 Subject: [PATCH 01/13] adding functional test for private terraform repo Signed-off-by: Vishwanath Hiremath --- .../shared/resources/recipe_terraform_test.go | 86 +++++++++++++++++++ ...ces-terraform-private-git-repo-redis.bicep | 72 ++++++++++++++++ test/functional/testUtil.go | 13 +++ 3 files changed, 171 insertions(+) create mode 100644 test/functional/shared/resources/testdata/corerp-resources-terraform-private-git-repo-redis.bicep diff --git a/test/functional/shared/resources/recipe_terraform_test.go b/test/functional/shared/resources/recipe_terraform_test.go index c7b4db95a6..407520a095 100644 --- a/test/functional/shared/resources/recipe_terraform_test.go +++ b/test/functional/shared/resources/recipe_terraform_test.go @@ -425,3 +425,89 @@ func getSecretSuffix(resourceID, envName, appName string) (string, error) { return kubernetes["secret_suffix"].(string), nil } + +// Test_TerraformRecipe_Redis covers the following terraform recipe scenario: +// +// - Create an extender resource using a Terraform recipe that deploys Redis on Kubernetes. +// - The recipe deployment creates a Kubernetes deployment and a Kubernetes service. +func Test_TerraformPrivateGitModule_KubernetesRedis(t *testing.T) { + template := "testdata/corerp-resources-terraform-private-git-repo-redis.bicep" + name := "corerp-resources-terraform-private-redis" + appName := "corerp-resources-terraform-private-app" + envName := "corerp-resources-terraform-private-env" + redisCacheName := "tf-redis-cache-private" + sourcePath := fmt.Sprintf("%s/%s", functional.GetTerraformPrivateModuleSource(), "/tree/main/kubernetes-redis") + + secretSuffix, err := getSecretSuffix("/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/extenders/"+name, envName, appName) + require.NoError(t, err) + + test := shared.NewRPTest(t, name, []shared.TestStep{ + { + Executor: step.NewDeployExecutor(template, "privateGitModule="+sourcePath, "appName="+appName, "redisCacheName="+redisCacheName, functional.GetGitPAT()), + RPResources: &validation.RPResourceSet{ + Resources: []validation.RPResource{ + { + Name: envName, + Type: validation.EnvironmentsResource, + }, + { + Name: appName, + Type: validation.ApplicationsResource, + }, + { + Name: name, + Type: validation.ExtendersResource, + App: appName, + OutputResources: []validation.OutputResourceResponse{ + {ID: "/planes/kubernetes/local/namespaces/corerp-resources-terraform-redis-app/providers/apps/Deployment/tf-redis-cache-private"}, + {ID: "/planes/kubernetes/local/namespaces/corerp-resources-terraform-redis-app/providers/core/Service/tf-redis-cache-private"}, + }, + }, + }, + }, + K8sObjects: &validation.K8sObjectSet{ + Namespaces: map[string][]validation.K8sObject{ + appName: { + validation.NewK8sServiceForResource(appName, redisCacheName). + ValidateLabels(false), + }, + secretNamespace: { + validation.NewK8sSecretForResourceWithResourceName(secretPrefix + secretSuffix). + ValidateLabels(false), + }, + }, + }, + PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { + secret, err := test.Options.K8sClient.CoreV1().Secrets(secretNamespace). + Get(ctx, secretPrefix+secretSuffix, metav1.GetOptions{}) + require.NoError(t, err) + require.Equal(t, secretNamespace, secret.Namespace) + require.Equal(t, secretPrefix+secretSuffix, secret.Name) + + redis, err := test.Options.ManagementClient.ShowResource(ctx, "Applications.Core/extenders", name) + require.NoError(t, err) + require.NotNil(t, redis) + status := redis.Properties["status"].(map[string]any) + recipe := status["recipe"].(map[string]interface{}) + require.Equal(t, "terraform", recipe["templateKind"].(string)) + expectedTemplatePath := strings.Replace(functional.GetTerraformRecipeModuleServerURL()+"/kubernetes-redis.zip//modules", "moduleServer=", "", 1) + require.Equal(t, expectedTemplatePath, recipe["templatePath"].(string)) + // At present, it is not possible to verify the template version in functional tests + // This is verified by UTs though + + // Manually delete Kubernetes the secret that stores the Terraform state file now. The next step in the test will be the deletion + // of the portable resource that uses this secret for Terraform recipe. This is to verify that the test and portable resource + // deletion will not fail even though the secret is already deleted. + err = test.Options.K8sClient.CoreV1().Secrets(secretNamespace).Delete(ctx, secretPrefix+secretSuffix, metav1.DeleteOptions{}) + require.NoError(t, err) + }, + }, + }) + + test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test shared.RPTest) { + resourceID := "/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/extenders/" + name + testSecretDeletion(t, ctx, test, appName, envName, resourceID) + } + + test.Test(t) +} diff --git a/test/functional/shared/resources/testdata/corerp-resources-terraform-private-git-repo-redis.bicep b/test/functional/shared/resources/testdata/corerp-resources-terraform-private-git-repo-redis.bicep new file mode 100644 index 0000000000..57bd11ea06 --- /dev/null +++ b/test/functional/shared/resources/testdata/corerp-resources-terraform-private-git-repo-redis.bicep @@ -0,0 +1,72 @@ +import radius as radius + +@description('Name of the Redis Cache resource.') +param redisCacheName string + +@description('Name of the Radius Application.') +param appName string + +@secure() +param pat string='' + +@description('Private Git module source in generic git format.') +param privateGitModule string + +resource env 'Applications.Core/environments@2023-10-01-preview' = { + name: 'corerp-resources-terraform-private-env' + properties: { + compute: { + kind: 'kubernetes' + resourceId: 'self' + namespace: 'corerp-resources-terraform-private-env' + } + recipes: { + 'Applications.Core/extenders': { + default: { + templateKind: 'terraform' + templatePath: privateGitModule + } + } + } + } +} + +resource app 'Applications.Core/applications@2023-10-01-preview' = { + name: appName + properties: { + environment: env.id + extensions: [ + { + kind: 'kubernetesNamespace' + namespace: appName + } + ] + } +} + +resource webapp 'Applications.Core/extenders@2023-10-01-preview' = { + name: 'corerp-resources-terraform-private-redis' + properties: { + application: app.id + environment: env.id + recipe: { + name: 'default' + parameters: { + redis_cache_name: redisCacheName + } + } + } +} + +resource moduleSecrets 'Applications.Core/secretStores@2023-10-01-preview' = { + name: 'module-secrets' + properties: { + resource: 'test-namespace/github' + type: 'generic' + data: { + pat: { + value: pat + } + } + } +} diff --git a/test/functional/testUtil.go b/test/functional/testUtil.go index 9ee366707a..717823f8f1 100644 --- a/test/functional/testUtil.go +++ b/test/functional/testUtil.go @@ -126,6 +126,19 @@ func GetTerraformRecipeModuleServerURL() string { return "moduleServer=" + u } +func GetTerraformPrivateModuleSource() string { + u := os.Getenv("TF_RECIPE_PRIVATE_GIT_SOURCE") + if u == "" { + return "privateGitModule=git::https://github.com/radius-project/terraform-private-modules" + } + return "privateGitModule=" + u +} + +func GetGitPAT() string { + u := os.Getenv("GITHUB_TOKEN") + return "pat=" + u +} + // GetAWSAccountId retrieves the AWS Account ID from the environment and returns it as a string. func GetAWSAccountId() string { awsAccountId := os.Getenv("AWS_ACCOUNT_ID") From 525ac2456a26f362d614b748b9ded84db7abaf51 Mon Sep 17 00:00:00 2001 From: Vishwanath Hiremath Date: Mon, 4 Mar 2024 11:51:48 -0800 Subject: [PATCH 02/13] add missing diff Signed-off-by: Vishwanath Hiremath --- .github/workflows/functional-test.yaml | 2 ++ test/functional/shared/resources/recipe_terraform_test.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/functional-test.yaml b/.github/workflows/functional-test.yaml index 5ebe748620..10da4f32b0 100644 --- a/.github/workflows/functional-test.yaml +++ b/.github/workflows/functional-test.yaml @@ -70,6 +70,8 @@ env: ACTION_LINK: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' # Server where terraform test modules are deployed TF_RECIPE_MODULE_SERVER_URL: "http://tf-module-server.radius-test-tf-module-server.svc.cluster.local" + # Private Git repository where terraform module is stored. + TF_RECIPE_PRIVATE_GIT_SOURCE: "git::https://github.com/radius-project/terraform-private-modules" jobs: build: diff --git a/test/functional/shared/resources/recipe_terraform_test.go b/test/functional/shared/resources/recipe_terraform_test.go index 407520a095..4ced557ab0 100644 --- a/test/functional/shared/resources/recipe_terraform_test.go +++ b/test/functional/shared/resources/recipe_terraform_test.go @@ -490,7 +490,7 @@ func Test_TerraformPrivateGitModule_KubernetesRedis(t *testing.T) { status := redis.Properties["status"].(map[string]any) recipe := status["recipe"].(map[string]interface{}) require.Equal(t, "terraform", recipe["templateKind"].(string)) - expectedTemplatePath := strings.Replace(functional.GetTerraformRecipeModuleServerURL()+"/kubernetes-redis.zip//modules", "moduleServer=", "", 1) + expectedTemplatePath := strings.Replace(sourcePath, "moduleServer=", "", 1) require.Equal(t, expectedTemplatePath, recipe["templatePath"].(string)) // At present, it is not possible to verify the template version in functional tests // This is verified by UTs though From 116d624ed361ee780515c9c0cd23f48fdab45078 Mon Sep 17 00:00:00 2001 From: Vishwanath Hiremath Date: Mon, 4 Mar 2024 11:58:35 -0800 Subject: [PATCH 03/13] adding recipeconfig Signed-off-by: Vishwanath Hiremath --- ...resources-terraform-private-git-repo-redis.bicep | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/functional/shared/resources/testdata/corerp-resources-terraform-private-git-repo-redis.bicep b/test/functional/shared/resources/testdata/corerp-resources-terraform-private-git-repo-redis.bicep index 57bd11ea06..7b5301ae5b 100644 --- a/test/functional/shared/resources/testdata/corerp-resources-terraform-private-git-repo-redis.bicep +++ b/test/functional/shared/resources/testdata/corerp-resources-terraform-private-git-repo-redis.bicep @@ -20,6 +20,19 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { resourceId: 'self' namespace: 'corerp-resources-terraform-private-env' } + recipeConfig: { + terraform: { + authentication: { + git: { + pat: { + 'github.com':{ + secret: moduleSecrets.id + } + } + } + } + } + } recipes: { 'Applications.Core/extenders': { default: { From 7ccc51cc2666392759e8786c03d5d175be7041d7 Mon Sep 17 00:00:00 2001 From: Vishwanath Hiremath Date: Wed, 6 Mar 2024 17:42:21 -0800 Subject: [PATCH 04/13] fixing linting errors Signed-off-by: Vishwanath Hiremath --- test/functional/shared/resources/recipe_terraform_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/functional/shared/resources/recipe_terraform_test.go b/test/functional/shared/resources/recipe_terraform_test.go index 0dfa636885..d9a7c975e4 100644 --- a/test/functional/shared/resources/recipe_terraform_test.go +++ b/test/functional/shared/resources/recipe_terraform_test.go @@ -436,14 +436,14 @@ func Test_TerraformPrivateGitModule_KubernetesRedis(t *testing.T) { appName := "corerp-resources-terraform-private-app" envName := "corerp-resources-terraform-private-env" redisCacheName := "tf-redis-cache-private" - sourcePath := fmt.Sprintf("%s/%s", functional.GetTerraformPrivateModuleSource(), "/tree/main/kubernetes-redis") + sourcePath := fmt.Sprintf("%s/%s", testutil.GetTerraformPrivateModuleSource(), "/tree/main/kubernetes-redis") secretSuffix, err := getSecretSuffix("/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/extenders/"+name, envName, appName) require.NoError(t, err) test := shared.NewRPTest(t, name, []shared.TestStep{ { - Executor: step.NewDeployExecutor(template, "privateGitModule="+sourcePath, "appName="+appName, "redisCacheName="+redisCacheName, functional.GetGitPAT()), + Executor: step.NewDeployExecutor(template, "privateGitModule="+sourcePath, "appName="+appName, "redisCacheName="+redisCacheName, testutil.GetGitPAT()), RPResources: &validation.RPResourceSet{ Resources: []validation.RPResource{ { From 62ab2a72cef08180865eba5a50be57f8a57cc0e1 Mon Sep 17 00:00:00 2001 From: Vishwanath Hiremath Date: Wed, 6 Mar 2024 18:10:54 -0800 Subject: [PATCH 05/13] adding token to env Signed-off-by: Vishwanath Hiremath --- .github/workflows/functional-test.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/functional-test.yaml b/.github/workflows/functional-test.yaml index e8e10b3023..34cc835a70 100644 --- a/.github/workflows/functional-test.yaml +++ b/.github/workflows/functional-test.yaml @@ -559,6 +559,7 @@ jobs: INTEGRATION_TEST_RESOURCE_GROUP_NAME: ${{ env.AZURE_TEST_RESOURCE_GROUP }} BICEP_RECIPE_REGISTRY: ${{ env.BICEP_RECIPE_REGISTRY }} BICEP_RECIPE_TAG_VERSION: ${{ env.BICEP_RECIPE_TAG_VERSION }} + GITHUB_TOKEN: ${{ steps.get_installation_token.outputs.token }} - uses: azure/setup-kubectl@v3 if: always() with: From 1a9b05e3b72e15028774d7d0baf9e7a26ff23955 Mon Sep 17 00:00:00 2001 From: Vishwanath Hiremath Date: Thu, 7 Mar 2024 11:48:09 -0800 Subject: [PATCH 06/13] fix token Signed-off-by: Vishwanath Hiremath --- .github/workflows/functional-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/functional-test.yaml b/.github/workflows/functional-test.yaml index 34cc835a70..341be7aa96 100644 --- a/.github/workflows/functional-test.yaml +++ b/.github/workflows/functional-test.yaml @@ -559,7 +559,7 @@ jobs: INTEGRATION_TEST_RESOURCE_GROUP_NAME: ${{ env.AZURE_TEST_RESOURCE_GROUP }} BICEP_RECIPE_REGISTRY: ${{ env.BICEP_RECIPE_REGISTRY }} BICEP_RECIPE_TAG_VERSION: ${{ env.BICEP_RECIPE_TAG_VERSION }} - GITHUB_TOKEN: ${{ steps.get_installation_token.outputs.token }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: azure/setup-kubectl@v3 if: always() with: From 1e3d80546a0088afaa36c7797f59a2c852d8a390 Mon Sep 17 00:00:00 2001 From: Vishwanath Hiremath Date: Thu, 7 Mar 2024 13:26:30 -0800 Subject: [PATCH 07/13] adding token to env Signed-off-by: Vishwanath Hiremath --- .github/workflows/functional-test.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/functional-test.yaml b/.github/workflows/functional-test.yaml index 341be7aa96..1c8bf5361d 100644 --- a/.github/workflows/functional-test.yaml +++ b/.github/workflows/functional-test.yaml @@ -73,6 +73,8 @@ env: # Private Git repository where terraform module is stored. TF_RECIPE_PRIVATE_GIT_SOURCE: "git::https://github.com/radius-project/terraform-private-modules" + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + jobs: build: name: Build Radius for test From 800d65de58d1d2a0ce33cb3fdedbc810a7d9614f Mon Sep 17 00:00:00 2001 From: Vishwanath Hiremath Date: Fri, 8 Mar 2024 14:01:07 -0800 Subject: [PATCH 08/13] testing Signed-off-by: Vishwanath Hiremath --- .github/workflows/functional-test.yaml | 4 +--- test/testutil/testutil.go | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/functional-test.yaml b/.github/workflows/functional-test.yaml index 1c8bf5361d..9d2fdab461 100644 --- a/.github/workflows/functional-test.yaml +++ b/.github/workflows/functional-test.yaml @@ -73,8 +73,6 @@ env: # Private Git repository where terraform module is stored. TF_RECIPE_PRIVATE_GIT_SOURCE: "git::https://github.com/radius-project/terraform-private-modules" - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - jobs: build: name: Build Radius for test @@ -561,7 +559,7 @@ jobs: INTEGRATION_TEST_RESOURCE_GROUP_NAME: ${{ env.AZURE_TEST_RESOURCE_GROUP }} BICEP_RECIPE_REGISTRY: ${{ env.BICEP_RECIPE_REGISTRY }} BICEP_RECIPE_TAG_VERSION: ${{ env.BICEP_RECIPE_TAG_VERSION }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: azure/setup-kubectl@v3 if: always() with: diff --git a/test/testutil/testutil.go b/test/testutil/testutil.go index b925ae15c3..4c53179e52 100644 --- a/test/testutil/testutil.go +++ b/test/testutil/testutil.go @@ -135,7 +135,7 @@ func GetTerraformPrivateModuleSource() string { } func GetGitPAT() string { - u := os.Getenv("GITHUB_TOKEN") + u := os.Getenv("GH_TOKEN") return "pat=" + u } From 5984d3feb800d279f3bd9cfa2f732a2ca106650a Mon Sep 17 00:00:00 2001 From: Vishwanath Hiremath Date: Fri, 8 Mar 2024 14:38:54 -0800 Subject: [PATCH 09/13] testing Signed-off-by: Vishwanath Hiremath --- .github/workflows/functional-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/functional-test.yaml b/.github/workflows/functional-test.yaml index 9d2fdab461..a0818af737 100644 --- a/.github/workflows/functional-test.yaml +++ b/.github/workflows/functional-test.yaml @@ -559,7 +559,7 @@ jobs: INTEGRATION_TEST_RESOURCE_GROUP_NAME: ${{ env.AZURE_TEST_RESOURCE_GROUP }} BICEP_RECIPE_REGISTRY: ${{ env.BICEP_RECIPE_REGISTRY }} BICEP_RECIPE_TAG_VERSION: ${{ env.BICEP_RECIPE_TAG_VERSION }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: "test-git-pat" - uses: azure/setup-kubectl@v3 if: always() with: From 4f563159e7b2832b07c7c09f00256a83132b8c59 Mon Sep 17 00:00:00 2001 From: Vishwanath Hiremath Date: Mon, 11 Mar 2024 10:17:06 -0700 Subject: [PATCH 10/13] testing Signed-off-by: Vishwanath Hiremath --- .github/workflows/functional-test.yaml | 2 +- test/functional/shared/resources/recipe_terraform_test.go | 6 +++--- .../corerp-resources-terraform-private-git-repo-redis.bicep | 2 +- test/testutil/testutil.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/functional-test.yaml b/.github/workflows/functional-test.yaml index a0818af737..9aeef2ab5b 100644 --- a/.github/workflows/functional-test.yaml +++ b/.github/workflows/functional-test.yaml @@ -71,7 +71,7 @@ env: # Server where terraform test modules are deployed TF_RECIPE_MODULE_SERVER_URL: "http://tf-module-server.radius-test-tf-module-server.svc.cluster.local" # Private Git repository where terraform module is stored. - TF_RECIPE_PRIVATE_GIT_SOURCE: "git::https://github.com/radius-project/terraform-private-modules" + TF_RECIPE_PRIVATE_GIT_SOURCE: "git::https://github.com/radius-project/terraform-private-modules//kubernetes-redis" jobs: build: diff --git a/test/functional/shared/resources/recipe_terraform_test.go b/test/functional/shared/resources/recipe_terraform_test.go index d9a7c975e4..04f045c324 100644 --- a/test/functional/shared/resources/recipe_terraform_test.go +++ b/test/functional/shared/resources/recipe_terraform_test.go @@ -436,14 +436,14 @@ func Test_TerraformPrivateGitModule_KubernetesRedis(t *testing.T) { appName := "corerp-resources-terraform-private-app" envName := "corerp-resources-terraform-private-env" redisCacheName := "tf-redis-cache-private" - sourcePath := fmt.Sprintf("%s/%s", testutil.GetTerraformPrivateModuleSource(), "/tree/main/kubernetes-redis") secretSuffix, err := getSecretSuffix("/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/extenders/"+name, envName, appName) require.NoError(t, err) - + T.Logf(fmt.Sprintf("modulesource terraform git:%s",testutil.GetTerraformPrivateModuleSource())) + T.Logf(fmt.Sprintf("modulesource git token :%s", testutil.GetGitPAT())) test := shared.NewRPTest(t, name, []shared.TestStep{ { - Executor: step.NewDeployExecutor(template, "privateGitModule="+sourcePath, "appName="+appName, "redisCacheName="+redisCacheName, testutil.GetGitPAT()), + Executor: step.NewDeployExecutor(template, testutil.GetTerraformPrivateModuleSource(), "appName="+appName, "redisCacheName="+redisCacheName, testutil.GetGitPAT()), RPResources: &validation.RPResourceSet{ Resources: []validation.RPResource{ { diff --git a/test/functional/shared/resources/testdata/corerp-resources-terraform-private-git-repo-redis.bicep b/test/functional/shared/resources/testdata/corerp-resources-terraform-private-git-repo-redis.bicep index 7b5301ae5b..08648c1e28 100644 --- a/test/functional/shared/resources/testdata/corerp-resources-terraform-private-git-repo-redis.bicep +++ b/test/functional/shared/resources/testdata/corerp-resources-terraform-private-git-repo-redis.bicep @@ -7,7 +7,7 @@ param redisCacheName string param appName string @secure() -param pat string='' +param pat string @description('Private Git module source in generic git format.') param privateGitModule string diff --git a/test/testutil/testutil.go b/test/testutil/testutil.go index 4c53179e52..78cb6e89a7 100644 --- a/test/testutil/testutil.go +++ b/test/testutil/testutil.go @@ -129,7 +129,7 @@ func GetTerraformRecipeModuleServerURL() string { func GetTerraformPrivateModuleSource() string { u := os.Getenv("TF_RECIPE_PRIVATE_GIT_SOURCE") if u == "" { - return "privateGitModule=git::https://github.com/radius-project/terraform-private-modules" + return "privateGitModule=git::https://github.com/radius-project/terraform-private-modules//kubernetes-redis" } return "privateGitModule=" + u } From c675cc4132cf7c688e6f3fc5081ab424b0867d8a Mon Sep 17 00:00:00 2001 From: Vishwanath Hiremath Date: Mon, 11 Mar 2024 11:03:53 -0700 Subject: [PATCH 11/13] fixing lint error Signed-off-by: Vishwanath Hiremath --- test/functional/shared/resources/recipe_terraform_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/functional/shared/resources/recipe_terraform_test.go b/test/functional/shared/resources/recipe_terraform_test.go index 04f045c324..9d33326795 100644 --- a/test/functional/shared/resources/recipe_terraform_test.go +++ b/test/functional/shared/resources/recipe_terraform_test.go @@ -439,8 +439,8 @@ func Test_TerraformPrivateGitModule_KubernetesRedis(t *testing.T) { secretSuffix, err := getSecretSuffix("/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/extenders/"+name, envName, appName) require.NoError(t, err) - T.Logf(fmt.Sprintf("modulesource terraform git:%s",testutil.GetTerraformPrivateModuleSource())) - T.Logf(fmt.Sprintf("modulesource git token :%s", testutil.GetGitPAT())) + t.Logf(fmt.Sprintf("modulesource terraform git:%s",testutil.GetTerraformPrivateModuleSource())) + t.Logf(fmt.Sprintf("modulesource git token :%s", testutil.GetGitPAT())) test := shared.NewRPTest(t, name, []shared.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetTerraformPrivateModuleSource(), "appName="+appName, "redisCacheName="+redisCacheName, testutil.GetGitPAT()), From e349dd6e666c61d9f29047890491a6de5a370275 Mon Sep 17 00:00:00 2001 From: Vishwanath Hiremath Date: Mon, 11 Mar 2024 11:30:26 -0700 Subject: [PATCH 12/13] fix compile error Signed-off-by: Vishwanath Hiremath --- test/functional/shared/resources/recipe_terraform_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/functional/shared/resources/recipe_terraform_test.go b/test/functional/shared/resources/recipe_terraform_test.go index 9d33326795..6cd50f1cc0 100644 --- a/test/functional/shared/resources/recipe_terraform_test.go +++ b/test/functional/shared/resources/recipe_terraform_test.go @@ -439,7 +439,7 @@ func Test_TerraformPrivateGitModule_KubernetesRedis(t *testing.T) { secretSuffix, err := getSecretSuffix("/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/extenders/"+name, envName, appName) require.NoError(t, err) - t.Logf(fmt.Sprintf("modulesource terraform git:%s",testutil.GetTerraformPrivateModuleSource())) + t.Logf(fmt.Sprintf("modulesource terraform git:%s", testutil.GetTerraformPrivateModuleSource())) t.Logf(fmt.Sprintf("modulesource git token :%s", testutil.GetGitPAT())) test := shared.NewRPTest(t, name, []shared.TestStep{ { @@ -490,7 +490,7 @@ func Test_TerraformPrivateGitModule_KubernetesRedis(t *testing.T) { status := redis.Properties["status"].(map[string]any) recipe := status["recipe"].(map[string]interface{}) require.Equal(t, "terraform", recipe["templateKind"].(string)) - expectedTemplatePath := strings.Replace(sourcePath, "moduleServer=", "", 1) + expectedTemplatePath := strings.Replace(testutil.GetTerraformPrivateModuleSource(), "moduleServer=", "", 1) require.Equal(t, expectedTemplatePath, recipe["templatePath"].(string)) // At present, it is not possible to verify the template version in functional tests // This is verified by UTs though From 3c967f7f823952e3f3a47931fcc4bf47e5383867 Mon Sep 17 00:00:00 2001 From: Vishwanath Hiremath Date: Mon, 11 Mar 2024 11:52:48 -0700 Subject: [PATCH 13/13] testing Signed-off-by: Vishwanath Hiremath --- .github/workflows/functional-test.yaml | 2 +- test/testutil/testutil.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/functional-test.yaml b/.github/workflows/functional-test.yaml index 9aeef2ab5b..b97f0a480b 100644 --- a/.github/workflows/functional-test.yaml +++ b/.github/workflows/functional-test.yaml @@ -559,7 +559,7 @@ jobs: INTEGRATION_TEST_RESOURCE_GROUP_NAME: ${{ env.AZURE_TEST_RESOURCE_GROUP }} BICEP_RECIPE_REGISTRY: ${{ env.BICEP_RECIPE_REGISTRY }} BICEP_RECIPE_TAG_VERSION: ${{ env.BICEP_RECIPE_TAG_VERSION }} - GH_TOKEN: "test-git-pat" + GH_ACCOUNT: "test-git-pat" - uses: azure/setup-kubectl@v3 if: always() with: diff --git a/test/testutil/testutil.go b/test/testutil/testutil.go index 78cb6e89a7..6cb9397686 100644 --- a/test/testutil/testutil.go +++ b/test/testutil/testutil.go @@ -135,7 +135,7 @@ func GetTerraformPrivateModuleSource() string { } func GetGitPAT() string { - u := os.Getenv("GH_TOKEN") + u := os.Getenv("GH_ACCOUNT") return "pat=" + u }