-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
96 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
machine: true | ||
hosts: | ||
kafka: 127.0.0.1 | ||
|
||
steps: | ||
- checkout | ||
# Don't want thread-safety test because musl bug | ||
- run: sed -i 's%\$(TESTS_\(DRD\|HELGRIND\)_XML)%%g' Makefile | ||
# Bug caused by LTO, mem checks are impossible & unknown failure | ||
- run: rm -f tests/0013-mem.c tests/0005-monitors_split_op_blanks.c | ||
# Build kafka container | ||
- run: docker run -d --name kafka --add-host=kafka:127.0.0.1 --env ADVERTISED_HOST=kafka --env ADVERTISED_PORT=9092 spotify/kafka | ||
# Create development docker | ||
- run: | ||
environment: | ||
DOCKER_BUILD_PARAMETERS: -t monitor-dev --rm=false | ||
command: make dev-docker | ||
# Run test | ||
- run: ./tests/circle-test.sh "$CIRCLE_ARTIFACTS/O2" "--bootstrap" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
|
||
# Run a command in development docker container | ||
# Arguments | ||
# Docker extra args | ||
# Others: command to execute | ||
function docker_run () { | ||
local DOCKER_COMMON_ARGS="-e CC=gcc -v ${PWD}:/app" | ||
local docker_extra_args="$1" | ||
shift | ||
docker run $DOCKER_COMMON_ARGS $docker_extra_args monitor-dev $* | ||
} | ||
|
||
# Download a coverage budget | ||
# Arguments | ||
# Coverage percent | ||
function wget_coverage_budget { | ||
local readonly cov_d=$(printf '%d' $1) # Coverage integer format | ||
echo "cov_d=${cov_d}" | ||
local readonly green=$((cov_d*255/100)) | ||
local readonly red=$((255-green)) | ||
|
||
local readonly color="$(printf '%02x' $red)$(printf '%02x' $green)00" | ||
|
||
# Current directory could be created by docker root user | ||
sudo wget "https://img.shields.io/badge/coverage-$1-$color.svg" \ | ||
-O "coverage.svg" | ||
} | ||
|
||
# Run monitor test | ||
# Arguments: | ||
# [--coverage] Create coverage output | ||
# $1: results output dir | ||
# Others: Configure options | ||
function run_monitor_tests () { | ||
local coverage_arg="" | ||
if [[ "$1" == "--coverage" ]]; then | ||
coverage_arg="--enable-coverage" | ||
shift | ||
fi | ||
|
||
local readonly output_dir="$1" | ||
shift | ||
|
||
#if [[ ! -z "$coverage_arg" ]]; then | ||
# local readonly make_target=checks # no need to valgrind tests | ||
#else | ||
# local readonly make_target=tests | ||
#fi | ||
local -r make_target=checks | ||
|
||
git clean -fqx | ||
docker_run "" "./configure $coverage_arg $*" | ||
docker_run "" "make all" | ||
docker_run "-v $output_dir:$output_dir -e TEST_REPORTS_DIR=$output_dir --link kafka" "make ${make_target}" | ||
|
||
if [[ ! -z "$coverage_arg" ]]; then | ||
docker_run "--link kafka -v $output_dir:$output_dir -e COVERAGE_OUTPUT_DIRECTORY=\"$output_dir/coverage\"" "make coverage" | ||
coverage=$(grep -o 'branches\.\.\.: [[:digit:]]*\.[[:digit:]]*' coverage.out | cut -d ' ' -f 2) | ||
(cd $output_dir; wget_coverage_budget $coverage) | ||
fi | ||
} | ||
|
||
set -e # Return at first error | ||
set -x # Print commands | ||
run_monitor_tests $* | ||
|
||
|