Skip to content

Commit

Permalink
test: fix acceptance tests on Apple Silicon Macs
Browse files Browse the repository at this point in the history
We observed sporadic compilation or bytecode issues
on Apple Silicon Macs.

According to golang/go#42774,
the env variable `GODEBUG=asyncpreemptoff=1` works around
the issue by disabling asynchronous preemption of
goroutines.

This might impact garbage collection performance, but restores
the same level of reliability to locally running tests as
when run in Docker on an Intel based Mac.

The `GODEBUG=asyncpreemptoff=1` variable is set when creating
the Docker container for running tests locally, and applies
to all Go code, including `go vet`, for which we also observed
sporadic issues.
  • Loading branch information
peanball committed Jan 13, 2025
1 parent 41b9b92 commit dc22931
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scripts/create-docker-container.bash
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,24 @@ else
ARGS="${*}"
fi

# disable asyncpreempt on MacOS ARM64 (Apple Silicon) as it may cause sporadic errors in emulation
# see: https://github.com/golang/go/issues/42774
DISABLE_ASYNC_PREEMPT=
if [ "$(uname -s) $(uname -m)" == "Darwin arm64" ]; then
DISABLE_ASYNC_PREEMPT='--env "GODEBUG=asyncpreemptoff=1"'
fi

docker pull "${IMAGE}"
docker rm -f $CONTAINER_NAME
docker run -it \
--env "DB=${DB}" \
--env "REPO_NAME=$REPO_NAME" \
--env "REPO_PATH=/repo" \
$DISABLE_ASYNC_PREEMPT \
--rm \
--name "$CONTAINER_NAME" \
-v "${REPO_PATH}:/repo" \
-v "${CI}:/ci" \
${ARGS} \
"${IMAGE}" \
/bin/bash

0 comments on commit dc22931

Please sign in to comment.