mirror of
https://github.com/outbackdingo/cozystack.git
synced 2026-01-27 10:18:39 +00:00
Add test for openapi schema
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
This commit is contained in:
5
.github/workflows/pull-requests.yaml
vendored
5
.github/workflows/pull-requests.yaml
vendored
@@ -254,6 +254,11 @@ jobs:
|
||||
done
|
||||
echo "✅ The task completed successfully after $attempt attempts."
|
||||
|
||||
- name: Run OpenAPI tests
|
||||
run: |
|
||||
cd /tmp/$SANDBOX_NAME
|
||||
make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME test-openapi
|
||||
|
||||
detect_test_matrix:
|
||||
name: "Detect e2e test matrix"
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
20
hack/e2e-test-openapi.bats
Normal file
20
hack/e2e-test-openapi.bats
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bats
|
||||
# -----------------------------------------------------------------------------
|
||||
# Test OpenAPI endpoints in a Kubernetes cluster
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
@test "Test OpenAPI v2 endpoint" {
|
||||
kubectl get -v7 --raw '/openapi/v2?timeout=32s' > /dev/null
|
||||
}
|
||||
|
||||
@test "Test OpenAPI v3 endpoint" {
|
||||
kubectl get -v7 --raw '/openapi/v3/apis/apps.cozystack.io/v1alpha1' > /dev/null
|
||||
}
|
||||
|
||||
@test "Test OpenAPI v2 endpoint (protobuf)" {
|
||||
(
|
||||
kubectl proxy --port=21234 & sleep 0.5
|
||||
trap "kill $!" EXIT
|
||||
curl -sS --fail 'http://localhost:21234/openapi/v2?timeout=32s' -H 'Accept: application/com.github.proto-openapi.spec.v2@v1.0+protobuf' > /dev/null
|
||||
)
|
||||
}
|
||||
@@ -30,7 +30,7 @@ image-e2e-sandbox:
|
||||
yq -i '.e2e.image = strenv(IMAGE)' values.yaml
|
||||
rm -f images/e2e-sandbox.json
|
||||
|
||||
test: test-cluster test-apps ## Run the end-to-end tests in existing sandbox
|
||||
test: test-cluster test-openapi test-apps ## Run the end-to-end tests in existing sandbox
|
||||
|
||||
copy-nocloud-image:
|
||||
docker cp ../../../_out/assets/nocloud-amd64.raw.xz "${SANDBOX_NAME}":/workspace/_out/assets/nocloud-amd64.raw.xz
|
||||
@@ -47,6 +47,9 @@ install-cozystack: copy-installer-manifest
|
||||
test-cluster: copy-nocloud-image copy-installer-manifest ## Run the end-to-end for creating a cluster
|
||||
docker exec "${SANDBOX_NAME}" sh -c 'cd /workspace && hack/cozytest.sh hack/e2e-cluster.bats'
|
||||
|
||||
test-openapi:
|
||||
docker exec "${SANDBOX_NAME}" sh -c 'cd /workspace && hack/cozytest.sh hack/e2e-test-openapi.bats'
|
||||
|
||||
test-apps-%:
|
||||
docker exec "${SANDBOX_NAME}" sh -c 'cd /workspace && hack/cozytest.sh hack/e2e-apps/$*.bats'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user