-
Notifications
You must be signed in to change notification settings - Fork 164
300 lines (298 loc) · 14.9 KB
/
eden_gcp.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
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
---
name: EdenGCP
on: # yamllint disable-line rule:truthy
workflow_run:
workflows:
- Publish
types:
- completed
workflow_dispatch:
inputs:
test_type:
description: 'test type'
required: true
type: choice
options:
- PR
- docker
pr_number:
description: '[PR] number'
required: false
type: string
eve_docker_tag:
description: '[docker] eve tag'
required: false
eve_docker_reg:
description: '[docker] eve registry'
required: false
type: choice
options:
- lfedge/eve
- evebuild/pr
- custom
eve_docker_reg_custom:
description: '[docker] eve custom registry'
required: false
type: string
concurrency:
group: ${{ github.workflow }}
# yamllint disable rule:line-length
jobs:
integration:
name: Integration test (${{ matrix.backend }};${{ matrix.hv }};${{ matrix.fs }})
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
backend: ["gcp", "rol"]
hv: ["kvm", "xen"]
fs: ["zfs", "ext4"]
steps:
- name: Check
run: |
for addr in $(ip addr list|sed -En -e 's/.*inet ([0-9.]+).*/\1/p')
do
if echo "$addr" | grep -q -E "10.11.(12|13).[0-9]+"; then
echo "$addr overlaps with test"; exit 1
fi
if echo "$addr" | grep -q -E "10.8.0.[0-9]+"; then
echo "$addr overlaps with vpn"; exit 1
fi
done
sudo df -h
sudo swapoff -a
sudo free
- name: Check RoL secrets
if: matrix.backend == 'rol'
run: |
if [ -z "$ROL_API_URL" ]; then echo "::error::ROL_API_URL is empty" && exit 1; fi
if [ -z "$ROL_API_KEY" ]; then echo "::error::ROL_API_KEY is empty" && exit 1; fi
if [ -z "$ROL_PROJECT" ]; then echo "::error::ROL_PROJECT is empty" && exit 1; fi
if [ -z "$ROL_OVPN_CONF_BASE64" ]; then echo "::error::ROL_OVPN_CONF_BASE64 is empty" && exit 1; fi
env:
ROL_API_URL: ${{ secrets.ROL_API_URL }}
ROL_API_KEY: ${{ secrets.ROL_API_KEY }}
ROL_PROJECT: ${{ secrets.ROL_PROJECT }}
ROL_OVPN_CONF_BASE64: ${{ secrets.ROL_OVPN_CONF_BASE64 }}
- name: Setup packages
run: |
sudo apt update
sudo apt install -y qemu binfmt-support qemu-user-static qemu-system-x86 qemu-system-aarch64 qemu-utils openvpn curl jq
- id: 'gcpauth'
if: matrix.backend == 'gcp'
name: GCP Auth to Google Cloud SDK
uses: google-github-actions/auth@v1
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
credentials_json: ${{ secrets.GCP_SA_KEY }}
create_credentials_file: true
- name: GCP Set up Google Cloud SDK
if: matrix.backend == 'gcp'
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
- name: GCP Clean
if: matrix.backend == 'gcp'
run: |
gcloud compute instances delete eve-edengcp-actions-${{ matrix.hv }}-${{ matrix.fs }}-${{github.run_number}} -q --zone=us-west1-a || echo "Does not exist"
gcloud compute images delete eve-edengcp-actions-${{ matrix.hv }}-${{ matrix.fs }}-${{github.run_number}} -q || echo "Does not exist"
- name: Connect VPN
id: connect_vpn
timeout-minutes: 1
run: |
echo "$OVPN_GCP_FILE" | base64 -d > ./config_gcp.ovpn
echo "$OVPN_ROL_FILE" | base64 -d > ./config_rol.ovpn
sudo openvpn --config ./config_${{ matrix.backend }}.ovpn --daemon
until ip -f inet addr show tun0; do sleep 5; ip a; done
echo "tunnel_ip=$(ip -f inet addr show tun0 | sed -En -e 's/.*inet ([0-9.]+).*/\1/p')" >> $GITHUB_OUTPUT
env:
OVPN_GCP_FILE: ${{ secrets.OVPN_FILE }}
OVPN_ROL_FILE: ${{ secrets.ROL_OVPN_CONF_BASE64 }}
- name: Check workflow dispatch inputs
if: github.event_name == 'workflow_dispatch'
run: |
if [ "${{ github.event.inputs.test_type }}" == "docker" ]; then
if [ -z "${{ github.event.inputs.eve_docker_tag }}" ]; then echo "::error::eve_docker_tag is empty" && exit 1; fi
if [ -z "${{ github.event.inputs.eve_docker_reg }}" ]; then echo "::error::eve_docker_reg is empty" && exit 1; fi
if [ "${{ github.event.inputs.eve_docker_reg }}" == "custom"]; then
if [ -z "${{ github.event.inputs.eve_docker_reg_custom }}" ]; then echo "::error::eve_docker_reg_custom is empty" && exit 1; fi
fi
fi
if [ "${{ github.event.inputs.test_type }}" == "PR" ]; then
if [ -z "${{ github.event.inputs.pr_number }}" ]; then echo "::error::pr_number is empty" && exit 1; fi
fi
# We run this workflow for tags, release and default branches,
# so we should pull required branch here
# in case of workflow_dispatch ref will be empty (will point onto main branch)
- name: Checkout EVE
uses: actions/checkout@v4
with:
fetch-depth: 0
path: eve
ref: '${{ github.event.workflow_run.head_branch }}'
- name: Force fetch annotated tags (workaround)
working-directory: ./eve
# Workaround for https://github.com/actions/checkout/issues/290
run: |
git fetch --force --tags
# we want to test the same commit as we publish during workflow_run
- name: Prepare EVE (workflow)
if: github.event_name == 'workflow_run'
working-directory: ./eve
run: |
git reset --hard '${{ github.event.workflow_run.head_sha }}'
git clean -f -x -d
echo "EVE_TAG=$(make version)" >> "$GITHUB_ENV"
echo "EVE_REGISTRY=lfedge/eve" >> "$GITHUB_ENV"
- name: Prepare EVE (manual run)
if: github.event_name == 'workflow_dispatch'
working-directory: ./eve
run: |
if [ "${{ github.event.inputs.test_type }}" == "PR" ]; then
git fetch origin pull/${{ github.event.inputs.pr_number }}/head && git checkout FETCH_HEAD
echo "EVE_TAG=${{ github.event.inputs.pr_number }}" >> "$GITHUB_ENV"
echo "EVE_REGISTRY=evebuild/pr" >> "$GITHUB_ENV"
else
echo "EVE_TAG=${{ github.event.inputs.eve_docker_tag }}" >> "$GITHUB_ENV"
if [ "${{ github.event.inputs.eve_docker_reg }}" == "custom" ]; then
echo "EVE_REGISTRY=${{ github.event.inputs.eve_docker_reg_custom }}" >> "$GITHUB_ENV"
else
echo "EVE_REGISTRY=${{ github.event.inputs.eve_docker_reg }}" >> "$GITHUB_ENV"
fi
fi
# Use stored or the latest version of EDEN with subset of tests from EVE-OS repo
- name: Prepare eden
run: |
if [ -f ${{ github.workspace }}/eve/tests/eden/eden-version ]; then
EDEN_VERSION=$(cat ${{ github.workspace }}/eve/tests/eden/eden-version)
else
EDEN_VERSION=lfedge/eden:0.8.0
fi
docker run -v $PWD:/out $EDEN_VERSION cp -a /eden/. /out/
sudo chown -R $(whoami) .
- name: Eden setup
run: |
if [ "${{ matrix.backend }}" == "rol" ]; then
devmodel='general'
arch='arm64'
netboot='true'
tpm='false'
else
devmodel='GCP'
arch='amd64'
netboot='false'
tpm='true'
fi
./eden config add default --devmodel="${devmodel}" --arch="${arch}"
./eden config set default --key eve.registry --value="${{ env.EVE_REGISTRY }}"
./eden config set default --key eve.tag --value="${{ env.EVE_TAG }}"
./eden config set default --key eve.hv --value ${{ matrix.hv }}
./eden config set default --key eve.tpm --value "${tpm}"
./eden config set default --key adam.eve-ip --value ${{ steps.connect_vpn.outputs.tunnel_ip }}
./eden config set default --key registry.ip --value ${{ steps.connect_vpn.outputs.tunnel_ip }}
./eden config set default --key=eden.tests --value=${{ github.workspace }}/eve/tests/eden
if [ "${{ matrix.fs }}" == "zfs" ]; then
if [ "${{ matrix.backend }}" == "gcp" ]; then
./eden config set default --key=eve.disks --value=4
fi
grub_options='set_global dom0_extra_args "$dom0_extra_args eve_install_zfs_with_raid_level "'
else
grub_options=''
fi
./eden setup -v debug --grub-options="${grub_options}" --netboot="${netboot}"
./eden start
- name: GCP Create VM
if: matrix.backend == 'gcp'
run: |
export ipv4=`curl https://api.ipify.org/?format=json | jq ".ip" -r`
./eden utils gcp firewall --source-range $ipv4/32 --name eve-edengcp-actions-${{ matrix.hv }}-${{ matrix.fs }}-${{github.run_number}} -k "${{ steps.gcpauth.outputs.credentials_file_path }}"
./eden utils gcp image --image-name eve-edengcp-actions-${{ matrix.hv }}-${{ matrix.fs }}-${{github.run_number}} -k "${{ steps.gcpauth.outputs.credentials_file_path }}" upload
./eden utils gcp vm --image-name eve-edengcp-actions-${{ matrix.hv }}-${{ matrix.fs }}-${{github.run_number}} --vm-name eve-edengcp-actions-${{ matrix.hv }}-${{ matrix.fs }}-${{github.run_number}} -k "${{ steps.gcpauth.outputs.credentials_file_path }}" run
sleep 100
BWD=$(./eden utils gcp vm get-ip --vm-name eve-edengcp-actions-${{ matrix.hv }}-${{ matrix.fs }}-${{github.run_number}} -k "${{ steps.gcpauth.outputs.credentials_file_path }}") || { echo "no IP, probably VM does not exist"; exit 1; }
echo "the IP is $BWD"
./eden utils gcp firewall -k "${{ steps.gcpauth.outputs.credentials_file_path }}" --source-range $BWD --name edengcp-actions-${{ matrix.hv }}-${{ matrix.fs }}-${{github.run_number}} || { echo "cannot set firewall"; exit 1; }
- name: RoL rent RPi4
id: rol
if: matrix.backend == 'rol'
timeout-minutes: 60
run: |
rent_id=$(./eden rol rent create -p "$ROL_PROJECT" -m raspberry --model pi_4_model_b_8gb -n GHAction-${{ github.run_number }}-snapshot-${{ matrix.hv }}-${{ matrix.fs }})
echo "id=$rent_id" >> $GITHUB_OUTPUT
until [[ "$(./eden rol rent get -p "$ROL_PROJECT" -i $rent_id | jq -r .machineState)" == "Ready" ]]; do sleep 10; echo "Waiting for EVE to load"; done
env:
ROL_API_URL: ${{ secrets.ROL_API_URL }}
ROL_API_KEY: ${{ secrets.ROL_API_KEY }}
ROL_PROJECT: ${{ secrets.ROL_PROJECT }}
- name: Eden EVE onboard
run: |
./eden eve onboard
- name: Test
run: |
if [ "${{ matrix.backend }}" == "gcp" ]; then export EDEN_TEST=gcp; fi
EDEN_TEST_STOP=n ./eden test ${{ github.workspace }}/eve/tests/eden/workflow -v debug
- name: Collect logs
if: ${{ always() }}
run: |
./eden log --format json > trace.log || echo "no log"
./eden info --format json > info.log || echo "no info"
./eden metric --format json > metric.log || echo "no metric"
./eden netstat --format json > netstat.log || echo "no netstat"
docker logs eden_adam > adam.log 2>&1 || echo "no adam log"
if [ "${{ matrix.backend }}" == "gcp" ]; then
./eden utils gcp vm log --vm-name eve-edengcp-actions-${{ matrix.hv }}-${{ matrix.fs }}-${{github.run_number}} -k "${{ steps.gcpauth.outputs.credentials_file_path }}" > console.log || echo "no device log"
else
./eden rol rent console-output -p "$ROL_PROJECT" -i "${{ steps.rol.outputs.id }}" > console.log || echo "no device log"
fi
env:
ROL_API_URL: ${{ secrets.ROL_API_URL }}
ROL_API_KEY: ${{ secrets.ROL_API_KEY }}
ROL_PROJECT: ${{ secrets.ROL_PROJECT }}
- name: Log counting
if: ${{ always() }}
run: |
echo "::group::Total errors"
echo "$(jq '.severity' trace.log|grep err|wc -l)"
echo "::endgroup::"
echo "::group::Errors by source"
echo "errors by source: $(jq -s 'map(select(.severity|contains("err")))|group_by(.source)|map({"source": .[0].source, "total":length})|sort_by(.total)|reverse[]' trace.log)"
echo "::endgroup::"
echo "::group::Error log content duplicates"
echo "$(jq -s 'map(select(.severity | contains("err")))|group_by(.content)|map(select(length>1))' trace.log)"
echo "::endgroup::"
echo "::group::Error log function filename duplicates"
echo "$(jq -s 'map(select(.severity | contains("err")))|group_by(.filename)|map(select(length>10))|map({"source": .[0].source, "filename": .[0].filename, "function": .[0].function, "content": [.[].content], "total":length})|sort_by(.total)| reverse[]' trace.log)"
echo "::endgroup::"
echo "::group::Segfaults"
echo "$(jq -s 'map(select(.content | contains("segfault at")))' trace.log)"|tee segfaults.log
[ "$(jq length segfaults.log)" -gt 0 ] && echo "::warning::segfaults found, you can see them in Log counting->Segfaults section"
echo "::endgroup::"
- name: GCP Clean
if: ${{ always() }}
run: |
gcloud compute firewall-rules delete eve-edengcp-actions-${{ matrix.hv }}-${{ matrix.fs }}-${{github.run_number}} || echo "Does not exist"
gcloud compute firewall-rules delete edengcp-actions-${{ matrix.hv }}-${{ matrix.fs }}-${{github.run_number}} || echo "Does not exist"
gcloud compute instances delete eve-edengcp-actions-${{ matrix.hv }}-${{ matrix.fs }}-${{github.run_number}} -q --zone=us-west1-a || echo "Does not exist"
gcloud compute images delete eve-edengcp-actions-${{ matrix.hv }}-${{ matrix.fs }}-${{github.run_number}} -q || echo "Does not exist"
gsutil -o "Credentials:gs_service_key_file=${{ steps.gcpauth.outputs.credentials_file_path }}" rm gs://eve-live/eve-edengcp-actions-${{ matrix.hv }}-${{ matrix.fs }}-${{github.run_number}}.img.tar.gz || echo "Does not exists"
- name: RoL Clean
if: ${{ always() }}
run: |
if [ -z "${{ steps.rol.outputs.id }}" ]; then exit 0; fi
./eden rol rent close -p $ROL_PROJECT -i ${{ steps.rol.outputs.id }}
env:
ROL_API_URL: ${{ secrets.ROL_API_URL }}
ROL_API_KEY: ${{ secrets.ROL_API_KEY }}
ROL_PROJECT: ${{ secrets.ROL_PROJECT }}
- name: Store raw test results
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: eden-report-${{ matrix.backend }}-${{ matrix.hv }}-${{ matrix.fs }}
path: |
${{ github.workspace }}/trace.log
${{ github.workspace }}/info.log
${{ github.workspace }}/adam.log
${{ github.workspace }}/netstat.log
${{ github.workspace }}/metric.log
${{ github.workspace }}/console.log