Skip to content

Commit

Permalink
Re-enable skipped test Test_RecipeCommands (#7080)
Browse files Browse the repository at this point in the history
# Description

This re-enables `Test_RecipeCommands` 

## 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 is a minor refactor, code cleanup, test improvement,
or other maintenance task and doesn't change the functionality of Radius
#6776

<!--

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

-->

Fixes: #6776

---------

Signed-off-by: sk593 <shruthikumar@microsoft.com>
Co-authored-by: Karishma Chawla <kachawla@microsoft.com>
  • Loading branch information
sk593 and kachawla authored Jan 31, 2024
1 parent f3dc14a commit 6108d14
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 38 deletions.
66 changes: 33 additions & 33 deletions test/functional/shared/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,35 +62,48 @@ const (
func verifyRecipeCLI(ctx context.Context, t *testing.T, test shared.RPTest) {
options := shared.NewRPTestOptions(t)
cli := radcli.NewCLI(t, options.ConfigFilePath)
// get the current environment to switch back to after the test since the environment is used
// for AWS test and has the AWS scope which the environment created in this does not.
envName := test.Steps[0].RPResources.Resources[0].Name
recipeName := "recipeName"
recipeTemplate := "ghcr.io/testpublicrecipe/bicep/modules/testTemplate:v1"
templateKind := "bicep"
resourceType := "Applications.Datastores/mongoDatabases"
file := "testdata/corerp-redis-recipe.bicep"
registry := strings.TrimPrefix(functional.GetBicepRecipeRegistry(), "registry=")
version := strings.TrimPrefix(functional.GetBicepRecipeVersion(), "version=")
resourceType := "Applications.Datastores/redisCaches"
file := "../../shared/resources/testdata/recipes/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)
templateKindBicep := "bicep"

terraformRecipe := "recipe2"
terraformRecipeTemplate := "Azure/cosmosdb/azurerm"
templateKindTerraform := "terraform"

t.Run("Validate rad recipe register", func(t *testing.T) {
output, err := cli.RecipeRegister(ctx, envName, recipeName, templateKind, recipeTemplate, resourceType, false)
output, err := cli.RecipeRegister(ctx, envName, recipeName, templateKindBicep, recipeTemplate, resourceType, false)
require.NoError(t, err)
require.Contains(t, output, "Successfully linked recipe")
})

t.Run("Validate rad recipe register with insecure registry", func(t *testing.T) {
output, err := cli.RecipeRegister(ctx, envName, recipeName, templateKind, recipeTemplate, resourceType, true)
output, err := cli.RecipeRegister(ctx, envName, recipeName, templateKindBicep, recipeTemplate, resourceType, true)
require.NoError(t, err)
require.Contains(t, output, "Successfully linked recipe")
})

t.Run("Validate rad recipe list", func(t *testing.T) {
output, err := cli.RecipeList(ctx, envName)
require.NoError(t, err)
require.Regexp(t, bicepRecipe, output)
require.Regexp(t, terraformRecipe, output)
require.Regexp(t, recipeName, output)
require.Regexp(t, resourceType, output)
require.Regexp(t, bicepRecipeTemplate, output)
require.Regexp(t, terraformRecipeTemplate, output)
require.Regexp(t, recipeTemplate, output)
require.Regexp(t, "true", output)
require.Regexp(t, templateKindBicep, output)
require.Regexp(t, templateKindTerraform, output)
})

t.Run("Validate rad recipe unregister", func(t *testing.T) {
Expand All @@ -100,31 +113,19 @@ func verifyRecipeCLI(ctx context.Context, t *testing.T, test shared.RPTest) {
})

t.Run("Validate rad recipe show", func(t *testing.T) {
showRecipeName := "mongodbtest"
showRecipeTemplate := "ghcr.io/radius-project/dev/recipes/functionaltest/parameters/mongodatabases/azure:1.0"
showRecipeResourceType := "Applications.Datastores/mongoDatabases"
output, err := cli.RecipeRegister(ctx, envName, showRecipeName, templateKind, showRecipeTemplate, showRecipeResourceType, false)
output, err := cli.RecipeShow(ctx, envName, bicepRecipe, resourceType)
require.NoError(t, err)
require.Contains(t, output, "Successfully linked recipe")
output, err = cli.RecipeShow(ctx, envName, showRecipeName, resourceType)
require.NoError(t, err)
require.Contains(t, output, showRecipeName)
require.Contains(t, output, showRecipeTemplate)
require.Contains(t, output, showRecipeResourceType)
require.Contains(t, output, "mongodbName")
require.Contains(t, output, "documentdbName")
require.Contains(t, output, "location")
require.Contains(t, output, bicepRecipe)
require.Contains(t, output, bicepRecipeTemplate)
require.Contains(t, output, resourceType)
require.Contains(t, output, "redisName")
require.Contains(t, output, "string")
require.Contains(t, output, "resourceGroup().location]")
})

t.Run("Validate rad recipe show - terraform recipe", func(t *testing.T) {
showRecipeName := "redistesttf"
moduleServer := os.Getenv("TF_RECIPE_MODULE_SERVER_URL")
if moduleServer == "" {
moduleServer = "http://localhost:8999"
}
showRecipeTemplate := fmt.Sprintf("%s/kubernetes-redis.zip", moduleServer)
moduleServer := strings.TrimPrefix(functional.GetTerraformRecipeModuleServerURL(), "moduleServer=")
showRecipeTemplate := fmt.Sprintf("%s/kubernetes-redis.zip//modules", moduleServer)
showRecipeResourceType := "Applications.Datastores/redisCaches"
output, err := cli.RecipeRegister(ctx, envName, showRecipeName, "terraform", showRecipeTemplate, showRecipeResourceType, false)
require.NoError(t, err)
Expand All @@ -144,8 +145,8 @@ func verifyRecipeCLI(ctx context.Context, t *testing.T, test shared.RPTest) {
require.Contains(t, output, "Successfully published")
})

t.Run("Validate rad recipe register with recipe name conflicting with dev recipe", func(t *testing.T) {
output, err := cli.RecipeRegister(ctx, envName, "mongo-azure", templateKind, recipeTemplate, resourceType, false)
t.Run("Validate rad recipe register with recipe name conflicting with existing recipe", func(t *testing.T) {
output, err := cli.RecipeRegister(ctx, envName, bicepRecipe, templateKindBicep, recipeTemplate, resourceType, false)
require.Contains(t, output, "Successfully linked recipe")
require.NoError(t, err)
output, err = cli.RecipeList(ctx, envName)
Expand Down Expand Up @@ -692,13 +693,12 @@ func Test_CLI_Only_version(t *testing.T) {
}

func Test_RecipeCommands(t *testing.T) {
t.Skip("TODO: disabling this test temporarily while we determine which recipes it should pull")
template := "testdata/corerp-resources-recipe-env.bicep"
name := "corerp-resources-recipe-env"

test := shared.NewRPTest(t, name, []shared.TestStep{
{
Executor: step.NewDeployExecutor(template),
Executor: step.NewDeployExecutor(template, functional.GetBicepRecipeRegistry(), functional.GetBicepRecipeVersion()),
RPResources: &validation.RPResourceSet{
Resources: []validation.RPResource{
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import radius as radius

@description('Specifies the location for resources.')
param location string = 'global'
@description('The OCI registry for test Bicep recipes.')
param registry string
@description('The OCI tag for test Bicep recipes.')
param version string

resource env 'Applications.Core/environments@2023-10-01-preview' = {
name: 'corerp-resources-recipe-env'
Expand All @@ -13,10 +17,10 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = {
namespace: 'corerp-resources-recipe-env'
}
recipes: {
'Applications.Datastores/mongoDatabases':{
'Applications.Datastores/redisCaches':{
recipe1: {
templateKind: 'bicep'
templatePath: 'ghcr.io/testpublicrecipe/bicep/modules/mongodatabases:v1'
templatePath: '${registry}/test/functional/shared/recipes/corerp-redis-recipe:${version}'
}
recipe2: {
templateKind: 'terraform'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import radius as radius

param registry string

@description('The OCI registry for test Bicep recipes.')
param registry string
@description('The OCI tag for test Bicep recipes.')
param version string

resource env 'Applications.Core/environments@2023-10-01-preview' = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
param redisName string

resource redis 'Microsoft.Cache/redis@2022-06-01' = {
name: 'rds-${uniqueString(resourceGroup().id, deployment().name)}'
name: 'rds-${uniqueString(resourceGroup().id, redisName, deployment().name)}'
location: 'global'
properties: {
enableNonSslPort: false
Expand Down

0 comments on commit 6108d14

Please sign in to comment.