Skip to content

Commit

Permalink
Change test organization for shared tests. (#7227)
Browse files Browse the repository at this point in the history
# Description

- Change test organization for shared tests. These tests are now
organized under the corerp directory.
- Separate cloud/non-cloud tests
- Organize the corerp tests as per
radius-project/design-notes#35. There will be
more PRs that will follow to re-org the other tests.

## Type of change

<!--

Please select **one** of the following options that describes your
change and delete the others. Clearly identifying the type of change you
are making will help us review your PR faster, and is used in authoring
release notes.

If you are making a bug fix or functionality change to Radius and do not
have an associated issue link please create one now.

-->

- This pull request adds or changes features of Radius and has an
approved issue (#6588 ).

<!--

Please update the following to link the associated issue. This is
required for some kinds of changes (see above).

-->

Fixes: Fixes part of
#6588. This is a part of
a multi-PR fix

---------

Signed-off-by: vinayada1 <[email protected]>
  • Loading branch information
vinayada1 authored Mar 26, 2024
1 parent 166d872 commit dc8e1b2
Show file tree
Hide file tree
Showing 172 changed files with 613 additions and 577 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/functional-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/<name>:${{ env.REL_VERSION }}`
* Bicep recipe location `${{ env.BICEP_RECIPE_REGISTRY }}/test/testrecipes/test-bicep-recipes/<name>:${{ env.REL_VERSION }}`
* Terraform recipe location `${{ env.TF_RECIPE_MODULE_SERVER_URL }}/<name>.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 }}`
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/long-running-azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ jobs:
<summary> Click here to see the list of tools in the current test run</summary>
* gotestsum ${{ env.GOTESTSUM_VER }}
* Bicep recipe location `${{ env.BICEP_RECIPE_REGISTRY }}/test/functional/shared/recipes/<name>:${{ steps.gen-id.outputs.REL_VERSION }}`
* Bicep recipe location `${{ env.BICEP_RECIPE_REGISTRY }}/test/testrecipes/test-bicep-recipes/<name>:${{ steps.gen-id.outputs.REL_VERSION }}`
* Terraform recipe location `${{ env.TF_RECIPE_MODULE_SERVER_URL }}/<name>.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 }}`
Expand Down
10 changes: 5 additions & 5 deletions build/recipes.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ TERRAFORM_MODULE_CONFIGMAP_NAME=tf-module-server-content
publish-test-bicep-recipes: ## Publishes test recipes to <BICEP_RECIPE_REGISTRY> with version <BICEP_RECIPE_TAG_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
publish-test-terraform-recipes: ## Publishes test terraform recipes to the current Kubernetes cluster
@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)

Expand Down
9 changes: 7 additions & 2 deletions build/test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
@@ -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|
|-|-|
Expand Down
37 changes: 19 additions & 18 deletions test/functional-portable/cli/noncloud/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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{
Expand All @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand Down Expand Up @@ -89,5 +89,7 @@ func Test_AWSRedeployWithUpdatedResourceUpdatesResource(t *testing.T) {
},
},
})

test.RequiredFeatures = []rp.RequiredFeature{rp.FeatureAWS}
test.Test(t)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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,
Expand Down Expand Up @@ -64,5 +64,6 @@ func Test_AWS_MultiIdentifier_Resource(t *testing.T) {
},
})

test.RequiredFeatures = []rp.RequiredFeature{rp.FeatureAWS}
test.Test(t)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand Down Expand Up @@ -60,6 +60,7 @@ func Test_AWS_S3Bucket(t *testing.T) {
},
})

test.RequiredFeatures = []rp.RequiredFeature{rp.FeatureAWS}
test.Test(t)
}

Expand All @@ -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,
Expand Down Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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{
Expand All @@ -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)
}
Loading

0 comments on commit dc8e1b2

Please sign in to comment.