Skip to content

Commit

Permalink
Merge branch 'main' into tf-submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
sk593 authored Jan 18, 2024
2 parents 370a14b + 33a43ca commit 2e6c6a4
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 56 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/functional-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,28 @@ jobs:
with:
name: ${{ matrix.name }}_container_logs
path: ./${{ env.RADIUS_CONTAINER_LOG_BASE }}
- name: Get Terraform recipe publishing logs
if: always()
run: |
# Create pod-logs directory
mkdir -p recipes/pod-logs
# Get pod logs and save to file
namespace="radius-test-tf-module-server"
label="app.kubernetes.io/name=tf-module-server"
pod_names=($(kubectl get pods -l $label -n $namespace -o jsonpath='{.items[*].metadata.name}'))
for pod_name in "${pod_names[@]}"; do
kubectl logs $pod_name -n $namespace > recipes/pod-logs/${pod_name}.txt
done
echo "Pod logs saved to recipes/pod-logs/"
# Get kubernetes events and save to file
kubectl get events -n $namespace > recipes/pod-logs/events.txt
- name: Upload Terraform recipe publishing logs
uses: actions/upload-artifact@v3
if: always()
with:
name: recipes-pod-logs
path: recipes/pod-logs
if-no-files-found: error
- uses: marocchino/sticky-pull-request-comment@v2
if: success() && env.PR_NUMBER != ''
continue-on-error: true
Expand Down
56 changes: 0 additions & 56 deletions test/functional/datastoresrp/resources/mongodb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package resource_test

import (
"os"
"testing"

"github.com/radius-project/radius/test/functional"
Expand Down Expand Up @@ -117,58 +116,3 @@ func Test_MongoDB_Recipe(t *testing.T) {

test.Test(t)
}

// Test_MongoDB_Recipe_ContextParameter validates creation of a mongoDB from
// a default recipe using the context parameter generated and set by DatastoresRP,
// and container using the mongoDatabases portable resource to connect to the underlying mongoDB resource.
func Test_MongoDB_Recipe_ContextParameter(t *testing.T) {
t.Skip("Skipping test as creating/deleting cosmosdb resource is unreliable - https://github.com/radius-project/radius/issues/5929")

template := "testdata/datastoresrp-resources-mongodb-recipe-context.bicep"
name := "dsrp-resources-mongodb-recipe-context"
appNamespace := "dsrp-resources-mongodb-recipe-context-app"
rg := os.Getenv("INTEGRATION_TEST_RESOURCE_GROUP_NAME")
// Error the test if INTEGRATION_TEST_RESOURCE_GROUP_NAME is not set
// for running locally set the INTEGRATION_TEST_RESOURCE_GROUP_NAME with the test resourceGroup
if rg == "" {
t.Error("This test needs the env variable INTEGRATION_TEST_RESOURCE_GROUP_NAME to be set")
}

test := shared.NewRPTest(t, name, []shared.TestStep{
{
Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), functional.GetBicepRecipeRegistry(), functional.GetBicepRecipeVersion()),
RPResources: &validation.RPResourceSet{
Resources: []validation.RPResource{
{
Name: "dsrp-resources-env-recipes-context-env",
Type: validation.EnvironmentsResource,
},
{
Name: name,
Type: validation.ApplicationsResource,
App: name,
},
{
Name: "mdb-ctx-ctnr",
Type: validation.ContainersResource,
App: name,
},
{
Name: "mdb-ctx",
Type: validation.MongoDatabasesResource,
App: name,
},
},
},
K8sObjects: &validation.K8sObjectSet{
Namespaces: map[string][]validation.K8sObject{
appNamespace: {
validation.NewK8sPodForResource(name, "mdb-ctx-ctnr").ValidateLabels(false),
},
},
},
},
})

test.Test(t)
}
47 changes: 47 additions & 0 deletions test/functional/shared/resources/recipe_bicep_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,53 @@ func Test_BicepRecipe_ParametersAndOutputs(t *testing.T) {
test.Test(t)
}

// This test validates that the recipe context parameter is populated as expected.
func Test_BicepRecipe_ContextParameter(t *testing.T) {
template := "testdata/corerp-resources-recipe-bicep.bicep"
name := "corerp-resources-recipe-bicep-contextparameter"

parameters := []string{
functional.GetBicepRecipeRegistry(),
functional.GetBicepRecipeVersion(),
fmt.Sprintf("basename=%s", name),
fmt.Sprintf("recipe=%s", "context-parameter"),
}

test := shared.NewRPTest(t, name, []shared.TestStep{
{
Executor: step.NewDeployExecutor(template, parameters...),
RPResources: &validation.RPResourceSet{
Resources: []validation.RPResource{
{
Name: name,
Type: validation.ApplicationsResource,
},
{
Name: name,
Type: validation.ExtendersResource,
},
},
},
K8sObjects: &validation.K8sObjectSet{},
PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) {
resource, err := test.Options.ManagementClient.ShowResource(ctx, "Applications.Core/extenders", name)
require.NoError(t, err)

text, err := json.MarshalIndent(resource, "", " ")
require.NoError(t, err)
t.Logf("resource data:\n %s", text)

require.Equal(t, name, resource.Properties["environment"])
require.Equal(t, name, resource.Properties["application"])
require.Equal(t, name, resource.Properties["resource"])
require.Equal(t, name+"-app", resource.Properties["namespace"])
require.Equal(t, name+"-env", resource.Properties["envNamespace"])
},
},
})
test.Test(t)
}

// This test actually creates a Radius resource using a recipe (yeah, not a real user scenario).
//
// The purpose of this test is to test creation and behavior of **output resources**. This way we
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// A simple Bicep recipe that tests context parameter is applied. It doesn't provision any resources.
param context object

output result object = {
values: {
environment: context.environment.Name
application: context.application.Name
resource: context.resource.Name
namespace: context.runtime.kubernetes.namespace
envNamespace: context.runtime.kubernetes.environmentNamespace
}
}

0 comments on commit 2e6c6a4

Please sign in to comment.