Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,26 @@ jobs:
- test-steps
- persist-artifacts

sanitize:
docker:
- image: redisfab/clang:13-x64-bullseye
parameters:
san-type:
type: string
steps:
- early-returns
- checkout-all
- setup-automation
- run:
name: System setup
command: ./sbin/system-setup.py
- run:
name: Build & test
shell: /bin/bash -l -eo pipefail
command: make SAN=<<parameters.san-type>> build test SHOW=1 VERBOSE=1
no_output_timeout: 30m
- save-tests-logs

deploy-artifacts:
parameters:
location:
Expand Down Expand Up @@ -458,6 +478,12 @@ workflows:
platform: [bionic]
- build-macos:
<<: *on-integ-and-version-tags
- sanitize:
name: sanitize-<< matrix.san-type >>
matrix:
parameters:
san-type: [address] # [address, memory]
<<: *on-any-branch
- deploy-artifacts:
name: deploy_snapshot
location: snapshots
Expand Down
63 changes: 44 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@

ifneq ($(SAN),)
override DEBUG:=1
ifeq ($(SAN),mem)
else ifeq ($(SAN),memory)
override SAN=memory
else ifeq ($(SAN),addr)
override SAN=address
endif

override DEBUG:=1
ifeq ($(SAN),memory)
else ifeq ($(SAN),address)
else ifeq ($(SAN),leak)
else ifeq ($(SAN),thread)
else
$(error SAN=mem|addr|leak|thread)
endif
endif

export SAN
endif # SAN

ROOT=.
ifeq ($(wildcard $(ROOT)/deps/readies/mk),)
$(error Submodules not present. Please run 'git submodule update --init --recursive')
ifeq ($(wildcard $(ROOT)/deps/readies),)
$(shell git submodule update --init --recursive)
endif
MK.pyver:=3
include $(ROOT)/deps/readies/mk/main
Expand All @@ -33,14 +39,16 @@ make clean # remove binary files

make all # build all libraries and packages

make pytest # run tests
TEST=name # run test matching 'name'
TEST_ARGS="..." # RLTest arguments
GEN=0|1 # run general tests on a standalone Redis topology
AOF=0|1 # run AOF persistency tests on a standalone Redis topology
SLAVES=0|1 # run replication tests on standalone Redis topology
CLUSTER=0|1 # run general tests on a OSS Redis Cluster topology
VALGRIND|VG=1 # run specified tests with Valgrind
make pytest # run flow tests using RLTest
TEST=file:name # run test matching `name` from `file`
TEST_ARGS="..." # RLTest arguments
QUICK=1 # run only general tests
GEN=1 # run general tests on a standalone Redis topology
AOF=1 # run AOF persistency tests on a standalone Redis topology
SLAVES=1 # run replication tests on standalone Redis topology
CLUSTER=1 # run general tests on a OSS Redis Cluster topology
VALGRIND|VG=1 # run specified tests with Valgrind
VERBOSE=1 # display more RLTest-related information

make pack # build package (RAMP file)

Expand All @@ -55,6 +63,8 @@ make platform # build for specific Linux distribution
ARTIFACTS=1 # copy artifacts from docker image
PUBLISH=1 # publish (i.e. docker push) after build

make sanbox # create container for CLang Sanitizer tests

make builddocs
make localdocs
make deploydocs
Expand All @@ -76,6 +86,8 @@ MODULE_NAME=rejson.so
RUST_TARGET:=$(shell eval $$(rustc --print cfg | grep =); echo $$target_arch-$$target_vendor-$$target_os-$$target_env)
CARGO_TOOLCHAIN=
CARGO_FLAGS=
RUST_FLAGS=
RUST_DOCFLAGS=

ifeq ($(DEBUG),1)
ifeq ($(SAN),)
Expand All @@ -84,14 +96,18 @@ else
TARGET_DIR=$(BINDIR)/target/$(RUST_TARGET)/debug
CARGO_TOOLCHAIN = +nightly
CARGO_FLAGS += -Zbuild-std
RUST_FLAGS += -Zsanitizer=$(SAN)
ifeq ($(SAN),memory)
RUST_FLAGS += -Zsanitizer-memory-track-origins
endif
endif
else
CARGO_FLAGS += --release
TARGET_DIR=$(BINDIR)/target/release
endif

