-
Notifications
You must be signed in to change notification settings - Fork 14
166 lines (166 loc) · 6.45 KB
/
test-e2e-runtime-watcher.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: TestSuite E2E
on:
pull_request:
branches: [ "main" ]
workflow_dispatch:
inputs:
k8s_version:
description: "With Kubernetes version"
required: false
jobs:
wait-for-img:
name: "Wait for image build"
runs-on: ubuntu-latest
steps:
- uses: autotelic/action-wait-for-status-check@v1
id: wait-for-build
with:
token: ${{ secrets.GITHUB_TOKEN }}
statusName: ${{ (github.event_name == 'pull_request') && 'pull-runtime-watcher-img-build' || 'main-runtime-watcher-build' }}
timeoutSeconds: 900
intervalSeconds: 10
- name: Exit if build failed
if: steps.wait-for-build.outputs.state != 'success'
run: |
echo "Image build did not succeed, skipping E2E Test!"
exit 1
e2e-integration:
strategy:
matrix:
e2e-test: ["watcher-enqueue", "watcher-metrics"]
name: "E2E"
needs: [wait-for-img]
runs-on: ubuntu-latest
timeout-minutes: 10
env:
K3D_VERSION: v5.6.0
K8S_VERSION: ${{ github.event.inputs.k8s_version || '1.28.7' }}
ISTIO_VERSION: 1.20.3
CM_VERSION: v1.13.3
GOSUMDB: off
steps:
- name: Install kubectl
run: |
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | sudo gpg --batch --yes --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt update -y
sudo apt install kubectl -y
- name: Install istioctl
run: |
curl -L https://istio.io/downloadIstio | TARGET_ARCH=x86_64 sh -
chmod +x istio-$ISTIO_VERSION/bin/istioctl
mv istio-$ISTIO_VERSION/bin/istioctl /usr/local/bin
- name: Install kyma-cli
run: |
wget https://storage.googleapis.com/kyma-cli-unstable/kyma-linux
chmod +x kyma-linux && mv kyma-linux /usr/local/bin/kyma-unstable
echo "PATH=/usr/local/bin/kyma-unstable" >> $GITHUB_OUTPUT
ln -s /usr/local/bin/kyma-unstable /usr/local/bin/kyma
- name: Install cmctl
run: |
OS=$(go env GOOS); ARCH=$(go env GOARCH); curl -fsSL -o cmctl.tar.gz https://github.com/cert-manager/cert-manager/releases/latest/download/cmctl-$OS-$ARCH.tar.gz
tar xzf cmctl.tar.gz
sudo mv cmctl /usr/local/bin
- name: Install k3d
run: |
wget -qO - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=$K3D_VERSION bash
FILE=/etc/hosts
if [ -f "$FILE" ]; then
sudo echo "127.0.0.1 k3d-kcp-registry" | sudo tee -a $FILE
else
echo "$FILE does not exist."
exit 1
fi
echo "/etc/hosts file patched"
- name: Create SKR cluster
run: |
k3d cluster create skr \
-p 10080:80@loadbalancer \
-p 10443:443@loadbalancer \
-p 9090:9090@loadbalancer \
-p 2112:2112@loadbalancer \
--image rancher/k3s:v$K8S_VERSION-k3s1 \
--k3s-arg '--disable=traefik@server:*' \
--k3s-arg '--tls-san=host.k3d.internal@server:*'
- name: Create KCP cluster
run: |
k3d cluster create kcp \
-p 9443:443@loadbalancer \
-p 9080:80@loadbalancer \
-p 9081:8080@loadbalancer \
--registry-create k3d-kcp-registry:5111 \
--image rancher/k3s:v$K8S_VERSION-k3s1 \
--k3s-arg '--disable=traefik@server:*' \
--k3s-arg '--tls-san=host.k3d.internal@server:*'
- name: Export kubeconfigs
run: |
k3d kubeconfig merge -a -d
echo "KCP_KUBECONFIG=$(k3d kubeconfig write kcp)" >> $GITHUB_ENV
echo "SKR_KUBECONFIG=$(k3d kubeconfig write skr)" >> $GITHUB_ENV
- name: Switch context to KCP
run: kubectl config use-context k3d-kcp
- name: Deploy istio
run: |
istioctl install --set profile=demo -y
- name: Deploy cert-manager
run: |
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/$CM_VERSION/cert-manager.yaml
cmctl check api --wait=2m
- name: Checkout runtime-watcher
uses: actions/checkout@v4
- name: Checkout lifecycle-manager
uses: actions/checkout@v4
with:
repository: kyma-project/lifecycle-manager
path: lifecycle-manager
- name: Checkout template-operator
uses: actions/checkout@v4
with:
repository: kyma-project/template-operator
path: template-operator
- name: Set up go environment
uses: actions/setup-go@v4
with:
go-version-file: 'runtime-watcher/go.mod'
cache-dependency-path: 'runtime-watcher/go.sum'
- name: Add kustomize patch with PR image
if: ${{ github.event_name == 'pull_request' }}
working-directory: lifecycle-manager
run: |
IMAGE_TAG=PR-${{ github.event.pull_request.number }}
pushd config/watcher_local_test
echo \
"- op: add
path: /spec/template/spec/containers/0/args/-
value: --watcher-dev-registry=true
- op: add
path: /spec/template/spec/containers/0/args/-
value: --skr-watcher-image-tag=$IMAGE_TAG" >> patch_watcher_img.yaml
kustomize edit add patch --path patch_watcher_img.yaml --kind Deployment
popd
kustomize build config/watcher_local_test
- name: Deploy lifecycle-manager
working-directory: lifecycle-manager
run: |
maxRetry=5
for retry in $(seq 1 $maxRetry)
do
if make local-deploy-with-watcher IMG=europe-docker.pkg.dev/kyma-project/prod/lifecycle-manager:latest; then
echo "KLM deployed successfully"
exit 0
elif [[ $retry -lt $maxRetry ]]; then
echo "Deploy encountered some error, will retry after 20 seconds"
sleep 20
else
echo "KLM deployment failed"
exit 1
fi
done
- name: Cluster info
run: |
kubectl get pods -A
kubectl get deploy klm-controller-manager -n kcp-system -oyaml
- name: Run tests
working-directory: runtime-watcher
run: |
make -C tests/e2e ${{ matrix.e2e-test }}