-
Notifications
You must be signed in to change notification settings - Fork 14
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
Changes from 62 commits
346e308
38b22ec
9558836
7760c05
56056fa
836694c
4e1ed6e
4439cf8
e3e562a
f89c26f
244ddf9
5579c8e
dd31fcf
50dd80c
c10a5a3
0a4b054
ba568ed
20fd892
119de17
680961c
3961fe5
b8d6ea4
f42345f
78ee846
16c011b
ee4a3be
e589dc5
ed2772f
1e6ca22
e31b78f
5e6823b
5b0328b
e8acdc1
b84b12a
610f51a
975122f
7f1aa5f
70f1c29
0efeeea
e3201e7
8b2e2ac
80b8882
b5ac87e
76c0639
922e663
110b415
8b866ca
c7c379b
49db336
f6c443f
a1f7c78
7268235
eef9b3b
2558b26
b098527
d3ef63e
8c44a62
b39260e
91d213d
3a7f527
607dd57
9d3158a
89e9258
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
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 |
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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this check be added? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. its not required, removed it |
||
} | ||
} |
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we add descriptions to these? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
} | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied this install script from samples https://github.com/radius-project/samples/blob/d611db9ee7687bf643b09570f979a0eeb99f4e25/.github/scripts/install-radius.sh#L23-L24