Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding test workflow #52

Merged
Show file tree
Hide file tree
Changes from 62 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
346e308
adding tests for recipes
vishwahiremat Nov 22, 2023
38b22ec
testing to run test.yaml
vishwahiremat Nov 22, 2023
9558836
fix syntax
vishwahiremat Nov 22, 2023
7760c05
fixing test.yaml
vishwahiremat Nov 22, 2023
56056fa
fixing test.yaml
vishwahiremat Nov 22, 2023
836694c
setting output variables
vishwahiremat Nov 22, 2023
4e1ed6e
add install radius script
vishwahiremat Nov 22, 2023
4439cf8
fix test.yaml
vishwahiremat Nov 22, 2023
e3e562a
rename file
vishwahiremat Nov 22, 2023
f89c26f
test
vishwahiremat Nov 22, 2023
244ddf9
test
vishwahiremat Nov 22, 2023
5579c8e
test
vishwahiremat Nov 22, 2023
dd31fcf
test
vishwahiremat Nov 22, 2023
50dd80c
test
vishwahiremat Nov 22, 2023
c10a5a3
install edge version
vishwahiremat Nov 22, 2023
0a4b054
test
vishwahiremat Nov 22, 2023
ba568ed
adding checkout step
vishwahiremat Nov 22, 2023
20fd892
adding execute permissions
vishwahiremat Nov 22, 2023
119de17
path fix
vishwahiremat Nov 22, 2023
680961c
fixing k3d create command
vishwahiremat Nov 22, 2023
3961fe5
adding mongo test
vishwahiremat Nov 27, 2023
b8d6ea4
fix syntax error
vishwahiremat Nov 27, 2023
f42345f
fix syntax error
vishwahiremat Nov 27, 2023
78ee846
remove provider
vishwahiremat Nov 27, 2023
16c011b
testing
vishwahiremat Nov 27, 2023
ee4a3be
adding all tests
vishwahiremat Nov 27, 2023
e589dc5
adding matrix
vishwahiremat Nov 27, 2023
ed2772f
testing
vishwahiremat Nov 27, 2023
1e6ca22
test
vishwahiremat Nov 27, 2023
e31b78f
testing
vishwahiremat Nov 27, 2023
5e6823b
testing
vishwahiremat Nov 27, 2023
5b0328b
testing
vishwahiremat Nov 27, 2023
e8acdc1
testing
vishwahiremat Nov 27, 2023
b84b12a
testing
vishwahiremat Nov 27, 2023
610f51a
testing
vishwahiremat Nov 27, 2023
975122f
testing
vishwahiremat Nov 27, 2023
7f1aa5f
testing
vishwahiremat Nov 27, 2023
70f1c29
test sql
vishwahiremat Nov 27, 2023
0efeeea
test-statestore
vishwahiremat Nov 27, 2023
e3201e7
testing
vishwahiremat Nov 27, 2023
8b2e2ac
adding magpie
vishwahiremat Nov 28, 2023
80b8882
fix errors
vishwahiremat Nov 28, 2023
b5ac87e
enable all tests
vishwahiremat Nov 28, 2023
76c0639
testSecretStores
vishwahiremat Nov 28, 2023
922e663
fix sescret store test
vishwahiremat Nov 28, 2023
110b415
adding pod logs
vishwahiremat Nov 28, 2023
8b866ca
test uploading logs
vishwahiremat Nov 28, 2023
c7c379b
fix upload logs error
vishwahiremat Nov 28, 2023
49db336
fix test error
vishwahiremat Nov 28, 2023
f6c443f
updating magpie to ghcr
vishwahiremat Nov 28, 2023
a1f7c78
testing
vishwahiremat Nov 29, 2023
7268235
testing
vishwahiremat Nov 29, 2023
eef9b3b
remove build magpie
vishwahiremat Nov 29, 2023
2558b26
have single app to deploy all recipes
vishwahiremat Nov 29, 2023
b098527
fix syntax error
vishwahiremat Nov 29, 2023
d3ef63e
remove RUN_TEST
vishwahiremat Nov 29, 2023
8c44a62
addressing comments
vishwahiremat Dec 4, 2023
b39260e
addressing review comments
vishwahiremat Dec 4, 2023
91d213d
remove sql test
vishwahiremat Dec 5, 2023
3a7f527
fixing sql test
vishwahiremat Dec 5, 2023
607dd57
updating wait for pods
vishwahiremat Dec 5, 2023
9d3158a
upgrading dapr version
vishwahiremat Dec 5, 2023
89e9258
adressing comments
vishwahiremat Dec 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/scripts/install-radius.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# ------------------------------------------------------------
# Copyright 2023 The Radius Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------------------------------------

set -xe

VERSION=$1
RAD_CLI_URL=https://raw.githubusercontent.com/radius-project/radius/main/deploy/install.sh
RAD_CLI_EDGE_URL=ghcr.io/radius-project/rad/linux-amd64:latest

if [[ $VERSION == "edge" ]]; then
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still have edge version accessible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

echo Downloading rad CLI edge version
oras pull $RAD_CLI_EDGE_URL
chmod +x ./rad
mv ./rad /usr/local/bin/rad
elif [[ -n $VERSION && $VERSION != *"rc"* ]]; then
INPUT_CHANNEL=$(echo $VERSION | cut -d '.' -f 1,2)
echo "Downloading rad CLI version $INPUT_CHANNEL"
wget -q $RAD_CLI_URL -O - | /bin/bash -s $INPUT_CHANNEL
elif [[ -n $VERSION ]]; then
echo Downloading rad CLI version $VERSION
wget -q $RAD_CLI_URL -O - | /bin/bash -s $VERSION
else
echo Downloading latest rad CLI
wget -q $RAD_CLI_URL -O - | /bin/bash
fi
102 changes: 102 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Test Recipes

on:
workflow_dispatch:
inputs:
version:
description: 'Radius version number to use (e.g. 0.1.0, 0.1.0-rc1, edge). Defaults to edge.'
required: false
default: 'edge'
type: string
push:
branches:
- v*.*
- edge
paths:
- "local-dev/**"
- ".github/workflows/**"
pull_request:
types: [opened, synchronize, reopened]
env:
RUN_IDENTIFIER: recipestest-${{ github.run_id }}-${{ github.run_attempt }}
APP_NAME: local-dev-recipe-app
APP_NAMESPACE: local-dev-recipe-app
jobs:
test:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is not supposed to run on forks please add the if check like this: https://github.com/radius-project/radius/blob/main/.github/workflows/assets.yaml#L29.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this check be added?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking we should run this on fork as well, wondering if there is reason why we dont want to run on forks?

