dendrite/run-sytest.sh
Brian Meek de78eab63a
Add race testing to tests, and fix a few small race conditions in the tests (#2587)
* Add race testing to tests, and fix a few small race conditions in the tests

* Enable run-sytest on MacOS

* Remove deadlock detecting mutex, per code review feedback

* Remove autoformatting related changes and a closure that is not needed

* Adjust to importing nats client as 'natsclient'

Signed-off-by: Brian Meek <brian@hntlabs.com>

* Clarify the use of gooseMutex to proect goose internal state

Signed-off-by: Brian Meek <brian@hntlabs.com>

* Remove no longer needed mutex for guarding goose

Signed-off-by: Brian Meek <brian@hntlabs.com>
2022-08-05 09:19:33 +01:00

63 lines
1.9 KiB
Bash
Executable file

#!/bin/bash
#
# Runs SyTest either from Docker Hub, or from ../sytest. If it's run
# locally, the Docker image is rebuilt first.
#
# Logs are stored in ../sytestout/logs.
set -e
set -o pipefail
main() {
local tag=buster
local base_image=debian:$tag
local runargs=()
cd "$(dirname "$0")"
if [ -d ../sytest ]; then
local tmpdir
tmpdir="$(mktemp -d -t run-systest.XXXXXXXXXX)"
trap "rm -r '$tmpdir'" EXIT
if [ -z "$DISABLE_BUILDING_SYTEST" ]; then
echo "Re-building ../sytest Docker images..."
local status
(
cd ../sytest
docker build -f docker/base.Dockerfile --build-arg BASE_IMAGE="$base_image" --tag matrixdotorg/sytest:"$tag" .
docker build -f docker/dendrite.Dockerfile --build-arg SYTEST_IMAGE_TAG="$tag" --tag matrixdotorg/sytest-dendrite:latest .
) &>"$tmpdir/buildlog" || status=$?
if (( status != 0 )); then
# Docker is very verbose, and we don't really care about
# building SyTest. So we accumulate and only output on
# failure.
cat "$tmpdir/buildlog" >&2
return $status
fi
fi
runargs+=( -v "$PWD/../sytest:/sytest:ro" )
fi
if [ -n "$SYTEST_POSTGRES" ]; then
runargs+=( -e POSTGRES=1 )
fi
local sytestout=$PWD/../sytestout
mkdir -p "$sytestout"/{logs,cache/go-build,cache/go-pkg}
docker run \
--rm \
--name "sytest-dendrite-${LOGNAME}" \
-e LOGS_USER=$(id -u) \
-e LOGS_GROUP=$(id -g) \
-v "$PWD:/src/:ro" \
-v "$sytestout/logs:/logs/" \
-v "$sytestout/cache/go-build:/root/.cache/go-build" \
-v "$sytestout/cache/go-pkg:/gopath/pkg" \
"${runargs[@]}" \
matrixdotorg/sytest-dendrite:latest "$@"
}
main "$@"