diff --git a/.github/workflows/functional-test.yaml b/.github/workflows/functional-test.yaml index fcd8d6c11f..58d9de7444 100644 --- a/.github/workflows/functional-test.yaml +++ b/.github/workflows/functional-test.yaml @@ -211,7 +211,7 @@ jobs: * Dapr: ${{ env.DAPR_VER }} * Azure KeyVault CSI driver: ${{ env.AZURE_KEYVAULT_CSI_DRIVER_VER }} * Azure Workload identity webhook: ${{ env.AZURE_WORKLOAD_IDENTITY_WEBHOOK_VER }} - * Bicep recipe location `${{ env.BICEP_RECIPE_REGISTRY }}/test/functional/shared/recipes/:${{ env.REL_VERSION }}` + * Bicep recipe location `${{ env.BICEP_RECIPE_REGISTRY }}/test/testrecipes/test-bicep-recipes/:${{ env.REL_VERSION }}` * Terraform recipe location `${{ env.TF_RECIPE_MODULE_SERVER_URL }}/.zip` (in cluster) * applications-rp test image location: `${{ env.CONTAINER_REGISTRY }}/applications-rp:${{ env.REL_VERSION }}` * controller test image location: `${{ env.CONTAINER_REGISTRY }}/controller:${{ env.REL_VERSION }}` diff --git a/.github/workflows/long-running-azure.yaml b/.github/workflows/long-running-azure.yaml index 797f8b7994..1c3710c300 100644 --- a/.github/workflows/long-running-azure.yaml +++ b/.github/workflows/long-running-azure.yaml @@ -197,7 +197,7 @@ jobs: Click here to see the list of tools in the current test run * gotestsum ${{ env.GOTESTSUM_VER }} - * Bicep recipe location `${{ env.BICEP_RECIPE_REGISTRY }}/test/functional/shared/recipes/:${{ steps.gen-id.outputs.REL_VERSION }}` + * Bicep recipe location `${{ env.BICEP_RECIPE_REGISTRY }}/test/testrecipes/test-bicep-recipes/:${{ steps.gen-id.outputs.REL_VERSION }}` * Terraform recipe location `${{ env.TF_RECIPE_MODULE_SERVER_URL }}/.zip` (in cluster) * applications-rp test image location: `${{ env.CONTAINER_REGISTRY }}/applications-rp:${{ steps.gen-id.outputs.REL_VERSION }}` * controller test image location: `${{ env.CONTAINER_REGISTRY }}/controller:${{ steps.gen-id.outputs.REL_VERSION }}` diff --git a/.github/workflows/retry-functional-test.yaml b/.github/workflows/retry-functional-test.yaml index dc624b7683..ef0f4d5f1d 100644 --- a/.github/workflows/retry-functional-test.yaml +++ b/.github/workflows/retry-functional-test.yaml @@ -23,8 +23,8 @@ permissions: on: schedule: - # Run every 20 minutes - - cron: "*/20 * * * *" + # Run every 2 hours + - cron: "0 */2 * * *" env: # Go version diff --git a/build/recipes.mk b/build/recipes.mk index dcda7766bb..60173f8a4f 100644 --- a/build/recipes.mk +++ b/build/recipes.mk @@ -27,10 +27,10 @@ TERRAFORM_MODULE_CONFIGMAP_NAME=tf-module-server-content publish-test-bicep-recipes: ## Publishes test recipes to with version @if [ -z "$(BICEP_RECIPE_REGISTRY)" ]; then echo "Error: BICEP_RECIPE_REGISTRY must be set to a valid OCI registry"; exit 1; fi - @echo "$(ARROW) Publishing Bicep test recipes from ./test/functional/shared/resources/testdata/recipes/test-bicep-recipes..." + @echo "$(ARROW) Publishing Bicep test recipes from ./test/testrecipes/test-bicep-recipes..." ./.github/scripts/publish-recipes.sh \ - ./test/functional/shared/resources/testdata/recipes/test-bicep-recipes \ - ${BICEP_RECIPE_REGISTRY}/test/functional/shared/recipes \ + ./test/testrecipes/test-bicep-recipes \ + ${BICEP_RECIPE_REGISTRY}/test/testrecipes/test-bicep-recipes \ ${BICEP_RECIPE_TAG_VERSION} .PHONY: publish-test-terraform-recipes @@ -38,9 +38,9 @@ publish-test-terraform-recipes: ## Publishes test terraform recipes to the curre @echo "$(ARROW) Creating Kubernetes namespace $(TERRAFORM_MODULE_SERVER_NAMESPACE)..." kubectl create namespace $(TERRAFORM_MODULE_SERVER_NAMESPACE) --dry-run=client -o yaml | kubectl apply -f - - @echo "$(ARROW) Publishing Terraform test recipes from ./test/functional/shared/resources/testdata/recipes/test-terraform-recipes..." + @echo "$(ARROW) Publishing Terraform test recipes from ./test/testrecipes/test-terraform-recipes..." ./.github/scripts/publish-test-terraform-recipes.py \ - ./test/functional/shared/resources/testdata/recipes/test-terraform-recipes \ + ./test/testrecipes/test-terraform-recipes \ $(TERRAFORM_MODULE_SERVER_NAMESPACE) \ $(TERRAFORM_MODULE_CONFIGMAP_NAME) diff --git a/build/test.mk b/build/test.mk index 6dc4cf98d4..9c9741a1da 100644 --- a/build/test.mk +++ b/build/test.mk @@ -74,8 +74,13 @@ test-functional-kubernetes: test-functional-kubernetes-noncloud ## Runs all Kube test-functional-kubernetes-noncloud: ## Runs Kubernetes functional tests that do not require cloud resources CGO_ENABLED=1 $(GOTEST_TOOL) ./test/functional-portable/kubernetes/noncloud/... -timeout ${TEST_TIMEOUT} -v -parallel 5 $(GOTEST_OPTS) -test-functional-shared: ## Runs shared functional tests - CGO_ENABLED=1 $(GOTEST_TOOL) ./test/functional/shared/... -timeout ${TEST_TIMEOUT} -v -parallel 10 $(GOTEST_OPTS) +test-functional-shared: test-functional-corerp-noncloud test-functional-corerp-cloud ## Runs all Core RP functional tests (both cloud and non-cloud) + +test-functional-corerp-noncloud: ## Runs corerp functional tests that do not require cloud resources + CGO_ENABLED=1 $(GOTEST_TOOL) ./test/functional-portable/corerp/noncloud/... -timeout ${TEST_TIMEOUT} -v -parallel 10 $(GOTEST_OPTS) + +test-functional-corerp-cloud: ## Runs corerp functional tests that require cloud resources + CGO_ENABLED=1 $(GOTEST_TOOL) ./test/functional-portable/corerp/cloud/... -timeout ${TEST_TIMEOUT} -v -parallel 10 $(GOTEST_OPTS) test-functional-msgrp: test-functional-msgrp-noncloud ## Runs all Messaging RP functional tests (both cloud and non-cloud) diff --git a/docs/contributing/contributing-code/contributing-code-tests/tests-naming-conventions.md b/docs/contributing/contributing-code/contributing-code-tests/tests-naming-conventions.md index 231ca9260c..e3eeb76c6a 100644 --- a/docs/contributing/contributing-code/contributing-code-tests/tests-naming-conventions.md +++ b/docs/contributing/contributing-code/contributing-code-tests/tests-naming-conventions.md @@ -1,5 +1,5 @@ # Radius functional test naming conventions -Today, the [functional tests](https://github.com/radius-project/radius/tree/main/test/functional/shared/resources) use some abbreviations to make sure that the resource labels will not exceed 63 characters (application + resource name). Here are a list of some of the abbreviations and patterns: +Today, the [functional tests](https://github.com/radius-project/radius/tree/main/test/functional-portable/corerp/resources) use some abbreviations to make sure that the resource labels will not exceed 63 characters (application + resource name). Here are a list of some of the abbreviations and patterns: |Keyword|Abbreviation| |-|-| diff --git a/test/functional-portable/cli/noncloud/cli_test.go b/test/functional-portable/cli/noncloud/cli_test.go index 981530cab3..bc4fe05f84 100644 --- a/test/functional-portable/cli/noncloud/cli_test.go +++ b/test/functional-portable/cli/noncloud/cli_test.go @@ -44,8 +44,9 @@ import ( "github.com/radius-project/radius/pkg/corerp/api/v20231001preview" "github.com/radius-project/radius/pkg/ucp/resources" "github.com/radius-project/radius/pkg/version" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/radcli" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testcontext" "github.com/radius-project/radius/test/testutil" @@ -59,21 +60,21 @@ const ( retries = 10 ) -func verifyRecipeCLI(ctx context.Context, t *testing.T, test shared.RPTest) { - options := shared.NewRPTestOptions(t) +func verifyRecipeCLI(ctx context.Context, t *testing.T, test rp.RPTest) { + options := rp.NewRPTestOptions(t) cli := radcli.NewCLI(t, options.ConfigFilePath) envName := test.Steps[0].RPResources.Resources[0].Name registry := strings.TrimPrefix(testutil.GetBicepRecipeRegistry(), "registry=") version := strings.TrimPrefix(testutil.GetBicepRecipeVersion(), "version=") resourceType := "Applications.Datastores/redisCaches" - file := "../../../functional/shared/resources/testdata/recipes/test-bicep-recipes/corerp-redis-recipe.bicep" + file := "../../../testrecipes/test-bicep-recipes/corerp-redis-recipe.bicep" target := fmt.Sprintf("br:ghcr.io/radius-project/dev/test-bicep-recipes/redis-recipe:%s", generateUniqueTag()) recipeName := "recipeName" recipeTemplate := fmt.Sprintf("%s/recipes/local-dev/rediscaches:%s", registry, version) bicepRecipe := "recipe1" - bicepRecipeTemplate := fmt.Sprintf("%s/test/functional/shared/recipes/corerp-redis-recipe:%s", registry, version) + bicepRecipeTemplate := fmt.Sprintf("%s/test/testrecipes/test-bicep-recipes/corerp-redis-recipe:%s", registry, version) templateKindBicep := "bicep" terraformRecipe := "recipe2" @@ -155,8 +156,8 @@ func verifyRecipeCLI(ctx context.Context, t *testing.T, test shared.RPTest) { }) } -func verifyCLIBasics(ctx context.Context, t *testing.T, test shared.RPTest) { - options := shared.NewRPTestOptions(t) +func verifyCLIBasics(ctx context.Context, t *testing.T, test rp.RPTest) { + options := rp.NewRPTestOptions(t) cli := radcli.NewCLI(t, options.ConfigFilePath) appName := test.Name containerName := "containerA" @@ -280,7 +281,7 @@ func Test_Run_Logger(t *testing.T) { // Will be used to cancel `rad run` ctx, cancel := testcontext.NewWithCancel(t) t.Cleanup(cancel) - options := shared.NewRPTestOptions(t) + options := rp.NewRPTestOptions(t) template := "testdata/corerp-kubernetes-cli-run.bicep" applicationName := "cli-run-logger" @@ -354,7 +355,7 @@ func Test_Run_Portforward(t *testing.T) { // Will be used to cancel `rad run` ctx, cancel := testcontext.NewWithCancel(t) t.Cleanup(cancel) - options := shared.NewRPTestOptions(t) + options := rp.NewRPTestOptions(t) template := "testdata/corerp-kubernetes-cli-run-portforward.bicep" applicationName := "cli-run-portforward" @@ -453,7 +454,7 @@ func Test_CLI(t *testing.T) { template := "testdata/corerp-kubernetes-cli.bicep" name := "kubernetes-cli" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -493,7 +494,7 @@ func Test_CLI_JSON(t *testing.T) { template := "testdata/corerp-kubernetes-cli.json" name := "kubernetes-cli-json" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -533,7 +534,7 @@ func Test_CLI_Delete(t *testing.T) { ctx, cancel := testcontext.NewWithCancel(t) t.Cleanup(cancel) - options := shared.NewRPTestOptions(t) + options := rp.NewRPTestOptions(t) appName := "kubernetes-cli-with-resources" appNameUnassociatedResources := "kubernetes-cli-with-unassociated-resources" appNameEmptyResources := "kubernetes-cli-empty-resources" @@ -631,7 +632,7 @@ func Test_CLI_DeploymentParameters(t *testing.T) { // corerp-kubernetes-cli-parameters.parameters.json uses ghcr.io/radius-project/dev as a registry parameter. // Use the specified tag only if the test uses ghcr.io/radius-project/dev registry. Otherwise, use latest tag. - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, "@"+parameterFilePath, testutil.GetMagpieTag()), RPResources: &validation.RPResourceSet{ @@ -670,7 +671,7 @@ func Test_CLI_version(t *testing.T) { ctx, cancel := testcontext.NewWithCancel(t) t.Cleanup(cancel) - options := shared.NewTestOptions(t) + options := rp.NewTestOptions(t) cli := radcli.NewCLI(t, options.ConfigFilePath) output, err := cli.Version(ctx) @@ -691,7 +692,7 @@ func Test_CLI_Only_version(t *testing.T) { ctx, cancel := testcontext.NewWithCancel(t) t.Cleanup(cancel) - options := shared.NewTestOptions(t) + options := rp.NewTestOptions(t) cli := radcli.NewCLI(t, options.ConfigFilePath) output, err := cli.CliVersion(ctx) @@ -709,7 +710,7 @@ func Test_RecipeCommands(t *testing.T) { template := "testdata/corerp-resources-recipe-env.bicep" name := "corerp-resources-recipe-env" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetBicepRecipeRegistry(), testutil.GetBicepRecipeVersion()), RPResources: &validation.RPResourceSet{ @@ -735,7 +736,7 @@ func Test_DevRecipes(t *testing.T) { ctx, cancel := testcontext.NewWithCancel(t) t.Cleanup(cancel) - options := shared.NewTestOptions(t) + options := rp.NewTestOptions(t) cli := radcli.NewCLI(t, options.ConfigFilePath) envName := "test-dev-recipes" @@ -797,7 +798,7 @@ func GetAvailablePort() (int, error) { // DeleteAppWithoutDeletingResources creates a client to delete an application without deleting its resources and returns // an error if one occurs. -func DeleteAppWithoutDeletingResources(t *testing.T, ctx context.Context, options shared.RPTestOptions, applicationName string) error { +func DeleteAppWithoutDeletingResources(t *testing.T, ctx context.Context, options rp.RPTestOptions, applicationName string) error { client := options.ManagementClient require.IsType(t, client, &clients.UCPApplicationsManagementClient{}) appManagementClient := client.(*clients.UCPApplicationsManagementClient) diff --git a/test/functional-portable/cli/noncloud/testdata/corerp-resources-recipe-env.bicep b/test/functional-portable/cli/noncloud/testdata/corerp-resources-recipe-env.bicep index 359b58fccc..9076ae069c 100644 --- a/test/functional-portable/cli/noncloud/testdata/corerp-resources-recipe-env.bicep +++ b/test/functional-portable/cli/noncloud/testdata/corerp-resources-recipe-env.bicep @@ -20,7 +20,7 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { 'Applications.Datastores/redisCaches':{ recipe1: { templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/corerp-redis-recipe:${version}' + templatePath: '${registry}/test/testrecipes/test-bicep-recipes/corerp-redis-recipe:${version}' } recipe2: { templateKind: 'terraform' diff --git a/test/functional/shared/mechanics/aws_mechanics_test.go b/test/functional-portable/corerp/cloud/mechanics/aws_mechanics_test.go similarity index 94% rename from test/functional/shared/mechanics/aws_mechanics_test.go rename to test/functional-portable/corerp/cloud/mechanics/aws_mechanics_test.go index ccc392e600..a8384255eb 100644 --- a/test/functional/shared/mechanics/aws_mechanics_test.go +++ b/test/functional-portable/corerp/cloud/mechanics/aws_mechanics_test.go @@ -21,7 +21,7 @@ import ( "testing" "github.com/google/uuid" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -32,7 +32,7 @@ func Test_AWSRedeployWithUpdatedResourceUpdatesResource(t *testing.T) { name := "radiusfunctionaltestbucket-" + uuid.New().String() creationTimestamp := testutil.GetCreationTimestamp() - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(fmt.Sprintf(templateFmt, 1), "bucketName="+name, "creationTimestamp="+creationTimestamp), SkipKubernetesOutputResourceValidation: true, @@ -89,5 +89,7 @@ func Test_AWSRedeployWithUpdatedResourceUpdatesResource(t *testing.T) { }, }, }) + + test.RequiredFeatures = []rp.RequiredFeature{rp.FeatureAWS} test.Test(t) } diff --git a/test/functional/shared/mechanics/testdata/aws-mechanics-redeploy-withcreateandwritepropertyupdate.step1.bicep b/test/functional-portable/corerp/cloud/mechanics/testdata/aws-mechanics-redeploy-withcreateandwritepropertyupdate.step1.bicep similarity index 100% rename from test/functional/shared/mechanics/testdata/aws-mechanics-redeploy-withcreateandwritepropertyupdate.step1.bicep rename to test/functional-portable/corerp/cloud/mechanics/testdata/aws-mechanics-redeploy-withcreateandwritepropertyupdate.step1.bicep diff --git a/test/functional/shared/mechanics/testdata/aws-mechanics-redeploy-withcreateandwritepropertyupdate.step2.bicep b/test/functional-portable/corerp/cloud/mechanics/testdata/aws-mechanics-redeploy-withcreateandwritepropertyupdate.step2.bicep similarity index 100% rename from test/functional/shared/mechanics/testdata/aws-mechanics-redeploy-withcreateandwritepropertyupdate.step2.bicep rename to test/functional-portable/corerp/cloud/mechanics/testdata/aws-mechanics-redeploy-withcreateandwritepropertyupdate.step2.bicep diff --git a/test/functional/shared/mechanics/testdata/aws-mechanics-redeploy-withupdatedresource.step1.bicep b/test/functional-portable/corerp/cloud/mechanics/testdata/aws-mechanics-redeploy-withupdatedresource.step1.bicep similarity index 100% rename from test/functional/shared/mechanics/testdata/aws-mechanics-redeploy-withupdatedresource.step1.bicep rename to test/functional-portable/corerp/cloud/mechanics/testdata/aws-mechanics-redeploy-withupdatedresource.step1.bicep diff --git a/test/functional/shared/mechanics/testdata/aws-mechanics-redeploy-withupdatedresource.step2.bicep b/test/functional-portable/corerp/cloud/mechanics/testdata/aws-mechanics-redeploy-withupdatedresource.step2.bicep similarity index 100% rename from test/functional/shared/mechanics/testdata/aws-mechanics-redeploy-withupdatedresource.step2.bicep rename to test/functional-portable/corerp/cloud/mechanics/testdata/aws-mechanics-redeploy-withupdatedresource.step2.bicep diff --git a/test/functional/shared/resources/aws_multi_identifier_resource_test.go b/test/functional-portable/corerp/cloud/resources/aws_multi_identifier_resource_test.go similarity index 92% rename from test/functional/shared/resources/aws_multi_identifier_resource_test.go rename to test/functional-portable/corerp/cloud/resources/aws_multi_identifier_resource_test.go index 0ef7f13c2e..c5d29da1c4 100644 --- a/test/functional/shared/resources/aws_multi_identifier_resource_test.go +++ b/test/functional-portable/corerp/cloud/resources/aws_multi_identifier_resource_test.go @@ -22,7 +22,7 @@ import ( "time" "github.com/google/uuid" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/validation" ) @@ -34,7 +34,7 @@ func Test_AWS_MultiIdentifier_Resource(t *testing.T) { testName := "ms" + uuid.New().String() creationTimestamp := fmt.Sprintf("%d", time.Now().Unix()) - test := shared.NewRPTest(t, testName, []shared.TestStep{ + test := rp.NewRPTest(t, testName, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, "filterName="+filterName, "logGroupName="+logGroupName, "creationTimestamp="+creationTimestamp), SkipKubernetesOutputResourceValidation: true, @@ -64,5 +64,6 @@ func Test_AWS_MultiIdentifier_Resource(t *testing.T) { }, }) + test.RequiredFeatures = []rp.RequiredFeature{rp.FeatureAWS} test.Test(t) } diff --git a/test/functional/shared/resources/aws_s3_bucket_test.go b/test/functional-portable/corerp/cloud/resources/aws_s3_bucket_test.go similarity index 93% rename from test/functional/shared/resources/aws_s3_bucket_test.go rename to test/functional-portable/corerp/cloud/resources/aws_s3_bucket_test.go index d6bfb25c9d..a2d7c5a317 100644 --- a/test/functional/shared/resources/aws_s3_bucket_test.go +++ b/test/functional-portable/corerp/cloud/resources/aws_s3_bucket_test.go @@ -19,7 +19,7 @@ package resource_test import ( "testing" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -30,7 +30,7 @@ func Test_AWS_S3Bucket(t *testing.T) { name := testutil.GenerateS3BucketName() creationTimestamp := testutil.GetCreationTimestamp() - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, "bucketName="+name, "creationTimestamp="+creationTimestamp), SkipKubernetesOutputResourceValidation: true, @@ -60,6 +60,7 @@ func Test_AWS_S3Bucket(t *testing.T) { }, }) + test.RequiredFeatures = []rp.RequiredFeature{rp.FeatureAWS} test.Test(t) } @@ -69,7 +70,7 @@ func Test_AWS_S3Bucket_Existing(t *testing.T) { name := testutil.GenerateS3BucketName() creationTimestamp := testutil.GetCreationTimestamp() - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, "bucketName="+name, "creationTimestamp="+creationTimestamp), SkipKubernetesOutputResourceValidation: true, @@ -129,6 +130,6 @@ func Test_AWS_S3Bucket_Existing(t *testing.T) { }, }) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureAWS} + test.RequiredFeatures = []rp.RequiredFeature{rp.FeatureAWS} test.Test(t) } diff --git a/test/functional/shared/resources/azure_connections_test.go b/test/functional-portable/corerp/cloud/resources/azure_connections_test.go similarity index 91% rename from test/functional/shared/resources/azure_connections_test.go rename to test/functional-portable/corerp/cloud/resources/azure_connections_test.go index efe7a126d7..f314f5dda5 100644 --- a/test/functional/shared/resources/azure_connections_test.go +++ b/test/functional-portable/corerp/cloud/resources/azure_connections_test.go @@ -20,7 +20,7 @@ import ( "os" "testing" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -37,7 +37,7 @@ func Test_AzureConnections(t *testing.T) { cosmosmongodbresourceid := "cosmosmongodbresourceid=" + os.Getenv("AZURE_COSMOS_MONGODB_ACCOUNT_ID") appNamespace := "default-corerp-azure-connection-database-service" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage(), cosmosmongodbresourceid), RPResources: &validation.RPResourceSet{ @@ -63,6 +63,6 @@ func Test_AzureConnections(t *testing.T) { }, }) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureAzure} + test.RequiredFeatures = []rp.RequiredFeature{rp.FeatureAzure} test.Test(t) } diff --git a/test/functional/shared/resources/extender_test.go b/test/functional-portable/corerp/cloud/resources/extender_test.go similarity index 62% rename from test/functional/shared/resources/extender_test.go rename to test/functional-portable/corerp/cloud/resources/extender_test.go index e18a9d46eb..961d98a5fb 100644 --- a/test/functional/shared/resources/extender_test.go +++ b/test/functional-portable/corerp/cloud/resources/extender_test.go @@ -22,81 +22,12 @@ import ( "os" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" ) -func Test_Extender_Manual(t *testing.T) { - template := "testdata/corerp-resources-extender.bicep" - name := "corerp-resources-extender" - appNamespace := "default-corerp-resources-extender" - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: name, - Type: validation.ApplicationsResource, - }, - { - Name: "extr-ctnr", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "extr-twilio", - Type: validation.ExtendersResource, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "extr-ctnr"), - }, - }, - }, - }, - }) - - test.Test(t) -} - -func Test_Extender_Recipe(t *testing.T) { - template := "testdata/corerp-resources-extender-recipe.bicep" - name := "corerp-resources-extender-recipe" - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, testutil.GetBicepRecipeRegistry(), testutil.GetBicepRecipeVersion()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: "corerp-resources-extender-recipe-env", - Type: validation.EnvironmentsResource, - }, - { - Name: name, - Type: validation.ApplicationsResource, - }, - { - Name: "extender-recipe", - Type: validation.ExtendersResource, - App: name, - }, - }, - }, - SkipObjectValidation: true, - }, - }) - - test.Test(t) -} - func Test_Extender_RecipeAWS(t *testing.T) { awsAccountID := os.Getenv("AWS_ACCOUNT_ID") awsRegion := os.Getenv("AWS_REGION") @@ -113,7 +44,7 @@ func Test_Extender_RecipeAWS(t *testing.T) { bucketID := fmt.Sprintf("/planes/aws/aws/accounts/%s/regions/%s/providers/AWS.S3/Bucket/%s", awsAccountID, awsRegion, bucketName) creationTimestamp := testutil.GetCreationTimestamp() - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor( template, diff --git a/test/functional/shared/resources/persistent_volume_test.go b/test/functional-portable/corerp/cloud/resources/persistent_volume_test.go similarity index 90% rename from test/functional/shared/resources/persistent_volume_test.go rename to test/functional-portable/corerp/cloud/resources/persistent_volume_test.go index 763ef6d65f..9722ffa6b3 100644 --- a/test/functional/shared/resources/persistent_volume_test.go +++ b/test/functional-portable/corerp/cloud/resources/persistent_volume_test.go @@ -19,7 +19,7 @@ package resource_test import ( "testing" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -30,7 +30,7 @@ func Test_PersistentVolume(t *testing.T) { name := "corerp-resources-volume-azure-keyvault" appNamespace := "corerp-resources-volume-azure-keyvault-app" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage(), testutil.GetOIDCIssuer()), RPResources: &validation.RPResourceSet{ @@ -64,7 +64,6 @@ func Test_PersistentVolume(t *testing.T) { }, }, }) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureCSIDriver} - + test.RequiredFeatures = []rp.RequiredFeature{rp.FeatureCSIDriver, rp.FeatureAzure} test.Test(t) } diff --git a/test/functional-portable/corerp/cloud/resources/recipe_terraform_test.go b/test/functional-portable/corerp/cloud/resources/recipe_terraform_test.go new file mode 100644 index 0000000000..ee327ab830 --- /dev/null +++ b/test/functional-portable/corerp/cloud/resources/recipe_terraform_test.go @@ -0,0 +1,94 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package resource_test + +// This file contains tests for Terraform recipes functionality - covering general behaviors that should +// be consistent across all resource types. These tests mostly use the extender resource type and mostly +// avoid cloud resources to avoid unnecessary coupling and reliability issues. +// +// Tests in this file should only use cloud resources if absolutely necessary. +// +// Tests in this file should be kept *roughly* in sync with recipe_bicep_test and any other drivers. + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/radius-project/radius/test/functional-portable/corerp" + "github.com/radius-project/radius/test/rp" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/testutil" + "github.com/radius-project/radius/test/validation" +) + +var ( + secretNamespace = "radius-system" + secretPrefix = "tfstate-default-" +) + +// Test_TerraformRecipe_AzureStorage creates an Extender resource consuming a Terraform recipe that deploys an Azure blob storage instance. +func Test_TerraformRecipe_AzureStorage(t *testing.T) { + template := "testdata/corerp-resources-terraform-azurestorage.bicep" + name := "corerp-resources-terraform-azstorage" + appName := "corerp-resources-terraform-azstorage-app" + envName := "corerp-resources-terraform-azstorage-env" + + test := rp.NewRPTest(t, name, []rp.TestStep{ + { + Executor: step.NewDeployExecutor(template, testutil.GetTerraformRecipeModuleServerURL(), "appName="+appName), + RPResources: &validation.RPResourceSet{ + Resources: []validation.RPResource{ + { + Name: envName, + Type: validation.EnvironmentsResource, + }, + { + Name: appName, + Type: validation.ApplicationsResource, + }, + { + Name: name, + Type: validation.ExtendersResource, + App: appName, + }, + }, + }, + SkipObjectValidation: true, + PostStepVerify: func(ctx context.Context, t *testing.T, test rp.RPTest) { + resourceID := "/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/extenders/" + name + secretSuffix, err := corerp.GetSecretSuffix(resourceID, envName, appName) + require.NoError(t, err) + + 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) + }, + }, + }) + + test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test rp.RPTest) { + resourceID := "/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/extenders/" + name + corerp.TestSecretDeletion(t, ctx, test, appName, envName, resourceID, secretNamespace, secretPrefix) + } + + test.Test(t) +} diff --git a/test/functional/shared/resources/storage_test.go b/test/functional-portable/corerp/cloud/resources/storage_test.go similarity index 92% rename from test/functional/shared/resources/storage_test.go rename to test/functional-portable/corerp/cloud/resources/storage_test.go index d501707321..dcfbde80f6 100644 --- a/test/functional/shared/resources/storage_test.go +++ b/test/functional-portable/corerp/cloud/resources/storage_test.go @@ -19,7 +19,7 @@ package resource_test import ( "testing" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -31,7 +31,7 @@ func Test_Storage(t *testing.T) { name := "corerp-resources-container-workload" appNamespace := "azstorage-workload-app" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage(), testutil.GetOIDCIssuer()), RPResources: &validation.RPResourceSet{ @@ -61,5 +61,6 @@ func Test_Storage(t *testing.T) { }, }) + test.RequiredFeatures = []rp.RequiredFeature{rp.FeatureAzure} test.Test(t) } diff --git a/test/functional/shared/resources/testdata/aws-multi-identifier.bicep b/test/functional-portable/corerp/cloud/resources/testdata/aws-multi-identifier.bicep similarity index 100% rename from test/functional/shared/resources/testdata/aws-multi-identifier.bicep rename to test/functional-portable/corerp/cloud/resources/testdata/aws-multi-identifier.bicep diff --git a/test/functional/shared/resources/testdata/aws-s3-bucket-existing.bicep b/test/functional-portable/corerp/cloud/resources/testdata/aws-s3-bucket-existing.bicep similarity index 100% rename from test/functional/shared/resources/testdata/aws-s3-bucket-existing.bicep rename to test/functional-portable/corerp/cloud/resources/testdata/aws-s3-bucket-existing.bicep diff --git a/test/functional/shared/resources/testdata/aws-s3-bucket.bicep b/test/functional-portable/corerp/cloud/resources/testdata/aws-s3-bucket.bicep similarity index 100% rename from test/functional/shared/resources/testdata/aws-s3-bucket.bicep rename to test/functional-portable/corerp/cloud/resources/testdata/aws-s3-bucket.bicep diff --git a/test/functional/shared/resources/testdata/corerp-azure-connection-database-service.bicep b/test/functional-portable/corerp/cloud/resources/testdata/corerp-azure-connection-database-service.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-azure-connection-database-service.bicep rename to test/functional-portable/corerp/cloud/resources/testdata/corerp-azure-connection-database-service.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-container-workload.bicep b/test/functional-portable/corerp/cloud/resources/testdata/corerp-resources-container-workload.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-container-workload.bicep rename to test/functional-portable/corerp/cloud/resources/testdata/corerp-resources-container-workload.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-extender-aws-s3-recipe.bicep b/test/functional-portable/corerp/cloud/resources/testdata/corerp-resources-extender-aws-s3-recipe.bicep similarity index 93% rename from test/functional/shared/resources/testdata/corerp-resources-extender-aws-s3-recipe.bicep rename to test/functional-portable/corerp/cloud/resources/testdata/corerp-resources-extender-aws-s3-recipe.bicep index bd781ae120..d2c4fec050 100644 --- a/test/functional/shared/resources/testdata/corerp-resources-extender-aws-s3-recipe.bicep +++ b/test/functional-portable/corerp/cloud/resources/testdata/corerp-resources-extender-aws-s3-recipe.bicep @@ -25,7 +25,7 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { 'Applications.Core/extenders': { s3: { templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/extenders-aws-s3-recipe:${version}' + templatePath: '${registry}/test/testrecipes/test-bicep-recipes/extenders-aws-s3-recipe:${version}' parameters: { bucketName: bucketName } diff --git a/test/functional/shared/resources/testdata/corerp-resources-terraform-azurestorage.bicep b/test/functional-portable/corerp/cloud/resources/testdata/corerp-resources-terraform-azurestorage.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-terraform-azurestorage.bicep rename to test/functional-portable/corerp/cloud/resources/testdata/corerp-resources-terraform-azurestorage.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-volume-azure-keyvault.bicep b/test/functional-portable/corerp/cloud/resources/testdata/corerp-resources-volume-azure-keyvault.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-volume-azure-keyvault.bicep rename to test/functional-portable/corerp/cloud/resources/testdata/corerp-resources-volume-azure-keyvault.bicep diff --git a/test/functional/shared/api_test.go b/test/functional-portable/corerp/noncloud/api_test.go similarity index 97% rename from test/functional/shared/api_test.go rename to test/functional-portable/corerp/noncloud/api_test.go index 44c0f73297..8c9b843131 100644 --- a/test/functional/shared/api_test.go +++ b/test/functional-portable/corerp/noncloud/api_test.go @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -package shared +package corerp import ( "fmt" "testing" + aztoken "github.com/radius-project/radius/pkg/azure/tokencredentials" "github.com/radius-project/radius/pkg/cli/clients" "github.com/radius-project/radius/pkg/cli/clients_new/generated" "github.com/radius-project/radius/pkg/ucp/resources" resources_radius "github.com/radius-project/radius/pkg/ucp/resources/radius" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/testcontext" "github.com/stretchr/testify/require" - - aztoken "github.com/radius-project/radius/pkg/azure/tokencredentials" ) // Test_ResourceList covers the plane and resource-group scope list APIs for all Radius resource types. @@ -35,7 +35,7 @@ import ( // This test exists as a smoke test that these APIs can be called safely. They are mainly used by the CLI // at this time, and this is a better way to get coverage. func Test_ResourceList(t *testing.T) { - options := NewRPTestOptions(t) + options := rp.NewRPTestOptions(t) // Extract the scope and client options from the management client so we can make our own API calls. require.IsType(t, options.ManagementClient, &clients.UCPApplicationsManagementClient{}) diff --git a/test/functional/shared/mechanics/k8s_extensibility_test.go b/test/functional-portable/corerp/noncloud/mechanics/k8s_extensibility_test.go similarity index 94% rename from test/functional/shared/mechanics/k8s_extensibility_test.go rename to test/functional-portable/corerp/noncloud/mechanics/k8s_extensibility_test.go index 747f507dee..3ec59a0928 100644 --- a/test/functional/shared/mechanics/k8s_extensibility_test.go +++ b/test/functional-portable/corerp/noncloud/mechanics/k8s_extensibility_test.go @@ -22,7 +22,7 @@ import ( "strings" "testing" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/validation" "gopkg.in/yaml.v3" @@ -33,7 +33,7 @@ func Test_Kubernetes_Extensibility(t *testing.T) { template := "testdata/k8s-extensibility/connection-string.bicep" name := "corerp-mechanics-k8s-extensibility" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template), RPResources: &validation.RPResourceSet{}, diff --git a/test/functional/shared/mechanics/mechanics_test.go b/test/functional-portable/corerp/noncloud/mechanics/mechanics_test.go similarity index 95% rename from test/functional/shared/mechanics/mechanics_test.go rename to test/functional-portable/corerp/noncloud/mechanics/mechanics_test.go index 89355c11e6..be521ff627 100644 --- a/test/functional/shared/mechanics/mechanics_test.go +++ b/test/functional-portable/corerp/noncloud/mechanics/mechanics_test.go @@ -24,7 +24,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/radius-project/radius/pkg/kubernetes" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -36,7 +36,7 @@ func Test_NestedModules(t *testing.T) { template := "testdata/corerp-mechanics-nestedmodules.bicep" name := "corerp-mechanics-nestedmodules" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template), RPResources: &validation.RPResourceSet{ @@ -63,7 +63,7 @@ func Test_RedeployWithAnotherResource(t *testing.T) { appNamespace := "default-corerp-mechanics-redeploy-with-another-resource" templateFmt := "testdata/corerp-mechanics-redeploy-withanotherresource.step%d.bicep" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(fmt.Sprintf(templateFmt, 1), testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -126,7 +126,7 @@ func Test_RedeployWithUpdatedResourceUpdatesResource(t *testing.T) { appNamespace := "default-corerp-mechanics-redeploy-withupdatedresource" templateFmt := "testdata/corerp-mechanics-redeploy-withupdatedresource.step%d.bicep" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(fmt.Sprintf(templateFmt, 1), testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -172,7 +172,7 @@ func Test_RedeployWithUpdatedResourceUpdatesResource(t *testing.T) { }, }, }, - PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, test rp.RPTest) { labelset := kubernetes.MakeSelectorLabels(name, "mechanicsd") deployments, err := test.Options.K8sClient.AppsV1().Deployments(appNamespace).List(context.Background(), metav1.ListOptions{ @@ -196,7 +196,7 @@ func Test_RedeployWithTwoSeparateResourcesKeepsResource(t *testing.T) { appNamespace := "default-corerp-mechanics-redeploy-withtwoseparateresource" templateFmt := "testdata/corerp-mechanics-redeploy-withtwoseparateresource.step%d.bicep" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(fmt.Sprintf(templateFmt, 1), testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -259,7 +259,7 @@ func Test_CommunicationCycle(t *testing.T) { appNamespace := "default-corerp-mechanics-communication-cycle" template := "testdata/corerp-mechanics-communication-cycle.bicep" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -330,7 +330,7 @@ func Test_InvalidResourceIDs(t *testing.T) { }, }) - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployErrorExecutor(template, validate, testutil.GetMagpieImage(), testutil.GetBicepRecipeRegistry(), testutil.GetBicepRecipeVersion()), RPResources: &validation.RPResourceSet{ diff --git a/test/functional/shared/mechanics/testdata/corerp-mechanics-communication-cycle.bicep b/test/functional-portable/corerp/noncloud/mechanics/testdata/corerp-mechanics-communication-cycle.bicep similarity index 100% rename from test/functional/shared/mechanics/testdata/corerp-mechanics-communication-cycle.bicep rename to test/functional-portable/corerp/noncloud/mechanics/testdata/corerp-mechanics-communication-cycle.bicep diff --git a/test/functional/shared/mechanics/testdata/corerp-mechanics-invalid-resourceids.bicep b/test/functional-portable/corerp/noncloud/mechanics/testdata/corerp-mechanics-invalid-resourceids.bicep similarity index 94% rename from test/functional/shared/mechanics/testdata/corerp-mechanics-invalid-resourceids.bicep rename to test/functional-portable/corerp/noncloud/mechanics/testdata/corerp-mechanics-invalid-resourceids.bicep index 2a23f3a6e0..fd99bba623 100644 --- a/test/functional/shared/mechanics/testdata/corerp-mechanics-invalid-resourceids.bicep +++ b/test/functional-portable/corerp/noncloud/mechanics/testdata/corerp-mechanics-invalid-resourceids.bicep @@ -32,7 +32,7 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { 'Applications.Dapr/pubSubBrokers': { default: { templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/dapr-pubsub-broker:${version}' + templatePath: '${registry}/test/testrecipes/test-bicep-recipes/dapr-pubsub-broker:${version}' } } } diff --git a/test/functional/shared/mechanics/testdata/corerp-mechanics-nestedmodules.bicep b/test/functional-portable/corerp/noncloud/mechanics/testdata/corerp-mechanics-nestedmodules.bicep similarity index 100% rename from test/functional/shared/mechanics/testdata/corerp-mechanics-nestedmodules.bicep rename to test/functional-portable/corerp/noncloud/mechanics/testdata/corerp-mechanics-nestedmodules.bicep diff --git a/test/functional/shared/mechanics/testdata/corerp-mechanics-redeploy-withanotherresource.step1.bicep b/test/functional-portable/corerp/noncloud/mechanics/testdata/corerp-mechanics-redeploy-withanotherresource.step1.bicep similarity index 100% rename from test/functional/shared/mechanics/testdata/corerp-mechanics-redeploy-withanotherresource.step1.bicep rename to test/functional-portable/corerp/noncloud/mechanics/testdata/corerp-mechanics-redeploy-withanotherresource.step1.bicep diff --git a/test/functional/shared/mechanics/testdata/corerp-mechanics-redeploy-withanotherresource.step2.bicep b/test/functional-portable/corerp/noncloud/mechanics/testdata/corerp-mechanics-redeploy-withanotherresource.step2.bicep similarity index 100% rename from test/functional/shared/mechanics/testdata/corerp-mechanics-redeploy-withanotherresource.step2.bicep rename to test/functional-portable/corerp/noncloud/mechanics/testdata/corerp-mechanics-redeploy-withanotherresource.step2.bicep diff --git a/test/functional/shared/mechanics/testdata/corerp-mechanics-redeploy-withtwoseparateresource.step1.bicep b/test/functional-portable/corerp/noncloud/mechanics/testdata/corerp-mechanics-redeploy-withtwoseparateresource.step1.bicep similarity index 100% rename from test/functional/shared/mechanics/testdata/corerp-mechanics-redeploy-withtwoseparateresource.step1.bicep rename to test/functional-portable/corerp/noncloud/mechanics/testdata/corerp-mechanics-redeploy-withtwoseparateresource.step1.bicep diff --git a/test/functional/shared/mechanics/testdata/corerp-mechanics-redeploy-withtwoseparateresource.step2.bicep b/test/functional-portable/corerp/noncloud/mechanics/testdata/corerp-mechanics-redeploy-withtwoseparateresource.step2.bicep similarity index 100% rename from test/functional/shared/mechanics/testdata/corerp-mechanics-redeploy-withtwoseparateresource.step2.bicep rename to test/functional-portable/corerp/noncloud/mechanics/testdata/corerp-mechanics-redeploy-withtwoseparateresource.step2.bicep diff --git a/test/functional/shared/mechanics/testdata/corerp-mechanics-redeploy-withupdatedresource.step1.bicep b/test/functional-portable/corerp/noncloud/mechanics/testdata/corerp-mechanics-redeploy-withupdatedresource.step1.bicep similarity index 100% rename from test/functional/shared/mechanics/testdata/corerp-mechanics-redeploy-withupdatedresource.step1.bicep rename to test/functional-portable/corerp/noncloud/mechanics/testdata/corerp-mechanics-redeploy-withupdatedresource.step1.bicep diff --git a/test/functional/shared/mechanics/testdata/corerp-mechanics-redeploy-withupdatedresource.step2.bicep b/test/functional-portable/corerp/noncloud/mechanics/testdata/corerp-mechanics-redeploy-withupdatedresource.step2.bicep similarity index 100% rename from test/functional/shared/mechanics/testdata/corerp-mechanics-redeploy-withupdatedresource.step2.bicep rename to test/functional-portable/corerp/noncloud/mechanics/testdata/corerp-mechanics-redeploy-withupdatedresource.step2.bicep diff --git a/test/functional/shared/mechanics/testdata/k8s-extensibility/connection-string.bicep b/test/functional-portable/corerp/noncloud/mechanics/testdata/k8s-extensibility/connection-string.bicep similarity index 100% rename from test/functional/shared/mechanics/testdata/k8s-extensibility/connection-string.bicep rename to test/functional-portable/corerp/noncloud/mechanics/testdata/k8s-extensibility/connection-string.bicep diff --git a/test/functional/shared/mechanics/testdata/k8s-extensibility/secret.input.yaml b/test/functional-portable/corerp/noncloud/mechanics/testdata/k8s-extensibility/secret.input.yaml similarity index 100% rename from test/functional/shared/mechanics/testdata/k8s-extensibility/secret.input.yaml rename to test/functional-portable/corerp/noncloud/mechanics/testdata/k8s-extensibility/secret.input.yaml diff --git a/test/functional/shared/mechanics/testdata/k8s-extensibility/secret.output.yaml b/test/functional-portable/corerp/noncloud/mechanics/testdata/k8s-extensibility/secret.output.yaml similarity index 100% rename from test/functional/shared/mechanics/testdata/k8s-extensibility/secret.output.yaml rename to test/functional-portable/corerp/noncloud/mechanics/testdata/k8s-extensibility/secret.output.yaml diff --git a/test/functional/shared/mechanics/testdata/k8s-extensibility/service.input.yaml b/test/functional-portable/corerp/noncloud/mechanics/testdata/k8s-extensibility/service.input.yaml similarity index 100% rename from test/functional/shared/mechanics/testdata/k8s-extensibility/service.input.yaml rename to test/functional-portable/corerp/noncloud/mechanics/testdata/k8s-extensibility/service.input.yaml diff --git a/test/functional/shared/mechanics/testdata/modules/corerp-mechanics-nestedmodules-innerapp.bicep b/test/functional-portable/corerp/noncloud/mechanics/testdata/modules/corerp-mechanics-nestedmodules-innerapp.bicep similarity index 100% rename from test/functional/shared/mechanics/testdata/modules/corerp-mechanics-nestedmodules-innerapp.bicep rename to test/functional-portable/corerp/noncloud/mechanics/testdata/modules/corerp-mechanics-nestedmodules-innerapp.bicep diff --git a/test/functional/shared/mechanics/testdata/modules/corerp-mechanics-nestedmodules-outerapp.bicep b/test/functional-portable/corerp/noncloud/mechanics/testdata/modules/corerp-mechanics-nestedmodules-outerapp.bicep similarity index 100% rename from test/functional/shared/mechanics/testdata/modules/corerp-mechanics-nestedmodules-outerapp.bicep rename to test/functional-portable/corerp/noncloud/mechanics/testdata/modules/corerp-mechanics-nestedmodules-outerapp.bicep diff --git a/test/functional/shared/resources/application_environment_test.go b/test/functional-portable/corerp/noncloud/resources/application_environment_test.go similarity index 93% rename from test/functional/shared/resources/application_environment_test.go rename to test/functional-portable/corerp/noncloud/resources/application_environment_test.go index 23ee2a1adb..550fe216f1 100644 --- a/test/functional/shared/resources/application_environment_test.go +++ b/test/functional-portable/corerp/noncloud/resources/application_environment_test.go @@ -20,7 +20,7 @@ import ( "context" "testing" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/validation" "github.com/stretchr/testify/require" @@ -31,7 +31,7 @@ func Test_ApplicationAndEnvironment(t *testing.T) { template := "testdata/corerp-resources-app-env.bicep" name := "corerp-resources-app-env" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template), RPResources: &validation.RPResourceSet{ @@ -48,7 +48,7 @@ func Test_ApplicationAndEnvironment(t *testing.T) { }, // Application and Environment should not render any K8s Objects directly K8sObjects: &validation.K8sObjectSet{}, - PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, test rp.RPTest) { expectedNS := []string{ "corerp-resources-app-env", "corerp-resources-app-env-env-corerp-resources-app-env-app", diff --git a/test/functional/shared/resources/application_test.go b/test/functional-portable/corerp/noncloud/resources/application_test.go similarity index 92% rename from test/functional/shared/resources/application_test.go rename to test/functional-portable/corerp/noncloud/resources/application_test.go index 93fb90bc16..37e6ff4d9c 100644 --- a/test/functional/shared/resources/application_test.go +++ b/test/functional-portable/corerp/noncloud/resources/application_test.go @@ -20,7 +20,7 @@ import ( "context" "testing" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -37,7 +37,7 @@ func Test_Application(t *testing.T) { name := "corerp-resources-application" appNamespace := "corerp-resources-application-app" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template), RPResources: &validation.RPResourceSet{ @@ -50,7 +50,7 @@ func Test_Application(t *testing.T) { }, // Application should not render any K8s Objects directly K8sObjects: &validation.K8sObjectSet{}, - PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, test rp.RPTest) { _, err := test.Options.K8sClient.CoreV1().Namespaces().Get(ctx, appNamespace, metav1.GetOptions{}) require.NoErrorf(t, err, "%s must be created", appNamespace) }, @@ -65,7 +65,7 @@ func Test_ApplicationGraph(t *testing.T) { name := "corerp-application-simple1" appNamespace := "default-corerp-application-simple1" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -100,9 +100,9 @@ func Test_ApplicationGraph(t *testing.T) { }, }, }, - PostStepVerify: func(ctx context.Context, t *testing.T, ct shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, ct rp.RPTest) { // Verify the application graph - options := shared.NewRPTestOptions(t) + options := rp.NewRPTestOptions(t) client := options.ManagementClient require.IsType(t, client, &clients.UCPApplicationsManagementClient{}) diff --git a/test/functional/shared/resources/container_runtimes_test.go b/test/functional-portable/corerp/noncloud/resources/container_runtimes_test.go similarity index 96% rename from test/functional/shared/resources/container_runtimes_test.go rename to test/functional-portable/corerp/noncloud/resources/container_runtimes_test.go index b8c8389ca7..14a3478862 100644 --- a/test/functional/shared/resources/container_runtimes_test.go +++ b/test/functional-portable/corerp/noncloud/resources/container_runtimes_test.go @@ -20,7 +20,7 @@ import ( "context" "testing" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -41,7 +41,7 @@ func Test_Container_YAMLManifest(t *testing.T) { name := "corerp-resources-container-manifest" appNamespace := "corerp-resources-container-manifest" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -64,7 +64,7 @@ func Test_Container_YAMLManifest(t *testing.T) { }, }, }, - PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, test rp.RPTest) { deploy, err := test.Options.K8sClient.AppsV1().Deployments(appNamespace).Get(ctx, "ctnr-manifest", metav1.GetOptions{}) require.NoError(t, err) require.Equal(t, "base-manifest-test", deploy.ObjectMeta.Annotations["source"]) @@ -107,7 +107,7 @@ func Test_Container_YAMLManifest_SideCar(t *testing.T) { name := "corerp-resources-container-sidecar" appNamespace := "corerp-resources-container-sidecar" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -130,7 +130,7 @@ func Test_Container_YAMLManifest_SideCar(t *testing.T) { }, }, }, - PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, test rp.RPTest) { deploy, err := test.Options.K8sClient.AppsV1().Deployments(appNamespace).Get(ctx, "ctnr-sidecar", metav1.GetOptions{}) require.NoError(t, err) @@ -153,7 +153,7 @@ func Test_Container_pod_patching(t *testing.T) { name := "corerp-resources-container-podpatch" appNamespace := "corerp-resources-container-podpatch" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -176,7 +176,7 @@ func Test_Container_pod_patching(t *testing.T) { }, }, }, - PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, test rp.RPTest) { deploy, err := test.Options.K8sClient.AppsV1().Deployments(appNamespace).Get(ctx, "ctnr-podpatch", metav1.GetOptions{}) require.NoError(t, err) diff --git a/test/functional/shared/resources/container_test.go b/test/functional-portable/corerp/noncloud/resources/container_test.go similarity index 94% rename from test/functional/shared/resources/container_test.go rename to test/functional-portable/corerp/noncloud/resources/container_test.go index dcd1de21ee..4dc8e47e53 100644 --- a/test/functional/shared/resources/container_test.go +++ b/test/functional-portable/corerp/noncloud/resources/container_test.go @@ -21,7 +21,7 @@ import ( "fmt" "testing" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -34,7 +34,7 @@ func Test_Container(t *testing.T) { name := "corerp-resources-container" appNamespace := "corerp-resources-container-app" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -68,7 +68,7 @@ func Test_ContainerDNSSD_TwoContainersDNS(t *testing.T) { name := "corerp-resources-container-two-containers-dns" appNamespace := "corerp-resources-container-two-containers-dns" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -109,7 +109,7 @@ func Test_ContainerDNSSD_OptionalPortScheme(t *testing.T) { name := "corerp-resources-container-optional-port-scheme" appNamespace := "corerp-resources-container-optional-port-scheme" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -158,7 +158,7 @@ func Test_ContainerReadinessLiveness(t *testing.T) { name := "corerp-resources-container-live-ready" appNamespace := "corerp-resources-container-live-ready-app" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -192,7 +192,7 @@ func Test_ContainerManualScale(t *testing.T) { name := "corerp-resources-container-manualscale" appNamespace := "corerp-resources-container-manualscale-app" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -226,7 +226,7 @@ func Test_ContainerWithCommandAndArgs(t *testing.T) { name := "corerp-resources-container-cmd-args" appNamespace := "corerp-resources-container-cmd-args-app" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(container), RPResources: &validation.RPResourceSet{ @@ -249,7 +249,7 @@ func Test_ContainerWithCommandAndArgs(t *testing.T) { }, }, }, - PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, test rp.RPTest) { label := fmt.Sprintf("radapp.io/application=%s", name) pods, err := test.Options.K8sClient.CoreV1().Pods(appNamespace).List(ctx, metav1.ListOptions{ LabelSelector: label, @@ -299,7 +299,7 @@ func Test_Container_FailDueToNonExistentImage(t *testing.T) { }, }) - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployErrorExecutor(template, validate, "magpieimage=non-existent-image"), SkipKubernetesOutputResourceValidation: true, @@ -334,7 +334,7 @@ func Test_Container_FailDueToBadHealthProbe(t *testing.T) { }, }) - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployErrorExecutor(template, validate, testutil.GetMagpieImage()), SkipKubernetesOutputResourceValidation: true, diff --git a/test/functional/shared/resources/container_versioning_test.go b/test/functional-portable/corerp/noncloud/resources/container_versioning_test.go similarity index 95% rename from test/functional/shared/resources/container_versioning_test.go rename to test/functional-portable/corerp/noncloud/resources/container_versioning_test.go index 63786afcce..85cd3e54d3 100644 --- a/test/functional/shared/resources/container_versioning_test.go +++ b/test/functional-portable/corerp/noncloud/resources/container_versioning_test.go @@ -21,7 +21,7 @@ import ( "fmt" "testing" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -37,7 +37,7 @@ func Test_ContainerVersioning(t *testing.T) { name := "corerp-resources-container-versioning" appNamespace := "default-corerp-resources-container-versioning" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(containerV1, testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -61,7 +61,7 @@ func Test_ContainerVersioning(t *testing.T) { }, }, SkipResourceDeletion: true, - PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, test rp.RPTest) { label := fmt.Sprintf("radapp.io/application=%s", name) secrets, err := test.Options.K8sClient.CoreV1().Secrets(appNamespace).List(ctx, metav1.ListOptions{ LabelSelector: label, @@ -92,7 +92,7 @@ func Test_ContainerVersioning(t *testing.T) { }, }, }, - PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, test rp.RPTest) { label := fmt.Sprintf("radapp.io/application=%s", name) secrets, err := test.Options.K8sClient.CoreV1().Secrets(appNamespace).List(ctx, metav1.ListOptions{ LabelSelector: label, diff --git a/test/functional/shared/resources/environment_test.go b/test/functional-portable/corerp/noncloud/resources/environment_test.go similarity index 91% rename from test/functional/shared/resources/environment_test.go rename to test/functional-portable/corerp/noncloud/resources/environment_test.go index 6c9249785e..58f26abb54 100644 --- a/test/functional/shared/resources/environment_test.go +++ b/test/functional-portable/corerp/noncloud/resources/environment_test.go @@ -19,7 +19,7 @@ package resource_test import ( "testing" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/validation" ) @@ -28,7 +28,7 @@ func Test_Environment(t *testing.T) { template := "testdata/corerp-resources-environment.bicep" name := "corerp-resources-environment" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template), RPResources: &validation.RPResourceSet{ diff --git a/test/functional-portable/corerp/noncloud/resources/extender_test.go b/test/functional-portable/corerp/noncloud/resources/extender_test.go new file mode 100644 index 0000000000..907fd4243b --- /dev/null +++ b/test/functional-portable/corerp/noncloud/resources/extender_test.go @@ -0,0 +1,95 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package resource_test + +import ( + "testing" + + "github.com/radius-project/radius/test/rp" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/testutil" + "github.com/radius-project/radius/test/validation" +) + +func Test_Extender_Manual(t *testing.T) { + template := "testdata/corerp-resources-extender.bicep" + name := "corerp-resources-extender" + appNamespace := "default-corerp-resources-extender" + + test := rp.NewRPTest(t, name, []rp.TestStep{ + { + Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage()), + RPResources: &validation.RPResourceSet{ + Resources: []validation.RPResource{ + { + Name: name, + Type: validation.ApplicationsResource, + }, + { + Name: "extr-ctnr", + Type: validation.ContainersResource, + App: name, + }, + { + Name: "extr-twilio", + Type: validation.ExtendersResource, + }, + }, + }, + K8sObjects: &validation.K8sObjectSet{ + Namespaces: map[string][]validation.K8sObject{ + appNamespace: { + validation.NewK8sPodForResource(name, "extr-ctnr"), + }, + }, + }, + }, + }) + + test.Test(t) +} + +func Test_Extender_Recipe(t *testing.T) { + template := "testdata/corerp-resources-extender-recipe.bicep" + name := "corerp-resources-extender-recipe" + + test := rp.NewRPTest(t, name, []rp.TestStep{ + { + Executor: step.NewDeployExecutor(template, testutil.GetBicepRecipeRegistry(), testutil.GetBicepRecipeVersion()), + RPResources: &validation.RPResourceSet{ + Resources: []validation.RPResource{ + { + Name: "corerp-resources-extender-recipe-env", + Type: validation.EnvironmentsResource, + }, + { + Name: name, + Type: validation.ApplicationsResource, + }, + { + Name: "extender-recipe", + Type: validation.ExtendersResource, + App: name, + }, + }, + }, + SkipObjectValidation: true, + }, + }) + + test.Test(t) +} diff --git a/test/functional/shared/resources/gateway_test.go b/test/functional-portable/corerp/noncloud/resources/gateway_test.go similarity index 95% rename from test/functional/shared/resources/gateway_test.go rename to test/functional-portable/corerp/noncloud/resources/gateway_test.go index 7a64f51be0..82fe1bc414 100644 --- a/test/functional/shared/resources/gateway_test.go +++ b/test/functional-portable/corerp/noncloud/resources/gateway_test.go @@ -27,7 +27,7 @@ import ( "testing" "time" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -51,7 +51,7 @@ func Test_GatewayDNS(t *testing.T) { name := "corerp-resources-gateway-dns" appNamespace := "default-corerp-resources-gateway-dns" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -90,7 +90,7 @@ func Test_GatewayDNS(t *testing.T) { }, }, }, - PostStepVerify: func(ctx context.Context, t *testing.T, ct shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, ct rp.RPTest) { // Get hostname from root HTTPProxy in application namespace metadata, err := testutil.GetHTTPProxyMetadata(ctx, ct.Options.Client, appNamespace, name) require.NoError(t, err) @@ -130,7 +130,7 @@ func Test_Gateway_SSLPassthrough(t *testing.T) { name := "corerp-resources-gateway-sslpassthrough" appNamespace := "default-corerp-resources-gateway-sslpassthrough" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage(), "@testdata/parameters/test-tls-cert.parameters.json"), RPResources: &validation.RPResourceSet{ @@ -161,7 +161,7 @@ func Test_Gateway_SSLPassthrough(t *testing.T) { }, }, }, - PostStepVerify: func(ctx context.Context, t *testing.T, ct shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, ct rp.RPTest) { // Get hostname from root HTTPProxy in application namespace metadata, err := testutil.GetHTTPProxyMetadata(ctx, ct.Options.Client, appNamespace, name) require.NoError(t, err) @@ -196,7 +196,7 @@ func Test_Gateway_TLSTermination(t *testing.T) { name := "corerp-resources-gateway-tlstermination" appNamespace := "default-corerp-resources-gateway-tlstermination" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage(), "@testdata/parameters/test-tls-cert.parameters.json"), RPResources: &validation.RPResourceSet{ @@ -233,7 +233,7 @@ func Test_Gateway_TLSTermination(t *testing.T) { }, }, }, - PostStepVerify: func(ctx context.Context, t *testing.T, ct shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, ct rp.RPTest) { // Get hostname from root HTTPProxy in application namespace metadata, err := testutil.GetHTTPProxyMetadata(ctx, ct.Options.Client, appNamespace, name) require.NoError(t, err) @@ -281,7 +281,7 @@ func Test_Gateway_Failure(t *testing.T) { }, }) - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployErrorExecutor(template, validateFn), SkipObjectValidation: true, @@ -307,7 +307,7 @@ func Test_Gateway_Failure(t *testing.T) { test.Test(t) } -func testGatewayWithPortForward(t *testing.T, ctx context.Context, at shared.RPTest, hostname string, remotePort int, isHttps bool, tests []GatewayTestConfig) error { +func testGatewayWithPortForward(t *testing.T, ctx context.Context, at rp.RPTest, hostname string, remotePort int, isHttps bool, tests []GatewayTestConfig) error { // stopChan will close the port-forward connection on close stopChan := make(chan struct{}) diff --git a/test/functional/shared/resources/kubemetadata_cascade_test.go b/test/functional-portable/corerp/noncloud/resources/kubemetadata_cascade_test.go similarity index 97% rename from test/functional/shared/resources/kubemetadata_cascade_test.go rename to test/functional-portable/corerp/noncloud/resources/kubemetadata_cascade_test.go index 06ee0cb625..0a17234119 100644 --- a/test/functional/shared/resources/kubemetadata_cascade_test.go +++ b/test/functional-portable/corerp/noncloud/resources/kubemetadata_cascade_test.go @@ -21,7 +21,7 @@ import ( "fmt" "testing" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -68,7 +68,7 @@ func Test_KubeMetadataCascade(t *testing.T) { "radapp.io/cntr.lbl.1": "reserved.lbl.val.1", } - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -95,7 +95,7 @@ func Test_KubeMetadataCascade(t *testing.T) { }, }, }, - PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, test rp.RPTest) { // Verify pod labels and annotations label := fmt.Sprintf("radapp.io/application=%s", name) pods, err := test.Options.K8sClient.CoreV1().Pods(appNamespace).List(ctx, metav1.ListOptions{ diff --git a/test/functional/shared/resources/kubemetadata_container_test.go b/test/functional-portable/corerp/noncloud/resources/kubemetadata_container_test.go similarity index 95% rename from test/functional/shared/resources/kubemetadata_container_test.go rename to test/functional-portable/corerp/noncloud/resources/kubemetadata_container_test.go index d1461783fe..c08e104b9d 100644 --- a/test/functional/shared/resources/kubemetadata_container_test.go +++ b/test/functional-portable/corerp/noncloud/resources/kubemetadata_container_test.go @@ -21,7 +21,7 @@ import ( "fmt" "testing" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -44,7 +44,7 @@ func Test_KubeMetadataContainer(t *testing.T) { "user.cntr.lbl.2": "user.cntr.lbl.val.2", } - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -71,7 +71,7 @@ func Test_KubeMetadataContainer(t *testing.T) { }, }, }, - PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, test rp.RPTest) { // Verify pod labels and annotations label := fmt.Sprintf("radapp.io/application=%s", name) pods, err := test.Options.K8sClient.CoreV1().Pods(appNamespace).List(ctx, metav1.ListOptions{ diff --git a/test/functional/shared/resources/kubemetadata_gateway_test.go b/test/functional-portable/corerp/noncloud/resources/kubemetadata_gateway_test.go similarity index 94% rename from test/functional/shared/resources/kubemetadata_gateway_test.go rename to test/functional-portable/corerp/noncloud/resources/kubemetadata_gateway_test.go index 7409fc4975..62e06caebd 100644 --- a/test/functional/shared/resources/kubemetadata_gateway_test.go +++ b/test/functional-portable/corerp/noncloud/resources/kubemetadata_gateway_test.go @@ -20,7 +20,7 @@ import ( "context" "testing" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -36,7 +36,7 @@ func Test_Gateway_KubernetesMetadata(t *testing.T) { "user.ann.2": "user.ann.val.2", } - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -73,7 +73,7 @@ func Test_Gateway_KubernetesMetadata(t *testing.T) { }, }, }, - PostStepVerify: func(ctx context.Context, t *testing.T, ct shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, ct rp.RPTest) { // Check labels and annotations t.Logf("Checking label, annotation values in HTTPProxy resources") httpproxies, err := testutil.GetHTTPProxyList(ctx, ct.Options.Client, appNamespace, name) diff --git a/test/functional/shared/resources/recipe_bicep_test.go b/test/functional-portable/corerp/noncloud/resources/recipe_bicep_test.go similarity index 96% rename from test/functional/shared/resources/recipe_bicep_test.go rename to test/functional-portable/corerp/noncloud/resources/recipe_bicep_test.go index b7afaacc69..f2b2683134 100644 --- a/test/functional/shared/resources/recipe_bicep_test.go +++ b/test/functional-portable/corerp/noncloud/resources/recipe_bicep_test.go @@ -25,7 +25,7 @@ import ( "github.com/radius-project/radius/pkg/recipes" "github.com/radius-project/radius/pkg/ucp/resources" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -68,7 +68,7 @@ func Test_BicepRecipe_ParametersAndOutputs(t *testing.T) { "@" + parametersFilePath, } - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, parameters...), RPResources: &validation.RPResourceSet{ @@ -84,7 +84,7 @@ func Test_BicepRecipe_ParametersAndOutputs(t *testing.T) { }, }, K8sObjects: &validation.K8sObjectSet{}, - PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, test rp.RPTest) { resource, err := test.Options.ManagementClient.ShowResource(ctx, "Applications.Core/extenders", name) require.NoError(t, err) @@ -122,7 +122,7 @@ func Test_BicepRecipe_ContextParameter(t *testing.T) { fmt.Sprintf("recipe=%s", "context-parameter"), } - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, parameters...), RPResources: &validation.RPResourceSet{ @@ -138,7 +138,7 @@ func Test_BicepRecipe_ContextParameter(t *testing.T) { }, }, K8sObjects: &validation.K8sObjectSet{}, - PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, test rp.RPTest) { resource, err := test.Options.ManagementClient.ShowResource(ctx, "Applications.Core/extenders", name) require.NoError(t, err) @@ -190,7 +190,7 @@ func Test_BicepRecipe_ResourceCreation(t *testing.T) { fmt.Sprintf("basename=%s", name), } - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(fmt.Sprintf(templateFmt, "step0"), parametersStep0...), RPResources: &validation.RPResourceSet{ @@ -238,7 +238,7 @@ func Test_BicepRecipe_ResourceCreation(t *testing.T) { // Trying to delete the resources can cause multiple concurrent delete requests. // This currently fails. SkipResourceDeletion: true, - PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, test rp.RPTest) { resource, err := test.Options.ManagementClient.ShowResource(ctx, "Applications.Core/extenders", name) require.NoError(t, err) @@ -313,7 +313,7 @@ func Test_BicepRecipe_ParameterNotDefined(t *testing.T) { }, }) - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployErrorExecutor(template, validate, parameters...), RPResources: &validation.RPResourceSet{ @@ -354,7 +354,7 @@ func Test_BicepRecipe_WrongOutput(t *testing.T) { }, }) - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployErrorExecutor(template, validate, parameters...), RPResources: &validation.RPResourceSet{ @@ -407,7 +407,7 @@ func Test_BicepRecipe_LanguageFailure(t *testing.T) { }, }) - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployErrorExecutor(template, validate, parameters...), RPResources: &validation.RPResourceSet{ @@ -466,7 +466,7 @@ func Test_BicepRecipe_ResourceCreationFailure(t *testing.T) { }, }) - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployErrorExecutor(template, validate, parameters...), RPResources: &validation.RPResourceSet{ diff --git a/test/functional/shared/resources/recipe_terraform_test.go b/test/functional-portable/corerp/noncloud/resources/recipe_terraform_test.go similarity index 76% rename from test/functional/shared/resources/recipe_terraform_test.go rename to test/functional-portable/corerp/noncloud/resources/recipe_terraform_test.go index ec02155b16..07f6a7b9b5 100644 --- a/test/functional/shared/resources/recipe_terraform_test.go +++ b/test/functional-portable/corerp/noncloud/resources/recipe_terraform_test.go @@ -33,15 +33,13 @@ import ( "testing" "github.com/stretchr/testify/require" - corev1 "k8s.io/api/core/v1" - apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/radius-project/radius/pkg/recipes" - "github.com/radius-project/radius/pkg/recipes/terraform/config/backends" "github.com/radius-project/radius/pkg/ucp/resources" resources_radius "github.com/radius-project/radius/pkg/ucp/resources/radius" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/functional-portable/corerp" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -63,10 +61,10 @@ func Test_TerraformRecipe_KubernetesRedis(t *testing.T) { envName := "corerp-resources-terraform-redis-env" redisCacheName := "tf-redis-cache" - secretSuffix, err := getSecretSuffix("/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/extenders/"+name, envName, appName) + secretSuffix, err := corerp.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{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetTerraformRecipeModuleServerURL(), "appName="+appName, "redisCacheName="+redisCacheName), RPResources: &validation.RPResourceSet{ @@ -102,7 +100,7 @@ func Test_TerraformRecipe_KubernetesRedis(t *testing.T) { }, }, }, - PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, test rp.RPTest) { secret, err := test.Options.K8sClient.CoreV1().Secrets(secretNamespace). Get(ctx, secretPrefix+secretSuffix, metav1.GetOptions{}) require.NoError(t, err) @@ -129,9 +127,9 @@ func Test_TerraformRecipe_KubernetesRedis(t *testing.T) { }, }) - test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test shared.RPTest) { + test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test rp.RPTest) { resourceID := "/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/extenders/" + name - testSecretDeletion(t, ctx, test, appName, envName, resourceID) + corerp.TestSecretDeletion(t, ctx, test, appName, envName, resourceID, secretNamespace, secretPrefix) } test.Test(t) @@ -142,10 +140,10 @@ func Test_TerraformRecipe_Context(t *testing.T) { name := "corerp-resources-terraform-context" appNamespace := "corerp-resources-terraform-context-app" - secretSuffix, err := getSecretSuffix("/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/extenders/"+name, name, name) + secretSuffix, err := corerp.GetSecretSuffix("/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/extenders/"+name, name, name) require.NoError(t, err) - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetTerraformRecipeModuleServerURL()), RPResources: &validation.RPResourceSet{ @@ -175,7 +173,7 @@ func Test_TerraformRecipe_Context(t *testing.T) { }, }, }, - PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, test rp.RPTest) { // `k8ssecret-context` recipe should have created a secret with the populated recipe context. s, err := test.Options.K8sClient.CoreV1().Secrets(appNamespace).Get(ctx, name, metav1.GetOptions{}) require.NoError(t, err) @@ -222,59 +220,9 @@ func Test_TerraformRecipe_Context(t *testing.T) { }, }) - test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test shared.RPTest) { + test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test rp.RPTest) { resourceID := "/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/extenders/" + name - testSecretDeletion(t, ctx, test, name, name, resourceID) - } - - test.Test(t) -} - -// Test_TerraformRecipe_AzureStorage creates an Extender resource consuming a Terraform recipe that deploys an Azure blob storage instance. -func Test_TerraformRecipe_AzureStorage(t *testing.T) { - template := "testdata/corerp-resources-terraform-azurestorage.bicep" - name := "corerp-resources-terraform-azstorage" - appName := "corerp-resources-terraform-azstorage-app" - envName := "corerp-resources-terraform-azstorage-env" - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, testutil.GetTerraformRecipeModuleServerURL(), "appName="+appName), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: envName, - Type: validation.EnvironmentsResource, - }, - { - Name: appName, - Type: validation.ApplicationsResource, - }, - { - Name: name, - Type: validation.ExtendersResource, - App: appName, - }, - }, - }, - SkipObjectValidation: true, - PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { - resourceID := "/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/extenders/" + name - secretSuffix, err := getSecretSuffix(resourceID, envName, appName) - require.NoError(t, err) - - 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) - }, - }, - }) - - 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) + corerp.TestSecretDeletion(t, ctx, test, name, name, resourceID, secretNamespace, secretPrefix) } test.Test(t) @@ -307,7 +255,7 @@ func Test_TerraformRecipe_ParametersAndOutputs(t *testing.T) { "@" + parametersFilePath, } - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, parameters...), RPResources: &validation.RPResourceSet{ @@ -327,7 +275,7 @@ func Test_TerraformRecipe_ParametersAndOutputs(t *testing.T) { }, }, K8sObjects: &validation.K8sObjectSet{}, - PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, test rp.RPTest) { resource, err := test.Options.ManagementClient.ShowResource(ctx, "Applications.Core/extenders", name) require.NoError(t, err) @@ -372,7 +320,7 @@ func Test_TerraformRecipe_WrongOutput(t *testing.T) { }, }) - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployErrorExecutor(template, validate, parameters...), RPResources: &validation.RPResourceSet{ @@ -393,35 +341,3 @@ func Test_TerraformRecipe_WrongOutput(t *testing.T) { test.Test(t) } - -func testSecretDeletion(t *testing.T, ctx context.Context, test shared.RPTest, appName, envName, resourceID string) { - secretSuffix, err := getSecretSuffix(resourceID, envName, appName) - require.NoError(t, err) - - secret, err := test.Options.K8sClient.CoreV1().Secrets(secretNamespace). - Get(ctx, secretPrefix+secretSuffix, metav1.GetOptions{}) - require.Error(t, err) - require.True(t, apierrors.IsNotFound(err)) - require.Equal(t, secret, &corev1.Secret{}) -} - -func getSecretSuffix(resourceID, envName, appName string) (string, error) { - envID := "/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/environments/" + envName - appID := "/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/applications/" + appName - - resourceRecipe := recipes.ResourceMetadata{ - EnvironmentID: envID, - ApplicationID: appID, - ResourceID: resourceID, - Parameters: nil, - } - - backend := backends.NewKubernetesBackend(nil) - secretMap, err := backend.BuildBackend(&resourceRecipe) - if err != nil { - return "", err - } - kubernetes := secretMap["kubernetes"].(map[string]any) - - return kubernetes["secret_suffix"].(string), nil -} diff --git a/test/functional/shared/resources/recipe_test.go b/test/functional-portable/corerp/noncloud/resources/recipe_test.go similarity index 94% rename from test/functional/shared/resources/recipe_test.go rename to test/functional-portable/corerp/noncloud/resources/recipe_test.go index 28ca5f5eeb..fe5af73eb1 100644 --- a/test/functional/shared/resources/recipe_test.go +++ b/test/functional-portable/corerp/noncloud/resources/recipe_test.go @@ -21,7 +21,7 @@ import ( "testing" "github.com/radius-project/radius/pkg/recipes" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/validation" ) @@ -47,7 +47,7 @@ func Test_Recipe_NotFound(t *testing.T) { }, }) - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployErrorExecutor(template, validate, fmt.Sprintf("basename=%s", name)), RPResources: &validation.RPResourceSet{ diff --git a/test/functional/shared/resources/simulated_environment_test.go b/test/functional-portable/corerp/noncloud/resources/simulated_environment_test.go similarity index 92% rename from test/functional/shared/resources/simulated_environment_test.go rename to test/functional-portable/corerp/noncloud/resources/simulated_environment_test.go index b98a79e81a..cc782a2e72 100644 --- a/test/functional/shared/resources/simulated_environment_test.go +++ b/test/functional-portable/corerp/noncloud/resources/simulated_environment_test.go @@ -21,7 +21,7 @@ import ( "fmt" "testing" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -34,7 +34,7 @@ func Test_Deployment_SimulatedEnv(t *testing.T) { name := "corerp-resources-simulatedenv" appNamespace := "default-corerp-resources-simulatedenv" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -72,7 +72,7 @@ func Test_Deployment_SimulatedEnv(t *testing.T) { }, SkipKubernetesOutputResourceValidation: true, SkipObjectValidation: true, - PostStepVerify: func(ctx context.Context, t *testing.T, ct shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, ct rp.RPTest) { // Get pods in app namespace label := fmt.Sprintf("radapp.io/application=%s", name) pods, err := ct.Options.K8sClient.CoreV1().Pods(appNamespace).List(ctx, metav1.ListOptions{ diff --git a/test/functional/shared/resources/testdata/containers/corerp-resources-friendly-container-version-1.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/containers/corerp-resources-friendly-container-version-1.bicep similarity index 100% rename from test/functional/shared/resources/testdata/containers/corerp-resources-friendly-container-version-1.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/containers/corerp-resources-friendly-container-version-1.bicep diff --git a/test/functional/shared/resources/testdata/containers/corerp-resources-friendly-container-version-2.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/containers/corerp-resources-friendly-container-version-2.bicep similarity index 100% rename from test/functional/shared/resources/testdata/containers/corerp-resources-friendly-container-version-2.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/containers/corerp-resources-friendly-container-version-2.bicep diff --git a/test/functional/shared/resources/testdata/corerp-azure-container-manualscale.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-azure-container-manualscale.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-azure-container-manualscale.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-azure-container-manualscale.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-app-env.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-app-env.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-app-env.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-app-env.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-application-graph-out.json b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-application-graph-out.json similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-application-graph-out.json rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-application-graph-out.json diff --git a/test/functional/shared/resources/testdata/corerp-resources-application-graph.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-application-graph.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-application-graph.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-application-graph.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-application.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-application.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-application.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-application.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-container-bad-healthprobe.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-bad-healthprobe.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-container-bad-healthprobe.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-bad-healthprobe.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-container-cmd-args.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-cmd-args.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-container-cmd-args.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-cmd-args.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-container-liveness-readiness.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-liveness-readiness.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-container-liveness-readiness.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-liveness-readiness.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-container-manifest-sidecar.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-manifest-sidecar.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-container-manifest-sidecar.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-manifest-sidecar.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-container-manifest.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-manifest.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-container-manifest.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-manifest.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-container-multiple-containers-multiple-ports-dns.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-multiple-containers-multiple-ports-dns.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-container-multiple-containers-multiple-ports-dns.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-multiple-containers-multiple-ports-dns.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-container-multiple-ports.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-multiple-ports.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-container-multiple-ports.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-multiple-ports.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-container-nonexistent-container-image.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-nonexistent-container-image.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-container-nonexistent-container-image.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-nonexistent-container-image.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-container-optional-port-scheme.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-optional-port-scheme.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-container-optional-port-scheme.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-optional-port-scheme.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-container-pod-patching.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-pod-patching.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-container-pod-patching.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-pod-patching.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-container-single-dns-request.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-single-dns-request.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-container-single-dns-request.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-single-dns-request.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-container-single-dns-service-creation.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-single-dns-service-creation.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-container-single-dns-service-creation.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-single-dns-service-creation.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-container-two-containers-dns.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-two-containers-dns.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-container-two-containers-dns.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container-two-containers-dns.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-container.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-container.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-container.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-environment.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-environment.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-environment.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-environment.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-extender-recipe.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-extender-recipe.bicep similarity index 92% rename from test/functional/shared/resources/testdata/corerp-resources-extender-recipe.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-extender-recipe.bicep index b111e6d8c8..bca6d696ed 100644 --- a/test/functional/shared/resources/testdata/corerp-resources-extender-recipe.bicep +++ b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-extender-recipe.bicep @@ -18,7 +18,7 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { 'Applications.Core/extenders':{ default: { templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/extender-recipe:${version}' + templatePath: '${registry}/test/testrecipes/test-bicep-recipes/extender-recipe:${version}' parameters: { containerImage: '${registry}/magpiego:${version}' } diff --git a/test/functional/shared/resources/testdata/corerp-resources-extender.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-extender.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-extender.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-extender.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-gateway-dns.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-gateway-dns.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-gateway-dns.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-gateway-dns.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-gateway-failure.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-gateway-failure.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-gateway-failure.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-gateway-failure.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-gateway-kubernetesmetadata.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-gateway-kubernetesmetadata.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-gateway-kubernetesmetadata.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-gateway-kubernetesmetadata.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-gateway-sslpassthrough.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-gateway-sslpassthrough.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-gateway-sslpassthrough.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-gateway-sslpassthrough.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-gateway-tlstermination.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-gateway-tlstermination.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-gateway-tlstermination.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-gateway-tlstermination.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-httproute-kubernetesmetadata.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-httproute-kubernetesmetadata.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-httproute-kubernetesmetadata.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-httproute-kubernetesmetadata.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-kubemetadata-cascade.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-kubemetadata-cascade.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-kubemetadata-cascade.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-kubemetadata-cascade.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-kubemetadata-container.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-kubemetadata-container.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-kubemetadata-container.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-kubemetadata-container.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-recipe-bicep-resourcecreation.step0.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-recipe-bicep-resourcecreation.step0.bicep similarity index 94% rename from test/functional/shared/resources/testdata/corerp-resources-recipe-bicep-resourcecreation.step0.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-recipe-bicep-resourcecreation.step0.bicep index c09b173e28..6f6393b7fa 100644 --- a/test/functional/shared/resources/testdata/corerp-resources-recipe-bicep-resourcecreation.step0.bicep +++ b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-recipe-bicep-resourcecreation.step0.bicep @@ -26,7 +26,7 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { 'Applications.Core/extenders': { '${environmentRecipeName}': { templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/${recipe}:${version}' + templatePath: '${registry}/test/testrecipes/test-bicep-recipes/${recipe}:${version}' parameters: environmentParameters } } diff --git a/test/functional/shared/resources/testdata/corerp-resources-recipe-bicep-resourcecreation.step1.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-recipe-bicep-resourcecreation.step1.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-recipe-bicep-resourcecreation.step1.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-recipe-bicep-resourcecreation.step1.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-recipe-bicep.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-recipe-bicep.bicep similarity index 94% rename from test/functional/shared/resources/testdata/corerp-resources-recipe-bicep.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-recipe-bicep.bicep index 39cca4d3bf..cb30e86ec6 100644 --- a/test/functional/shared/resources/testdata/corerp-resources-recipe-bicep.bicep +++ b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-recipe-bicep.bicep @@ -30,7 +30,7 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { 'Applications.Core/extenders': { '${environmentRecipeName}': { templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/${recipe}:${version}' + templatePath: '${registry}/test/testrecipes/test-bicep-recipes/${recipe}:${version}' parameters: environmentParameters } } diff --git a/test/functional/shared/resources/testdata/corerp-resources-recipe-notfound.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-recipe-notfound.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-recipe-notfound.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-recipe-notfound.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-simulatedenv.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-simulatedenv.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-simulatedenv.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-simulatedenv.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-terraform-context.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-terraform-context.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-terraform-context.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-terraform-context.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-terraform-recipe-terraform.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-terraform-recipe-terraform.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-terraform-recipe-terraform.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-terraform-recipe-terraform.bicep diff --git a/test/functional/shared/resources/testdata/corerp-resources-terraform-redis.bicep b/test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-terraform-redis.bicep similarity index 100% rename from test/functional/shared/resources/testdata/corerp-resources-terraform-redis.bicep rename to test/functional-portable/corerp/noncloud/resources/testdata/corerp-resources-terraform-redis.bicep diff --git a/test/functional/shared/resources/testdata/manifest/basemanifest.yaml b/test/functional-portable/corerp/noncloud/resources/testdata/manifest/basemanifest.yaml similarity index 100% rename from test/functional/shared/resources/testdata/manifest/basemanifest.yaml rename to test/functional-portable/corerp/noncloud/resources/testdata/manifest/basemanifest.yaml diff --git a/test/functional/shared/resources/testdata/manifest/sidecar.yaml b/test/functional-portable/corerp/noncloud/resources/testdata/manifest/sidecar.yaml similarity index 100% rename from test/functional/shared/resources/testdata/manifest/sidecar.yaml rename to test/functional-portable/corerp/noncloud/resources/testdata/manifest/sidecar.yaml diff --git a/test/functional/shared/resources/testdata/parameters/test-tls-cert.parameters.json b/test/functional-portable/corerp/noncloud/resources/testdata/parameters/test-tls-cert.parameters.json similarity index 100% rename from test/functional/shared/resources/testdata/parameters/test-tls-cert.parameters.json rename to test/functional-portable/corerp/noncloud/resources/testdata/parameters/test-tls-cert.parameters.json diff --git a/test/functional-portable/corerp/util.go b/test/functional-portable/corerp/util.go new file mode 100644 index 0000000000..6063171872 --- /dev/null +++ b/test/functional-portable/corerp/util.go @@ -0,0 +1,65 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package corerp + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/recipes/terraform/config/backends" + "github.com/radius-project/radius/test/rp" +) + +// TestSecretDeletion tests that the secret is deleted after the resource is deleted +func TestSecretDeletion(t *testing.T, ctx context.Context, test rp.RPTest, appName, envName, resourceID string, secretNamespace string, secretPrefix string) { + secretSuffix, err := GetSecretSuffix(resourceID, envName, appName) + require.NoError(t, err) + + secret, err := test.Options.K8sClient.CoreV1().Secrets(secretNamespace). + Get(ctx, secretPrefix+secretSuffix, metav1.GetOptions{}) + require.Error(t, err) + require.True(t, apierrors.IsNotFound(err)) + require.Equal(t, secret, &corev1.Secret{}) +} + +// GetSecretSuffix returns the secret suffix for a given resource +func GetSecretSuffix(resourceID, envName, appName string) (string, error) { + envID := "/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/environments/" + envName + appID := "/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/applications/" + appName + + resourceRecipe := recipes.ResourceMetadata{ + EnvironmentID: envID, + ApplicationID: appID, + ResourceID: resourceID, + Parameters: nil, + } + + backend := backends.NewKubernetesBackend(nil) + secretMap, err := backend.BuildBackend(&resourceRecipe) + if err != nil { + return "", err + } + kubernetes := secretMap["kubernetes"].(map[string]any) + + return kubernetes["secret_suffix"].(string), nil +} diff --git a/test/functional-portable/daprrp/noncloud/resources/common.go b/test/functional-portable/daprrp/noncloud/resources/common.go index 3d4b53d380..97c84c6f85 100644 --- a/test/functional-portable/daprrp/noncloud/resources/common.go +++ b/test/functional-portable/daprrp/noncloud/resources/common.go @@ -22,7 +22,7 @@ import ( "github.com/radius-project/radius/pkg/cli/clients" "github.com/radius-project/radius/pkg/cli/clients_new/generated" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -30,7 +30,7 @@ import ( "k8s.io/client-go/dynamic" ) -func verifyDaprComponentsDeleted(ctx context.Context, t *testing.T, test shared.RPTest, resourceType, resourceName, namespace string) { +func verifyDaprComponentsDeleted(ctx context.Context, t *testing.T, test rp.RPTest, resourceType, resourceName, namespace string) { resource, err := test.Options.ManagementClient.ShowResource(ctx, resourceType, resourceName) require.Error(t, err) require.True(t, clients.Is404Error(err)) diff --git a/test/functional-portable/daprrp/noncloud/resources/dapr_component_name_conflict_test.go b/test/functional-portable/daprrp/noncloud/resources/dapr_component_name_conflict_test.go index acdd7049a2..81317a294d 100644 --- a/test/functional-portable/daprrp/noncloud/resources/dapr_component_name_conflict_test.go +++ b/test/functional-portable/daprrp/noncloud/resources/dapr_component_name_conflict_test.go @@ -20,7 +20,7 @@ import ( "testing" v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/validation" ) @@ -39,14 +39,14 @@ func Test_DaprComponentNameConflict(t *testing.T) { }, }) - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployErrorExecutor(template, validate), SkipKubernetesOutputResourceValidation: true, K8sObjects: &validation.K8sObjectSet{}, }, }) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} + test.RequiredFeatures = []rp.RequiredFeature{rp.FeatureDapr} test.Test(t) } diff --git a/test/functional-portable/daprrp/noncloud/resources/dapr_pubsub_test.go b/test/functional-portable/daprrp/noncloud/resources/dapr_pubsub_test.go index 7641c5e4e3..ea49c3d0da 100644 --- a/test/functional-portable/daprrp/noncloud/resources/dapr_pubsub_test.go +++ b/test/functional-portable/daprrp/noncloud/resources/dapr_pubsub_test.go @@ -21,7 +21,7 @@ import ( "fmt" "testing" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -32,7 +32,7 @@ func Test_DaprPubSubBroker_Manual(t *testing.T) { name := "dpsb-manual-app" appNamespace := "default-dpsb-manual-app" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage(), fmt.Sprintf("namespace=%s", appNamespace)), RPResources: &validation.RPResourceSet{ @@ -70,9 +70,9 @@ func Test_DaprPubSubBroker_Manual(t *testing.T) { }, }) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} + test.RequiredFeatures = []rp.RequiredFeature{rp.FeatureDapr} - test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test shared.RPTest) { + test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test rp.RPTest) { verifyDaprComponentsDeleted(ctx, t, test, "Applications.Dapr/pubSubBrokers", "dpsb-manual", appNamespace) } @@ -84,7 +84,7 @@ func Test_DaprPubSubBroker_Recipe(t *testing.T) { name := "dpsb-recipe-app" appNamespace := "dpsb-recipe-env" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage(), testutil.GetBicepRecipeRegistry(), testutil.GetBicepRecipeVersion()), RPResources: &validation.RPResourceSet{ @@ -124,9 +124,9 @@ func Test_DaprPubSubBroker_Recipe(t *testing.T) { }, }) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} + test.RequiredFeatures = []rp.RequiredFeature{rp.FeatureDapr} - test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test shared.RPTest) { + test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test rp.RPTest) { verifyDaprComponentsDeleted(ctx, t, test, "Applications.Dapr/pubSubBrokers", "dpsb-recipe", appNamespace) } diff --git a/test/functional-portable/daprrp/noncloud/resources/dapr_secretstore_test.go b/test/functional-portable/daprrp/noncloud/resources/dapr_secretstore_test.go index 342d6f6e72..bb2459de3c 100644 --- a/test/functional-portable/daprrp/noncloud/resources/dapr_secretstore_test.go +++ b/test/functional-portable/daprrp/noncloud/resources/dapr_secretstore_test.go @@ -20,7 +20,7 @@ import ( "context" "testing" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -31,7 +31,7 @@ func Test_DaprSecretStore_Manual(t *testing.T) { name := "daprrp-rs-secretstore-manual" appNamespace := "default-daprrp-rs-secretstore-manual" - test := shared.NewRPTest(t, appNamespace, []shared.TestStep{ + test := rp.NewRPTest(t, appNamespace, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -64,11 +64,11 @@ func Test_DaprSecretStore_Manual(t *testing.T) { }, }, }, - }, shared.K8sSecretResource(appNamespace, "mysecret", "", "fakekey", []byte("fakevalue"))) + }, rp.K8sSecretResource(appNamespace, "mysecret", "", "fakekey", []byte("fakevalue"))) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} + test.RequiredFeatures = []rp.RequiredFeature{rp.FeatureDapr} - test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test shared.RPTest) { + test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test rp.RPTest) { verifyDaprComponentsDeleted(ctx, t, test, "Applications.Dapr/secretStores", "gnrc-scs-manual", appNamespace) } @@ -80,7 +80,7 @@ func Test_DaprSecretStore_Recipe(t *testing.T) { name := "daprrp-rs-secretstore-recipe" appNamespace := "daprrp-rs-secretstore-recipe" - test := shared.NewRPTest(t, appNamespace, []shared.TestStep{ + test := rp.NewRPTest(t, appNamespace, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage(), testutil.GetBicepRecipeRegistry(), testutil.GetBicepRecipeVersion()), RPResources: &validation.RPResourceSet{ @@ -113,11 +113,11 @@ func Test_DaprSecretStore_Recipe(t *testing.T) { }, }, }, - }, shared.K8sSecretResource(appNamespace, "mysecret", "", "fakekey", []byte("fakevalue"))) + }, rp.K8sSecretResource(appNamespace, "mysecret", "", "fakekey", []byte("fakevalue"))) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} + test.RequiredFeatures = []rp.RequiredFeature{rp.FeatureDapr} - test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test shared.RPTest) { + test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test rp.RPTest) { verifyDaprComponentsDeleted(ctx, t, test, "Applications.Dapr/secretStores", "gnrc-scs-recipe", appNamespace) } diff --git a/test/functional-portable/daprrp/noncloud/resources/dapr_serviceinvocation_test.go b/test/functional-portable/daprrp/noncloud/resources/dapr_serviceinvocation_test.go index fbc3297fd4..765e51e172 100644 --- a/test/functional-portable/daprrp/noncloud/resources/dapr_serviceinvocation_test.go +++ b/test/functional-portable/daprrp/noncloud/resources/dapr_serviceinvocation_test.go @@ -19,7 +19,7 @@ package resource_test import ( "testing" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -30,7 +30,7 @@ func Test_DaprServiceInvocation(t *testing.T) { name := "dapr-serviceinvocation" appNamespace := "default-dapr-serviceinvocation" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -61,7 +61,7 @@ func Test_DaprServiceInvocation(t *testing.T) { }, }, }) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} + test.RequiredFeatures = []rp.RequiredFeature{rp.FeatureDapr} test.Test(t) } diff --git a/test/functional-portable/daprrp/noncloud/resources/dapr_statestore_test.go b/test/functional-portable/daprrp/noncloud/resources/dapr_statestore_test.go index 21bc7e2a75..448e298c9e 100644 --- a/test/functional-portable/daprrp/noncloud/resources/dapr_statestore_test.go +++ b/test/functional-portable/daprrp/noncloud/resources/dapr_statestore_test.go @@ -21,7 +21,7 @@ import ( "fmt" "testing" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -32,7 +32,7 @@ func Test_DaprStateStore_Manual(t *testing.T) { name := "daprrp-rs-statestore-manual" appNamespace := "default-daprrp-rs-statestore-manual" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage(), fmt.Sprintf("namespace=%s", appNamespace)), RPResources: &validation.RPResourceSet{ @@ -72,9 +72,9 @@ func Test_DaprStateStore_Manual(t *testing.T) { }, }) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} + test.RequiredFeatures = []rp.RequiredFeature{rp.FeatureDapr} - test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test shared.RPTest) { + test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test rp.RPTest) { verifyDaprComponentsDeleted(ctx, t, test, "Applications.Dapr/stateStores", "dapr-sts-manual", appNamespace) } @@ -86,7 +86,7 @@ func Test_DaprStateStore_Recipe(t *testing.T) { name := "daprrp-rs-sts-recipe" appNamespace := "daprrp-env-recipes-env" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage(), testutil.GetBicepRecipeRegistry(), testutil.GetBicepRecipeVersion()), RPResources: &validation.RPResourceSet{ @@ -126,9 +126,9 @@ func Test_DaprStateStore_Recipe(t *testing.T) { }, }) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} + test.RequiredFeatures = []rp.RequiredFeature{rp.FeatureDapr} - test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test shared.RPTest) { + test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test rp.RPTest) { verifyDaprComponentsDeleted(ctx, t, test, "Applications.Dapr/stateStores", "dapr-sts-recipe", appNamespace) } diff --git a/test/functional-portable/daprrp/noncloud/resources/testdata/daprrp-resources-pubsub-broker-manual.bicep b/test/functional-portable/daprrp/noncloud/resources/testdata/daprrp-resources-pubsub-broker-manual.bicep index 4dd9371036..39218a6580 100644 --- a/test/functional-portable/daprrp/noncloud/resources/testdata/daprrp-resources-pubsub-broker-manual.bicep +++ b/test/functional-portable/daprrp/noncloud/resources/testdata/daprrp-resources-pubsub-broker-manual.bicep @@ -39,7 +39,7 @@ resource myapp 'Applications.Core/containers@2023-10-01-preview' = { } -module redis '../../../../../functional/shared/resources/testdata/modules/redis-selfhost.bicep' = { +module redis '../../../../../../test/testrecipes/modules/redis-selfhost.bicep' = { name: 'dpsb-manual-redis-deployment' params: { name: 'dpsb-manual-redis' diff --git a/test/functional-portable/daprrp/noncloud/resources/testdata/daprrp-resources-pubsub-broker-recipe.bicep b/test/functional-portable/daprrp/noncloud/resources/testdata/daprrp-resources-pubsub-broker-recipe.bicep index 0fa7d537cc..04bd396d5e 100644 --- a/test/functional-portable/daprrp/noncloud/resources/testdata/daprrp-resources-pubsub-broker-recipe.bicep +++ b/test/functional-portable/daprrp/noncloud/resources/testdata/daprrp-resources-pubsub-broker-recipe.bicep @@ -16,7 +16,7 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { 'Applications.Dapr/pubSubBrokers': { default: { templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/dapr-pubsub-broker:${version}' + templatePath: '${registry}/test/testrecipes/test-bicep-recipes/dapr-pubsub-broker:${version}' } } } diff --git a/test/functional-portable/daprrp/noncloud/resources/testdata/daprrp-resources-secretstore-recipe.bicep b/test/functional-portable/daprrp/noncloud/resources/testdata/daprrp-resources-secretstore-recipe.bicep index fcac516e9b..aa911c23e6 100644 --- a/test/functional-portable/daprrp/noncloud/resources/testdata/daprrp-resources-secretstore-recipe.bicep +++ b/test/functional-portable/daprrp/noncloud/resources/testdata/daprrp-resources-secretstore-recipe.bicep @@ -18,7 +18,7 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { 'Applications.Dapr/secretStores': { default: { templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/dapr-secret-store:${version}' + templatePath: '${registry}/test/testrecipes/test-bicep-recipes/dapr-secret-store:${version}' } } } diff --git a/test/functional-portable/daprrp/noncloud/resources/testdata/daprrp-resources-statestore-manual.bicep b/test/functional-portable/daprrp/noncloud/resources/testdata/daprrp-resources-statestore-manual.bicep index 0d96d0a543..ed39af5123 100644 --- a/test/functional-portable/daprrp/noncloud/resources/testdata/daprrp-resources-statestore-manual.bicep +++ b/test/functional-portable/daprrp/noncloud/resources/testdata/daprrp-resources-statestore-manual.bicep @@ -39,7 +39,7 @@ resource myapp 'Applications.Core/containers@2023-10-01-preview' = { } -module redis '../../../../../functional/shared/resources/testdata/modules/redis-selfhost.bicep' = { +module redis '../../../../../../test/testrecipes/modules/redis-selfhost.bicep' = { name: 'dapr-sts-manual-redis-deployment' params: { name: 'dapr-sts-manual-redis' diff --git a/test/functional-portable/daprrp/noncloud/resources/testdata/daprrp-resources-statestore-recipe.bicep b/test/functional-portable/daprrp/noncloud/resources/testdata/daprrp-resources-statestore-recipe.bicep index 36ef27176e..4054e67582 100644 --- a/test/functional-portable/daprrp/noncloud/resources/testdata/daprrp-resources-statestore-recipe.bicep +++ b/test/functional-portable/daprrp/noncloud/resources/testdata/daprrp-resources-statestore-recipe.bicep @@ -16,7 +16,7 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { 'Applications.Dapr/stateStores': { default: { templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/dapr-state-store:${version}' + templatePath: '${registry}/test/testrecipes/test-bicep-recipes/dapr-state-store:${version}' } } } diff --git a/test/functional-portable/datastoresrp/cloud/resources/microsoftsql_test.go b/test/functional-portable/datastoresrp/cloud/resources/microsoftsql_test.go index 3e694c4753..1b836fc42a 100644 --- a/test/functional-portable/datastoresrp/cloud/resources/microsoftsql_test.go +++ b/test/functional-portable/datastoresrp/cloud/resources/microsoftsql_test.go @@ -20,7 +20,7 @@ import ( "os" "testing" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -49,7 +49,7 @@ func Test_MicrosoftSQL_Manual(t *testing.T) { sqlServer := "server=" + os.Getenv("AZURE_MSSQL_SERVER") appNamespace := "default-dsrp-resources-microsoft-sql" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage(), mssqlresourceid, adminUsername, adminPassword, sqlDatabse, sqlServer), RPResources: &validation.RPResourceSet{ @@ -75,6 +75,6 @@ func Test_MicrosoftSQL_Manual(t *testing.T) { }, }) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureAzure} + test.RequiredFeatures = []rp.RequiredFeature{rp.FeatureAzure} test.Test(t) } diff --git a/test/functional-portable/datastoresrp/noncloud/resources/mongodb_test.go b/test/functional-portable/datastoresrp/noncloud/resources/mongodb_test.go index 5c8d2b15ae..ee4a8de670 100644 --- a/test/functional-portable/datastoresrp/noncloud/resources/mongodb_test.go +++ b/test/functional-portable/datastoresrp/noncloud/resources/mongodb_test.go @@ -19,7 +19,7 @@ package resource_test import ( "testing" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -31,7 +31,7 @@ func Test_MongoDB_Manual(t *testing.T) { name := "dsrp-resources-mongodb-manual" appNamespace := "default-cdsrp-resources-mongodb-manual" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -78,7 +78,7 @@ func Test_MongoDB_Recipe(t *testing.T) { name := "dsrp-resources-mongodb-recipe" appNamespace := "dsrp-resources-mongodb-recipe-app" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage(), testutil.GetBicepRecipeRegistry(), testutil.GetBicepRecipeVersion()), RPResources: &validation.RPResourceSet{ diff --git a/test/functional-portable/datastoresrp/noncloud/resources/redis_test.go b/test/functional-portable/datastoresrp/noncloud/resources/redis_test.go index d62a62bf1c..d5c128ba8f 100644 --- a/test/functional-portable/datastoresrp/noncloud/resources/redis_test.go +++ b/test/functional-portable/datastoresrp/noncloud/resources/redis_test.go @@ -21,7 +21,7 @@ import ( "strings" "testing" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -33,7 +33,7 @@ func Test_Redis_Manual(t *testing.T) { name := "dsrp-resources-redis-manual" appNamespace := "default-dsrp-resources-redis-manual" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -77,7 +77,7 @@ func Test_Redis_Recipe(t *testing.T) { template := "testdata/datastoresrp-resources-redis-recipe.bicep" name := "dsrp-resources-redis-recipe" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetBicepRecipeRegistry(), testutil.GetBicepRecipeVersion()), RPResources: &validation.RPResourceSet{ @@ -98,7 +98,7 @@ func Test_Redis_Recipe(t *testing.T) { }, }, SkipObjectValidation: true, - PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, test rp.RPTest) { redis, err := test.Options.ManagementClient.ShowResource(ctx, "Applications.Datastores/redisCaches", "rds-recipe") require.NoError(t, err) require.NotNil(t, redis) @@ -106,7 +106,7 @@ func Test_Redis_Recipe(t *testing.T) { recipe := status["recipe"].(map[string]interface{}) require.Equal(t, "bicep", recipe["templateKind"].(string)) templatePath := strings.Split(recipe["templatePath"].(string), ":")[0] - require.Equal(t, "ghcr.io/radius-project/dev/test/functional/shared/recipes/redis-recipe-value-backed", templatePath) + require.Equal(t, "ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/redis-recipe-value-backed", templatePath) }, }, }) @@ -118,7 +118,7 @@ func Test_Redis_DefaultRecipe(t *testing.T) { template := "testdata/datastoresrp-resources-redis-default-recipe.bicep" name := "dsrp-resources-redis-default-recipe" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetBicepRecipeRegistry(), testutil.GetBicepRecipeVersion()), RPResources: &validation.RPResourceSet{ diff --git a/test/functional-portable/datastoresrp/noncloud/resources/simulated_environment_test.go b/test/functional-portable/datastoresrp/noncloud/resources/simulated_environment_test.go index cc2f6b7b4d..828e4065a7 100644 --- a/test/functional-portable/datastoresrp/noncloud/resources/simulated_environment_test.go +++ b/test/functional-portable/datastoresrp/noncloud/resources/simulated_environment_test.go @@ -21,7 +21,7 @@ import ( "fmt" "testing" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -37,7 +37,7 @@ func Test_Deployment_SimulatedEnv_BicepRecipe(t *testing.T) { mongoDBName := "mongodb-db-simenv" envName := "dsrp-resources-simenv-recipe-env" - test := shared.NewRPTest(t, appName, []shared.TestStep{ + test := rp.NewRPTest(t, appName, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage(), testutil.GetBicepRecipeRegistry(), testutil.GetBicepRecipeVersion()), RPResources: &validation.RPResourceSet{ @@ -65,7 +65,7 @@ func Test_Deployment_SimulatedEnv_BicepRecipe(t *testing.T) { }, SkipKubernetesOutputResourceValidation: true, SkipObjectValidation: true, - PostStepVerify: func(ctx context.Context, t *testing.T, ct shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, ct rp.RPTest) { // Get pods in app namespace label := fmt.Sprintf("radapp.io/application=%s", appName) pods, err := ct.Options.K8sClient.CoreV1().Pods(appNamespace).List(ctx, metav1.ListOptions{ diff --git a/test/functional-portable/datastoresrp/noncloud/resources/sql_test.go b/test/functional-portable/datastoresrp/noncloud/resources/sql_test.go index 0f0a8bb6a6..f1f265114f 100644 --- a/test/functional-portable/datastoresrp/noncloud/resources/sql_test.go +++ b/test/functional-portable/datastoresrp/noncloud/resources/sql_test.go @@ -20,7 +20,7 @@ import ( "runtime" "testing" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -35,7 +35,7 @@ func Test_SQLDatabase_Manual(t *testing.T) { name := "dsrp-resources-sql" appNamespace := "default-dsrp-resources-sql" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage()), RPResources: &validation.RPResourceSet{ @@ -82,7 +82,7 @@ func Test_SQLDatabase_Recipe(t *testing.T) { template := "testdata/datastoresrp-resources-sqldb-recipe.bicep" name := "dsrp-resources-sqldb-recipe" appNamespace := "dsrp-resources-sqldb-recipe-app" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage(), testutil.GetBicepRecipeRegistry(), testutil.GetBicepRecipeVersion()), RPResources: &validation.RPResourceSet{ diff --git a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-mongodb-recipe-context.bicep b/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-mongodb-recipe-context.bicep index a4899038a9..5c7a0ef04d 100644 --- a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-mongodb-recipe-context.bicep +++ b/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-mongodb-recipe-context.bicep @@ -28,7 +28,7 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { 'Applications.Datastores/mongoDatabases':{ default: { templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/mongodb-recipe-context:${version}' + templatePath: '${registry}/test/testrecipes/test-bicep-recipes/mongodb-recipe-context:${version}' } } } diff --git a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-mongodb-recipe.bicep b/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-mongodb-recipe.bicep index 9041e75a93..ccdc10dd63 100644 --- a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-mongodb-recipe.bicep +++ b/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-mongodb-recipe.bicep @@ -28,7 +28,7 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { 'Applications.Datastores/mongoDatabases':{ mongoazure: { templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/mongodb-recipe-kubernetes:${version}' + templatePath: '${registry}/test/testrecipes/test-bicep-recipes/mongodb-recipe-kubernetes:${version}' } } } diff --git a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-redis-default-recipe.bicep b/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-redis-default-recipe.bicep index dff0fccce7..81fed90878 100644 --- a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-redis-default-recipe.bicep +++ b/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-redis-default-recipe.bicep @@ -24,7 +24,7 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { 'Applications.Datastores/redisCaches': { default: { templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/redis-recipe-value-backed:${version}' + templatePath: '${registry}/test/testrecipes/test-bicep-recipes/redis-recipe-value-backed:${version}' } } } diff --git a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-redis-recipe.bicep b/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-redis-recipe.bicep index 2f518b3614..99304a666a 100644 --- a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-redis-recipe.bicep +++ b/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-redis-recipe.bicep @@ -24,7 +24,7 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { 'Applications.Datastores/redisCaches':{ rediscache: { templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/redis-recipe-value-backed:${version}' + templatePath: '${registry}/test/testrecipes/test-bicep-recipes/redis-recipe-value-backed:${version}' } } } diff --git a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-simulatedenv-recipe.bicep b/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-simulatedenv-recipe.bicep index 42fbbef164..b590629c85 100644 --- a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-simulatedenv-recipe.bicep +++ b/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-simulatedenv-recipe.bicep @@ -19,7 +19,7 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { 'Applications.Datastores/mongoDatabases':{ 'mongodb-recipe-kubernetes': { templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/mongodb-recipe-kubernetes:${version}' + templatePath: '${registry}/test/testrecipes/test-bicep-recipes/mongodb-recipe-kubernetes:${version}' } } } diff --git a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-sqldb-recipe.bicep b/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-sqldb-recipe.bicep index 545ba3edf4..9e438bf2bb 100644 --- a/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-sqldb-recipe.bicep +++ b/test/functional-portable/datastoresrp/noncloud/resources/testdata/datastoresrp-resources-sqldb-recipe.bicep @@ -33,7 +33,7 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { 'Applications.Datastores/sqlDatabases': { default: { templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/sqldb-recipe:${version}' + templatePath: '${registry}/test/testrecipes/test-bicep-recipes/sqldb-recipe:${version}' parameters: { username: username password: password diff --git a/test/functional-portable/kubernetes/noncloud/kubernetes_test.go b/test/functional-portable/kubernetes/noncloud/kubernetes_test.go index 75baf35a11..47ae1150d9 100644 --- a/test/functional-portable/kubernetes/noncloud/kubernetes_test.go +++ b/test/functional-portable/kubernetes/noncloud/kubernetes_test.go @@ -28,8 +28,8 @@ import ( radappiov1alpha3 "github.com/radius-project/radius/pkg/controller/api/radapp.io/v1alpha3" "github.com/radius-project/radius/pkg/controller/reconciler" "github.com/radius-project/radius/pkg/sdk" - "github.com/radius-project/radius/test/functional/shared" "github.com/radius-project/radius/test/radcli" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/testcontext" "github.com/radius-project/radius/test/testutil" "github.com/stretchr/testify/require" @@ -49,7 +49,7 @@ import ( func Test_TutorialApplication_KubernetesManifests(t *testing.T) { ctx := testcontext.New(t) - opts := shared.NewRPTestOptions(t) + opts := rp.NewRPTestOptions(t) namespace := "kubernetes-interop-tutorial" environmentName := namespace + "-env" diff --git a/test/functional-portable/kubernetes/noncloud/testdata/tutorial-environment.bicep b/test/functional-portable/kubernetes/noncloud/testdata/tutorial-environment.bicep index 68308687f0..5c38e0074f 100644 --- a/test/functional-portable/kubernetes/noncloud/testdata/tutorial-environment.bicep +++ b/test/functional-portable/kubernetes/noncloud/testdata/tutorial-environment.bicep @@ -17,7 +17,7 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { 'Applications.Datastores/redisCaches': { default: { templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/redis-recipe-value-backed:${version}' + templatePath: '${registry}/test/testrecipes/test-bicep-recipes/redis-recipe-value-backed:${version}' } } } diff --git a/test/functional-portable/messagingrp/noncloud/resources/rabbitmq_test.go b/test/functional-portable/messagingrp/noncloud/resources/rabbitmq_test.go index 94ddf7bdcc..490fced203 100644 --- a/test/functional-portable/messagingrp/noncloud/resources/rabbitmq_test.go +++ b/test/functional-portable/messagingrp/noncloud/resources/rabbitmq_test.go @@ -19,7 +19,7 @@ package resource_test import ( "testing" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -30,7 +30,7 @@ func Test_RabbitMQ_Manual(t *testing.T) { name := "msgrp-resources-rabbitmq" appNamespace := "default-msgrp-resources-rabbitmq" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage(), "password=guest"), RPResources: &validation.RPResourceSet{ @@ -76,7 +76,7 @@ func Test_RabbitMQ_Recipe(t *testing.T) { name := "msgrp-resources-rabbitmq-recipe" appNamespace := "default-msgrp-resources-rabbitmq-recipe" - test := shared.NewRPTest(t, name, []shared.TestStep{ + test := rp.NewRPTest(t, name, []rp.TestStep{ { Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage(), "password=guest", testutil.GetBicepRecipeRegistry(), testutil.GetBicepRecipeVersion()), RPResources: &validation.RPResourceSet{ diff --git a/test/functional-portable/messagingrp/noncloud/resources/testdata/msgrp-resources-rabbitmq-recipe.bicep b/test/functional-portable/messagingrp/noncloud/resources/testdata/msgrp-resources-rabbitmq-recipe.bicep index 499281a5aa..a7860e9264 100644 --- a/test/functional-portable/messagingrp/noncloud/resources/testdata/msgrp-resources-rabbitmq-recipe.bicep +++ b/test/functional-portable/messagingrp/noncloud/resources/testdata/msgrp-resources-rabbitmq-recipe.bicep @@ -30,7 +30,7 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { 'Applications.Messaging/rabbitMQQueues': { default: { templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/rabbitmq-recipe:${version}' + templatePath: '${registry}/test/testrecipes/test-bicep-recipes/rabbitmq-recipe:${version}' parameters: { password: password } diff --git a/test/functional-portable/samples/noncloud/testdata/tutorial-environment.bicep b/test/functional-portable/samples/noncloud/testdata/tutorial-environment.bicep index bdb8ee0302..3301e213fb 100644 --- a/test/functional-portable/samples/noncloud/testdata/tutorial-environment.bicep +++ b/test/functional-portable/samples/noncloud/testdata/tutorial-environment.bicep @@ -15,7 +15,7 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = { 'Applications.Datastores/redisCaches': { default: { templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/redis-recipe-value-backed:${version}' + templatePath: '${registry}/test/testrecipes/test-bicep-recipes/redis-recipe-value-backed:${version}' } } } diff --git a/test/functional-portable/samples/noncloud/tutorial_test.go b/test/functional-portable/samples/noncloud/tutorial_test.go index 25eb6a3e8d..9fd6f18db0 100644 --- a/test/functional-portable/samples/noncloud/tutorial_test.go +++ b/test/functional-portable/samples/noncloud/tutorial_test.go @@ -30,7 +30,7 @@ import ( "time" "github.com/radius-project/radius/pkg/kubernetes" - "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" @@ -64,7 +64,7 @@ func Test_FirstApplicationSample(t *testing.T) { appName := "demo" appNamespace := "tutorial-demo" - test := shared.NewRPTest(t, appName, []shared.TestStep{ + test := rp.NewRPTest(t, appName, []rp.TestStep{ { Executor: step.NewDeployExecutor("testdata/tutorial-environment.bicep", testutil.GetBicepRecipeRegistry(), testutil.GetBicepRecipeVersion()), SkipKubernetesOutputResourceValidation: true, @@ -89,7 +89,7 @@ func Test_FirstApplicationSample(t *testing.T) { }, }, }, - PostStepVerify: func(ctx context.Context, t *testing.T, ct shared.RPTest) { + PostStepVerify: func(ctx context.Context, t *testing.T, ct rp.RPTest) { // Set up pod port-forwarding for the pod for i := 1; i <= retries; i++ { t.Logf("Setting up portforward (attempt %d/%d)", i, retries) @@ -120,7 +120,7 @@ func Test_FirstApplicationSample(t *testing.T) { test.Test(t) } -func testWithPortForward(t *testing.T, ctx context.Context, at shared.RPTest, namespace string, container string, remotePort int) error { +func testWithPortForward(t *testing.T, ctx context.Context, at rp.RPTest, namespace string, container string, remotePort int) error { // stopChan will close the port-forward connection on close stopChan := make(chan struct{}) diff --git a/test/functional-portable/ucp/noncloud/tracked_resource_test.go b/test/functional-portable/ucp/noncloud/tracked_resource_test.go index 5ed7375afe..750715218e 100644 --- a/test/functional-portable/ucp/noncloud/tracked_resource_test.go +++ b/test/functional-portable/ucp/noncloud/tracked_resource_test.go @@ -31,7 +31,7 @@ import ( "github.com/radius-project/radius/pkg/sdk" ucp "github.com/radius-project/radius/pkg/ucp/api/v20231001preview" "github.com/radius-project/radius/pkg/ucp/resources" - "github.com/radius-project/radius/test/functional/shared" + corerptest "github.com/radius-project/radius/test/rp" "github.com/radius-project/radius/test/testcontext" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -45,7 +45,7 @@ func Test_TrackedResources(t *testing.T) { } ctx := testcontext.New(t) - options := shared.NewRPTestOptions(t) + options := corerptest.NewRPTestOptions(t) resourceGroupID := resources.MustParse("/planes/radius/local/resourcegroups/test-" + uuid.New().String()) rgc, err := ucp.NewResourceGroupsClient(&aztoken.AnonymousCredential{}, sdk.NewClientOptions(options.Connection)) diff --git a/test/functional/README.md b/test/functional/README.md deleted file mode 100644 index dfc9c96b3e..0000000000 --- a/test/functional/README.md +++ /dev/null @@ -1,3 +0,0 @@ -* [Writing functional tests](../../docs/contributing/contributing-code/contributing-code-tests/writing-functional-tests.md) - -* [Running functional tests](../../docs/contributing/contributing-code/contributing-code-tests/running-functional-tests.md) diff --git a/test/functional/shared/resources/kubemetadata_httproute_test.go b/test/functional/shared/resources/kubemetadata_httproute_test.go deleted file mode 100644 index 3b9df23c26..0000000000 --- a/test/functional/shared/resources/kubemetadata_httproute_test.go +++ /dev/null @@ -1,90 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package resource_test - -import ( - "context" - "testing" - - "github.com/radius-project/radius/test/functional/shared" - "github.com/radius-project/radius/test/step" - "github.com/radius-project/radius/test/testutil" - "github.com/radius-project/radius/test/validation" - "github.com/stretchr/testify/require" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -func Test_KubeMetadataHTTPRoute(t *testing.T) { - template := "testdata/corerp-resources-httproute-kubernetesmetadata.bicep" - name := "corerp-app-rte-kme" - appNamespace := "corerp-ns-rte-kme-app" - - expectedAnnotations := map[string]string{ - "user.ann.1": "user.ann.val.1", - "user.ann.2": "user.ann.val.2", - } - - expectedLabels := map[string]string{ - "app.kubernetes.io/managed-by": "radius-rp", - "app.kubernetes.io/name": "ctnr-rte-kme-ctnr", - "app.kubernetes.io/part-of": "corerp-app-rte-kme", - "radapp.io/application": "corerp-app-rte-kme", - "radapp.io/resource": "ctnr-rte-kme-ctnr", - "radapp.io/resource-type": "applications.core-containers", - "user.lbl.1": "user.lbl.val.1", - "user.lbl.2": "user.lbl.val.2", - } - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: name, - Type: validation.ApplicationsResource, - }, - { - Name: "ctnr-rte-kme-ctnr", - Type: validation.ContainersResource, - App: name, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "ctnr-rte-kme-ctnr"), - validation.NewK8sServiceForResource(name, "ctnr-rte-kme-ctnr"), - }, - }, - }, - PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { - - // Verify service labels and annotations - service, err := test.Options.K8sClient.CoreV1().Services(appNamespace).Get(ctx, "ctnr-rte-kme-ctnr", metav1.GetOptions{}) - require.NoError(t, err) - require.NotNil(t, service) - - require.Truef(t, testutil.IsMapSubSet(expectedAnnotations, service.Annotations), "Annotations do not match. expected: %v, actual: %v", expectedAnnotations, service.Annotations) - require.Truef(t, testutil.IsMapSubSet(expectedLabels, service.Labels), "Labels do not match. expected: %v, actual: %v", expectedLabels, service.Labels) - }, - }, - }) - - test.Test(t) -} diff --git a/test/functional/shared/test.go b/test/functional/shared/test.go deleted file mode 100644 index de9f1f0d97..0000000000 --- a/test/functional/shared/test.go +++ /dev/null @@ -1,105 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package shared - -import ( - "strings" - "testing" - - "github.com/aws/aws-sdk-go-v2/service/cloudcontrol" - "github.com/stretchr/testify/require" - - awsconfig "github.com/aws/aws-sdk-go-v2/config" - "github.com/radius-project/radius/pkg/azure/clientv2" - aztoken "github.com/radius-project/radius/pkg/azure/tokencredentials" - "github.com/radius-project/radius/pkg/cli" - "github.com/radius-project/radius/pkg/cli/clients" - "github.com/radius-project/radius/pkg/cli/connections" - "github.com/radius-project/radius/pkg/cli/workspaces" - "github.com/radius-project/radius/pkg/sdk" - "github.com/radius-project/radius/pkg/ucp/aws" - "github.com/radius-project/radius/test" - "github.com/radius-project/radius/test/testcontext" - "github.com/radius-project/radius/test/testutil" -) - -// NewRPTestOptions sets up the test environment by loading configs, creating a test context, creating an -// ApplicationsManagementClient, creating an AWSCloudControlClient, and returning an RPTestOptions struct. -func NewRPTestOptions(t *testing.T) RPTestOptions { - registry, tag := testutil.SetDefault() - t.Logf("Using container registry: %s - set DOCKER_REGISTRY to override", registry) - t.Logf("Using container tag: %s - set REL_VERSION to override", tag) - t.Logf("Using magpie image: %s/magpiego:%s", registry, tag) - - _, bicepRecipeRegistry, _ := strings.Cut(testutil.GetBicepRecipeRegistry(), "=") - _, bicepRecipeTag, _ := strings.Cut(testutil.GetBicepRecipeVersion(), "=") - t.Logf("Using recipe registry: %s - set BICEP_RECIPE_REGISTRY to override", bicepRecipeRegistry) - t.Logf("Using recipe tag: %s - set BICEP_RECIPE_TAG_VERSION to override", bicepRecipeTag) - - _, terraformRecipeModuleServerURL, _ := strings.Cut(testutil.GetTerraformRecipeModuleServerURL(), "=") - t.Logf("Using terraform recipe module server URL: %s - set TF_RECIPE_MODULE_SERVER_URL to override", terraformRecipeModuleServerURL) - - ctx := testcontext.New(t) - - config, err := cli.LoadConfig("") - require.NoError(t, err, "failed to read radius config") - - workspace, err := cli.GetWorkspace(config, "") - require.NoError(t, err, "failed to read default workspace") - require.NotNil(t, workspace, "default workspace is not set") - - t.Logf("Loaded workspace: %s (%s)", workspace.Name, workspace.FmtConnection()) - - client, err := connections.DefaultFactory.CreateApplicationsManagementClient(ctx, *workspace) - require.NoError(t, err, "failed to create ApplicationsManagementClient") - - connection, err := workspace.Connect() - require.NoError(t, err, "failed to connect to workspace") - - customAction, err := clientv2.NewCustomActionClient("", &clientv2.Options{ - BaseURI: strings.TrimRight(connection.Endpoint(), "/"), - Cred: &aztoken.AnonymousCredential{}, - }, sdk.NewClientOptions(connection)) - require.NoError(t, err, "failed to create CustomActionClient") - - cfg, err := awsconfig.LoadDefaultConfig(ctx) - require.NoError(t, err) - var awsClient aws.AWSCloudControlClient = cloudcontrol.NewFromConfig(cfg) - - return RPTestOptions{ - TestOptions: test.NewTestOptions(t), - Workspace: workspace, - CustomAction: customAction, - ManagementClient: client, - AWSClient: awsClient, - Connection: connection, - } -} - -type RPTestOptions struct { - test.TestOptions - - CustomAction *clientv2.CustomActionClient - ManagementClient clients.ApplicationsManagementClient - AWSClient aws.AWSCloudControlClient - - // Connection gets access to the Radius connection which can be used to create API clients. - Connection sdk.Connection - - // Workspace gets access to the Radius workspace which can be used to create API clients. - Workspace *workspaces.Workspace -} diff --git a/test/functional/shared/rptest.go b/test/rp/rptest.go similarity index 82% rename from test/functional/shared/rptest.go rename to test/rp/rptest.go index 427fa70219..ed9b515b0d 100644 --- a/test/functional/shared/rptest.go +++ b/test/rp/rptest.go @@ -14,16 +14,18 @@ See the License for the specific language governing permissions and limitations under the License. */ -package shared +package rp import ( "context" "fmt" "os" + "strings" "sync" "testing" "time" + "github.com/aws/aws-sdk-go-v2/service/cloudcontrol" "github.com/stretchr/testify/require" apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -32,11 +34,21 @@ import ( "k8s.io/client-go/discovery" "sigs.k8s.io/controller-runtime/pkg/client" + awsconfig "github.com/aws/aws-sdk-go-v2/config" + "github.com/radius-project/radius/pkg/azure/clientv2" + aztoken "github.com/radius-project/radius/pkg/azure/tokencredentials" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/connections" "github.com/radius-project/radius/pkg/cli/kubernetes" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/sdk" + "github.com/radius-project/radius/pkg/ucp/aws" "github.com/radius-project/radius/test" "github.com/radius-project/radius/test/radcli" "github.com/radius-project/radius/test/step" "github.com/radius-project/radius/test/testcontext" + "github.com/radius-project/radius/test/testutil" "github.com/radius-project/radius/test/validation" ) @@ -88,6 +100,20 @@ const ( RequiredFeatureValidatorTypeCloud RequiredFeatureValidatorType = "ValidatorCloud" ) +type RPTestOptions struct { + test.TestOptions + + CustomAction *clientv2.CustomActionClient + ManagementClient clients.ApplicationsManagementClient + AWSClient aws.AWSCloudControlClient + + // Connection gets access to the Radius connection which can be used to create API clients. + Connection sdk.Connection + + // Workspace gets access to the Radius workspace which can be used to create API clients. + Workspace *workspaces.Workspace +} + type TestStep struct { Executor step.Executor RPResources *validation.RPResourceSet @@ -118,6 +144,59 @@ type TestOptions struct { DiscoveryClient discovery.DiscoveryInterface } +// NewRPTestOptions sets up the test environment by loading configs, creating a test context, creating an +// ApplicationsManagementClient, creating an AWSCloudControlClient, and returning an RPTestOptions struct. +func NewRPTestOptions(t *testing.T) RPTestOptions { + registry, tag := testutil.SetDefault() + t.Logf("Using container registry: %s - set DOCKER_REGISTRY to override", registry) + t.Logf("Using container tag: %s - set REL_VERSION to override", tag) + t.Logf("Using magpie image: %s/magpiego:%s", registry, tag) + + _, bicepRecipeRegistry, _ := strings.Cut(testutil.GetBicepRecipeRegistry(), "=") + _, bicepRecipeTag, _ := strings.Cut(testutil.GetBicepRecipeVersion(), "=") + t.Logf("Using recipe registry: %s - set BICEP_RECIPE_REGISTRY to override", bicepRecipeRegistry) + t.Logf("Using recipe tag: %s - set BICEP_RECIPE_TAG_VERSION to override", bicepRecipeTag) + + _, terraformRecipeModuleServerURL, _ := strings.Cut(testutil.GetTerraformRecipeModuleServerURL(), "=") + t.Logf("Using terraform recipe module server URL: %s - set TF_RECIPE_MODULE_SERVER_URL to override", terraformRecipeModuleServerURL) + + ctx := testcontext.New(t) + + config, err := cli.LoadConfig("") + require.NoError(t, err, "failed to read radius config") + + workspace, err := cli.GetWorkspace(config, "") + require.NoError(t, err, "failed to read default workspace") + require.NotNil(t, workspace, "default workspace is not set") + + t.Logf("Loaded workspace: %s (%s)", workspace.Name, workspace.FmtConnection()) + + client, err := connections.DefaultFactory.CreateApplicationsManagementClient(ctx, *workspace) + require.NoError(t, err, "failed to create ApplicationsManagementClient") + + connection, err := workspace.Connect() + require.NoError(t, err, "failed to connect to workspace") + + customAction, err := clientv2.NewCustomActionClient("", &clientv2.Options{ + BaseURI: strings.TrimRight(connection.Endpoint(), "/"), + Cred: &aztoken.AnonymousCredential{}, + }, sdk.NewClientOptions(connection)) + require.NoError(t, err, "failed to create CustomActionClient") + + cfg, err := awsconfig.LoadDefaultConfig(ctx) + require.NoError(t, err) + var awsClient aws.AWSCloudControlClient = cloudcontrol.NewFromConfig(cfg) + + return RPTestOptions{ + TestOptions: test.NewTestOptions(t), + Workspace: workspace, + CustomAction: customAction, + ManagementClient: client, + AWSClient: awsClient, + Connection: connection, + } +} + // NewTestOptions creates a new TestOptions object with the given testing.T object. func NewTestOptions(t *testing.T) TestOptions { return TestOptions{TestOptions: test.NewTestOptions(t)} diff --git a/test/functional/shared/resources/testdata/modules/redis-selfhost.bicep b/test/testrecipes/modules/redis-selfhost.bicep similarity index 100% rename from test/functional/shared/resources/testdata/modules/redis-selfhost.bicep rename to test/testrecipes/modules/redis-selfhost.bicep diff --git a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/README.md b/test/testrecipes/test-bicep-recipes/README.md similarity index 83% rename from test/functional/shared/resources/testdata/recipes/test-bicep-recipes/README.md rename to test/testrecipes/test-bicep-recipes/README.md index 22ac1bf1bc..1fe19b3572 100644 --- a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/README.md +++ b/test/testrecipes/test-bicep-recipes/README.md @@ -2,7 +2,7 @@ The recipes in this folder are published as part of the PR process to: -> `ghcr.io/radius-project/dev/test/functional/shared/recipes/:pr-` +> `ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/:pr-` This is important because it allows us to make changes to the recipes, and test them in the same PR that contains the change. diff --git a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/_resource-creation.bicep b/test/testrecipes/test-bicep-recipes/_resource-creation.bicep similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-bicep-recipes/_resource-creation.bicep rename to test/testrecipes/test-bicep-recipes/_resource-creation.bicep diff --git a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/context-parameter.bicep b/test/testrecipes/test-bicep-recipes/context-parameter.bicep similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-bicep-recipes/context-parameter.bicep rename to test/testrecipes/test-bicep-recipes/context-parameter.bicep diff --git a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/corerp-redis-recipe.bicep b/test/testrecipes/test-bicep-recipes/corerp-redis-recipe.bicep similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-bicep-recipes/corerp-redis-recipe.bicep rename to test/testrecipes/test-bicep-recipes/corerp-redis-recipe.bicep diff --git a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/dapr-pubsub-broker.bicep b/test/testrecipes/test-bicep-recipes/dapr-pubsub-broker.bicep similarity index 92% rename from test/functional/shared/resources/testdata/recipes/test-bicep-recipes/dapr-pubsub-broker.bicep rename to test/testrecipes/test-bicep-recipes/dapr-pubsub-broker.bicep index 71dfd3c686..88c6ab7de5 100644 --- a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/dapr-pubsub-broker.bicep +++ b/test/testrecipes/test-bicep-recipes/dapr-pubsub-broker.bicep @@ -5,7 +5,7 @@ import kubernetes as kubernetes { param context object -module redis '../../modules/redis-selfhost.bicep' = { +module redis '../../../test/testrecipes/modules/redis-selfhost.bicep' = { name: 'redis-${uniqueString(context.resource.id)}' params: { name: 'redis-${uniqueString(context.resource.id)}' diff --git a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/dapr-secret-store.bicep b/test/testrecipes/test-bicep-recipes/dapr-secret-store.bicep similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-bicep-recipes/dapr-secret-store.bicep rename to test/testrecipes/test-bicep-recipes/dapr-secret-store.bicep diff --git a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/dapr-state-store.bicep b/test/testrecipes/test-bicep-recipes/dapr-state-store.bicep similarity index 92% rename from test/functional/shared/resources/testdata/recipes/test-bicep-recipes/dapr-state-store.bicep rename to test/testrecipes/test-bicep-recipes/dapr-state-store.bicep index 181ccc006e..6d0b8c5bc8 100644 --- a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/dapr-state-store.bicep +++ b/test/testrecipes/test-bicep-recipes/dapr-state-store.bicep @@ -5,7 +5,7 @@ import kubernetes as kubernetes { param context object -module redis '../../modules/redis-selfhost.bicep' = { +module redis '../../../test/testrecipes/modules/redis-selfhost.bicep' = { name: 'redis-${uniqueString(context.resource.id)}' params: { name: 'redis-${uniqueString(context.resource.id)}' diff --git a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/empty-recipe.bicep b/test/testrecipes/test-bicep-recipes/empty-recipe.bicep similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-bicep-recipes/empty-recipe.bicep rename to test/testrecipes/test-bicep-recipes/empty-recipe.bicep diff --git a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/extender-recipe.bicep b/test/testrecipes/test-bicep-recipes/extender-recipe.bicep similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-bicep-recipes/extender-recipe.bicep rename to test/testrecipes/test-bicep-recipes/extender-recipe.bicep diff --git a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/extenders-aws-s3-recipe.bicep b/test/testrecipes/test-bicep-recipes/extenders-aws-s3-recipe.bicep similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-bicep-recipes/extenders-aws-s3-recipe.bicep rename to test/testrecipes/test-bicep-recipes/extenders-aws-s3-recipe.bicep diff --git a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/language-failure.bicep b/test/testrecipes/test-bicep-recipes/language-failure.bicep similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-bicep-recipes/language-failure.bicep rename to test/testrecipes/test-bicep-recipes/language-failure.bicep diff --git a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/mongodb-recipe-context.bicep b/test/testrecipes/test-bicep-recipes/mongodb-recipe-context.bicep similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-bicep-recipes/mongodb-recipe-context.bicep rename to test/testrecipes/test-bicep-recipes/mongodb-recipe-context.bicep diff --git a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/mongodb-recipe-kubernetes.bicep b/test/testrecipes/test-bicep-recipes/mongodb-recipe-kubernetes.bicep similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-bicep-recipes/mongodb-recipe-kubernetes.bicep rename to test/testrecipes/test-bicep-recipes/mongodb-recipe-kubernetes.bicep diff --git a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/parameters-outputs.bicep b/test/testrecipes/test-bicep-recipes/parameters-outputs.bicep similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-bicep-recipes/parameters-outputs.bicep rename to test/testrecipes/test-bicep-recipes/parameters-outputs.bicep diff --git a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/rabbitmq-recipe.bicep b/test/testrecipes/test-bicep-recipes/rabbitmq-recipe.bicep similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-bicep-recipes/rabbitmq-recipe.bicep rename to test/testrecipes/test-bicep-recipes/rabbitmq-recipe.bicep diff --git a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/redis-recipe-value-backed.bicep b/test/testrecipes/test-bicep-recipes/redis-recipe-value-backed.bicep similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-bicep-recipes/redis-recipe-value-backed.bicep rename to test/testrecipes/test-bicep-recipes/redis-recipe-value-backed.bicep diff --git a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/resource-creation-failure.bicep b/test/testrecipes/test-bicep-recipes/resource-creation-failure.bicep similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-bicep-recipes/resource-creation-failure.bicep rename to test/testrecipes/test-bicep-recipes/resource-creation-failure.bicep diff --git a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/resource-creation.bicep b/test/testrecipes/test-bicep-recipes/resource-creation.bicep similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-bicep-recipes/resource-creation.bicep rename to test/testrecipes/test-bicep-recipes/resource-creation.bicep diff --git a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/sqldb-recipe.bicep b/test/testrecipes/test-bicep-recipes/sqldb-recipe.bicep similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-bicep-recipes/sqldb-recipe.bicep rename to test/testrecipes/test-bicep-recipes/sqldb-recipe.bicep diff --git a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/wrong-output.bicep b/test/testrecipes/test-bicep-recipes/wrong-output.bicep similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-bicep-recipes/wrong-output.bicep rename to test/testrecipes/test-bicep-recipes/wrong-output.bicep diff --git a/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/README.md b/test/testrecipes/test-terraform-recipes/README.md similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-terraform-recipes/README.md rename to test/testrecipes/test-terraform-recipes/README.md diff --git a/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/azure-storage/main.tf b/test/testrecipes/test-terraform-recipes/azure-storage/azure-storage/main.tf similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-terraform-recipes/azure-storage/main.tf rename to test/testrecipes/test-terraform-recipes/azure-storage/azure-storage/main.tf diff --git a/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/azure-storage/output.tf b/test/testrecipes/test-terraform-recipes/azure-storage/azure-storage/output.tf similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-terraform-recipes/azure-storage/output.tf rename to test/testrecipes/test-terraform-recipes/azure-storage/azure-storage/output.tf diff --git a/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/azure-storage/variables.tf b/test/testrecipes/test-terraform-recipes/azure-storage/azure-storage/variables.tf similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-terraform-recipes/azure-storage/variables.tf rename to test/testrecipes/test-terraform-recipes/azure-storage/azure-storage/variables.tf diff --git a/test/testrecipes/test-terraform-recipes/azure-storage/main.tf b/test/testrecipes/test-terraform-recipes/azure-storage/main.tf new file mode 100644 index 0000000000..8655f5fa5d --- /dev/null +++ b/test/testrecipes/test-terraform-recipes/azure-storage/main.tf @@ -0,0 +1,32 @@ +terraform { + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = "~> 3.0.0" + } + } +} + +resource "random_id" "unique_name" { + byte_length = 8 +} + +resource "azurerm_storage_account" "test_storage_account" { + name = "acct${random_id.unique_name.hex}" + resource_group_name = var.resource_group_name + location = var.location + account_tier = "Standard" + account_replication_type = "LRS" +} + +resource "azurerm_storage_container" "test_container" { + name = "ctr${random_id.unique_name.hex}" + storage_account_name = azurerm_storage_account.test_storage_account.name +} + +resource "azurerm_storage_blob" "test_blob" { + name = "blob${random_id.unique_name.hex}" + storage_account_name = azurerm_storage_account.test_storage_account.name + storage_container_name = azurerm_storage_container.test_container.name + type = "Block" +} \ No newline at end of file diff --git a/test/testrecipes/test-terraform-recipes/azure-storage/output.tf b/test/testrecipes/test-terraform-recipes/azure-storage/output.tf new file mode 100644 index 0000000000..a4026b54f3 --- /dev/null +++ b/test/testrecipes/test-terraform-recipes/azure-storage/output.tf @@ -0,0 +1,5 @@ +output "result" { + value = { + resources = [azurerm_storage_account.test_storage_account.id] + } +} \ No newline at end of file diff --git a/test/testrecipes/test-terraform-recipes/azure-storage/variables.tf b/test/testrecipes/test-terraform-recipes/azure-storage/variables.tf new file mode 100644 index 0000000000..b448fb39f2 --- /dev/null +++ b/test/testrecipes/test-terraform-recipes/azure-storage/variables.tf @@ -0,0 +1,7 @@ +variable "resource_group_name" { + type = string +} + +variable "location" { + type = string +} \ No newline at end of file diff --git a/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/k8ssecret-context/main.tf b/test/testrecipes/test-terraform-recipes/k8ssecret-context/main.tf similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-terraform-recipes/k8ssecret-context/main.tf rename to test/testrecipes/test-terraform-recipes/k8ssecret-context/main.tf diff --git a/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/k8ssecret-context/variables.tf b/test/testrecipes/test-terraform-recipes/k8ssecret-context/variables.tf similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-terraform-recipes/k8ssecret-context/variables.tf rename to test/testrecipes/test-terraform-recipes/k8ssecret-context/variables.tf diff --git a/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/kubernetes-redis/modules/main.tf b/test/testrecipes/test-terraform-recipes/kubernetes-redis/modules/main.tf similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-terraform-recipes/kubernetes-redis/modules/main.tf rename to test/testrecipes/test-terraform-recipes/kubernetes-redis/modules/main.tf diff --git a/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/kubernetes-redis/modules/variables.tf b/test/testrecipes/test-terraform-recipes/kubernetes-redis/modules/variables.tf similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-terraform-recipes/kubernetes-redis/modules/variables.tf rename to test/testrecipes/test-terraform-recipes/kubernetes-redis/modules/variables.tf diff --git a/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/parameter-outputs/output.tf b/test/testrecipes/test-terraform-recipes/parameter-outputs/output.tf similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-terraform-recipes/parameter-outputs/output.tf rename to test/testrecipes/test-terraform-recipes/parameter-outputs/output.tf diff --git a/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/parameter-outputs/variables.tf b/test/testrecipes/test-terraform-recipes/parameter-outputs/variables.tf similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-terraform-recipes/parameter-outputs/variables.tf rename to test/testrecipes/test-terraform-recipes/parameter-outputs/variables.tf diff --git a/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/wrong-output/output.tf b/test/testrecipes/test-terraform-recipes/wrong-output/output.tf similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-terraform-recipes/wrong-output/output.tf rename to test/testrecipes/test-terraform-recipes/wrong-output/output.tf diff --git a/versions.yaml b/versions.yaml index 6793141bc4..890c1332bc 100644 --- a/versions.yaml +++ b/versions.yaml @@ -1,4 +1,6 @@ supported: + - channel: '0.32' + version: 'v0.32.0-rc1' - channel: '0.31' version: 'v0.31.0' deprecated: