This repository was archived by the owner on Nov 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
233 lines (194 loc) · 6.76 KB
/
e2e.yml
File metadata and controls
233 lines (194 loc) · 6.76 KB
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
name: E2E
on:
workflow_dispatch:
schedule:
# Run everyday day at 9:00 AM
- cron: '0 9 * * *'
pull_request:
paths-ignore:
- 'scripts/**'
- '*.md'
push:
branches:
- 'release/*"'
- 'main'
- 'master'
env:
GOARCH: amd64
CGO_ENABLED: 0
SETUP_GO_VERSION: '^1.19'
HOST_NAME: telemetry-test # for `start` script
CLUSTER_NAME: telemetry-test
TOKEN: ${{ secrets.TOKEN }}
REPO: telemetry-stats
REPO_URL: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY
REPOSITORY: ${{ github.repository }}
BRANCH: ${{ github.ref_name }}
TELEMETRY_REPO: https://github.com/rancher/telemetry
TELEMETRY_BRANCH: ${{ vars.TELEMETRY_BRANCH || 'master' }}
jobs:
single-cluster:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
path: telemetry-stats
- name: Get latest tag for telemetry
uses: actions/github-script@v6
id: latest_tag
if: ${{ env.TELEMETRY_BRANCH == 'release' }}
with:
script: |
const { data } = await github.rest.repos.getLatestRelease({
owner: 'rancher',
repo: 'telemetry'
})
return data.tag_name;
- name: Replace TELEMETRY_BRANCH with latest tag
if: ${{ env.TELEMETRY_BRANCH == 'release' }}
run: |
export ACTUAL_TELEMETRY_BRANCH=${{ steps.latest_tag.outputs.result }}
echo "ACTUAL_TELEMETRY_BRANCH=${ACTUAL_TELEMETRY_BRANCH}" >> $GITHUB_ENV
- name: Set ACTUAL_TELEMETRY_BRANCH to the value of TELEMETRY_BRANCH if still unset
if: ${{ env.TELEMETRY_BRANCH != 'release' }}
run: |
echo "ACTUAL_TELEMETRY_BRANCH=${TELEMETRY_BRANCH}" >> $GITHUB_ENV
- name: Print TELEMETRY_BRANCH and ACTUAL_TELEMETRY_BRANCH
run: |
echo "TELEMETRY_BRANCH=${TELEMETRY_BRANCH}"
echo "ACTUAL_TELEMETRY_BRANCH=${ACTUAL_TELEMETRY_BRANCH}"
- uses: actions/checkout@v3
with:
repository: rancher/telemetry
path: telemetry
ref: ${{ env.ACTUAL_TELEMETRY_BRANCH }}
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-go@v3
with:
go-version: ${{ env.SETUP_GO_VERSION }}
- name: Compile & containerize Telemetry
if: ${{ env.TELEMETRY_BRANCH != 'release' }}
run: |
set -x
# Compile using dapper
cd telemetry
curl -sL https://releases.rancher.com/dapper/latest/dapper-$(uname -s)-$(uname -m) > /usr/local/bin/dapper
chmod +x /usr/local/bin/dapper
dapper
# Build container image
export image_name="rancher/telemetry:${ACTUAL_TELEMETRY_BRANCH}"
docker build \
--network=host \
-f package/Dockerfile \
-t ${image_name} \
.
# Make name of resulting image available to other steps
echo "TELEMETRY_IMAGE=${image_name}" >> $GITHUB_ENV
- name: Set remote container image for Telemetry release branch
if: ${{ env.TELEMETRY_BRANCH == 'release' }}
run: |
export image_name="rancher/telemetry:${ACTUAL_TELEMETRY_BRANCH}-amd64"
echo "TELEMETRY_IMAGE=${image_name}" >> $GITHUB_ENV
- name: Compile & containerize Telemetry Stats
run: |
cd telemetry-stats
set +x
docker build \
--network=host \
--build-arg VERSION=dev \
--build-arg upstream= \
-t rancherlabs/rancher-telemetry-stats:dev \
.
- name: Provision k3d Cluster
uses: AbsaOSS/k3d-action@v2
with:
cluster-name: ${{ env.CLUSTER_NAME }}
args: >-
--api-port 6443
--network "nw01"
- name: Upload Telemetry Docker image
if: ${{ env.TELEMETRY_BRANCH != 'release' }}
run: |
set -x
k3d image import -c ${{ env.CLUSTER_NAME }} rancher/telemetry:${ACTUAL_TELEMETRY_BRANCH}
- name: Upload Telemetry Stats Docker image
run: |
k3d image import -c ${{ env.CLUSTER_NAME }} rancherlabs/rancher-telemetry-stats:dev
- name: Install Rancher
run: |
set -ex
echo "working directory: $(pwd)"
echo "files in working directory: $(find)"
pip install httpie
cd telemetry-stats/e2e
source ./start
install-rancher
# Verify
for i in {0..20}; do
ip=$(
kubectl get -A ingress -o json |
jq -r '.items[0].status.loadBalancer.ingress[0].ip'
)
if [[ "${ip}" == "null" ]]; then
sleep 1
continue
fi
if http --check-status --verify=no GET "https://${ip}" Host:${HOST_NAME} ; then
>&2 echo "Rancher installation successfully verified"
exit 0
fi
sleep 1
done
>&2 echo "Rancher installation test failed"
exit 1
- name: Configure Rancher
run: |
cd telemetry-stats/e2e && \
source ./start && \
CLUSTER_IP=$(get-cluster-ip) && \
init-base "admin"
- name: Install PostgreSQL
run: |
cd telemetry-stats/e2e && source ./start && install-postgres-13.2
- name: Install Telemetry Server from $TELEMETRY_BRANCH branch
run: |
set -x
cd telemetry-stats/e2e && source ./start && install-telemetry-server
- name: Install Telemetry Client from $TELEMETRY_BRANCH branch
run: |
set -x
cd telemetry-stats/e2e && source ./start && install-telemetry-client
- name: Install InfluxDB
run: |
cd telemetry-stats/e2e && source ./start && install-influx
- name: Install Telemetry Stats
run: |
cd telemetry-stats/e2e && source ./start && \
install-telemetry-stats-dev
- name: Test installation
run: |
set -x
ns="${ns:-telemetry}"
cd telemetry-stats/e2e
kubectl -n "${ns}" apply --wait -k manifests/tests
kubectl -n telemetry wait \
--for=condition=complete \
--timeout=300s \
job/test-telemetry-server
kubectl -n telemetry wait \
--for=condition=complete \
--timeout=300s \
job/test-influxdb
- name: Collect logs
if: failure()
run: |
bash telemetry-stats/e2e/kubectl-dump telemetry
- name: Upload logs
uses: actions/upload-artifact@v3
if: ${{ failure() && github.action }}
with:
name: gha-telemetry-dev-e2e-logs-${{ github.sha }}-${{ github.run_id }}
path: |
kubectl-dump-*
retention-days: 2