Skip to content

Commit

Permalink
feat: add workflows for property-based testing
Browse files Browse the repository at this point in the history
  • Loading branch information
smrz2001 committed Sep 6, 2023
1 parent e5061d8 commit c57ce5e
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Publish Docker Image

on:
push:
branches: [ "main" ]
branches: [ "main", "feat/ci" ]

jobs:
publish:
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,11 @@ jobs:
-
name: Test ${{ matrix.networks }}
working-directory: k8s/tests/scripts
run: ./run-network-tests.sh ${{ matrix.networks }}
run: |
# Add a "_sha_runId" suffix to differentiate test runs
TEST_SUFFIX="_$(echo ${{ github.sha }} | head -c 12)_${{ github.run_id }}"
./run-tests.sh ${{ matrix.networks }}
-
name: Delete ${{ matrix.networks }}
working-directory: k8s/tests/scripts
run: ./delete-tests.sh ${{ matrix.networks }}
3 changes: 3 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ do
echo "Running tests in: $tb"
$tb
done

# Always exit successfully so that the test job isn't restarted
exit 0
4 changes: 2 additions & 2 deletions k8s/tests/scripts/check-network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ populate_peers() {
}

check_network() {
# Wait for 5 minutes, or till the network is ready.
# Wait for 10 minutes, or till the network is ready.
n=0
until [ "$n" -ge 30 ];
until [ "$n" -ge 60 ];
do
if [ "$(check_status)" == "true" ]; then
echo Network is ready
Expand Down
13 changes: 13 additions & 0 deletions k8s/tests/scripts/delete-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# Delete the tests job
yq "
.metadata.namespace = \"keramik-$1$TEST_SUFFIX\" |
(select(.subjects[] | length) | .subjects[0].namespace) = \"keramik-$1$TEST_SUFFIX\"
" ../manifests/setup.yaml | kubectl delete -f -

# Delete the test network
yq ".metadata.name = \"$1$TEST_SUFFIX\"" ../../networks/"$1".yaml | kubectl delete -f -

# Wait for namespace to get deleted
kubectl wait --for=delete namespace/"keramik-$1$TEST_SUFFIX" --timeout=10m
15 changes: 0 additions & 15 deletions k8s/tests/scripts/run-network-tests.sh

This file was deleted.

17 changes: 17 additions & 0 deletions k8s/tests/scripts/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Create namespace and setup RBAC
kubectl create namespace "keramik-$1$TEST_SUFFIX"
yq "
.metadata.namespace = \"keramik-$1$TEST_SUFFIX\" |
(select(.subjects[] | length) | .subjects[0].namespace) = \"keramik-$1$TEST_SUFFIX\"
" ../manifests/setup.yaml | kubectl apply -f -

# Create the network.
kubectl create configmap check-network --from-file=check-network.sh -n "keramik-$1$TEST_SUFFIX"
yq ".metadata.name = \"keramik-$1$TEST_SUFFIX\"" ../../networks/"$1".yaml | kubectl apply -f -

# Create the test job
kubectl apply -f ../manifests/tests.yaml -n "keramik-$1$TEST_SUFFIX"

# Wait for tests to complete

0 comments on commit c57ce5e

Please sign in to comment.