Skip to content

Commit 060bce5

Browse files
committed
chore: add integration test pr workflow
1 parent 251ae72 commit 060bce5

File tree

2 files changed

+182
-0
lines changed

2 files changed

+182
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Integration Test Pull Request
2+
on:
3+
pull_request:
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest-8core
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
15+
with:
16+
submodules: recursive
17+
18+
- name: Set up Go
19+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
20+
with:
21+
go-version-file: go.mod
22+
23+
- name: make revendor
24+
run: make revendor
25+
26+
- name: make build
27+
run: make build
28+
29+
- name: run integration test
30+
env:
31+
GARDENER_KUBECONFIG: ${{ secrets.GARDENER_LAAS_SERVICE_ACCOUNT }}
32+
run: |
33+
VERSION="$("./hack/get-version.sh")"
34+
35+
echo "check if integration tests should be started"
36+
(
37+
PR_ID=$(git config -f "./.git/config" pullrequest.id)
38+
echo "PR_ID: " $PR_ID
39+
40+
GIT_COMMENT=$(git show -s --format=%s)
41+
echo "git comment: " $GIT_COMMENT
42+
43+
if git show -s --format=%s | grep run-int-tests; then
44+
echo "'run-int-tests' in commit message, integration tests should be started"
45+
"./hack/integration-test-runner.sh" "$GARDENER_KUBECONFIG" "garden-laas" "$VERSION" "$PR_ID"
46+
elif git branch --show-current | grep -E "renovate/|dependabot/"; then
47+
echo "Dependency update from renovate or dependabot, integration tests should be started"
48+
"./hack/integration-test-runner.sh" "$GARDENER_KUBECONFIG" "garden-laas" "$VERSION" "$PR_ID"
49+
else
50+
echo "integration tests are skipped"
51+
fi
52+
)
53+

