Skip to content

Commit

Permalink
Merge branch 'main' into env-required
Browse files Browse the repository at this point in the history
  • Loading branch information
vinayada1 authored Jan 18, 2024
2 parents de8fbed + 33a43ca commit a7f7c2b
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 62 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
24 changes: 20 additions & 4 deletions .github/workflows/long-running-azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ env:
# Radius test environment name
RADIUS_TEST_ENVIRONMENT_NAME: 'kind-radius'

# The current GitHub action link
ACTION_LINK: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'

jobs:
build:
name: Build Radius for test
Expand Down Expand Up @@ -388,10 +391,6 @@ jobs:
rad env create ${{ env.RADIUS_TEST_ENVIRONMENT_NAME }} --namespace default
rad env switch ${{ env.RADIUS_TEST_ENVIRONMENT_NAME }}
# Temporary workaround to fix the x509 certificate error in the controller.
# https://github.com/radius-project/radius/issues/6989
kubectl delete secrets controller-cert -n radius-system --ignore-not-found
echo "*** Configuring Azure provider ***"
rad env update ${{ env.RADIUS_TEST_ENVIRONMENT_NAME }} --azure-subscription-id ${{ secrets.INTEGRATION_TEST_SUBSCRIPTION_ID }} \
--azure-resource-group ${{ env.AZURE_TEST_RESOURCE_GROUP }}
Expand Down Expand Up @@ -480,3 +479,20 @@ jobs:
- name: Clean up cluster
if: always()
run: ./.github/scripts/cleanup-cluster.sh
report-failure:
name: Report test failure
needs: [build, tests]
runs-on: ubuntu-latest
if: failure() && github.repository == 'radius-project/radius'
steps:
- name: Create failure issue for failing long running test run
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GH_RAD_CI_BOT_PAT }}
script: |
github.rest.issues.create({
...context.repo,
title: `Scheduled long running test failed - Run ID: ${context.runId}`,
labels: ['bug', 'test-failure'],
body: `## Bug information \n\nThis bug is generated automatically if the scheduled long running test fails. The Radius long running test operates on a schedule of every 2 hours everyday. It's important to understand that the test may fail due to workflow infrastructure issues, like network problems, rather than the flakiness of the test itself. For the further investigation, please visit [here](${process.env.ACTION_LINK}).`
})
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ metadata:
labels:
app.kubernetes.io/name: controller
app.kubernetes.io/part-of: radius
type: kubernetes.io/tls
data:
tls.crt: {{ include "secrets.lookup" (dict "secret" "controller-cert" "namespace" .Release.Namespace "key" "tls.crt" "defaultValue" $cert.Cert) }}
tls.key: {{ include "secrets.lookup" (dict "secret" "controller-cert" "namespace" .Release.Namespace "key" "tls.key" "defaultValue" $cert.Key) }}
Expand Down
1 change: 0 additions & 1 deletion deploy/Chart/templates/ucp/apiservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ metadata:
labels:
app.kubernetes.io/name: ucp
app.kubernetes.io/part-of: radius
type: kubernetes.io/tls
data:
tls.crt: {{ include "secrets.lookup" (dict "secret" "ucp-cert" "namespace" .Release.Namespace "key" "tls.crt" "defaultValue" $cert.Cert) }}
tls.key: {{ include "secrets.lookup" (dict "secret" "ucp-cert" "namespace" .Release.Namespace "key" "tls.key" "defaultValue" $cert.Key) }}
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 a7f7c2b

Please sign in to comment.