Skip to content

Commit

Permalink
feat: adding baremetal tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kammerdiener committed Sep 5, 2024
1 parent b9b50e3 commit 3f6ab40
Show file tree
Hide file tree
Showing 2 changed files with 233 additions and 0 deletions.
104 changes: 104 additions & 0 deletions .github/workflows/run-durable-baremetal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Run Durable tests Baremetal

on:
# "workflow_dispatch" allows this workflow to be triggered manually or via API through the CD manager
workflow_dispatch:
inputs:
environment:
type: choice
description: Durable infrastructure to run tests against
required: true
default: dev
options:
- dev
- qa
- tnet
- prod
build_tag:
type: string
description: Build tag for image used for running tests
required: true
default: latest
test_selector:
type: string
description: Path regex passed to Jest to select which tests to run
required: true
default: correctness/fast
# The "job_id" input is needed for the CD manager to be able to track a workflow run as part of a CD manager job.
# The GitHub API does not return the workflow run ID for a run created via the API. In order to track a workflow,
# we're forced to inject the CD manager job ID via a tagged job step. This allows the CD manager to lookup
# workflow runs and identify which one corresponds to a particular job so that it can be tracked.
# Ref: https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#create-a-workflow-dispatch-event
job_id:
type: string
description: Test job identifier
required: true
default: manual

env:
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

jobs:
run-tests:
name: Test
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment }}
steps:
-
# We're piggybacking on this step to inject the CD manager job ID into this workflow
name: ${{ github.event.inputs.job_id }}
uses: actions/checkout@v3
-
name: Login to Public ECR
uses: docker/login-action@v2
with:
registry: public.ecr.aws
username: ${{ env.AWS_ACCESS_KEY_ID }}
password: ${{ env.AWS_SECRET_ACCESS_KEY }}
env:
AWS_REGION: us-east-1
- name: pull kubeconfig
run: |
mkdir .kube
echo ${{ secrets.BAREMETAL_CLUSTER_KUBECONF }} > .kube/config
- name: Tailscale
uses: tailscale/github-action@v2
with:
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
tags: tag:github-actions
-
name: Test ${{ github.event.inputs.environment }}
env:
BUILD_TAG: ${{ github.event.inputs.build_tag }}
TEST_SELECTOR: ${{ github.event.inputs.test_selector }}
COMPOSEDB_ADMIN_DID_SEEDS: ${{ secrets.COMPOSEDB_ADMIN_DID_SEEDS }}
run: |
if [[ -z "$BUILD_TAG" ]]; then
BUILD_TAG=latest
fi
# Expose the Keramik ComposeDB port to the host so that the tests can connect to it
# source ./port-forward.sh "keramik-ceramic-v4-${{ github.event.inputs.environment }}"
# If we found any Keramik ComposeDB endpoints, we'll also have Ceramic API endpoints. Add them to the config.
# if [[ -n "$COMPOSEDB_URLS" ]];
# then
# sed -i "s|COMPOSEDB_URLS.*|&$COMPOSEDB_URLS|" suite/env/.env."${{ github.event.inputs.environment }}"
# sed -i "s|CERAMIC_URLS.*|&$CERAMIC_URLS|" suite/env/.env."${{ github.event.inputs.environment }}"
# fi
make DURABLE_ENV=${{ github.event.inputs.environment }} durable-tests
collect-results:
name: Durable Test Results
if: ${{ github.event.inputs.job_id != null }}
runs-on: ubuntu-latest
needs: [run-tests]
steps:
- run: exit 1
# see https://stackoverflow.com/a/67532120/4907315
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
}}
129 changes: 129 additions & 0 deletions .github/workflows/run-performance-baremetal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: Run Performance test Baremetal

on:
workflow_dispatch: # manually triggered
inputs:
test_name:
type: string
description: Folder name under "performance" that contains yaml
required: true
js_ceramic_image:
type: string
description: Image for js-ceramic
required: true
default: ceramicnetwork/js-ceramic:latest
rust_ceramic_image:
type: string
description: Image for rust-ceramic
required: true
default: public.ecr.aws/r5b3e0r5/3box/ceramic-one:latest
scenario_image:
type: string
description: Image for scenario
required: true
default: public.ecr.aws/r5b3e0r5/3box/keramik-runner:latest