name: "Recipe tests"
runs-on: [ubuntu-latest]
steps:
- name: Generate output variables
id: gen-id
run: |
# Set output variables to be used in the other jobs
echo "RUN_IDENTIFIER=${RUN_IDENTIFIER}" >> $GITHUB_OUTPUT
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
- name: Download k3d
run: wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
- name: Create k3d cluster
run: k3d cluster create --agents 2 -p "80:80@loadbalancer" --k3s-arg "--disable=traefik@server:0" --registry-create reciperegistry:51351
- name: Install Dapr
run: |
helm repo add dapr https://dapr.github.io/helm-charts/
helm install dapr dapr/dapr --version=1.12 --namespace dapr-system --create-namespace --wait
- name: Download rad CLI
run: |
RADIUS_VERSION="${{ inputs.version }}"
if [[ -z "${{ inputs.version }}" ]]; then
RADIUS_VERSION=edge
fi
chmod +x ./.github/scripts/install-radius.sh
./.github/scripts/install-radius.sh $RADIUS_VERSION
- name: Publish Recipes
run: |
files_list=$(ls "local-dev")
for file in $files_list; do
echo "Publishing recipe: local-dev/$file"
recipeName="${file%.*}"
rad bicep publish --file local-dev/$file --target br:localhost:51351/recipes/local-dev/$recipeName:latest --plain-http
done
- name: Initialize default environment
run: |
rad install kubernetes --set rp.publicEndpointOverride=localhost
rad group create default
rad workspace create kubernetes default --group default
rad group switch default
rad env create default
rad env switch default
- name: Deploy app
id: deploy-app
run: rad deploy ./tests/test-local-dev-recipes.bicep --parameters magpieimage="ghcr.io/radius-project/magpiego:latest" --parameters registry="reciperegistry:5000" --parameters version="latest"
- name: Wait for all pods to be ready
id: wait-for-pods
run: |
label="radapp.io/application=${APP_NAME}"
kubectl rollout status deployment -l $label -n ${APP_NAMESPACE} --timeout=90s
- name: Get Pod logs for failed tests
id: get-pod-logs
if: failure() && (steps.deploy-app.outcome == 'failure' || steps.wait-for-pods.outcome == 'failure')
run: |
# Create pod-logs directory
mkdir -p recipe-tests/pod-logs/local_dev_recipe_test_container_logs
# Get pod logs and save to file
label="radapp.io/application=${APP_NAME}"
pod_names=($(kubectl get pods -l $label -n ${APP_NAMESPACE} -o jsonpath='{.items[*].metadata.name}'))
for pod_name in "${pod_names[@]}"; do
kubectl logs $pod_name -n ${APP_NAMESPACE} > recipe-tests/pod-logs/local_dev_recipe_test_container_logs/${pod_name}.txt
done
echo "Pod logs saved to recipe-tests/pod-logs/local_dev_recipe_test_container_logs/"
# Get kubernetes events and save to file
kubectl get events -n ${APP_NAMESPACE} > recipe-tests/pod-logs/local_dev_recipe_test_container_logs/events.txt
- name: Upload Pod logs for failed tests
uses: actions/upload-artifact@v3
if: failure() && steps.get-pod-logs.outcome == 'success'
with:
name: local_dev_recipe_test_container_logs-pod-logs
path: recipe-tests/pod-logs/local_dev_recipe_test_container_logs
retention-days: 30
if-no-files-found: error
2 changes: 1 addition & 1 deletion local-dev/pubsubbrokers.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ resource daprComponent 'dapr.io/Component@v1alpha1' = {
metadata: [
{
name: 'redisHost'
value: '${svc.metadata.name}.${svc.metadata.namespace}.svc.cluster.local'
value: '${svc.metadata.name}.${svc.metadata.namespace}.svc.cluster.local:6379'
vishwahiremat marked this conversation as resolved.
Show resolved Hide resolved
}
{
name: 'redisPassword'
Expand Down
1 change: 1 addition & 0 deletions local-dev/secretstores.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ output result object = {
type: daprType
AaronCrawfis marked this conversation as resolved.
Show resolved Hide resolved
version: daprVersion
metadata: daprComponent.spec.metadata
componentName: daprComponent.metadata.name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this required? And if so should we add it to all the other dapr recipes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its not required, removed it

}
}
204 changes: 204 additions & 0 deletions tests/test-local-dev-recipes.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
import radius as radius

param magpieimage string

param registry string

param version string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add descriptions to these?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added descriptions


import kubernetes as kubernetes {
namespace: 'daprrp-rs-secretstore-recipe'
kubeConfig: ''
}

resource env 'Applications.Core/environments@2023-10-01-preview' = {
name: 'local-dev-recipe-env'
location: 'global'
properties: {
compute: {
kind: 'kubernetes'
resourceId: 'self'
namespace: 'local-dev-recipe-env'
}
recipes: {
'Applications.Datastores/mongoDatabases':{
mongoazure: {
templateKind: 'bicep'
plainHTTP: true
templatePath: '${registry}/recipes/local-dev/mongodatabases:${version}'
}
}
'Applications.Dapr/pubSubBrokers': {
default: {
templateKind: 'bicep'
plainHTTP: true
templatePath: '${registry}/recipes/local-dev/pubsubbrokers:${version}'
}
}
'Applications.Messaging/rabbitMQQueues': {
default: {
templateKind: 'bicep'
plainHTTP: true
templatePath: '${registry}/recipes/local-dev/rabbitmqqueues:${version}'
}
}
'Applications.Datastores/redisCaches':{
default: {
templateKind: 'bicep'
plainHTTP: true
templatePath: '${registry}/recipes/local-dev/rediscaches:${version}'
}
}
'Applications.Dapr/secretStores': {
default: {
templateKind: 'bicep'
plainHTTP: true
templatePath: '${registry}/recipes/local-dev/secretstores:${version}'
}
}
'Applications.Datastores/sqlDatabases': {
default: {
templateKind: 'bicep'
plainHTTP: true
templatePath: '${registry}/recipes/local-dev/sqldatabases:${version}'
}
}
'Applications.Dapr/stateStores': {
default: {
templateKind: 'bicep'
plainHTTP: true
templatePath: '${registry}/recipes/local-dev/statestores:${version}'
}
}
}
}
}

resource app 'Applications.Core/applications@2023-10-01-preview' = {
name: 'local-dev-recipe-app'
location: 'global'
properties: {
environment: env.id
extensions: [
{
kind: 'kubernetesNamespace'
namespace: 'local-dev-recipe-app'
}
]
}
}

resource webapp 'Applications.Core/containers@2023-10-01-preview' = {
name: 'mongodb-app-ctnr'
location: 'global'
properties: {
application: app.id
connections: {
mongodb: {
source: recipedb.id
}
daprpubsub: {
source: pubsubBroker.id
}
rabbitmq: {
source: rabbitmq.id
}
redis: {
source: redis.id
}
daprsecretstore: {
source: secretstore.id
}
sql: {
source: db.id
disableDefaultEnvVars: true
}
daprstatestore: {
source: statestore.id
}
}
container: {
image: magpieimage
readinessProbe:{
kind:'httpGet'
containerPort:3000
path: '/healthz'
}
}
extensions: [
{
kind: 'daprSidecar'
appId: 'dpsb-recipe-app-ctnr'
appPort: 3000
}
]
}
}

resource recipedb 'Applications.Datastores/mongoDatabases@2023-10-01-preview' = {
name: 'mongodb-db'
properties: {
application: app.id
environment: env.id
recipe: {
name: 'mongoazure'
}
}
}

resource pubsubBroker 'Applications.Dapr/pubSubBrokers@2023-10-01-preview' = {
name: 'dpsb-recipe'
properties: {
application: app.id
environment: env.id
}
}

resource rabbitmq 'Applications.Messaging/rabbitMQQueues@2023-10-01-preview' = {
name: 'rmq-recipe-resource'
properties: {
application: app.id
environment: env.id
}
}

resource redis 'Applications.Datastores/redisCaches@2023-10-01-preview' = {
name: 'rds-recipe'
properties: {
environment: env.id
application: app.id
}
}

resource secretstore 'Applications.Dapr/secretStores@2023-10-01-preview' = {
name: 'gnrc-scs-recipe'
properties: {
environment: env.id
application: app.id
}
}

resource mysecret 'core/Secret@v1' = {
AaronCrawfis marked this conversation as resolved.
Show resolved Hide resolved
metadata: {
name: 'mysecret'
namespace: 'local-dev-recipe-app'
}
type: 'opaque'
data: {}
}

resource db 'Applications.Datastores/sqlDatabases@2023-10-01-preview' = {
name: 'sql-db-recipe'
properties: {
application: app.id
environment: env.id
}
}

resource statestore 'Applications.Dapr/stateStores@2023-10-01-preview' = {
name: 'dapr-sts-recipe'
properties: {
application: app.id
environment: env.id
}
}