Skip to content

Commit

Permalink
Change test organization for shared tests. These tests are now organi…
Browse files Browse the repository at this point in the history
…zed under the corerp directory. Note that cli tests are no longer a part of the corerp tests

Signed-off-by: vinayada1 <[email protected]>
  • Loading branch information
vinayada1 committed Mar 1, 2024
1 parent e3c8e51 commit c396bb0
Show file tree
Hide file tree
Showing 160 changed files with 290 additions and 289 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/functional-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,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/functional-portable/corerp/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 Expand Up @@ -307,7 +307,7 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest]
name: [ucp,kubernetes,shared,msgrp,daprrp,samples]
name: [ucp,kubernetes,corerp,msgrp,daprrp,samples]
include:
# datastorerp functional tests need the larger VM.
- os: ubuntu-latest-m
Expand Down
11 changes: 8 additions & 3 deletions build/test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,21 @@ test-get-envtools:
test-validate-cli: ## Run cli integration tests
CGO_ENABLED=1 $(GOTEST_TOOL) -coverpkg= ./pkg/cli/cmd/... ./cmd/rad/... -timeout ${TEST_TIMEOUT} -v -parallel 5 $(GOTEST_OPTS)

test-functional-all: test-functional-ucp test-functional-kubernetes test-functional-shared test-functional-msgrp test-functional-daprrp test-functional-datastoresrp test-functional-samples ## Runs all functional tests
test-functional-all: test-functional-ucp test-functional-kubernetes test-functional-corerp test-functional-msgrp test-functional-daprrp test-functional-datastoresrp test-functional-samples ## Runs all functional tests

test-functional-ucp: ## Runs UCP functional tests
CGO_ENABLED=1 $(GOTEST_TOOL) ./test/functional/ucp/... -timeout ${TEST_TIMEOUT} -v -parallel 5 $(GOTEST_OPTS)