ifeq ($(PROFILE),1)
RUSTFLAGS += " -g -C force-frame-pointers=yes"
RUST_FLAGS += -g -C force-frame-pointers=yes
endif

export CARGO_TARGET_DIR=$(BINDIR)/target
Expand Down Expand Up @@ -127,12 +143,12 @@ RUST_SOEXT.macos=dylib
build:
ifeq ($(SAN),)
$(SHOW)set -e ;\
export RUSTFLAGS=$(RUSTFLAGS) ;\
export RUSTFLAGS="$(RUST_FLAGS)" ;\
cargo build --all --all-targets $(CARGO_FLAGS)
else
$(SHOW)set -e ;\
export RUSTFLAGS=-Zsanitizer=$(SAN) ;\
export RUSTDOCFLAGS=-Zsanitizer=$(SAN) ;\
export RUSTFLAGS="$(RUST_FLAGS)" ;\
export RUSTDOCFLAGS="$(RUST_DOCFLAGS)" ;\
cargo $(CARGO_TOOLCHAIN) build --target $(RUST_TARGET) $(CARGO_FLAGS)
endif
$(SHOW)cp $(TARGET_DIR)/librejson.$(RUST_SOEXT.$(OS)) $(TARGET)
Expand All @@ -146,7 +162,7 @@ clean:
ifneq ($(ALL),1)
$(SHOW)cargo clean
else
$(SHOW)rm -rf target
$(SHOW)rm -rf $(BINDIR)
endif

.PHONY: build clean
Expand All @@ -156,7 +172,7 @@ endif
test: pytest

pytest:
$(SHOW)MODULE=$(abspath $(TARGET)) ./tests/pytest/tests.sh
$(SHOW)MODULE=$(abspath $(TARGET)) $(realpath ./tests/pytest/tests.sh)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

realpath (sadly) still isn't completely portable. Can you use realink -f?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This in gnu make's realpath, not /bin/realpath. This fortunately works properly.

@rafie rafie Dec 22, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chayim BTW the reason we require realpath here in the first place is because using a relative path causing test.sh not to print program name properly when it detects an error. So this needs to be fixed to (probably something like PROGNAME="$0" at the top).


cargo_test:
$(SHOW)cargo $(CARGO_TOOLCHAIN) test --features test --all
Expand Down Expand Up @@ -209,6 +225,15 @@ ifeq ($(PUBLISH),1)
$(SHOW)make -C build/platforms publish
endif

ifneq ($(wildcard /w/*),)
SANBOX_ARGS += -v /w:/w
endif

sanbox:
@docker run -it -v $(PWD):/rejson -w /rejson --cap-add=SYS_PTRACE --security-opt seccomp=unconfined $(SANBOX_ARGS) redisfab/clang:13-x64-bullseye bash

.PHONY: sanbox

#----------------------------------------------------------------------------------------------

builddocs:
Expand Down
5 changes: 4 additions & 1 deletion tests/pytest/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ def testGetFormatting(env):

def testBackwardRDB(env):
env.skipOnCluster()
if env.useAof:
env.skip()
dbFileName = env.cmd('config', 'get', 'dbfilename')[1]
dbDir = env.cmd('config', 'get', 'dir')[1]
rdbFilePath = os.path.join(dbDir, dbFileName)
Expand All @@ -284,7 +286,8 @@ def testBackwardRDB(env):
env.start()

r = env
data = json.loads(r.execute_command('JSON.GET', 'complex'))
res = r.execute_command('JSON.GET', 'complex')
data = json.loads(res)
r.assertEqual(data, {"a":{"b":[{"c":{"d":[1,'2'],"e":None}},True],"a":'a'},"b":1,"c":True,"d":None})

def testSetBSON(env):
Expand Down
Loading