Skip to content

Commit 26799be

Browse files
DvirDukhanfilipecosta90Dvir Dukhanrafielantiga
authored
Add valgrind to CI (#507)
* wip * [fix] Fixed missing suppressions file ( we might need to double check supressions file ) * added supressions Co-authored-by: filipecosta90 <filipecosta.90@gmail.com> Co-authored-by: Dvir Dukhan <dvirdukhan@pop-os.localdomain> Co-authored-by: rafie <rafi@redislabs.com> Co-authored-by: Luca Antiga <luca.antiga@orobix.com>
1 parent 65787a1 commit 26799be

File tree

7 files changed

+132
-29
lines changed

7 files changed

+132
-29
lines changed

.circleci/config.yml

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ commands:
1212
- setup_remote_docker:
1313
docker_layer_caching: true
1414

15+
setup-automation:
16+
steps:
17+
- run:
18+
name: Setup automation
19+
command: |
20+
PIP=1 ./opt/readies/bin/getpy3
21+
./opt/system-setup.py
22+
1523
build-steps:
1624
parameters:
1725
platform:
@@ -25,11 +33,10 @@ commands:
2533
keys:
2634
- v1-dependencies-{{ checksum "get_deps.sh" }}
2735
# If no exact match is found will get dependencies from source
36+
- setup-automation
2837
- run:
2938
name: Install dependencies
3039
command: |
31-
./opt/readies/bin/getpy3
32-
BREW_NO_UPDATE=1 ./opt/system-setup.py
3340
./opt/readies/bin/getredis -v 6 --force
3441
./get_deps.sh cpu
3542
- save_cache:
@@ -60,8 +67,6 @@ commands:
6067
- artifacts/*.zip
6168
- artifacts/*.tgz
6269
- artifacts/*.tar
63-
# - artifacts/shapshots/*.zip
64-
# - artifacts/shapshots/*.tgz
6570
- store_artifacts:
6671
path: tests/logs
6772

@@ -98,8 +103,6 @@ commands:
98103
- artifacts/*.zip
99104
- artifacts/*.tgz
100105
- artifacts/*.tar
101-
# - artifacts/shapshots/*.zip
102-
# - artifacts/shapshots/*.tgz
103106
- store_artifacts:
104107
path: test/logs
105108

@@ -156,11 +159,10 @@ jobs:
156159
keys:
157160
- build-dependencies-{{ checksum "get_deps.sh" }}
158161
# If no exact match is found will get dependencies from source
162+
- setup-automation
159163
- run:
160164
name: Install dependencies
161165
command: |
162-
./opt/readies/bin/getpy3
163-
./opt/system-setup.py
164166
./opt/readies/bin/getredis -v 6 --valgrind --force
165167
./get_deps.sh cpu
166168
- run:
@@ -174,6 +176,34 @@ jobs:
174176
make -C opt cov-upload
175177
no_output_timeout: 30m
176178

179+
valgrind:
180+
docker:
181+
- image: redisfab/rmbuilder:6.0.5-x64-buster
182+
steps:
183+
- checkout
184+
- run:
185+
name: Submodule checkout
186+
command: git submodule update --init --recursive
187+
- restore_cache:
188+
keys:
189+
- build-dependencies-{{ checksum "get_deps.sh" }}
190+
# If no exact match is found will get dependencies from source
191+
- setup-automation
192+
- run:
193+
name: Install dependencies
194+
command: |
195+
./opt/readies/bin/getredis -v 6 --valgrind --force
196+
./get_deps.sh cpu
197+
- run:
198+
name: Build for valgrind
199+
command: |
200+
make -C opt all VALGRIND=1 SHOW=1
201+
- run:
202+
name: Test with valgrind
203+
command: |
204+
make -C opt test VALGRIND=1
205+
no_output_timeout: 120m
206+
177207
build-macos:
178208
macos:
179209
xcode: 11.3.0
@@ -322,7 +352,6 @@ on-master-and-version-tags: &on-master-and-version-tags
322352
tags:
323353
only: /^v[0-9].*/
324354

325-
326355
platform-build-defs: &platform-build-defs
327356
requires:
328357
- build-debian
@@ -362,6 +391,9 @@ workflows:
362391
- coverage:
363392
<<: *on-any-branch
364393
<<: *after-linter
394+
- valgrind:
395+
<<: *on-master
396+
<<: *after-linter
365397
- build-and-test-gpu:
366398
<<: *on-any-branch
367399
<<: *after-linter

opt/Makefile

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,15 +231,29 @@ export SLAVES ?= 1
231231
export AOF ?= 1
232232
export CLUSTER ?= 1
233233

234+
define UNIT_TESTS
235+
$(SHOW)echo Running unit tests ...
236+
$(SHOW)\
237+
BINDIR=$(realpath $(BINDIR)) \
238+
$(ROOT)/tests/unit/tests.sh
239+
endef
240+
241+
define FLOW_TESTS
242+
$(SHOW)echo Running flow tests ...
243+
$(SHOW)\
244+
DEVICE=$(DEVICE) \
245+
MODULE=$(realpath $(INSTALLED_TARGET)) \
246+
CLUSTER=$(CLUSTER) \
247+
GEN=$(GEN) AOF=$(AOF) SLAVES=$(SLAVES) \
248+
VALGRIND=$(VALGRIND) \
249+
$(ROOT)/tests/flow/tests.sh
250+
endef
251+
234252
unit_tests: build
235-
@echo "$(BINDIR)"
236253
$(COVERAGE_RESET)
237-
$(SHOW)\
238-
BINDIR=$(realpath $(BINDIR)) \
239-
$(ROOT)/tests/unit/tests.sh
254+
$(UNIT_TESTS)
240255
$(COVERAGE_COLLECT_REPORT)
241256

242-
243257
flow_tests: build
244258
$(COVERAGE_RESET)
245259
$(SHOW)\
@@ -250,10 +264,12 @@ flow_tests: build
250264
VALGRIND=$(VALGRIND) \
251265
REDIS=$(REDIS) \
252266
$(ROOT)/tests/flow/tests.sh
267+
253268
$(COVERAGE_COLLECT_REPORT)
254269

255270
test: build
256271
$(COVERAGE_RESET)
272+
$(UNIT_TESTS)
257273
$(SHOW)\
258274
BINDIR=$(realpath $(BINDIR)) \
259275
$(ROOT)/tests/unit/tests.sh
@@ -267,6 +283,8 @@ test: build
267283
$(ROOT)/tests/flow/tests.sh
268284
$(COVERAGE_COLLECT_REPORT)
269285

286+
#----------------------------------------------------------------------------------------------
287+
270288
valgrind:
271289
$(SHOW)$(ROOT)/tests/flow/valgrind.sh $(realpath $(INSTALLED_TARGET))
272290

opt/redis_valgrind.sup

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,28 @@
4343
Memcheck:Value8
4444
fun:lzf_compress
4545
}
46+
47+
{
48+
<dlopen>
49+
Memcheck:Leak
50+
fun:malloc
51+
...
52+
fun:dlopen@@GLIBC_2.2.5
53+
...
54+
fun:RAI_LoadBackend
55+
}
56+
57+
{
58+
<tf-operator new>
59+
Memcheck:Leak
60+
...
61+
fun:clone
62+
}
63+
64+
{
65+
<malloc>
66+
Memcheck:Leak
67+
fun:malloc
68+
...
69+
fun:clone
70+
}