hack/integration-test-runner.sh

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#!/bin/bash
2+
3+
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
7+
set -o nounset
8+
set -o pipefail
9+
10+
GARDENER_KUBECONFIG_PATH=$1
11+
NAMESPACE=$2
12+
VERSION=$3
13+
PR_ID=$4
14+
15+
MAX_NUM_CLUSTERS=20
16+
NUM_CLUSTERS_START_DELETE_OLDEST=15
17+
DURATION_FOR_CLUSTER_DELETION=48h
18+
19+
PROJECT_ROOT="$(realpath $(dirname $0)/..)"
20+
21+
make -C $PROJECT_ROOT revendor
22+
23+
echo "Run integration tests with cluster and registry creation"
24+
echo "Source path: ${PROJECT_ROOT}"
25+
echo "Gardener kubeconfig path: ${GARDENER_KUBECONFIG_PATH}"
26+
echo "Shoot cluster namespace: ${NAMESPACE}"
27+
echo "Landscaper version: ${VERSION}"
28+
29+
TMP="${PROJECT_ROOT}/tmp-int-test-cluster"
30+
rm -f -r $TMP
31+
mkdir -p $TMP
32+
TARGET_SHOOT_DIR="${TMP}/target-shoot"
33+
RESOURCE_SHOOT_DIR="${TMP}/resource-shoot"
34+
mkdir -p $TARGET_SHOOT_DIR
35+
mkdir -p $RESOURCE_SHOOT_DIR
36+
echo "Config directory: ${TMP}"
37+
38+
exit_on_error() {
39+
if [ "$1" -ne 0 ]; then
40+
echo -e "Error: $2"
41+
exit 1
42+
fi
43+
}
44+
45+
"${PROJECT_ROOT}/hack/int-test-helper/install-missing-software"
46+
exit_on_error $? "install software failed"
47+
48+
CREATE_SHOOT_PIDS=()
49+
50+
echo "Creating Target Shoot Cluster"
51+
NGINX_INGRESS_ENABLED=true
52+
DISABLE_SHOOT_DELETION=false
53+
WORKERLESS=false
54+
timeout -k 30m 30m "${PROJECT_ROOT}/hack/int-test-helper/create-shoot-cluster" $GARDENER_KUBECONFIG_PATH \
55+
$NAMESPACE \
56+
$TARGET_SHOOT_DIR \
57+
$MAX_NUM_CLUSTERS \
58+
$NUM_CLUSTERS_START_DELETE_OLDEST \
59+
$DURATION_FOR_CLUSTER_DELETION \
60+
$PR_ID \
61+
$NGINX_INGRESS_ENABLED \
62+
$DISABLE_SHOOT_DELETION \
63+
$WORKERLESS \
64+
&>"${TARGET_SHOOT_DIR}/create-shoot-cluster.log" &
65+
66+
CREATE_SHOOT_PIDS+=($!)
67+
68+
# When both create-shoot-cluster calls are started at the same time,
69+
# the resource shoot may be cleaned-up by the target shoot create call.
70+
# To prevent this, the target shoot create gets a head start before the
71+
# resource shoot is being created.
72+
# The sleep also improves the entropy when generating a Shoot name.
73+
sleep 15
74+
75+
echo "Creating Resource Shoot Cluster"
76+
NGINX_INGRESS_ENABLED=false
77+
DISABLE_SHOOT_DELETION=true
78+
WORKERLESS=false
79+
timeout -k 30m 30m "${PROJECT_ROOT}/hack/int-test-helper/create-shoot-cluster" $GARDENER_KUBECONFIG_PATH \
80+
$NAMESPACE \
81+
$RESOURCE_SHOOT_DIR \
82+
$MAX_NUM_CLUSTERS \
83+
$NUM_CLUSTERS_START_DELETE_OLDEST \
84+
$DURATION_FOR_CLUSTER_DELETION \
85+
$PR_ID \
86+
$NGINX_INGRESS_ENABLED \
87+
$DISABLE_SHOOT_DELETION \
88+
$WORKERLESS \
89+
&>"${RESOURCE_SHOOT_DIR}/create-shoot-cluster.log" &
90+
91+
CREATE_SHOOT_PIDS+=($!)
92+
93+
echo "Waiting until shoot clusters are ready"
94+
wait "${CREATE_SHOOT_PIDS[@]}"
95+
96+
if [[ $? != 0 ]]; then
97+
echo "Creating the shoot clusters failed"
98+
echo "###### TARGET SHOOT LOG ######"
99+
cat "${TARGET_SHOOT_DIR}/create-shoot-cluster.log"
100+
echo "###### RESOURCE SHOOT LOG ######"
101+
cat "${RESOURCE_SHOOT_DIR}/create-shoot-cluster.log"
102+
exit 1
103+
fi
104+
105+
TARGET_SHOOT_KUBECONFIG_PATH="${TARGET_SHOOT_DIR}/kubeconfig.yaml"
106+
RESOURCE_SHOOT_KUBECONFIG_PATH="${RESOURCE_SHOOT_DIR}/kubeconfig.yaml"
107+
OIDC_ISSUER_URL_PATH="${RESOURCE_SHOOT_DIR}/oidc-issuer-url"
108+
109+
echo "Target Shoot Cluster Name: $(cat ${TARGET_SHOOT_DIR}/clustername)"
110+
echo "Resource Shoot Cluster Name: $(cat ${RESOURCE_SHOOT_DIR}/clustername)"
111+
112+
"${PROJECT_ROOT}/hack/int-test-helper/create-registry" $TARGET_SHOOT_KUBECONFIG_PATH $TARGET_SHOOT_DIR
113+
exit_on_error $? "create-registry failed"
114+
115+
echo "Installing Landscaper"
116+
"${PROJECT_ROOT}/hack/int-test-helper/install-landscaper-dual" \
117+
-w $TARGET_SHOOT_DIR \
118+
-v $VERSION \
119+
-t $TARGET_SHOOT_KUBECONFIG_PATH \
120+
-r $RESOURCE_SHOOT_KUBECONFIG_PATH \
121+
-i "$(cat ${TARGET_SHOOT_DIR}/ingress-domain)"
122+
123+
exit_on_error $? "installing landscaper failed"
124+
125+
"${PROJECT_ROOT}/hack/int-test-helper/run-tests" $RESOURCE_SHOOT_KUBECONFIG_PATH ${TARGET_SHOOT_DIR}/docker.config $VERSION true "$OIDC_ISSUER_URL_PATH"
126+
exit_on_error $? "run-tests failed"
127+
128+
"${PROJECT_ROOT}/hack/int-test-helper/delete-shoot-cluster" $GARDENER_KUBECONFIG_PATH $NAMESPACE $TARGET_SHOOT_DIR
129+
"${PROJECT_ROOT}/hack/int-test-helper/delete-shoot-cluster" $GARDENER_KUBECONFIG_PATH $NAMESPACE $RESOURCE_SHOOT_DIR

0 commit comments

Comments
 (0)