-
Notifications
You must be signed in to change notification settings - Fork 674
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[antithesis] Refactor existing job to support xsvm test setup
- Loading branch information
Showing
20 changed files
with
555 additions
and
188 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
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
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,56 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# Builds the images required for the 'avalanchego' Antithesis test setup. | ||
|
||
# e.g., | ||
# ./scripts/build_antithesis_avalanchego_image.sh # Build local images | ||
# IMAGE_PREFIX=<registry>/<repo> TAG=latest ./scripts/build_antithesis_avalanchego_image.sh # Specify a prefix to enable image push and use a specific tag | ||
|
||
# Directory above this script | ||
AVALANCHE_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd ) | ||
|
||
# Specifying an image prefix will ensure the image is pushed after build | ||
IMAGE_PREFIX="${IMAGE_PREFIX:-}" | ||
|
||
TAG="${TAG:-}" | ||
if [[ -z "${TAG}" ]]; then | ||
# Default to tagging with the commit hash | ||
source "${AVALANCHE_PATH}"/scripts/constants.sh | ||
TAG="${commit_hash}" | ||
fi | ||
|
||
# buildx (BuildKit) improves the speed and UI of builds over the legacy builder and | ||
# simplifies creation of multi-arch images. | ||
# | ||
# Reference: https://docs.docker.com/build/buildkit/ | ||
DOCKER_CMD="docker buildx build" | ||
|
||
# The dockerfiles don't specify the golang version to minimize the changes required to bump | ||
# the version. Instead, the golang version is provided as an argument. | ||
GO_VERSION="$(go list -m -f '{{.GoVersion}}')" | ||
DOCKER_CMD="${DOCKER_CMD} --build-arg GO_VERSION=${GO_VERSION}" | ||
|
||
# Antithesis instrumentation is only supported on amd64. On apple silicon (arm64), the | ||
# regular (uninstrumented) Dockerfile will be used to build the node image to enable local | ||
# test development. | ||
NODE_DOCKERFILE="${AVALANCHE_PATH}/tests/antithesis/avalanchego/Dockerfile.instrumented-node" | ||
GOARCH="$(go env GOARCH)" | ||
if [[ "${GOARCH}" == "arm64" ]]; then | ||
NODE_DOCKERFILE="${AVALANCHE_PATH}/Dockerfile" | ||
fi | ||
|
||
# Build node image. It is intended to be base image for the test image and will not be pushed. | ||
${DOCKER_CMD} -t antithesis-avalanchego-node:"${TAG}" -f "${NODE_DOCKERFILE}" "${AVALANCHE_PATH}" | ||
|
||
TEST_IMAGE_NAME=antithesis-avalanchego | ||
if [ -n "${IMAGE_PREFIX}" ]; then | ||
# Assume a prefix requires pushing to a registry. | ||
TEST_IMAGE_NAME="${IMAGE_PREFIX}/${TEST_IMAGE_NAME}" | ||
DOCKER_CMD="${DOCKER_CMD} --push" | ||
fi | ||
|
||
# Build test image based on the node image | ||
${DOCKER_CMD} -t "${TEST_IMAGE_NAME}:${TAG}" --build-arg NODE_IMAGE_TAG="${TAG}" \ | ||
-f "${AVALANCHE_PATH}"/tests/antithesis/avalanchego/Dockerfile "${AVALANCHE_PATH}" |
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,57 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# Validates the construction of the antithesis test image for avalanchego by: | ||
# | ||
# 1. Building the antithesis test image | ||
# 2. Extracting the docker compose configuration from the image | ||
# 3. Running the workload and its target network without error for a minute | ||
# 4. Stopping the workload and its target network | ||
# | ||
|
||
AVALANCHE_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd ) | ||
|
||
# Discover the tag that will be used for the image | ||
source "${AVALANCHE_PATH}"/scripts/constants.sh | ||
export TAG="${commit_hash}" | ||
|
||
# Build the image | ||
bash -x "${AVALANCHE_PATH}"/scripts/build_antithesis_avalanchego_image.sh | ||
|
||
# Create a container from the test image to extract compose configuration from | ||
IMAGE_NAME=antithesis-avalanchego | ||
CONTAINER_NAME="tmp-${IMAGE_NAME}" | ||
docker create --name "${CONTAINER_NAME}" "${IMAGE_NAME}:${TAG}" | ||
|
||
# Create a temporary directory to write the compose configuration to | ||
TMPDIR="$(mktemp -d)" | ||
COMPOSE_FILE="${TMPDIR}/docker-compose.yml" | ||
COMPOSE_CMD="docker-compose -f ${COMPOSE_FILE}" | ||
|
||
# Ensure cleanup | ||
function cleanup { | ||
echo "removing temporary container" | ||
docker rm "${CONTAINER_NAME}" | ||
echo "stopping and removing the docker compose project" | ||
${COMPOSE_CMD} down --volumes | ||
echo "removing temporary dir" | ||
rm -rf "${TMPDIR}" | ||
} | ||
trap cleanup EXIT | ||
|
||
# Copy the docker-compose.yml file out of the container | ||
docker cp "${CONTAINER_NAME}":/docker-compose.yml "${COMPOSE_FILE}" | ||
|
||
# Copy the volume paths out of the container | ||
docker cp "${CONTAINER_NAME}":/volumes "${TMPDIR}/" | ||
|
||
# Run the docker compose project for one minute without error | ||
${COMPOSE_CMD} up -d | ||
sleep 60 | ||
if ${COMPOSE_CMD} ps -q | xargs docker inspect -f '{{ .State.Status }}' | grep -v 'running'; then | ||
echo "An error occurred." | ||
exit 255 | ||
fi | ||
|
||
# Success! |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.