-
Notifications
You must be signed in to change notification settings - Fork 671
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 (#2976)
- Loading branch information
Showing
21 changed files
with
567 additions
and
171 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
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,66 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# Builds docker images for antithesis testing. | ||
|
||
# e.g., | ||
# ./scripts/build_antithesis_images.sh # Build local images | ||
# IMAGE_PREFIX=<registry>/<repo> TAG=latest ./scripts/build_antithesis_images.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 | ||
|
||
# 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}}')" | ||
|
||
function build_images { | ||
local test_setup=$1 | ||
local uninstrumented_node_dockerfile=$2 | ||
|
||
# Define image names | ||
local base_image_name="antithesis-${test_setup}" | ||
if [[ -n "${IMAGE_PREFIX}" ]]; then | ||
base_image_name="${IMAGE_PREFIX}/${base_image_name}" | ||
fi | ||
local node_image_name="${base_image_name}-node:${TAG}" | ||
local workload_image_name="${base_image_name}-workload:${TAG}" | ||
local config_image_name="${base_image_name}-config:${TAG}" | ||
|
||
# Define dockerfiles | ||
local base_dockerfile="${AVALANCHE_PATH}/tests/antithesis/${test_setup}/Dockerfile" | ||
local node_dockerfile="${base_dockerfile}.node" | ||
if [[ "$(go env GOARCH)" == "arm64" ]]; then | ||
# Antithesis instrumentation is only supported on amd64. On apple silicon (arm64), the | ||
# uninstrumented Dockerfile will be used to build the node image to enable local test | ||
# development. | ||
node_dockerfile="${uninstrumented_node_dockerfile}" | ||
fi | ||
|
||
# Define default build command | ||
local docker_cmd="docker buildx build --build-arg GO_VERSION=${GO_VERSION}" | ||
|
||
# Build node image first to allow the config and workload image builds to use it. | ||
${docker_cmd} -t "${node_image_name}" -f "${node_dockerfile}" "${AVALANCHE_PATH}" | ||
${docker_cmd} --build-arg NODE_IMAGE="${node_image_name}" -t "${workload_image_name}" -f "${base_dockerfile}.workload" "${AVALANCHE_PATH}" | ||
${docker_cmd} --build-arg IMAGE_TAG="${TAG}" -t "${config_image_name}" -f "${base_dockerfile}.config" "${AVALANCHE_PATH}" | ||
} | ||
|
||
TEST_SETUP="${TEST_SETUP:-}" | ||
if [[ "${TEST_SETUP}" == "avalanchego" ]]; then | ||
build_images avalanchego "${AVALANCHE_PATH}/Dockerfile" | ||
else | ||
echo "TEST_SETUP must be set. Valid values are 'avalanchego'" | ||
exit 255 | ||
fi |
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,58 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# Validates the construction of the antithesis images for a test setup specified by TEST_SETUP. | ||
# | ||
# 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 default tag that will be used for the image | ||
source "${AVALANCHE_PATH}"/scripts/constants.sh | ||
export TAG="${commit_hash}" | ||
|
||
# Build the images for the specified test setup | ||
export TEST_SETUP="${TEST_SETUP:-}" | ||
bash -x "${AVALANCHE_PATH}"/scripts/build_antithesis_images.sh | ||
|
||
# Create a container from the config image to extract compose configuration from | ||
IMAGE_NAME="antithesis-${TEST_SETUP}-config" | ||
CONTAINER_NAME="tmp-${IMAGE_NAME}" | ||
docker create --name "${CONTAINER_NAME}" "${IMAGE_NAME}:${TAG}" /bin/true | ||
|
||
# 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.
Oops, something went wrong.