-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0cfa807
commit f4efbf3
Showing
6 changed files
with
268 additions
and
3 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
name: 'Integration tests (Gardener)' | ||
description: 'Runs integration tests on Gardener' | ||
inputs: | ||
manager_image: | ||
description: "Manager image used for test" | ||
required: true | ||
gardener_secret: | ||
description: "Kubeconfig secret for Gardener" | ||
required: true | ||
gardener_provider: | ||
description: "Gardener provider to use" | ||
required: true | ||
gardener_project_name: | ||
required: true | ||
description: "Name of the gardener project" | ||
test_make_target: | ||
description: 'Make target for integration tests to run' | ||
default: 'test-integration' | ||
client_id: | ||
description: "Client id for oidc" | ||
required: true | ||
client_secret: | ||
description: "Client secret for oidc" | ||
required: true | ||
oidc_well_known_url: | ||
description: "OIDC well known URL" | ||
required: true | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Generate cluster name | ||
shell: bash | ||
run: echo CLUSTER_NAME=ag-$(echo $RANDOM | md5sum | head -c 7) >> $GITHUB_ENV | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: "go.mod" | ||
- name: Checkout to PR branch # to remove after getting rid of pull_request_target | ||
shell: bash | ||
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target' | ||
run: | | ||
git fetch origin pull/${{ github.event.number }}/head:PR-${{ github.event.number }} | ||
git checkout PR-${{ github.event.number }} | ||
- name: Prepare gardener kubeconfig | ||
shell: bash | ||
env: | ||
GARDENER_TOKEN: ${{ inputs.gardener_secret }} | ||
run: "${{ github.workspace }}/hack/ci/gardener_kubeconfig.sh" | ||
- name: Provision cluster | ||
shell: bash | ||
env: | ||
GARDENER_KUBECONFIG: "${{ github.workspace }}/gardener_kubeconfig.yaml" | ||
CLUSTER_KUBECONFIG: "${{ github.workspace }}/${{ env.CLUSTER_NAME }}_kubeconfig.yaml" | ||
GARDENER_PROVIDER: ${{ inputs.gardener_provider }} | ||
GARDENER_PROJECT_NAME: ${{ inputs.gardener_project_name }} | ||
run: "${{ github.workspace }}/hack/ci/provision-gardener.sh" | ||
- name: Run integration tests | ||
shell: bash | ||
env: | ||
IMG: ${{ inputs.manager_image }} | ||
CLIENT_ID: ${{ inputs.client_id }} | ||
CLIENT_SECRET: ${{ inputs.client_secret }} | ||
OIDC_CONFIG_URL: ${{ inputs.oidc_well_known_url }} | ||
CLUSTER_KUBECONFIG: "${{ github.workspace }}/${{ env.CLUSTER_NAME }}_kubeconfig.yaml" | ||
run: EXPORT_RESULT=true "${{ github.workspace }}/hack/ci/int-tests-gardener.sh" ${{ inputs.test_make_target }} | ||
- name: Gather deployment logs | ||
shell: bash | ||
if: always() | ||
run: | | ||
mkdir logs | ||
export KUBECONFIG="${{ github.workspace }}/${{ env.CLUSTER_NAME }}_kubeconfig.yaml" | ||
(kubectl logs -n kyma-system deployments/istio-controller-manager || true) > logs/istio-controller-manager.log | ||
(kubectl logs -n kyma-system deployments/api-gateway-controller-manager || true) > logs/api-gateway-controller-manager.log | ||
(kubectl logs -n istio-system deployments/istio-ingressgateway || true) > logs/istio-ingressgateway.log | ||
(kubectl logs -n istio-system deployments/istiod || true) > logs/istiod.log | ||
(kubectl logs -n kyma-system deployments/ory-oathkeeper || true) > logs/ory-oathkeeper.log | ||
(kubectl get --all-namespaces apirules.gateway.kyma-project.io -oyaml || true) > logs/apirules-dump.yaml | ||
(kubectl get --all-namespaces apigateways.operator.kyma-project.io -oyaml || true) > logs/gateway-dump.yaml | ||
(kubectl get -n kyma-system deployment ory-oathkeeper -oyaml || true) > logs/ory-oathkeeper-dump.yaml | ||
- name: Uploads logs | ||
uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: logs-${{ github.job }}-${{ inputs.test_make_target }} | ||
path: logs/ | ||
- name: Uploads artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: html-reports-${{ github.job }}-${{ inputs.test_make_target }} | ||
path: tests/integration/reports/ | ||
- name: Deprovision cluster | ||
if: always() | ||
shell: bash | ||
env: | ||
GARDENER_KUBECONFIG: "${{ github.workspace }}/gardener_kubeconfig.yaml" | ||
GARDENER_PROJECT_NAME: ${{ inputs.gardener_project_name }} | ||
run: "${{ github.workspace }}/hack/ci/deprovision-gardener.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
name: 'Lint' | ||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: "go.mod" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Description: This script runs given integration tests on a real Gardener cluster | ||
# It installs istio and api gateway and then runs make test targets provided via commandline arguments to that script | ||
# It requires the following env variables: | ||
# - IMG - API gateway image to be deployed (by make deploy) | ||
# - CLUSTER_NAME - Gardener cluster name | ||
# - CLUSTER_KUBECONFIG - Gardener cluster kubeconfig path | ||
# - TEST_SA_ACCESS_KEY_PATH - path to the GCP Service account json file | ||
# - TEST_CUSTOM_DOMAIN - a domain used by tests (a subdomain is created during tests execution) | ||
|
||
set -eo pipefail | ||
|
||
if [ $# -lt 1 ]; then | ||
>&2 echo "Make target is required as parameter" | ||
exit 2 | ||
fi | ||
|
||
function check_required_vars() { | ||
local requiredVarMissing=false | ||
for var in "$@"; do | ||
if [ -z "${!var}" ]; then | ||
>&2 echo "Environment variable ${var} is required but not set" | ||
requiredVarMissing=true | ||
fi | ||
done | ||
if [ "${requiredVarMissing}" = true ] ; then | ||
exit 2 | ||
fi | ||
} | ||
|
||
requiredVars=( | ||
IMG | ||
CLUSTER_NAME | ||
CLUSTER_KUBECONFIG | ||
TEST_SA_ACCESS_KEY_PATH | ||
) | ||
|
||
check_required_vars "${requiredVars[@]}" | ||
|
||
echo "Executing integration tests in cluster ${CLUSTER_NAME}, kubeconfig ${CLUSTER_KUBECONFIG}" | ||
export KUBECONFIG="${CLUSTER_KUBECONFIG}" | ||
|
||
export CLUSTER_DOMAIN=$(kubectl get configmap -n kube-system shoot-info -o jsonpath="{.data.domain}") | ||
echo "Cluster domain: ${CLUSTER_DOMAIN}" | ||
|
||
export GARDENER_PROVIDER=$(kubectl get configmap -n kube-system shoot-info -o jsonpath="{.data.provider}") | ||
echo "Gardener provider: ${GARDENER_PROVIDER}" | ||
|
||
echo "Custom domain: ${TEST_CUSTOM_DOMAIN}" | ||
|
||
export TEST_DOMAIN="${CLUSTER_DOMAIN}" | ||
export KYMA_DOMAIN="${CLUSTER_DOMAIN}" # it is required by env_vars.sh | ||
export IS_GARDENER=true | ||
|
||
# Add pwd to path to be able to use binaries downloaded in scripts | ||
export PATH="${PATH}:${PWD}" | ||
|
||
echo "Installing istio" | ||
make install-istio | ||
|
||
echo "Deploying api-gateway, image: ${IMG}" | ||
make deploy | ||
|
||
echo "Waiting for the ingress gateway external address" | ||
[ "$GARDENER_PROVIDER" == "aws" ] && address_field="{.status.loadBalancer.ingress[0].hostname}" || address_field="{.status.loadBalancer.ingress[0].ip}" | ||
kubectl wait --timeout=300s --namespace istio-system services/istio-ingressgateway --for=jsonpath="${address_field}" | ||
ingress_external_address=$(kubectl get services --namespace istio-system istio-ingressgateway --output jsonpath="${address_field}") | ||
ingress_external_status_port=$(kubectl get services --namespace istio-system istio-ingressgateway --output jsonpath='{.spec.ports[?(@.name=="status-port")].targetPort}') | ||
|
||
echo "Determined ingress external address: ${ingress_external_address} and external status port: ${ingress_external_status_port}" | ||
|
||
echo "Waiting until it is possible to connect to the ingress gateway" | ||
trial=1 | ||
# check if it is possible to establish connection to the ingress gateway (the exact http status code doesn't matter) | ||
until curl --silent --output /dev/null "http://${ingress_external_address}:${ingress_external_status_port}" | ||
do | ||
if (( trial >= 60 )) | ||
then | ||
echo "Exceeded number of trials while waiting for the ingress gateway, giving up..." | ||
exit 4 | ||
fi | ||
echo "Ingress gateway does not respond, trying again..." | ||
sleep 10 | ||
trial=$((trial + 1)) | ||
done | ||
echo "Ingress gateway responded" | ||
|
||
echo "Executing tests" | ||
for make_target in "$@" | ||
do | ||
echo "Executing make target $make_target" | ||
make $make_target | ||
done | ||
echo "Tests finished" |