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: 13 additions & 13 deletions docker/test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ if [[ -n "$existing_cache_image" ]]; then
fi

# Fix permissions before copying files, to avoid AUFS bug other must have read/access permissions
chmod -R o=rx *;
chmod -R o=rx -- *;

# This is required by the vtctld_web_test.py test.
# Otherwise, /usr/bin/chromium will crash with the error:
Expand Down Expand Up @@ -153,10 +153,10 @@ fi

# Mount in host VTDATAROOT if one exists, since it might be a RAM disk or SSD.
if [[ -n "$VTDATAROOT" ]]; then
hostdir=`mktemp -d $VTDATAROOT/test-XXX`
testid=`basename $hostdir`
hostdir=$(mktemp -d "$VTDATAROOT/test-XXX")
testid=$(basename "$hostdir")

chmod 777 $hostdir
chmod 777 "$hostdir"

echo "Mounting host dir $hostdir as VTDATAROOT"
args="$args -v $hostdir:/vt/vtdataroot --name=$testid -h $testid"
Expand Down Expand Up @@ -201,12 +201,14 @@ bashcmd=$(append_cmd "$bashcmd" "$cmd")
if tty -s; then
# interactive shell
# See above why we turn on "extglob" (extended Glob).
docker run -ti $args $image bash -O extglob -c "$bashcmd"
# shellcheck disable=SC2086
docker run -ti $args "$image" bash -O extglob -c "$bashcmd"
exitcode=$?
else
# non-interactive shell (kill child on signal)
trap 'docker kill $testid &>/dev/null' SIGTERM SIGINT
docker run $args $image bash -O extglob -c "$bashcmd" &
# shellcheck disable=SC2086
docker run $args "$image" bash -O extglob -c "$bashcmd" &
wait $!
exitcode=$?
trap - SIGTERM SIGINT
Expand All @@ -215,23 +217,21 @@ fi
# Clean up host dir mounted VTDATAROOT
if [[ -n "$hostdir" ]]; then
# Use Docker user to clean up first, to avoid permission errors.
docker run --name=rm_$testid -v $hostdir:/vt/vtdataroot $image bash -c 'rm -rf /vt/vtdataroot/*'
docker rm -f rm_$testid &>/dev/null
rm -rf $hostdir
docker run --name="rm_$testid" -v "$hostdir":/vt/vtdataroot "$image" bash -c 'rm -rf /vt/vtdataroot/*'
docker rm -f "rm_$testid" &>/dev/null
rm -rf "$hostdir"
fi

# If requested, create the cache image.
if [[ "$mode" == "create_cache" && $exitcode == 0 ]]; then
msg="DO NOT PUSH: This is a temporary layer meant to persist e.g. the result of 'make build'. Never push this layer back to our official Docker Hub repository."
docker commit -m "$msg" $testid $cache_image

if [[ $? != 0 ]]; then
if ! docker commit -m "$msg" "$testid" "$cache_image"; then
exitcode=$?
echo "ERROR: Failed to create Docker cache. Used command: docker commit -m '$msg' $testid $image"
fi
fi

# Delete the container
docker rm -f $testid &>/dev/null
docker rm -f "$testid" &>/dev/null

exit $exitcode
4 changes: 2 additions & 2 deletions test.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ func main() {
}

junitDir := path.Join("_test", "junit")
if err := os.MkdirAll(junitDir, os.FileMode(0755)); err != nil {
if err := os.MkdirAll(junitDir, os.FileMode(0o755)); err != nil {
log.Fatalf("Can't create junit directory: %v", err)
}

Expand Down Expand Up @@ -533,7 +533,7 @@ func main() {
outFile := fmt.Sprintf("%v.%v-%v.log", test.flavor, test.name, test.runIndex+1)
outFilePath := path.Join(outDir, outFile)
test.logf("saving test output to %v", outFilePath)
if fileErr := os.WriteFile(outFilePath, output, os.FileMode(0644)); fileErr != nil {
if fileErr := os.WriteFile(outFilePath, output, os.FileMode(0o644)); fileErr != nil {
test.logf("WriteFile error: %v", fileErr)
}
}
Expand Down
1 change: 1 addition & 0 deletions tools/unit_test_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,5 @@ if [[ -n "${JSON_OUTPUT:-}" ]]; then
GOTESTSUM_ARGS="$GOTESTSUM_ARGS --jsonfile $JSON_OUTPUT"
fi

# shellcheck disable=SC2086
go tool gotestsum $GOTESTSUM_ARGS --packages="$packages_with_tests" -- $VT_GO_PARALLEL $RACE_FLAG -count=1
Loading