test-functional-kubernetes: ## Runs Kubernetes functional tests
CGO_ENABLED=1 $(GOTEST_TOOL) ./test/functional/kubernetes/... -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-corerp: test-functional-corerp-noncloud test-functional-corerp-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: ## Runs Messaging RP functional tests
CGO_ENABLED=1 $(GOTEST_TOOL) ./test/functional/messagingrp/... -timeout ${TEST_TIMEOUT} -v -parallel 2 $(GOTEST_OPTS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package shared
package corerp

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"github.com/google/uuid"
"github.com/radius-project/radius/test/functional"
"github.com/radius-project/radius/test/functional/shared"
"github.com/radius-project/radius/test/functional-portable/corerp"
"github.com/radius-project/radius/test/step"
"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 := functional.GetCreationTimestamp()

test := shared.NewRPTest(t, name, []shared.TestStep{
test := corerp.NewRPTest(t, name, []corerp.TestStep{
{
Executor: step.NewDeployExecutor(fmt.Sprintf(templateFmt, 1), "bucketName="+name, "creationTimestamp="+creationTimestamp),
SkipKubernetesOutputResourceValidation: true,
Expand Down
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/functional-portable/corerp"
"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 := corerp.NewRPTest(t, testName, []corerp.TestStep{
{
Executor: step.NewDeployExecutor(template, "filterName="+filterName, "logGroupName="+logGroupName, "creationTimestamp="+creationTimestamp),
SkipKubernetesOutputResourceValidation: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"testing"

"github.com/radius-project/radius/test/functional"
"github.com/radius-project/radius/test/functional/shared"
"github.com/radius-project/radius/test/functional-portable/corerp"
"github.com/radius-project/radius/test/step"
"github.com/radius-project/radius/test/validation"
)
Expand All @@ -30,7 +30,7 @@ func Test_AWS_S3Bucket(t *testing.T) {
name := functional.GenerateS3BucketName()
creationTimestamp := functional.GetCreationTimestamp()

test := shared.NewRPTest(t, name, []shared.TestStep{
test := corerp.NewRPTest(t, name, []corerp.TestStep{
{
Executor: step.NewDeployExecutor(template, "bucketName="+name, "creationTimestamp="+creationTimestamp),
SkipKubernetesOutputResourceValidation: true,
Expand Down Expand Up @@ -69,7 +69,7 @@ func Test_AWS_S3Bucket_Existing(t *testing.T) {
name := functional.GenerateS3BucketName()
creationTimestamp := functional.GetCreationTimestamp()

test := shared.NewRPTest(t, name, []shared.TestStep{
test := corerp.NewRPTest(t, name, []corerp.TestStep{
{
Executor: step.NewDeployExecutor(template, "bucketName="+name, "creationTimestamp="+creationTimestamp),
SkipKubernetesOutputResourceValidation: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"testing"

"github.com/radius-project/radius/test/functional"
"github.com/radius-project/radius/test/functional/shared"
"github.com/radius-project/radius/test/functional-portable/corerp"
"github.com/radius-project/radius/test/step"
"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 := corerp.NewRPTest(t, name, []corerp.TestStep{
{
Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), cosmosmongodbresourceid),
RPResources: &validation.RPResourceSet{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"testing"

"github.com/radius-project/radius/test/functional"
"github.com/radius-project/radius/test/functional/shared"
"github.com/radius-project/radius/test/functional-portable/corerp"
"github.com/radius-project/radius/test/step"
"github.com/radius-project/radius/test/validation"
)
Expand All @@ -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 := corerp.NewRPTest(t, name, []corerp.TestStep{
{
Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), functional.GetOIDCIssuer()),
RPResources: &validation.RPResourceSet{
Expand Down Expand Up @@ -64,7 +64,7 @@ func Test_PersistentVolume(t *testing.T) {
},
},
})
test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureCSIDriver}
test.RequiredFeatures = []corerp.RequiredFeature{corerp.FeatureCSIDriver}

test.Test(t)
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (
"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"
"github.com/radius-project/radius/test/functional/shared"
"github.com/radius-project/radius/test/functional-portable/corerp"
"github.com/radius-project/radius/test/step"
"github.com/radius-project/radius/test/validation"
)
Expand All @@ -66,7 +66,7 @@ func Test_TerraformRecipe_KubernetesRedis(t *testing.T) {
secretSuffix, err := getSecretSuffix("/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/extenders/"+name, envName, appName)
require.NoError(t, err)

test := shared.NewRPTest(t, name, []shared.TestStep{
test := corerp.NewRPTest(t, name, []corerp.TestStep{
{
Executor: step.NewDeployExecutor(template, functional.GetTerraformRecipeModuleServerURL(), "appName="+appName, "redisCacheName="+redisCacheName),
RPResources: &validation.RPResourceSet{
Expand Down Expand Up @@ -102,7 +102,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 corerp.RPTest) {
secret, err := test.Options.K8sClient.CoreV1().Secrets(secretNamespace).
Get(ctx, secretPrefix+secretSuffix, metav1.GetOptions{})
require.NoError(t, err)
Expand All @@ -129,7 +129,7 @@ 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 corerp.RPTest) {
resourceID := "/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/extenders/" + name
testSecretDeletion(t, ctx, test, appName, envName, resourceID)
}
Expand All @@ -145,7 +145,7 @@ func Test_TerraformRecipe_Context(t *testing.T) {
secretSuffix, err := 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 := corerp.NewRPTest(t, name, []corerp.TestStep{
{
Executor: step.NewDeployExecutor(template, functional.GetTerraformRecipeModuleServerURL()),
RPResources: &validation.RPResourceSet{
Expand Down Expand Up @@ -175,7 +175,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 corerp.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)
Expand Down Expand Up @@ -222,7 +222,7 @@ 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 corerp.RPTest) {
resourceID := "/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/extenders/" + name
testSecretDeletion(t, ctx, test, name, name, resourceID)
}
Expand All @@ -237,7 +237,7 @@ func Test_TerraformRecipe_AzureStorage(t *testing.T) {
appName := "corerp-resources-terraform-azstorage-app"
envName := "corerp-resources-terraform-azstorage-env"

test := shared.NewRPTest(t, name, []shared.TestStep{
test := corerp.NewRPTest(t, name, []corerp.TestStep{
{
Executor: step.NewDeployExecutor(template, functional.GetTerraformRecipeModuleServerURL(), "appName="+appName),
RPResources: &validation.RPResourceSet{
Expand All @@ -258,7 +258,7 @@ func Test_TerraformRecipe_AzureStorage(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 corerp.RPTest) {
resourceID := "/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/extenders/" + name
secretSuffix, err := getSecretSuffix(resourceID, envName, appName)
require.NoError(t, err)
Expand All @@ -272,7 +272,7 @@ func Test_TerraformRecipe_AzureStorage(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 corerp.RPTest) {
resourceID := "/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/extenders/" + name
testSecretDeletion(t, ctx, test, appName, envName, resourceID)
}
Expand Down Expand Up @@ -307,7 +307,7 @@ func Test_TerraformRecipe_ParametersAndOutputs(t *testing.T) {
"@" + parametersFilePath,
}

test := shared.NewRPTest(t, name, []shared.TestStep{
test := corerp.NewRPTest(t, name, []corerp.TestStep{
{
Executor: step.NewDeployExecutor(template, parameters...),
RPResources: &validation.RPResourceSet{
Expand All @@ -327,7 +327,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 corerp.RPTest) {
resource, err := test.Options.ManagementClient.ShowResource(ctx, "Applications.Core/extenders", name)
require.NoError(t, err)

Expand Down Expand Up @@ -372,7 +372,7 @@ func Test_TerraformRecipe_WrongOutput(t *testing.T) {
},
})

test := shared.NewRPTest(t, name, []shared.TestStep{
test := corerp.NewRPTest(t, name, []corerp.TestStep{
{
Executor: step.NewDeployErrorExecutor(template, validate, parameters...),
RPResources: &validation.RPResourceSet{
Expand All @@ -394,7 +394,7 @@ 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) {
func testSecretDeletion(t *testing.T, ctx context.Context, test corerp.RPTest, appName, envName, resourceID string) {
secretSuffix, err := getSecretSuffix(resourceID, envName, appName)
require.NoError(t, err)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"testing"

"github.com/radius-project/radius/test/functional"
"github.com/radius-project/radius/test/functional/shared"
"github.com/radius-project/radius/test/functional-portable/corerp"
"github.com/radius-project/radius/test/step"
"github.com/radius-project/radius/test/validation"
)
Expand All @@ -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 := corerp.NewRPTest(t, name, []corerp.TestStep{
{
Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), functional.GetOIDCIssuer()),
RPResources: &validation.RPResourceSet{
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
output "result" {
value = {
resources = [azurerm_storage_account.test_storage_account.id]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
variable "resource_group_name" {
type = string
}

variable "location" {
type = string
}
Loading

0 comments on commit c396bb0

Please sign in to comment.