-
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
19 changed files
with
479 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
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,51 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# Builds the images required for the 'avalanchego' Antithesis test setup. | ||
|
||
# e.g., | ||
# ./scripts/build_antithesis_avalanchego.sh # Build local images | ||
# IMAGE_PREFIX=<registry>/<repo> TAG=latest ./scripts/build_antithesis_avalanchego.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" | ||
|
||
# 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-test | ||
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.test "${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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/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 file 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 | ||
"${AVALANCHE_PATH}"/scripts/build_antithesis_avalanchego_image.sh | ||
|
||
# Extract the docker compose file from the image | ||
IMAGE_NAME=antithesis-avalanchego-test | ||
CONTAINER_NAME="tmp-${IMAGE_NAME}" | ||
docker create --name tmp-antithesis-avalanchego-test "${IMAGE_NAME}:${TAG}" | ||
|
||
# Create a temporary directory to write the docker-compose.yml file 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}" | ||
|
||
# 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.