Skip to content

Commit b759445

Browse files
authored
reduce ci performance time (#599)
### What problem were solved in this pull request? <img width="1008" height="646" alt="pass all tests" src="https://github.com/user-attachments/assets/7a9c4aab-cb71-47f6-8e15-11ae7b0ab607" /> Issue Number: close #538 ### What is changed and how it works? Merge initialization environments and compilation steps for multiple tests. Remove a duplicate test from memtracer test and sysbench test. ### Other information This is just a process optimization, a more effective method is to reduce the time of sysbench testing, and this PR has not completely solved the problem.
1 parent bcdb641 commit b759445

File tree

3 files changed

+389
-248
lines changed

3 files changed

+389
-248
lines changed

.github/workflows/build-test.yml

Lines changed: 389 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,389 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
env:
10+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
11+
BUILD_TYPE: Release
12+
13+
permissions:
14+
contents: read
15+
actions: write
16+
17+
jobs:
18+
init-ubuntu:
19+
runs-on: ubuntu-latest
20+
name: init-ubuntu
21+
outputs:
22+
cache-key: ${{ steps.build-cache.outputs.cache-key }}
23+
steps:
24+
- name: Checkout repository and submodules
25+
uses: actions/checkout@v4
26+
27+
- name: Setup build cache
28+
id: build-cache
29+
run: |
30+
echo "cache-key=build-${{ runner.os }}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**', 'deps/3rd/**', 'build.sh') }}" >> $GITHUB_OUTPUT
31+
- name: Cache build dependencies
32+
uses: actions/cache@v4
33+
with:
34+
path: |
35+
deps/3rd/usr/local
36+
build_debug
37+
build_release
38+
key: ${{ steps.build-cache.outputs.cache-key }}
39+
restore-keys: |
40+
build-${{ runner.os }}-
41+
build-
42+
- name: Init
43+
shell: bash
44+
run: sudo bash build.sh init
45+
- name: Upload deps artifact (fallback for fork PR)
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: deps-${{ runner.os }}
49+
path: deps/3rd/usr/local
50+
retention-days: 7
51+
52+
build-and-test-on-ubuntu:
53+
runs-on: ubuntu-latest
54+
name: build-and-test-on-ubuntu
55+
needs: init-ubuntu
56+
57+
steps:
58+
- name: Checkout repository and submodules
59+
uses: actions/checkout@v4
60+
61+
- name: Cache build dependencies
62+
id: cache
63+
uses: actions/cache@v4
64+
with:
65+
path: |
66+
deps/3rd/usr/local
67+
build_debug
68+
key: ${{ needs.init-ubuntu.outputs.cache-key }}
69+
restore-keys: |
70+
build-${{ runner.os }}-
71+
build-
72+
- name: Download deps artifact if cache missed
73+
if: steps.cache.outputs.cache-hit != 'true'
74+
uses: actions/download-artifact@v4
75+
with:
76+
name: deps-${{ runner.os }}
77+
path: deps/3rd/usr/local
78+
- name: BuildDebug
79+
shell: bash
80+
run: bash build.sh debug -DCONCURRENCY=ON -DENABLE_COVERAGE=ON -DWITH_BENCHMARK=ON -DWITH_MEMTRACER=ON -DWITH_UNIT_TESTS=ON --make -j4
81+
82+
- name: Test
83+
shell: bash
84+
run: |
85+
cd build_debug
86+
ctest -E memtracer_test --verbose
87+
- name: lcov
88+
shell: bash
89+
run: |
90+
export DEBIAN_FRONTEND=noninteractive
91+
sudo apt-get update && sudo apt-get install -y lcov
92+
cd build_debug
93+
rm -rf unittest
94+
lcov -c -d ./ -o coverage.info --ignore-errors source
95+
- uses: codecov/codecov-action@v3
96+
with:
97+
file: build_debug/coverage.info
98+
token: ${{ secrets.CODECOV_TOKEN }}
99+
100+
build-release:
101+
runs-on: ubuntu-latest
102+
name: build-release-ubuntu
103+
needs: init-ubuntu
104+
105+
steps:
106+
- name: Checkout repository and submodules
107+
uses: actions/checkout@v4
108+
109+
- name: Cache build dependencies
110+
id: cache
111+
uses: actions/cache@v4
112+
with:
113+
path: |
114+
deps/3rd/usr/local
115+
build_release
116+
key: ${{ needs.init-ubuntu.outputs.cache-key }}
117+
restore-keys: |
118+
build-${{ runner.os }}-
119+
build-
120+
- name: Download deps artifact if cache missed
121+
if: steps.cache.outputs.cache-hit != 'true'
122+
uses: actions/download-artifact@v4
123+
with:
124+
name: deps-${{ runner.os }}
125+
path: deps/3rd/usr/local
126+
- name: BuildRelease
127+
shell: bash
128+
run: bash build.sh release -DCONCURRENCY=ON -DWITH_UNIT_TESTS=ON -DWITH_BENCHMARK=ON -DENABLE_ASAN=OFF -DWITH_MEMTRACER=ON --make -j4
129+
130+
- name: Upload release artifacts
131+
uses: actions/upload-artifact@v4
132+
with:
133+
name: build-release-artifacts
134+
path: |
135+
build_release/
136+
deps/3rd/usr/local/
137+
retention-days: 7
138+
139+
basic-test:
140+
runs-on: ubuntu-latest
141+
needs: build-release
142+
steps:
143+
- name: Checkout repository and submodules
144+
uses: actions/checkout@v4
145+
146+
- name: Download build artifacts
147+
uses: actions/download-artifact@v4
148+
with:
149+
name: build-release-artifacts
150+
path: ./
151+
152+
- name: Fix permissions
153+
shell: bash
154+
run: |
155+
chmod +x build_release/bin/* || true
156+
chmod +x build_release/benchmark/* || true
157+
chmod +x build_release/unittest/* || true
158+
find build_release -name "*.so" -exec chmod +x {} \; || true
159+
find build_release -name "*.a" -exec chmod +x {} \; || true
160+
- name: run basic test
161+
shell: bash
162+
run: |
163+
echo "begin test..."
164+
python3 test/case/miniob_test.py --test-cases=basic | tail -1 | grep "basic is success"
165+
sysbench-test:
166+
needs: [build-release]
167+
strategy:
168+
matrix:
169+
include:
170+
# 基础sysbench测试
171+
- thread_model: 'one-thread-per-connection'
172+
test_case: 'miniob_insert'
173+
build_type: 'release'
174+
memtracer: ''
175+
- thread_model: 'one-thread-per-connection'
176+
test_case: 'miniob_delete'
177+
build_type: 'release'
178+
memtracer: ''
179+
- thread_model: 'one-thread-per-connection'
180+
test_case: 'miniob_select'
181+
build_type: 'release'
182+
memtracer: ''
183+
- thread_model: 'java-thread-pool'
184+
test_case: 'miniob_insert'
185+
build_type: 'release'
186+
memtracer: ''
187+
- thread_model: 'java-thread-pool'
188+
test_case: 'miniob_delete'
189+
build_type: 'release'
190+
memtracer: ''
191+
- thread_model: 'java-thread-pool'
192+
test_case: 'miniob_select'
193+
build_type: 'release'
194+
memtracer: ''
195+
# memtracer sysbench测试
196+
- thread_model: 'one-thread-per-connection'
197+
test_case: 'miniob_insert'
198+
build_type: 'release'
199+
memtracer: 'LD_PRELOAD=./lib/libmemtracer.so'
200+
201+
runs-on: ubuntu-latest
202+
name: sysbench-test-${{ matrix.build_type }}-${{ matrix.thread_model }}-${{ matrix.test_case }}-${{ matrix.memtracer == '' && 'normal' || 'memtracer' }}
203+
steps:
204+
- name: Checkout repository and submodules
205+
uses: actions/checkout@v4
206+
207+
- name: Download build artifacts
208+
uses: actions/download-artifact@v4
209+
with:
210+
name: ${{ matrix.build_type == 'debug' && 'build-debug-artifacts' || 'build-release-artifacts' }}
211+
path: ./
212+
213+
- name: Fix permissions
214+
shell: bash
215+
run: |
216+
chmod +x build_${{ matrix.build_type }}/bin/* || true
217+
chmod +x build_${{ matrix.build_type }}/benchmark/* || true
218+
chmod +x build_${{ matrix.build_type }}/unittest/* || true
219+
find build_${{ matrix.build_type }} -name "*.so" -exec chmod +x {} \; || true
220+
find build_${{ matrix.build_type }} -name "*.a" -exec chmod +x {} \; || true
221+
- name: install sysbench and mariadb-client
222+
shell: bash
223+
run: |
224+
curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.deb.sh -o script.deb.sh
225+
sudo bash script.deb.sh
226+
sudo apt -y install sysbench mariadb-client
227+
- name: start server
228+
shell: bash
229+
run: |
230+
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' &
231+
sleep 10 && echo "wake up"
232+
mysql --version
233+
mysql -S /tmp/miniob.sock -e "show tables"
234+
- name: sysbench test
235+
shell: bash
236+
run: |
237+
cd test/sysbench
238+
sysbench --mysql-socket=/tmp/miniob.sock --mysql-ignore-errors=41 --threads=10 ${{ matrix.test_case }} prepare
239+
sysbench --mysql-socket=/tmp/miniob.sock --mysql-ignore-errors=41 --threads=10 ${{ matrix.test_case }} run || { cat ../../nohup.txt*; exit 1; }
240+
- name: stop server
241+
shell: bash
242+
run: |
243+
mysql -S /tmp/miniob.sock -e "create table t(id int)"
244+
mysql -S /tmp/miniob.sock -e "show tables"
245+
killall observer
246+
- name: restart server
247+
shell: bash
248+
run: |
249+
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' &
250+
sleep 10 && echo "wake up"
251+
mysql -S /tmp/miniob.sock -e "show tables"
252+
- name: sysbench test again
253+
shell: bash
254+
run: |
255+
cd test/sysbench
256+
sysbench --mysql-socket=/tmp/miniob.sock --mysql-ignore-errors=41 --threads=10 ${{ matrix.test_case }} run || { cat ../../nohup.txt*; exit 1; }
257+
benchmark-test:
258+
runs-on: ubuntu-latest
259+
needs: build-release
260+
steps:
261+
- name: Checkout repository and submodules
262+
uses: actions/checkout@v4
263+
264+
- name: Download build artifacts
265+
uses: actions/download-artifact@v4
266+
with:
267+
name: build-release-artifacts
268+
path: ./
269+
270+
- name: Fix permissions
271+
shell: bash
272+
run: |
273+
chmod +x build_release/bin/* || true
274+
chmod +x build_release/benchmark/* || true
275+
chmod +x build_release/unittest/* || true
276+
find build_release -name "*.so" -exec chmod +x {} \; || true
277+
find build_release -name "*.a" -exec chmod +x {} \; || true
278+
- name: concurrency-test
279+
shell: bash
280+
run: |
281+
cd build_release/bin/
282+
for file in `find ./ -name "*_concurrency_test" -executable`; do $file; if [ $? -ne 0 ]; then exit 1; fi; done
283+
memtracer-test:
284+
needs: build-release
285+
strategy:
286+
matrix:
287+
memtracer: ['LD_PRELOAD=./lib/libmemtracer.so', '']
288+
runs-on: ubuntu-latest
289+
steps:
290+
- name: Checkout repository and submodules
291+
uses: actions/checkout@v4
292+
293+
- name: Download build artifacts
294+
uses: actions/download-artifact@v4
295+
with:
296+
name: build-release-artifacts
297+
path: ./
298+
299+
- name: Fix permissions
300+
shell: bash
301+
run: |
302+
chmod +x build_release/bin/* || true
303+
chmod +x build_release/benchmark/* || true
304+
chmod +x build_release/unittest/* || true
305+
find build_release -name "*.so" -exec chmod +x {} \; || true
306+
find build_release -name "*.a" -exec chmod +x {} \; || true
307+
- name: memtracer-performance-test
308+
shell: bash
309+
run: |
310+
cd build_release
311+
${{matrix.memtracer}} ./benchmark/memtracer_performance_test
312+
- name: memtracer-unittest
313+
shell: bash
314+
run: |
315+
cd build_release
316+
LD_PRELOAD=./lib/libmemtracer.so ./unittest/memtracer_test
317+
integration-test:
318+
needs: build-release
319+
runs-on: ubuntu-latest
320+
steps:
321+
- name: Checkout repository and submodules
322+
uses: actions/checkout@v4
323+
324+
- name: Download build artifacts
325+
uses: actions/download-artifact@v4
326+
with:
327+
name: build-release-artifacts
328+
path: ./
329+
330+
- name: Fix permissions
331+
shell: bash
332+
run: |
333+
chmod +x build_release/bin/* || true
334+
chmod +x build_release/benchmark/* || true
335+
chmod +x build_release/unittest/* || true
336+
find build_release -name "*.so" -exec chmod +x {} \; || true
337+
find build_release -name "*.a" -exec chmod +x {} \; || true
338+
339+
- name: init mysql
340+
uses: shogo82148/actions-setup-mysql@v1
341+
with:
342+
mysql-version: "8.0"
343+
- name: init
344+
shell: bash
345+
run: |
346+
sudo apt -y install pip python3-pymysql python3-psutil
347+
- name: integration test
348+
shell: bash
349+
run: |
350+
cd test/integration_test/
351+
bash ./miniob_test_docker_entry.sh
352+
python3 ./libminiob_test.py -c conf.ini
353+
build-on-mac:
354+
runs-on: macos-latest
355+
name: build-macos
356+
357+
steps:
358+
- name: Init environment
359+
shell: bash
360+
run: |
361+
brew install bison
362+
- name: Checkout repository and submodules
363+
uses: actions/checkout@v4
364+
365+
- name: Setup build cache
366+
id: build-cache
367+
run: |
368+
echo "cache-key=build-${{ runner.os }}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**', 'deps/3rd/**', 'build.sh') }}" >> $GITHUB_OUTPUT
369+
- name: Cache build dependencies
370+
id: cache
371+
uses: actions/cache@v4
372+
with:
373+
path: |
374+
deps/3rd/usr/local
375+
build_release
376+
build_debug
377+
key: ${{ steps.build-cache.outputs.cache-key }}
378+
restore-keys: |
379+
build-${{ runner.os }}-
380+
build-
381+
382+
- name: Build
383+
shell: bash
384+
run: |
385+
export ASAN_OPTIONS=detect_container_overflow=0
386+
export PATH="/opt/homebrew/opt/bison/bin:$PATH"
387+
sudo bash build.sh init
388+
bash build.sh debug -DWITH_MEMTRACER=ON --make -j4
389+
bash build.sh release -DCONCURRENCY=ON -DWITH_UNIT_TESTS=OFF -DWITH_BENCHMARK=ON -DWITH_MEMTRACER=ON --make -j4

0 commit comments

Comments
 (0)