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 testkube sample swoop tests #30

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
ee57d90
Add testkube tests
Jun 21, 2023
98c1fd1
Testing failure
Jun 22, 2023
5fc5ac3
Adding root api test
Jun 22, 2023
915c1ba
Adding jobs and payload input tests
Jun 22, 2023
ac81a5a
Adding a simple load test example
Jun 22, 2023
f6f4849
Adding k6 load test
Jun 22, 2023
24f16e1
Fixing environment variable reference
Jun 22, 2023
4c8d1d9
Adding testkube tests
Jun 22, 2023
a37b346
fixing env variables
Jun 22, 2023
ec1133e
fixing env variables
Jun 22, 2023
f7da8fa
fixing env variables
Jun 22, 2023
4efc2d6
fixing env variables
Jun 22, 2023
0fb3c32
Fix minio and swoop tests
Jun 22, 2023
32bc788
Adding github runner ip
Jun 22, 2023
3403748
Finding Docker host ip
Jun 22, 2023
3a99621
Using a local IP
Jun 22, 2023
be0ce3e
Running testkube tests
Jun 22, 2023
b21253c
Running testkube tests
Jun 22, 2023
39f117f
Running testkube tests
Jun 22, 2023
85acccc
Running testkube tests
Jun 22, 2023
8bf91e9
Running testkube tests
Jun 22, 2023
9f54756
Running testkube tests
Jun 22, 2023
cbe2bde
Using local eth0 ip
Jun 22, 2023
664cfb3
Using local eth0 ip
Jun 22, 2023
d8b73e8
Using local eth0 ip
Jun 22, 2023
228d1a1
Using local eth0 ip
Jun 22, 2023
5cfb15b
Using local eth0 ip
Jun 22, 2023
73afe58
Using local eth0 ip
Jun 22, 2023
0c6c0e5
Adding docker internal
Jun 22, 2023
f71abc0
Adding host.k3d.internal
Jun 22, 2023
cb3365e
Adding host.k3d.internal
Jun 23, 2023
06fccba
kubernetes tests
Jun 23, 2023
8798d4d
kubernetes tests
Jun 23, 2023
54e5807
kubernetes tests
Jun 23, 2023
ff52934
kubernetes tests
Jun 23, 2023
e960b38
kubernetes tests
Jun 23, 2023
ff4dccf
kubernetes tests
Jun 23, 2023
0e3f70a
Pinning swoop-db to v0.1.3
Jun 23, 2023
b1e211b
Initializing testkube agent
Jun 23, 2023
9db2f2a
Initializing testkube agent
Jun 23, 2023
d9e1c2c
Switching to local testkube testing
Jun 23, 2023
5dcaf48
Adding testkube agent
Jun 23, 2023
ed4e328
continuing even if tests creation errors out because it exists
Jun 23, 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
110 changes: 110 additions & 0 deletions .github/workflows/testkube.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# This workflow sets up Testkube Kubernetes Tests

name: Testkube Kubernetes Tests

on:
push:
branches: ["main" ]
pull_request:
branches: ["main"]

permissions:
contents: read

jobs:
testkube:
permissions:
contents: read
security-events: write
actions: read
strategy:
matrix:
python-version:
- "3.11"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

- name: Create k3d Cluster
uses: nolar/setup-k3d-k3s@v1

- name: Configuring kube context and getting cluster info
run: |
export KUBECONFIG=${HOME}/.kube/config
kubectl cluster-info
kubectl get pods -n kube-system
kubectl get nodes
kubectl get svc -A
echo "kubeconfig-file-location:" $KUBECONFIG
echo "current-context:" $(kubectl config current-context)
export KUBE_CONFIG_CONTEXT=$(kubectl config current-context)
sudo ufw allow in to 172.0.0.0/8 proto tcp port 8000
sudo ufw allow in to 10.0.0.0/8 proto tcp port 8000

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install '.[dev]'

- name: Load .env file into environment
uses: cardinalby/export-env-action@v2
with:
envFile: '.env'
expand: true

- name: Create SWOOP Container
run: docker compose up --build -V -d

- name: Setup MinIO
run: |
curl https://dl.min.io/client/mc/release/linux-amd64/mc \
--create-dirs \
-o $HOME/minio-binaries/mc
chmod +x $HOME/minio-binaries/mc
export PATH=$PATH:$HOME/minio-binaries/
mc alias set swoopminio http://127.0.0.1:9000 $SWOOP_ACCESS_KEY_ID $SWOOP_SECRET_ACCESS_KEY
mc cp --recursive tests/fixtures/io/base_01/ swoopminio/swoop/execution/2595f2da-81a6-423c-84db-935e6791046e/

- name: Checkout swoop-db repo
uses: actions/checkout@master
with:
repository: Element84/swoop-db
ref: v0.1.3
path: swoop-db

- name: Setup Postgres
run: |
sudo apt update
sudo apt install postgresql postgresql-contrib
psql -p $PGPORT -U $PGUSER $PGDATABASE < swoop-db/src/swoop/db/migrations/00000_base_schema.up.sql
psql -p $PGPORT -U $PGUSER $PGDATABASE < swoop-db/src/swoop/db/fixtures/base_01.sql

- name: Installing Testkube
run: |
wget -qO - https://repo.testkube.io/key.pub | sudo apt-key add -
echo "deb https://repo.testkube.io/linux linux main" | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get install -y testkube
helm repo add kubeshop https://kubeshop.github.io/helm-charts ; helm repo update && helm upgrade --install --reuse-values --create-namespace testkube kubeshop/testkube --set testkube-api.cloud.key=${{ secrets.TESTKUBE_CLOUD_KEY }} --set testkube-api.cloud.orgId=${{ secrets.TESTKUBE_ORG_ID }} --set testkube-api.cloud.envId=${{ secrets.TESTKUBE_ENV_ID }} --set testkube-api.minio.enabled=false --set mongodb.enabled=false --set testkube-dashboard.enabled=false --set testkube-api.cloud.url=agent.testkube.io:443 --namespace testkube
kubectl wait --for=condition=ready --timeout=30m pod -n testkube -l app.kubernetes.io/instance=testkube

- name: Create Testkube Tests
continue-on-error: true
run: |
testkube create test --namespace testkube --name swoop-api-root-test --type curl/test --test-content-type git-file --git-uri https://github.com/Element84/swoop-testkube.git --git-branch main --git-path tests/curl/swoop-api-root-test.json --variable apiHost=host.k3d.internal:8000
testkube create test --namespace testkube --name swoop-api-jobs-test --type curl/test --test-content-type git-file --git-uri https://github.com/Element84/swoop-testkube.git --git-branch main --git-path tests/curl/swoop-api-jobs-test.json --variable apiHost=host.k3d.internal:8000
testkube create test --namespace testkube --name swoop-api-payload-input-test --type curl/test --test-content-type git-file --git-uri https://github.com/Element84/swoop-testkube.git --git-branch main --git-path tests/curl/swoop-api-payload-input-test.json --variable apiHost=host.k3d.internal:8000
testkube create test --namespace testkube --name swoop-api-simple-k6-load-test --type k6/script --test-content-type git-file --git-uri https://github.com/Element84/swoop-testkube.git --git-branch main --git-path tests/k6/swoop-api-simple-k6-load-test.js --variable API_HOST=host.k3d.internal:8000

- name: Running Testkube Tests
run: |
testkube run test --watch swoop-api-root-test
testkube run test --watch swoop-api-jobs-test
testkube run test --watch swoop-api-payload-input-test
testkube run test --watch swoop-api-simple-k6-load-test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,4 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
.DS_Store