-
Notifications
You must be signed in to change notification settings - Fork 230
400 lines (362 loc) · 15.7 KB
/
system-tests.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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0
#
# SPDX-License-Identifier: EPL-2.0
name: System Tests
# To run locally using https://github.com/nektos/act
# Define the following environment variable in your shell:
# $WORKSPACE: The path to a workspace directory of your choice
# $DITTO_ROOT: The path to the root directory of the Ditto repository
# Create an input file with the following content:
# ditto_branch="feature/branch-to-tst"
# ditto_repo="eclipse/ditto"
# ditto_testing_branch="main"
# ditto_testing_repo="eclipse-ditto/ditto-testing"
# Run the following command:
# act workflow_dispatch -C /Users/sta1sf3/temp/workflow-workspace --bind --container-options "-v $WORKSPACE/.m2:/home/runner/.m2"
# --env HOST_M2_REPO="$WORKSPACE/.m2" --input-file $WORKSPACE/input-file
# -s GITHUB_TOKEN="$(gh auth token)" -P ditto-runner=ghcr.io/catthehacker/ubuntu:full-20.04 --container-architecture linux/amd64
# -W $DITTO_ROOT/ditto/.github/workflows/system-tests.yml
on:
workflow_dispatch:
inputs:
ditto_branch:
description: 'Branch to use for ditto repo (default: master)'
required: false
default: 'master'
ditto_repo:
description: 'Repository to use for ditto repo (default: eclipse-ditto/ditto)'
required: false
default: 'eclipse-ditto/ditto'
ditto_testing_branch:
description: 'Branch to use for ditto-testing repo (default: main)'
required: false
default: 'main'
ditto_testing_repo:
description: 'Repository to use for ditto-testing repo (default: eclipse-ditto/ditto-testing)'
required: false
default: 'eclipse-ditto/ditto-testing'
extra_maven_args:
description: 'Extra arguments to pass to Maven'
required: false
default: ''
jobs:
system-tests:
runs-on: ditto-runner
env:
DITTO_BRANCH: ${{ github.event.inputs.ditto_branch }}
DITTO_REPO: ${{ github.event.inputs.ditto_repo }}
DITTO_TESTING_BRANCH: ${{ github.event.inputs.ditto_testing_branch }}
DITTO_TESTING_REPO: ${{ github.event.inputs.ditto_testing_repo }}
DITTO_VERSION: '0-SNAPSHOT'
COMPOSE_PROJECT_NAME: '${{ github.job }}-${{ github.run_number }}'
DOCKER_NETWORK: 'test'
TEST_JAVA_OPTIONS: '-XX:+UseContainerSupport -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -Dpekko.cluster.failure-detector.acceptable-heartbeat-pause=20s'
MAVEN_OPTS: '-Xmx1400M --add-opens java.base/java.lang=ALL-UNNAMED'
EXTRA_MAVEN_ARGS: ${{ github.event.inputs.extra_maven_args }}
HTTP_PUSH_MOCK_SERVER_PORT: '8080'
EXTRA_DOCKER_ARGS: '--memory="8g" --cpus="8.0"'
FORK_COUNT: '6'
steps:
- name: Debug GitHub Context
run: |
echo "DITTO_BRANCH: ${{ env.DITTO_BRANCH }}"
echo "DITTO_REPO: ${{ env.DITTO_REPO }}"
echo "DITTO_TESTING_BRANCH: ${{ env.DITTO_TESTING_BRANCH }}"
echo "DITTO_TESTING_REPO: ${{ env.DITTO_TESTING_REPO }}"
echo "COMPOSE_PROJECT_NAME: ${{ env.COMPOSE_PROJECT_NAME }}"
echo "DOCKER_NETWORK: ${{ env.DOCKER_NETWORK }}"
echo "TEST_JAVA_OPTIONS: ${{ env.TEST_JAVA_OPTIONS }}"
echo "MAVEN_OPTS: ${{ env.MAVEN_OPTS }}"
echo "EXTRA_MAVEN_ARGS: ${{ env.EXTRA_MAVEN_ARGS }}"
echo "FORK_COUNT: ${{ env.FORK_COUNT }}"
echo "WORKSPACE: ${{ env.WORKSPACE }}"
echo "M2_REPO: ${{ env.M2_REPO }}"
echo "HOST_M2_REPO: ${{ env.HOST_M2_REPO }}"
echo "HTTP_PUSH_MOCK_SERVER_PORT: ${{ env.HTTP_PUSH_MOCK_SERVER_PORT }}"
echo "EXTRA_DOCKER_ARGS: ${{ env.EXTRA_DOCKER_ARGS }}"
- name: Checkout Ditto code
uses: actions/checkout@v4
with:
repository: ${{env.DITTO_REPO }}
ref: ${{ env.DITTO_BRANCH }}
token: ${{ secrets.GITHUB_TOKEN }}
path: ditto
- name: Checkout ditto-testing repo
uses: actions/checkout@v4
with:
repository: ${{ env.DITTO_TESTING_REPO }}
ref: ${{ env.DITTO_TESTING_BRANCH }}
token: ${{ secrets.GITHUB_TOKEN }}
path: ditto-testing
- name: Checkout ditto-clients repo
uses: actions/checkout@v4
with:
repository: 'eclipse-ditto/ditto-clients'
ref: 'master'
token: ${{ secrets.GITHUB_TOKEN }}
path: ditto-clients
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'temurin'
cache: 'maven'
java-version: 21
- name: Cache local Maven repository
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set env vars dynamically
run: |
echo "JAVA_TOOL_OPTIONS=-Duser.home=$HOME" >> $GITHUB_ENV
echo "M2_REPO=$HOME/.m2" >> $GITHUB_ENV
if [[ $GITHUB_ACTOR != "nektos/act" ]]; then
echo "HOST_M2_REPO=$HOME/.m2" >> $GITHUB_ENV
fi
- name: Debug maven repo
run: |
echo "M2_REPO: $M2_REPO"
echo "HOST_M2_REPO: $HOST_M2_REPO"
- name: Compile Ditto
working-directory: ./ditto
run: |
mvn clean install -DskipTests -DskipITs --batch-mode --errors \
-Drevision=$DITTO_VERSION \
-DforkCount=$FORK_COUNT \
-Dbuild.environment=Github
- name: Compile Ditto Clients
working-directory: ./ditto-clients/java
run: |
mvn clean install -DskipTests --errors -Drevision=$DITTO_VERSION
- name: Compile Ditto testing
working-directory: ./ditto-testing
run: |
mvn clean install --batch-mode --errors -DskipTests -DskipITs -Drevision=$DITTO_VERSION -DforkCount=$FORK_COUNT ${EXTRA_MAVEN_ARGS}
- name: Preparation
working-directory: ./ditto-testing
run: |
echo "environments for docker-compose"
echo "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME"
echo "DOCKER_REGISTRY=$DOCKER_REGISTRY"
echo "DITTO_VERSION=$DITTO_VERSION"
echo "DOCKER_NETWORK=$DOCKER_NETWORK"
echo "Delete compose override to avoid port binding"
rm docker/docker-compose.override.yml || true
sudo chown root:root -R docker/sshd/config/custom-cont-init.d || true
export USER=$(whoami)
sudo chown $USER:$USER /var/run/docker.sock
- name: Build docker images
if: ${{ steps.set_version.outputs.ditto_version != 'nightly' }}
working-directory: ./ditto
run: |
echo "Building docker images"
./build-images.sh
- name: Modify start.sh and stop.sh and compose files
working-directory: ./ditto-testing/docker
run: |
sed -i 's/docker-compose/docker compose/g' start.sh
sed -i 's/docker-compose/docker compose/g' stop.sh
if [[ $DITTO_VERSION != 'nightly' ]]; then
sed -i '/printf "\\nPulling newest versions of images ...\\n\\n"/,/assert_success $?/d' start.sh
fi
# Run module: system
- name: Start docker environment for module system
working-directory: ./ditto-testing/docker
run: |
TAG=system ./start.sh
- name: Run system tests in Docker
working-directory: ./ditto-testing
run: |
docker run --rm \
--network test \
-v "${{ github.workspace }}":/workspace \
-v $HOST_M2_REPO:/root/.m2 \
-w /workspace/ditto-testing \
-e DITTO_VERSION=$DITTO_VERSION \
-e FORK_COUNT=$FORK_COUNT \
maven:3.9.5-eclipse-temurin-21 \
mvn verify -am -amd --batch-mode --errors \
--projects=:system \
-Dtest.environment=docker-compose \
-Drevision=$DITTO_VERSION \
-DforkCount=$FORK_COUNT -DreuseForks=false
- name: Upload test results for module system
if: env.GITHUB_ACTOR != 'nektos/act'
uses: actions/upload-artifact@v3
with:
name: system-test-results
path: 'ditto-testing/system/target/failsafe-reports/**/*.xml'
- name: Upload system services logs
if: env.GITHUB_ACTOR != 'nektos/act'
uses: actions/upload-artifact@v3
with:
name: system-services-logs
path: 'ditto-testing/docker/logs/**/*.log'
- name: Stop docker environment for module system
if: always()
working-directory: ./ditto-testing/docker
run: |
./stop.sh
# Run module: sync-completely-enabled
- name: Start sync-completely-enabled docker environment
working-directory: ./ditto-testing/docker
env:
EVENT_PROCESSING_ACTIVE: 'true'
BACKGROUND_SYNC_ENABLED: 'true'
BACKGROUND_SYNC_QUIET_PERIOD: '1s'
BACKGROUND_SYNC_TOLERANCE_WINDOW: '1ms'
THINGS_SEARCH_UPDATER_STREAM_WRITE_INTERVAL: '1s'
THINGS_SEARCH_UPDATER_STREAM_POLICY_CACHE_RETRY_DELAY: '1s'
THINGS_SEARCH_UPDATER_STREAM_THING_CACHE_RETRY_DELAY: '1s'
run: |
TAG=sync-completely-enabled ./start.sh
- name: Run sync-completely-enabled tests
working-directory: ./ditto-testing
run: |
docker run --rm \
--network test \
-v "${{ github.workspace }}":/workspace \
-v $HOST_M2_REPO:/root/.m2 \
-w /workspace/ditto-testing \
-e DITTO_VERSION=$DITTO_VERSION \
-e FORK_COUNT=$FORK_COUNT \
maven:3.9.5-eclipse-temurin-21 \
mvn verify -am -amd --batch-mode --errors --update-snapshots \
--projects=:sync-completely-enabled \
-Dtest.environment=docker-compose \
-Drevision=$DITTO_VERSION
env:
EVENT_PROCESSING_ACTIVE: 'true'
BACKGROUND_SYNC_ENABLED: 'true'
BACKGROUND_SYNC_QUIET_PERIOD: '1s'
BACKGROUND_SYNC_TOLERANCE_WINDOW: '1ms'
THINGS_SEARCH_UPDATER_STREAM_WRITE_INTERVAL: '1s'
THINGS_SEARCH_UPDATER_STREAM_POLICY_CACHE_RETRY_DELAY: '1s'
THINGS_SEARCH_UPDATER_STREAM_THING_CACHE_RETRY_DELAY: '1s'
- name: Upload test results for sync-completely-enabled
if: env.GITHUB_ACTOR != 'nektos/act'
uses: actions/upload-artifact@v3
with:
name: sync-completely-enabled-test-results
path: 'ditto-testing/system-sync/sync-completely-enabled/target/failsafe-reports/**/*.xml'
- name: Upload sync-completely-enabled services logs
if: env.GITHUB_ACTOR != 'nektos/act'
uses: actions/upload-artifact@v3
with:
name: system-services-logs
path: 'ditto-testing/docker/logs/**/*.log'
- name: Stop sync-completely-enabled docker environment
if: always()
working-directory: ./ditto-testing/docker
run: |
./stop.sh
# Run module: sync-event-processing-enabled
- name: Start sync-event-processing-enabled docker environment
working-directory: ./ditto-testing/docker
env:
EVENT_PROCESSING_ACTIVE: 'true'
BACKGROUND_SYNC_ENABLED: 'false'
THINGS_SEARCH_UPDATER_STREAM_WRITE_INTERVAL: '1s'
THINGS_SEARCH_UPDATER_STREAM_POLICY_CACHE_RETRY_DELAY: '1s'
THINGS_SEARCH_UPDATER_STREAM_THING_CACHE_RETRY_DELAY: '1s'
run: |
TAG=sync-event-processing-enabled ./start.sh
- name: Run sync-event-processing-enabled tests
run: |
docker run --rm \
--network test \
-v "${{ github.workspace }}":/workspace \
-v $HOST_M2_REPO:/root/.m2 \
-w /workspace/ditto-testing \
-e DITTO_VERSION=$DITTO_VERSION \
-e FORK_COUNT=$FORK_COUNT \
maven:3.9.5-eclipse-temurin-21 \
mvn verify -am -amd --batch-mode --errors --update-snapshots \
--projects=:sync-event-processing-enabled \
-Dtest.environment=docker-compose \
-Drevision=$DITTO_VERSION
env:
EVENT_PROCESSING_ACTIVE: 'true'
BACKGROUND_SYNC_ENABLED: 'false'
THINGS_SEARCH_UPDATER_STREAM_WRITE_INTERVAL: '1s'
THINGS_SEARCH_UPDATER_STREAM_POLICY_CACHE_RETRY_DELAY: '1s'
THINGS_SEARCH_UPDATER_STREAM_THING_CACHE_RETRY_DELAY: '1s'
- name: Upload module sync-event-processing-enabled test results
if: env.GITHUB_ACTOR != 'nektos/act'
uses: actions/upload-artifact@v3
with:
name: sync-event-processing-enabled-test-results
path: 'ditto-testing/system-sync/sync-event-processing-enabled/target/failsafe-reports/**/*.xml'
- name: Upload sync-event-processing-enabled services logs
if: env.GITHUB_ACTOR != 'nektos/act'
uses: actions/upload-artifact@v3
with:
name: system-services-logs
path: 'ditto-testing/docker/logs/**/*.log'
- name: Stop docker environment for module sync-event-processing-enabled
if: always()
working-directory: ./ditto-testing/docker
run: |
./stop.sh
# Run module: sync-tags-streaming-enabled
- name: Start sync-tags-streaming-enabled docker environment
working-directory: ./ditto-testing/docker
env:
EVENT_PROCESSING_ACTIVE: 'false'
BACKGROUND_SYNC_ENABLED: 'true'
BACKGROUND_SYNC_QUIET_PERIOD: '1s'
BACKGROUND_SYNC_TOLERANCE_WINDOW: '1ms'
THINGS_SEARCH_UPDATER_STREAM_WRITE_INTERVAL: '1s'
THINGS_SEARCH_UPDATER_STREAM_POLICY_CACHE_RETRY_DELAY: '1s'
THINGS_SEARCH_UPDATER_STREAM_THING_CACHE_RETRY_DELAY: '1s'
run: |
TAG=sync-tags-streaming-enabled ./start.sh
- name: Run sync-tags-streaming-enabled tests
working-directory: ./ditto-testing
run: |
docker run --rm \
--network test \
-v "${{ github.workspace }}":/workspace \
-v $HOST_M2_REPO:/root/.m2 \
-w /workspace/ditto-testing \
-e DITTO_VERSION=$DITTO_VERSION \
-e FORK_COUNT=$FORK_COUNT \
maven:3.9.5-eclipse-temurin-21 \
mvn verify -am -amd --batch-mode --errors --update-snapshots \
--projects=:sync-tags-streaming-enabled \
-Dtest.environment=docker-compose \
-Drevision=$DITTO_VERSION
env:
EVENT_PROCESSING_ACTIVE: 'false'
BACKGROUND_SYNC_ENABLED: 'true'
BACKGROUND_SYNC_QUIET_PERIOD: '1s'
BACKGROUND_SYNC_TOLERANCE_WINDOW: '1ms'
THINGS_SEARCH_UPDATER_STREAM_WRITE_INTERVAL: '1s'
THINGS_SEARCH_UPDATER_STREAM_POLICY_CACHE_RETRY_DELAY: '1s'
THINGS_SEARCH_UPDATER_STREAM_THING_CACHE_RETRY_DELAY: '1s'
- name: Upload sync-tags-streaming-enabled test results
if: env.GITHUB_ACTOR != 'nektos/act'
uses: actions/upload-artifact@v3
with:
name: sync-tags-streaming-enabled-test-results
path: 'ditto-testing/system-sync/sync-tags-streaming-enabled/target/failsafe-reports/**/*.xml'
- name: Upload sync-tags-streaming-enabled services logs
if: env.GITHUB_ACTOR != 'nektos/act'
uses: actions/upload-artifact@v3
with:
name: system-services-logs
path: 'ditto-testing/docker/logs/**/*.log'
- name: Stop sync-tags-streaming-enabled docker environment
if: always()
working-directory: ./ditto-testing/docker
run: |
./stop.sh