opt/system-setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ def fedora(self):
6666
self.install("clang")
6767
self.install_git_lfs_on_linux()
6868

69+
def linux_last(self):
70+
self.install("valgrind")
71+
6972
def macos(self):
7073
self.install_gnu_utils()
7174
self.install("git-lfs")

tests/flow/tests.sh

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ error() {
1212
[[ -z $_Dbg_DEBUGGER_LEVEL ]] && trap 'error $LINENO' ERR
1313

1414
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
15-
. $HERE/../../opt/readies/shibumi/functions
15+
export ROOT=$(cd $HERE/../..; pwd)
16+
. $ROOT/opt/readies/shibumi/functions
1617

17-
export ROOT=$(realpath $HERE/../..)
18+
cd $HERE
1819

1920
#----------------------------------------------------------------------------------------------
2021

@@ -34,6 +35,7 @@ help() {
3435
SLAVES=0|1 Tests with --test-slaves
3536
3637
TEST=test Run specific test (e.g. test.py:test_name)
38+
LOG=0|1 Write to log
3739
VALGRIND|VGD=1 Run with Valgrind
3840
CALLGRIND|CGD=1 Run with Callgrind
3941
@@ -69,13 +71,25 @@ valgrind_config() {
6971
VALGRIND_SUPRESSIONS=$ROOT/opt/redis_valgrind.sup
7072

7173
RLTEST_ARGS+="\
72-
--no-output-catch \
7374
--use-valgrind \
7475
--vg-no-fail-on-errors \
75-
--vg-verbose \
7676
--vg-suppressions $VALGRIND_SUPRESSIONS"
7777
}
7878

79+
valgrind_summary() {
80+
# Collect name of each flow log that contains leaks
81+
FILES_WITH_LEAKS=$(grep -l "definitely lost" logs/*.valgrind.log)
82+
if [[ ! -z $FILES_WITH_LEAKS ]]; then
83+
echo "Memory leaks introduced in flow tests."
84+
echo $FILES_WITH_LEAKS
85+
# Print the full Valgrind output for each leaking file
86+
echo $FILES_WITH_LEAKS | xargs cat
87+
exit 1
88+
else
89+
echo Valgrind test ok
90+
fi
91+
}
92+
7993
#----------------------------------------------------------------------------------------------
8094

8195
run_tests() {
@@ -107,8 +121,11 @@ MODULE=${MODULE:-$1}
107121
[[ $VALGRIND == 1 || $VGD == 1 ]] && valgrind_config
108122

109123
if [[ ! -z $TEST ]]; then
110-
RLTEST_ARGS+=" --test $TEST -s"
111-
export PYDEBUG=${PYDEBUG:-1}
124+
RLTEST_ARGS+=" --test $TEST"
125+
if [[ $LOG != 1 ]]; then
126+
RLTEST_ARGS+=" -s"
127+
export PYDEBUG=${PYDEBUG:-1}
128+
fi
112129
fi
113130

114131
[[ $VERBOSE == 1 ]] && RLTEST_ARGS+=" -v"
@@ -124,5 +141,7 @@ check_redis_server
124141
[[ ! -z $REDIS ]] && RL_TEST_ARGS+=" --env exiting-env --existing-env-addr $REDIS" run_tests "redis-server: $REDIS"
125142
[[ $GEN == 1 ]] && run_tests
126143
[[ $CLUSTER == 1 ]] && RLTEST_ARGS+=" --env oss-cluster --shards-count 1" run_tests "--env oss-cluster"
127-
[[ $SLAVES == 1 ]] && RLTEST_ARGS+=" --use-slaves" run_tests "--use-slaves"
128-
[[ $AOF == 1 ]] && RLTEST_ARGS+=" --use-aof" run_tests "--use-aof"
144+
[[ $VALGRIND != 1 && $SLAVES == 1 ]] && RLTEST_ARGS+=" --use-slaves" run_tests "--use-slaves"
145+
[[ $AOF == 1 ]] && RLTEST_ARGS+=" --use-aof" run_tests "--use-aof"
146+
[[ $VALGRIND == 1 ]] && valgrind_summary
147+
exit 0

tests/flow/tests_dag.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ def test_dagro_common_errors(env):
141141
def test_dagrun_ro_modelrun_scriptrun_resnet(env):
142142
if (not TEST_TF or not TEST_PT):
143143
return
144+
if(VALGRIND):
145+
env.debugPrint("skipping {} since it's hanging CI".format(sys._getframe().f_code.co_name), force=True)
146+
env.skip()
144147
con = env.getConnection()
145148
model_name = 'imagenet_model{{1}}'
146149
script_name = 'imagenet_script{{1}}'
@@ -188,6 +191,9 @@ def test_dagrun_ro_modelrun_scriptrun_resnet(env):
188191
def test_dagrun_modelrun_scriptrun_resnet(env):
189192
if (not TEST_TF or not TEST_PT):
190193
return
194+
if(VALGRIND):
195+
env.debugPrint("skipping {} since it's hanging CI".format(sys._getframe().f_code.co_name), force=True)
196+
env.skip()
191197
con = env.getConnection()
192198
model_name = 'imagenet_model:{{1}}'
193199
script_name = 'imagenet_script:{{1}}'

tests/flow/valgrind.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ error() {
1111
# trap error ERR
1212

1313
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
14-
. $HERE/../opt/readies/shibumi/functions
14+
export ROOT=$(cd $HERE/../..; pwd)
15+
. $ROOT/opt/readies/shibumi/functions
1516

16-
export ROOT=$(realpath $HERE/..)
17+
cd $HERE
1718

1819
#----------------------------------------------------------------------------------------------
1920

@@ -24,10 +25,10 @@ help() {
2425
[ARGVARS...] valgrind.sh [--help|help] [<module-so-path>]
2526
2627
Argument variables:
27-
VERBOSE=1 Print commands
28-
IGNERR=1 Do not abort on error
28+
VERBOSE=1 Print commands
29+
IGNERR=1 Do not abort on error
2930
30-
CALLGRIND|CGD=1 Run with Callgrind
31+
CALLGRIND|CGD=1 Run with Callgrind
3132
3233
END
3334
}
@@ -59,6 +60,7 @@ valgrind_config() {
5960
else
6061
VALGRIND_OPTIONS+="\
6162
-q \
63+
--suppressions=$VALGRIND_SUPRESSIONS \
6264
--leak-check=full \
6365
--show-reachable=no \
6466
--show-possibly-lost=no \
@@ -83,7 +85,5 @@ valgrind_config
8385

8486
#----------------------------------------------------------------------------------------------
8587

86-
cd $ROOT/test
87-
8888
check_redis_server
8989
$OP valgrind $(echo "$VALGRIND_OPTIONS") redis-server --protected-mode no --save '' --appendonly no --loadmodule $MODULE

0 commit comments

Comments
 (0)