-
Notifications
You must be signed in to change notification settings - Fork 1.6k
389 lines (360 loc) · 12.6 KB
/
Copy pathbuild-test.yml
File metadata and controls
389 lines (360 loc) · 12.6 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
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
name: build
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
permissions:
contents: read
actions: write
jobs:
init-ubuntu:
runs-on: ubuntu-latest
name: init-ubuntu
outputs:
cache-key: ${{ steps.build-cache.outputs.cache-key }}
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
- name: Setup build cache
id: build-cache
run: |
echo "cache-key=build-${{ runner.os }}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**', 'deps/3rd/**', 'build.sh') }}" >> $GITHUB_OUTPUT
- name: Cache build dependencies
uses: actions/cache@v4
with:
path: |
deps/3rd/usr/local
build_debug
build_release
key: ${{ steps.build-cache.outputs.cache-key }}
restore-keys: |
build-${{ runner.os }}-
build-
- name: Init
shell: bash
run: sudo bash build.sh init
- name: Upload deps artifact (fallback for fork PR)
uses: actions/upload-artifact@v4
with:
name: deps-${{ runner.os }}
path: deps/3rd/usr/local
retention-days: 7
build-and-test-on-ubuntu:
runs-on: ubuntu-latest
name: build-and-test-on-ubuntu
needs: init-ubuntu
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
- name: Cache build dependencies
id: cache
uses: actions/cache@v4
with:
path: |
deps/3rd/usr/local
build_debug
key: ${{ needs.init-ubuntu.outputs.cache-key }}
restore-keys: |
build-${{ runner.os }}-
build-
- name: Download deps artifact if cache missed
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/download-artifact@v4
with:
name: deps-${{ runner.os }}
path: deps/3rd/usr/local
- name: BuildDebug
shell: bash
run: bash build.sh debug -DCONCURRENCY=ON -DENABLE_COVERAGE=ON -DWITH_BENCHMARK=ON -DWITH_MEMTRACER=ON -DWITH_UNIT_TESTS=ON --make -j4
- name: Test
shell: bash
run: |
cd build_debug
ctest -E memtracer_test --verbose
- name: lcov
shell: bash
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update && sudo apt-get install -y lcov
cd build_debug
rm -rf unittest
lcov -c -d ./ -o coverage.info --ignore-errors source
- uses: codecov/codecov-action@v3
with:
file: build_debug/coverage.info
token: ${{ secrets.CODECOV_TOKEN }}
build-release:
runs-on: ubuntu-latest
name: build-release-ubuntu
needs: init-ubuntu
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
- name: Cache build dependencies
id: cache
uses: actions/cache@v4
with:
path: |
deps/3rd/usr/local
build_release
key: ${{ needs.init-ubuntu.outputs.cache-key }}
restore-keys: |
build-${{ runner.os }}-
build-
- name: Download deps artifact if cache missed
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/download-artifact@v4
with:
name: deps-${{ runner.os }}
path: deps/3rd/usr/local
- name: BuildRelease
shell: bash
run: bash build.sh release -DCONCURRENCY=ON -DWITH_UNIT_TESTS=ON -DWITH_BENCHMARK=ON -DENABLE_ASAN=OFF -DWITH_MEMTRACER=ON --make -j4
- name: Upload release artifacts
uses: actions/upload-artifact@v4
with:
name: build-release-artifacts
path: |
build_release/
deps/3rd/usr/local/
retention-days: 7
basic-test:
runs-on: ubuntu-latest
needs: build-release
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-release-artifacts
path: ./
- name: Fix permissions
shell: bash
run: |
chmod +x build_release/bin/* || true
chmod +x build_release/benchmark/* || true
chmod +x build_release/unittest/* || true
find build_release -name "*.so" -exec chmod +x {} \; || true
find build_release -name "*.a" -exec chmod +x {} \; || true
- name: run basic test
shell: bash
run: |
echo "begin test..."
python3 test/case/miniob_test.py --test-cases=basic | tail -1 | grep "basic is success"
sysbench-test:
needs: [build-release]
strategy:
matrix:
include:
# 基础sysbench测试
- thread_model: 'one-thread-per-connection'
test_case: 'miniob_insert'
build_type: 'release'
memtracer: ''
- thread_model: 'one-thread-per-connection'
test_case: 'miniob_delete'
build_type: 'release'
memtracer: ''
- thread_model: 'one-thread-per-connection'
test_case: 'miniob_select'
build_type: 'release'
memtracer: ''
- thread_model: 'java-thread-pool'
test_case: 'miniob_insert'
build_type: 'release'
memtracer: ''
- thread_model: 'java-thread-pool'
test_case: 'miniob_delete'
build_type: 'release'
memtracer: ''
- thread_model: 'java-thread-pool'
test_case: 'miniob_select'
build_type: 'release'
memtracer: ''
# memtracer sysbench测试
- thread_model: 'one-thread-per-connection'
test_case: 'miniob_insert'
build_type: 'release'
memtracer: 'LD_PRELOAD=./lib/libmemtracer.so'
runs-on: ubuntu-latest
name: sysbench-test-${{ matrix.build_type }}-${{ matrix.thread_model }}-${{ matrix.test_case }}-${{ matrix.memtracer == '' && 'normal' || 'memtracer' }}
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: ${{ matrix.build_type == 'debug' && 'build-debug-artifacts' || 'build-release-artifacts' }}
path: ./
- name: Fix permissions
shell: bash
run: |
chmod +x build_${{ matrix.build_type }}/bin/* || true
chmod +x build_${{ matrix.build_type }}/benchmark/* || true
chmod +x build_${{ matrix.build_type }}/unittest/* || true
find build_${{ matrix.build_type }} -name "*.so" -exec chmod +x {} \; || true
find build_${{ matrix.build_type }} -name "*.a" -exec chmod +x {} \; || true
- name: install sysbench and mariadb-client
shell: bash
run: |
curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.deb.sh -o script.deb.sh
sudo bash script.deb.sh
sudo apt -y install sysbench mariadb-client
- name: start server
shell: bash
run: |
nohup sh -c '${{ matrix.memtracer }} ./build_${{ matrix.build_type }}/bin/observer -T ${{ matrix.thread_model }} -s /tmp/miniob.sock -f etc/observer.ini -P mysql -t mvcc -d disk' &
sleep 10 && echo "wake up"
mysql --version
mysql -S /tmp/miniob.sock -e "show tables"
- name: sysbench test
shell: bash
run: |
cd test/sysbench
sysbench --mysql-socket=/tmp/miniob.sock --mysql-ignore-errors=41 --threads=10 ${{ matrix.test_case }} prepare
sysbench --mysql-socket=/tmp/miniob.sock --mysql-ignore-errors=41 --threads=10 ${{ matrix.test_case }} run || { cat ../../nohup.txt*; exit 1; }
- name: stop server
shell: bash
run: |
mysql -S /tmp/miniob.sock -e "create table t(id int)"
mysql -S /tmp/miniob.sock -e "show tables"
killall observer
- name: restart server
shell: bash
run: |
nohup sh -c '${{ matrix.memtracer }} ./build_${{ matrix.build_type }}/bin/observer -T ${{ matrix.thread_model }} -s /tmp/miniob.sock -f etc/observer.ini -P mysql -t mvcc -d disk' &
sleep 10 && echo "wake up"
mysql -S /tmp/miniob.sock -e "show tables"
- name: sysbench test again
shell: bash
run: |
cd test/sysbench
sysbench --mysql-socket=/tmp/miniob.sock --mysql-ignore-errors=41 --threads=10 ${{ matrix.test_case }} run || { cat ../../nohup.txt*; exit 1; }
benchmark-test:
runs-on: ubuntu-latest
needs: build-release
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-release-artifacts
path: ./
- name: Fix permissions
shell: bash
run: |
chmod +x build_release/bin/* || true
chmod +x build_release/benchmark/* || true
chmod +x build_release/unittest/* || true
find build_release -name "*.so" -exec chmod +x {} \; || true
find build_release -name "*.a" -exec chmod +x {} \; || true
- name: concurrency-test
shell: bash
run: |
cd build_release/bin/
for file in `find ./ -name "*_concurrency_test" -executable`; do $file; if [ $? -ne 0 ]; then exit 1; fi; done
memtracer-test:
needs: build-release
strategy:
matrix:
memtracer: ['LD_PRELOAD=./lib/libmemtracer.so', '']
runs-on: ubuntu-latest
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-release-artifacts
path: ./
- name: Fix permissions
shell: bash
run: |
chmod +x build_release/bin/* || true
chmod +x build_release/benchmark/* || true
chmod +x build_release/unittest/* || true
find build_release -name "*.so" -exec chmod +x {} \; || true
find build_release -name "*.a" -exec chmod +x {} \; || true
- name: memtracer-performance-test
shell: bash
run: |
cd build_release
${{matrix.memtracer}} ./benchmark/memtracer_performance_test
- name: memtracer-unittest
shell: bash
run: |
cd build_release
LD_PRELOAD=./lib/libmemtracer.so ./unittest/memtracer_test
integration-test:
needs: build-release
runs-on: ubuntu-latest
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-release-artifacts
path: ./
- name: Fix permissions
shell: bash
run: |
chmod +x build_release/bin/* || true
chmod +x build_release/benchmark/* || true
chmod +x build_release/unittest/* || true
find build_release -name "*.so" -exec chmod +x {} \; || true
find build_release -name "*.a" -exec chmod +x {} \; || true
- name: init mysql
uses: shogo82148/actions-setup-mysql@v1
with:
mysql-version: "8.0"
- name: init
shell: bash
run: |
sudo apt -y install pip python3-pymysql python3-psutil
- name: integration test
shell: bash
run: |
cd test/integration_test/
bash ./miniob_test_docker_entry.sh
python3 ./libminiob_test.py -c conf.ini
build-on-mac:
runs-on: macos-latest
name: build-macos
steps:
- name: Init environment
shell: bash
run: |
brew install bison
- name: Checkout repository and submodules
uses: actions/checkout@v4
- name: Setup build cache
id: build-cache
run: |
echo "cache-key=build-${{ runner.os }}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**', 'deps/3rd/**', 'build.sh') }}" >> $GITHUB_OUTPUT
- name: Cache build dependencies
id: cache
uses: actions/cache@v4
with:
path: |
deps/3rd/usr/local
build_release
build_debug
key: ${{ steps.build-cache.outputs.cache-key }}
restore-keys: |
build-${{ runner.os }}-
build-
- name: Build
shell: bash
run: |
export ASAN_OPTIONS=detect_container_overflow=0
export PATH="/opt/homebrew/opt/bison/bin:$PATH"
sudo bash build.sh init
bash build.sh debug -DWITH_MEMTRACER=ON --make -j4
bash build.sh release -DCONCURRENCY=ON -DWITH_UNIT_TESTS=OFF -DWITH_BENCHMARK=ON -DWITH_MEMTRACER=ON --make -j4