jobs:
run-performance-test:
name: Run Performance Test ${{ github.run_id }}
runs-on: ubuntu-latest
environment: cas-scaling-2024
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install yq
run: |
# sudo apt-get update
# sudo apt-get install -y software-properties-common
# sudo add-apt-repository -y ppa:rmescandon/yq
# sudo apt-get update
# sudo apt-get install -y yq
curl -L https://github.com/mikefarah/yq/releases/download/v4.40.7/yq_linux_amd64 -o yq
chmod +x yq
sudo mv ./yq /usr/local/bin/yq
- name: Template network
run: |
set -exo pipefail
export RUST_CERAMIC_IMAGE=${{ inputs.rust_ceramic_image }}
export SCENARIO_IMAGE=${{ inputs.scenario_image }}
export JS_CERAMIC_IMAGE=${{ inputs.js_ceramic_image }}
export TEST_NAME=${{ inputs.test_name }}
ls -l performance/$TEST_NAME
export THIS_TEST=${{ inputs.test_name }}-${{ github.run_id }}
mkdir -p performance/$THIS_TEST
# set the network name yaml key to the test names
yq e '.metadata.name = env(THIS_TEST)' performance/$TEST_NAME/network.yaml \
> performance/$THIS_TEST/network.yaml
yq e '.spec.ceramic[0].image = env(JS_CERAMIC_IMAGE)' -i performance/$THIS_TEST/network.yaml
yq e '.spec.ceramic[0].ipfs.rust.image = env(RUST_CERAMIC_IMAGE)' -i performance/$THIS_TEST/network.yaml
cat performance/$THIS_TEST/network.yaml
echo "THIS_TEST=$THIS_TEST" >> $GITHUB_ENV
echo "THIS_TEST_NAMESPACE=keramik-${THIS_TEST}" >> $GITHUB_ENV
echo "TEST_NAME=${TEST_NAME}" >> $GITHUB_ENV
- name: pull kubeconfig
run: |
mkdir .kube
echo ${{ secrets.BAREMETAL_CLUSTER_KUBECONF }} > .kube/config
- name: Deploy network
run: |
kubectl apply -f performance/$THIS_TEST/network.yaml
- name: Wait for bootstrap to complete
timeout-minutes: 8
run: |
set -exo pipefail
sleep 60
kubectl wait --for=condition=ready \
--timeout=240s \
pod \
-l app=ceramic \
-n ${THIS_TEST_NAMESPACE}
sleep 60
kubectl wait --for=condition=complete \
--timeout=120s \
job/bootstrap \
-n ${THIS_TEST_NAMESPACE}
- name: Template simulation
run: |
set -exo pipefail
yq e '.metadata.namespace = env(THIS_TEST_NAMESPACE)' performance/$TEST_NAME/simulation.yaml \
> performance/$THIS_TEST/simulation.yaml
cat performance/$THIS_TEST/simulation.yaml
- name: Run simulation
run: |
set -exo pipefail
kubectl apply -f performance/$THIS_TEST/simulation.yaml
SIMULATION_RUNTIME=$(yq e '.spec.runTime' performance/$THIS_TEST/simulation.yaml)
echo "SIMULATION_RUNTIME=${SIMULATION_RUNTIME}" >> $GITHUB_ENV
- name: Notify Discord
env:
SIMULATION_COLOR: 3066993
run: |
set -exo pipefail
export SIMULATION_STATUS_TAG="Simulation $THIS_TEST started"
export CLUSTER_NAME=${{ vars.GKE_CLUSTER }}
envsubst < notifications/notification-template.json > message.json
cat message.json
curl -v -H "Content-Type: application/json" -X POST -d @./message.json "${{ secrets.DISCORD_WEBHOOK_URL_SUCCEEDED }}"
- name: Wait for simulation to complete
run: |
set -exo pipefail
# runtime is in minutes
sleep $((${SIMULATION_RUNTIME} * 60))
kubectl wait --for=condition=complete \
--timeout=120s \
job/simulate-manager \
-n ${THIS_TEST_NAMESPACE}
- name: Cleanup
if: always()
run: |
kubectl delete -f performance/$THIS_TEST/network.yaml

0 comments on commit 3f6ab40

Please sign in to comment.