Add back tests for examples
Signed-off-by: Marco Franssen <[email protected]>
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
TESTS_PATH="$(dirname "${BASH_SOURCE[0]}")/../tests"
|
||||
|
||||
# Set repo and version env variables
|
||||
REPOS=$(jq -r '.[] | "export " + ("HELM_REPO_" + .name | ascii_upcase | gsub("-";"_")) + "=" + .repo' "${TESTS_PATH}/charts.json")
|
||||
VERSIONS=$(jq -r '.[] | "export " + ("VERSION_" + .name | ascii_upcase | gsub("-";"_")) + "=" + .version' "${TESTS_PATH}/charts.json")
|
||||
eval "$REPOS"
|
||||
eval "$VERSIONS"
|
||||
@@ -4,7 +4,6 @@ set -x
|
||||
|
||||
SCRIPT="$(readlink -f "$0")"
|
||||
SCRIPTPATH="$(dirname "${SCRIPT}")"
|
||||
scenario="${scenario:-$(basename "${SCRIPTPATH}")}"
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
source "${SCRIPTPATH}/common.sh"
|
||||
|
||||
@@ -6,11 +6,8 @@ SCRIPT="$(readlink -f "$0")"
|
||||
SCRIPTPATH="$(dirname "${SCRIPT}")"
|
||||
DEPS="${SCRIPTPATH}/dependencies"
|
||||
|
||||
# Set repo and version env variables
|
||||
REPOS=$(jq -r '.[] | "export " + ("HELM_REPO_" + .name | ascii_upcase | gsub("-";"_")) + "=" + .repo' "${SCRIPTPATH}/charts.json")
|
||||
VERSIONS=$(jq -r '.[] | "export " + ("VERSION_" + .name | ascii_upcase | gsub("-";"_")) + "=" + .version' "${SCRIPTPATH}/charts.json")
|
||||
eval "$REPOS"
|
||||
eval "$VERSIONS"
|
||||
# shellcheck source=/dev/null
|
||||
source "${SCRIPTPATH}/../scripts/parse-versions.sh"
|
||||
|
||||
helm_install=(helm upgrade --install --create-namespace)
|
||||
|
||||
@@ -21,8 +18,7 @@ kubectl create namespace spire-server || true
|
||||
# nginx ingress
|
||||
"${helm_install[@]}" ingress-nginx ingress-nginx --version "${VERSION_INGRESS_NGINX}" --repo "${HELM_REPO_INGRESS_NGINX}" \
|
||||
--namespace ingress-nginx \
|
||||
--set controller.extraArgs.enable-ssl-passthrough='' \
|
||||
--wait
|
||||
--set controller.extraArgs.enable-ssl-passthrough=
|
||||
kubectl wait --namespace ingress-nginx --for=condition=ready pod --selector=app.kubernetes.io/component=controller
|
||||
|
||||
# prometheus
|
||||
|
||||
@@ -12,6 +12,7 @@ on:
|
||||
- '.github/tests/**/*.sh'
|
||||
- '.github/tests/**/*.json'
|
||||
- 'examples/**/*.yaml'
|
||||
- 'examples/**/*.sh'
|
||||
- 'tests/**/*'
|
||||
- 'helm-docs.sh'
|
||||
|
||||
@@ -22,6 +23,7 @@ concurrency:
|
||||
env:
|
||||
HELM_VERSION: v3.12.0
|
||||
PYTHON_VERSION: 3.11.3
|
||||
KIND_VERSION: v0.19.0
|
||||
CHART_TESTING_VERSION: v3.8.0
|
||||
|
||||
jobs:
|
||||
@@ -160,7 +162,7 @@ jobs:
|
||||
uses: helm/[email protected]
|
||||
# Only build a kind cluster if there are chart changes to test.
|
||||
with:
|
||||
version: v0.19.0
|
||||
version: ${{ env.KIND_VERSION }}
|
||||
node_image: kindest/node:${{ matrix.k8s }}
|
||||
config: .github/kind/conf/kind-config.yaml
|
||||
verbosity: 1
|
||||
@@ -172,9 +174,67 @@ jobs:
|
||||
- name: Run chart-testing (install)
|
||||
run: |
|
||||
ct install --config ct.yaml \
|
||||
--target-branch ${{ github.base_ref }} \
|
||||
--target-branch ${{ github.base_ref }}
|
||||
|
||||
- name: Test summary
|
||||
if: always()
|
||||
run: ./post-install.sh
|
||||
working-directory: .github/tests
|
||||
|
||||
build-matrix:
|
||||
name: Build matrix
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/[email protected]
|
||||
|
||||
- id: set-matrix
|
||||
name: Collect all examples
|
||||
run: |
|
||||
examples="$(find examples -maxdepth 2 -type f -name run-tests.sh | xargs -I % dirname %)"
|
||||
examples_json="$(echo "$examples" | jq -c --slurp --raw-input 'split("\n") | map(select(. != ""))')"
|
||||
echo "${examples_json}"
|
||||
echo "examples=$examples_json" >>"$GITHUB_OUTPUT"
|
||||
|
||||
outputs:
|
||||
examples: ${{ steps.set-matrix.outputs.examples }}
|
||||
|
||||
example-test:
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
needs:
|
||||
- lint-chart
|
||||
- build-matrix
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
example:
|
||||
- ${{ fromJson(needs.build-matrix.outputs.examples) }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/[email protected]
|
||||
|
||||
- name: Set up Helm
|
||||
uses: azure/[email protected]
|
||||
with:
|
||||
version: ${{ env.HELM_VERSION }}
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ env.PYTHON_VERSION }}
|
||||
|
||||
- name: Create kind cluster
|
||||
uses: helm/[email protected]
|
||||
# Only build a kind cluster if there are chart changes to test.
|
||||
with:
|
||||
version: ${{ env.KIND_VERSION }}
|
||||
node_image: kindest/node:v1.26.4
|
||||
config: .github/kind/conf/kind-config.yaml
|
||||
verbosity: 1
|
||||
|
||||
- name: Install and test example
|
||||
run: ${{ matrix.example }}/run-tests.sh
|
||||
|
||||
@@ -52,3 +52,11 @@ cleanup-test-dependencies: ## Cleans up all test dependencies resources
|
||||
@kubectl delete ns postgresql 2>/dev/null || true
|
||||
@helm uninstall -n ingress-nginx ingress-nginx 2>/dev/null || true
|
||||
@kubectl delete ns ingress-nginx 2>/dev/null || true
|
||||
|
||||
test-example-%:
|
||||
@echo Running tests for $* example…
|
||||
@examples/$*/run-tests.sh
|
||||
@echo
|
||||
|
||||
.PHONY: test-examples
|
||||
test-examples: $(patsubst examples/%/values.yaml,test-example-%,$(wildcard examples/*/values.yaml)) ## Run helm install for and helm test for all the examples
|
||||
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -xe
|
||||
|
||||
SCRIPT="$(readlink -f "$0")"
|
||||
SCRIPTPATH="$(dirname "${SCRIPT}")"
|
||||
TESTDIR="${SCRIPTPATH}/../../.github/tests"
|
||||
DEPS="${TESTDIR}/dependencies"
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
source "${SCRIPTPATH}/../../.github/scripts/parse-versions.sh"
|
||||
# shellcheck source=/dev/null
|
||||
source "${TESTDIR}/common.sh"
|
||||
|
||||
helm_install=(helm upgrade --install --create-namespace)
|
||||
ns=spire-system
|
||||
|
||||
teardown() {
|
||||
helm uninstall --namespace "${ns}" spire 2>/dev/null || true
|
||||
kubectl delete ns "${ns}" 2>/dev/null || true
|
||||
|
||||
helm uninstall --namespace mysql mysql 2>/dev/null || true
|
||||
kubectl delete ns mysql 2>/dev/null || true
|
||||
}
|
||||
|
||||
trap 'trap - SIGTERM && teardown' SIGINT SIGTERM EXIT
|
||||
|
||||
"${helm_install[@]}" mysql mysql --version "$VERSION_MYSQL" --repo "$HELM_REPO_MYSQL" \
|
||||
--namespace mysql \
|
||||
--values "${DEPS}/mysql.yaml" \
|
||||
--wait
|
||||
|
||||
"${helm_install[@]}" --namespace "${ns}" --values "${SCRIPTPATH}/values.yaml" \
|
||||
--set 'spire-server.dataStore.sql.password=sp1ff3Test' --wait spire charts/spire
|
||||
helm test --namespace "${ns}" spire
|
||||
|
||||
print_helm_releases
|
||||
print_spire_workload_status "${ns}"
|
||||
|
||||
if [[ "$1" -ne 0 ]]; then
|
||||
get_namespace_details "${ns}"
|
||||
fi
|
||||
@@ -2,7 +2,8 @@ spire-server:
|
||||
dataStore:
|
||||
sql:
|
||||
databaseType: mysql
|
||||
databaseName: spire
|
||||
host: mysql
|
||||
databaseName: spire-server
|
||||
host: mysql.mysql
|
||||
port: 3306
|
||||
username: spire
|
||||
# password: CHANGE_ME
|
||||
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -xe
|
||||
|
||||
SCRIPT="$(readlink -f "$0")"
|
||||
SCRIPTPATH="$(dirname "${SCRIPT}")"
|
||||
TESTDIR="${SCRIPTPATH}/../../.github/tests"
|
||||
DEPS="${TESTDIR}/dependencies"
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
source "${SCRIPTPATH}/../../.github/scripts/parse-versions.sh"
|
||||
# shellcheck source=/dev/null
|
||||
source "${TESTDIR}/common.sh"
|
||||
|
||||
helm_install=(helm upgrade --install --create-namespace)
|
||||
ns=spire-system
|
||||
|
||||
teardown() {
|
||||
helm uninstall --namespace "${ns}" spire 2>/dev/null || true
|
||||
kubectl delete ns "${ns}" 2>/dev/null || true
|
||||
|
||||
helm uninstall --namespace postgresql postgresql 2>/dev/null || true
|
||||
kubectl delete ns postgresql 2>/dev/null || true
|
||||
}
|
||||
|
||||
trap 'trap - SIGTERM && teardown' SIGINT SIGTERM EXIT
|
||||
|
||||
"${helm_install[@]}" postgresql postgresql --version "$VERSION_POSTGRESQL" --repo "$HELM_REPO_POSTGRESQL" \
|
||||
--namespace postgresql \
|
||||
--values "${DEPS}/postgresql.yaml" \
|
||||
--wait
|
||||
|
||||
"${helm_install[@]}" --namespace "${ns}" --values "${SCRIPTPATH}/values.yaml" \
|
||||
--set 'spire-server.dataStore.sql.password=sp1ff3Test' --wait spire charts/spire
|
||||
helm test --namespace "${ns}" spire
|
||||
|
||||
print_helm_releases
|
||||
print_spire_workload_status "${ns}"
|
||||
|
||||
if [[ "$1" -ne 0 ]]; then
|
||||
get_namespace_details "${ns}"
|
||||
fi
|
||||
@@ -2,9 +2,10 @@ spire-server:
|
||||
dataStore:
|
||||
sql:
|
||||
databaseType: postgres
|
||||
databaseName: spire
|
||||
host: postgresql
|
||||
databaseName: spire-server
|
||||
host: postgresql.postgresql
|
||||
port: 5432
|
||||
username: spire
|
||||
# password: CHANGE_ME
|
||||
options:
|
||||
- sslmode: disable
|
||||
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -xe
|
||||
|
||||
SCRIPT="$(readlink -f "$0")"
|
||||
SCRIPTPATH="$(dirname "${SCRIPT}")"
|
||||
TESTDIR="${SCRIPTPATH}/../../.github/tests"
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
source "${TESTDIR}/common.sh"
|
||||
|
||||
helm_install=(helm upgrade --install --create-namespace)
|
||||
ns=spire-server
|
||||
|
||||
teardown() {
|
||||
helm uninstall --namespace "${ns}" spire 2>/dev/null || true
|
||||
kubectl delete ns "${ns}" 2>/dev/null || true
|
||||
kubectl delete ns spire-system 2>/dev/null || true
|
||||
}
|
||||
|
||||
trap 'trap - SIGTERM && teardown' SIGINT SIGTERM EXIT
|
||||
|
||||
kubectl create namespace spire-system 2>/dev/null || true
|
||||
kubectl label namespace spire-system pod-security.kubernetes.io/enforce=privileged || true
|
||||
kubectl create namespace "${ns}" 2>/dev/null || true
|
||||
kubectl label namespace "${ns}" pod-security.kubernetes.io/enforce=restricted || true
|
||||
|
||||
"${helm_install[@]}" --namespace "${ns}" --values "${SCRIPTPATH}/values.yaml" --wait spire charts/spire
|
||||
helm test --namespace "${ns}" spire
|
||||
|
||||
print_helm_releases
|
||||
print_spire_workload_status "${ns}"
|
||||
|
||||
if [[ "$1" -ne 0 ]]; then
|
||||
get_namespace_details "${ns}"
|
||||
fi
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -xe
|
||||
|
||||
SCRIPT="$(readlink -f "$0")"
|
||||
SCRIPTPATH="$(dirname "${SCRIPT}")"
|
||||
TESTDIR="${SCRIPTPATH}/../../.github/tests"
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
source "${TESTDIR}/common.sh"
|
||||
|
||||
helm_install=(helm upgrade --install --create-namespace)
|
||||
ns=spire-system
|
||||
|
||||
teardown() {
|
||||
helm uninstall --namespace "${ns}" spire 2>/dev/null || true
|
||||
kubectl delete ns "${ns}" 2>/dev/null || true
|
||||
}
|
||||
|
||||
trap 'trap - SIGTERM && teardown' SIGINT SIGTERM EXIT
|
||||
|
||||
"${helm_install[@]}" --namespace "${ns}" --values "${SCRIPTPATH}/values.yaml" --wait spire charts/spire
|
||||
helm test --namespace "${ns}" spire
|
||||
|
||||
print_helm_releases
|
||||
print_spire_workload_status "${ns}"
|
||||
|
||||
if [[ "$1" -ne 0 ]]; then
|
||||
get_namespace_details "${ns}"
|
||||
fi
|
||||
Reference in New Issue
Block a user