diff --git a/.github/workflows/publish_antithesis_images.yml b/.github/workflows/publish_antithesis_images.yml index 8dc9d426f942..f8dbebfe4438 100644 --- a/.github/workflows/publish_antithesis_images.yml +++ b/.github/workflows/publish_antithesis_images.yml @@ -35,12 +35,12 @@ jobs: run: bash -x ./scripts/build_antithesis_images.sh env: IMAGE_PREFIX: ${{ env.REGISTRY }}/${{ env.REPOSITORY }} - TAG: ${{ github.event.inputs.image_tag || 'latest' }} + IMAGE_TAG: ${{ github.event.inputs.image_tag || 'latest' }} TEST_SETUP: avalanchego - name: Build and push images for xsvm test setup run: bash -x ./scripts/build_antithesis_images.sh env: IMAGE_PREFIX: ${{ env.REGISTRY }}/${{ env.REPOSITORY }} - TAG: ${{ github.event.inputs.image_tag || 'latest' }} + IMAGE_TAG: ${{ github.event.inputs.image_tag || 'latest' }} TEST_SETUP: xsvm diff --git a/scripts/build_antithesis_images.sh b/scripts/build_antithesis_images.sh index 958f80a250b9..3aa7469c58f2 100755 --- a/scripts/build_antithesis_images.sh +++ b/scripts/build_antithesis_images.sh @@ -5,142 +5,85 @@ set -euo pipefail # Builds docker images for antithesis testing. # e.g., -# TEST_SETUP=avalanchego ./scripts/build_antithesis_images.sh # Build local images for avalanchego -# TEST_SETUP=avalanchego NODE_ONLY=1 ./scripts/build_antithesis_images.sh # Build only a local node image for avalanchego -# TEST_SETUP=xsvm ./scripts/build_antithesis_images.sh # Build local images for xsvm -# TEST_SETUP=xsvm IMAGE_PREFIX=/ TAG=latest ./scripts/build_antithesis_images.sh # Specify a prefix to enable image push and use a specific tag +# TEST_SETUP=avalanchego ./scripts/build_antithesis_images.sh # Build local images for avalanchego +# TEST_SETUP=avalanchego NODE_ONLY=1 ./scripts/build_antithesis_images.sh # Build only a local node image for avalanchego +# TEST_SETUP=xsvm ./scripts/build_antithesis_images.sh # Build local images for xsvm +# TEST_SETUP=xsvm IMAGE_PREFIX=/ IMAGE_TAG=latest ./scripts/build_antithesis_images.sh # Specify a prefix to enable image push and use a specific tag + +TEST_SETUP="${TEST_SETUP:-}" +if [[ "${TEST_SETUP}" != "avalanchego" && "${TEST_SETUP}" != "xsvm" ]]; then + echo "TEST_SETUP must be set. Valid values are 'avalanchego' or 'xsvm'" + exit 255 +fi # Directory above this script AVALANCHE_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd ) +# Import common functions used to build images for antithesis test setups +source "${AVALANCHE_PATH}"/scripts/lib_build_antithesis_images.sh + # Specifying an image prefix will ensure the image is pushed after build IMAGE_PREFIX="${IMAGE_PREFIX:-}" -TAG="${TAG:-}" -if [[ -z "${TAG}" ]]; then +IMAGE_TAG="${IMAGE_TAG:-}" +if [[ -z "${IMAGE_TAG}" ]]; then # Default to tagging with the commit hash source "${AVALANCHE_PATH}"/scripts/constants.sh - TAG="${commit_hash}" + IMAGE_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 { +# Helper to simplify calling build_builder_image for test setups in this repo +function build_builder_image_for_avalanchego { + echo "Building builder image" + build_antithesis_builder_image "${GO_VERSION}" "antithesis-avalanchego-builder:${IMAGE_TAG}" "${AVALANCHE_PATH}" "${AVALANCHE_PATH}" +} + +# Helper to simplify calling build_antithesis_images for test setups in this repo +function build_antithesis_images_for_avalanchego { local test_setup=$1 - local uninstrumented_node_dockerfile=$2 - local image_prefix=$3 + local image_prefix=$2 + local uninstrumented_node_dockerfile=$3 local node_only=${4:-} - # 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}" - # The same builder image is used to build node and workload images for all test - # setups. It is not intended to be pushed. - local builder_image_name="antithesis-avalanchego-builder:${TAG}" - - # Define dockerfiles - local base_dockerfile="${AVALANCHE_PATH}/tests/antithesis/${test_setup}/Dockerfile" - local builder_dockerfile="${base_dockerfile}.builder-instrumented" - local node_dockerfile="${base_dockerfile}.node" - # Working directory for instrumented builds - local builder_workdir="/avalanchego_instrumented/customer" - if [[ "$(go env GOARCH)" == "arm64" ]]; then - # Antithesis instrumentation is only supported on amd64. On apple silicon (arm64), - # uninstrumented Dockerfiles will be used to enable local test development. - builder_dockerfile="${base_dockerfile}.builder-uninstrumented" - node_dockerfile="${uninstrumented_node_dockerfile}" - # Working directory for uninstrumented builds - builder_workdir="/build" - fi - - # Define default build command - local docker_cmd="docker buildx build\ - --build-arg GO_VERSION=${GO_VERSION}\ - --build-arg NODE_IMAGE=${node_image_name}\ - --build-arg BUILDER_IMAGE=${builder_image_name}\ - --build-arg BUILDER_WORKDIR=${builder_workdir}\ - --build-arg TAG=${TAG}" - - if [[ "${test_setup}" == "xsvm" ]]; then - # The xsvm node image is built on the avalanchego node image, which is assumed to have already been - # built. The image name doesn't include the image prefix because it is not intended to be pushed. - docker_cmd="${docker_cmd} --build-arg AVALANCHEGO_NODE_IMAGE=antithesis-avalanchego-node:${TAG}" - fi - - if [[ "${test_setup}" == "avalanchego" ]]; then - # Build the image that enables compiling golang binaries for the node and workload - # image builds. The builder image is intended to enable building instrumented binaries - # if built on amd64 and non-instrumented binaries if built on arm64. - # - # The builder image is not intended to be pushed so it needs to be built in advance of - # adding `--push` to docker_cmd. Since it is never prefixed with `[registry]/[repo]`, - # attempting to push will result in an error like `unauthorized: access token has - # insufficient scopes`. - ${docker_cmd} -t "${builder_image_name}" -f "${builder_dockerfile}" "${AVALANCHE_PATH}" - fi - - if [[ -n "${image_prefix}" && -z "${node_only}" ]]; then - # Push images with an image prefix since the prefix defines a - # registry location, and only if building all images. When - # building just the node image the image is only intended to be - # used locally. - docker_cmd="${docker_cmd} --push" - fi - - # Build node image first to allow the workload image to use it. - ${docker_cmd} -t "${node_image_name}" -f "${node_dockerfile}" "${AVALANCHE_PATH}" - - if [[ -n "${node_only}" ]]; then - # Skip building the config and workload images. Supports building the avalanchego - # node image as the base image for the xsvm node image. - return - fi - - TARGET_PATH="${AVALANCHE_PATH}/build/antithesis/${test_setup}" - if [[ -d "${TARGET_PATH}" ]]; then - # Ensure the target path is empty before generating the compose config - rm -r "${TARGET_PATH:?}" + if [[ -z "${node_only}" ]]; then + echo "Building node image for ${test_setup}" + else + echo "Building images for ${test_setup}" fi + build_antithesis_images "${GO_VERSION}" "${image_prefix}" "antithesis-${test_setup}" "${IMAGE_TAG}" "${IMAGE_TAG}" \ + "${AVALANCHE_PATH}/tests/antithesis/${test_setup}/Dockerfile" "${uninstrumented_node_dockerfile}" \ + "${AVALANCHE_PATH}" "${node_only}" +} - # Define the env vars for the compose config generation - COMPOSE_ENV="TARGET_PATH=${TARGET_PATH} IMAGE_TAG=${TAG}" +if [[ "${TEST_SETUP}" == "avalanchego" ]]; then + build_builder_image_for_avalanchego - if [[ "${test_setup}" == "xsvm" ]]; then - # Ensure avalanchego and xsvm binaries are available to create an initial db state that includes subnets. - "${AVALANCHE_PATH}"/scripts/build.sh - "${AVALANCHE_PATH}"/scripts/build_xsvm.sh - COMPOSE_ENV="${COMPOSE_ENV} AVALANCHEGO_PATH=${AVALANCHE_PATH}/build/avalanchego AVALANCHEGO_PLUGIN_DIR=${HOME}/.avalanchego/plugins" - fi + echo "Generating compose configuration for ${TEST_SETUP}" + gen_antithesis_compose_config "${IMAGE_TAG}" "${AVALANCHE_PATH}/tests/antithesis/avalanchego/gencomposeconfig" \ + "${AVALANCHE_PATH}/build/antithesis/avalanchego" - # Generate compose config for copying into the config image - # shellcheck disable=SC2086 - env ${COMPOSE_ENV} go run "${AVALANCHE_PATH}/tests/antithesis/${test_setup}/gencomposeconfig" + build_antithesis_images_for_avalanchego "${TEST_SETUP}" "${IMAGE_PREFIX}" "${AVALANCHE_PATH}/Dockerfile" "${NODE_ONLY:-}" +else + build_builder_image_for_avalanchego - # Build the config image - ${docker_cmd} -t "${config_image_name}" -f "${base_dockerfile}.config" "${AVALANCHE_PATH}" + # Only build the avalanchego node image to use as the base for the xsvm image. Provide an empty + # image prefix (the 1st argument) to prevent the image from being pushed + NODE_ONLY=1 + build_antithesis_images_for_avalanchego avalanchego "" "${AVALANCHE_PATH}/Dockerfile" "${NODE_ONLY}" - # Build the workload image - ${docker_cmd} -t "${workload_image_name}" -f "${base_dockerfile}.workload" "${AVALANCHE_PATH}" -} + # Ensure avalanchego and xsvm binaries are available to create an initial db state that includes subnets. + echo "Building binaries required for configuring the ${TEST_SETUP} test setup" + "${AVALANCHE_PATH}"/scripts/build.sh + "${AVALANCHE_PATH}"/scripts/build_xsvm.sh -TEST_SETUP="${TEST_SETUP:-}" -if [[ "${TEST_SETUP}" == "avalanchego" ]]; then - build_images avalanchego "${AVALANCHE_PATH}/Dockerfile" "${IMAGE_PREFIX}" "${NODE_ONLY:-}" -elif [[ "${TEST_SETUP}" == "xsvm" ]]; then - # Only build the node image to use as the base for the xsvm image. Provide an empty - # image prefix (the 3rd argument) to prevent the image from being pushed - NODE_ONLY=1 - build_images avalanchego "${AVALANCHE_PATH}/Dockerfile" "" "${NODE_ONLY}" + echo "Generating compose configuration for ${TEST_SETUP}" + gen_antithesis_compose_config "${IMAGE_TAG}" "${AVALANCHE_PATH}/tests/antithesis/xsvm/gencomposeconfig" \ + "${AVALANCHE_PATH}/build/antithesis/xsvm" \ + "AVALANCHEGO_PATH=${AVALANCHE_PATH}/build/avalanchego AVALANCHEGO_PLUGIN_DIR=${HOME}/.avalanchego/plugins" - build_images xsvm "${AVALANCHE_PATH}/vms/example/xsvm/Dockerfile" "${IMAGE_PREFIX}" -else - echo "TEST_SETUP must be set. Valid values are 'avalanchego' or 'xsvm'" - exit 255 + build_antithesis_images_for_avalanchego "${TEST_SETUP}" "${IMAGE_PREFIX}" "${AVALANCHE_PATH}/vms/example/xsvm/Dockerfile" fi diff --git a/scripts/lib_build_antithesis_images.sh b/scripts/lib_build_antithesis_images.sh new file mode 100644 index 000000000000..f9bac6a13cdd --- /dev/null +++ b/scripts/lib_build_antithesis_images.sh @@ -0,0 +1,110 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# This script defines helper functions to enable building images for antithesis test setups. It is +# intended to be reusable by repos other than avalanchego so almost all inputs are accepted as parameters +# rather than being discovered from the environment. +# +# Since this file only defines functions, it is intended to be sourced rather than executed. + +# Build the image that enables compiling golang binaries for the node and workload image +# builds. The builder image is intended to enable building instrumented binaries if built +# on amd64 and non-instrumented binaries if built on arm64. +function build_antithesis_builder_image { + local go_version=$1 + local image_name=$2 + local avalanchego_path=$3 + local target_path=$4 + + local base_dockerfile="${avalanchego_path}/tests/antithesis/Dockerfile" + local builder_dockerfile="${base_dockerfile}.builder-instrumented" + if [[ "$(go env GOARCH)" == "arm64" ]]; then + # Antithesis instrumentation is only supported on amd64. On apple silicon (arm64), + # an uninstrumented Dockerfile will be used to enable local test development. + builder_dockerfile="${base_dockerfile}.builder-uninstrumented" + fi + + docker buildx build --build-arg GO_VERSION="${go_version}" -t "${image_name}" -f "${builder_dockerfile}" "${target_path}" +} + +# Build the antithesis node, workload, and config images. +function build_antithesis_images { + local go_version=$1 + local image_prefix=$2 + local base_image_name=$3 + local image_tag=$4 + local node_image_tag=$5 + local base_dockerfile=$6 + local uninstrumented_node_dockerfile=$7 + local target_path=$8 + local node_only=${9:-} + + # Define image names + if [[ -n "${image_prefix}" ]]; then + base_image_name="${image_prefix}/${base_image_name}" + fi + local node_image_name="${base_image_name}-node:${image_tag}" + local workload_image_name="${base_image_name}-workload:${image_tag}" + local config_image_name="${base_image_name}-config:${image_tag}" + + # Define dockerfiles + local node_dockerfile="${base_dockerfile}.node" + # Working directory for instrumented builds + local builder_workdir="/instrumented/customer" + if [[ "$(go env GOARCH)" == "arm64" ]]; then + # Antithesis instrumentation is only supported on amd64. On apple silicon (arm64), + # uninstrumented Dockerfiles will be used to enable local test development. + node_dockerfile="${uninstrumented_node_dockerfile}" + # Working directory for uninstrumented builds + builder_workdir="/build" + fi + + # Define default build command + local docker_cmd="docker buildx build\ + --build-arg GO_VERSION=${go_version}\ + --build-arg BUILDER_IMAGE_TAG=${image_tag}\ + --build-arg BUILDER_WORKDIR=${builder_workdir}\ + --build-arg AVALANCHEGO_NODE_IMAGE=antithesis-avalanchego-node:${node_image_tag}" + + if [[ -n "${image_prefix}" && -z "${node_only}" ]]; then + # Push images with an image prefix since the prefix defines a registry location, and only if building + # all images. When building just the node image the image is only intended to be used locally. + docker_cmd="${docker_cmd} --push" + fi + + # Build node image first to allow the workload image to use it. + ${docker_cmd} -t "${node_image_name}" -f "${node_dockerfile}" "${target_path}" + + if [[ -n "${node_only}" ]]; then + # Skip building the config and workload images. Supports building the avalanchego node image as the + # base image for a VM node image. + return + fi + + # Build the config image + ${docker_cmd} -t "${config_image_name}" -f "${base_dockerfile}.config" "${target_path}" + + # Build the workload image + ${docker_cmd} -t "${workload_image_name}" -f "${base_dockerfile}.workload" "${target_path}" +} + +# Generate the docker compose configuration for the antithesis config image. +function gen_antithesis_compose_config { + local image_tag=$1 + local exe_path=$2 + local target_path=$3 + local extra_compose_args=${4:-} + + if [[ -d "${target_path}" ]]; then + # Ensure the target path is empty before generating the compose config + rm -r "${target_path:?}" + fi + + # Define the env vars for the compose config generation + local compose_env="TARGET_PATH=${target_path} IMAGE_TAG=${image_tag} ${extra_compose_args}" + + # Generate compose config for copying into the config image + # shellcheck disable=SC2086 + env ${compose_env} go run "${exe_path}" +} diff --git a/scripts/lib_test_antithesis_images.sh b/scripts/lib_test_antithesis_images.sh new file mode 100644 index 000000000000..eb01bbdcc810 --- /dev/null +++ b/scripts/lib_test_antithesis_images.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# Validates the compose configuration of the antithesis config image +# identified by IMAGE_NAME and IMAGE_TAG by: +# +# 1. Extracting the docker compose configuration from the image +# 2. Running the workload and its target network without error for a minute +# 3. Stopping the workload and its target network +# +# This script is intended to be sourced rather than executed directly. + +if [[ -z "${IMAGE_NAME:-}" || -z "${IMAGE_TAG:-}" ]]; then + echo "IMAGE_NAME and IMAGE_TAG must be set" + exit 1 +fi + +# Create a container from the config image to extract compose configuration from +CONTAINER_NAME="tmp-${IMAGE_NAME}" +docker create --name "${CONTAINER_NAME}" "${IMAGE_NAME}:${IMAGE_TAG}" /bin/true + +# Create a temporary directory to write the compose configuration to +TMPDIR="$(mktemp -d)" +echo "using temporary directory ${TMPDIR} as the docker compose path" + +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 + if [[ -z "${DEBUG:-}" ]]; then + echo "removing temporary dir" + rm -rf "${TMPDIR}" + fi +} +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 30 seconds without error. Local +# network bootstrap is ~6s, but github workers can be much slower. +${COMPOSE_CMD} up -d +sleep 30 +if ${COMPOSE_CMD} ps -q | xargs docker inspect -f '{{ .State.Status }}' | grep -v 'running'; then + echo "An error occurred." + exit 1 +fi + +echo "Successfully invoked the antithesis test setup configured by ${IMAGE_NAME}:${IMAGE_TAG}" diff --git a/scripts/tests.build_antithesis_images.sh b/scripts/tests.build_antithesis_images.sh index 266bae41a129..1093295fa311 100755 --- a/scripts/tests.build_antithesis_images.sh +++ b/scripts/tests.build_antithesis_images.sh @@ -2,7 +2,7 @@ set -euo pipefail -# Validates the construction of the antithesis images for a test setup specified by TEST_SETUP. +# Validates the construction of the antithesis images for a test setup specified by TEST_SETUP by: # # 1. Building the antithesis test image # 2. Extracting the docker compose configuration from the image @@ -13,57 +13,21 @@ set -euo pipefail # public github runners. `docker-compose` (the v1 plugin) is not installed by default. # e.g., -# TEST_SETUP=avalanchego ./scripts/tests.build_antithesis_images.sh # Test build of images for avalanchego test setup -# DEBUG=1 TEST_SETUP=avalanchego ./scripts/tests.build_antithesis_images.sh # Retain the temporary compose path for troubleshooting +# TEST_SETUP=avalanchego ./scripts/tests.build_antithesis_images.sh # Test build of images for avalanchego test setup +# DEBUG=1 TEST_SETUP=avalanchego ./scripts/tests.build_antithesis_images.sh # Retain the temporary compose path for troubleshooting 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}" +export IMAGE_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)" -echo "using temporary directory ${TMPDIR} as the docker compose path" - -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 - if [[ -z "${DEBUG:-}" ]]; then - echo "removing temporary dir" - rm -rf "${TMPDIR}" - fi -} -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 30 seconds without error. Local -# network bootstrap is ~6s, but github workers can be much slower. -${COMPOSE_CMD} up -d -sleep 30 -if ${COMPOSE_CMD} ps -q | xargs docker inspect -f '{{ .State.Status }}' | grep -v 'running'; then - echo "An error occurred." - exit 255 -fi - -# Success! +# Test the images +export IMAGE_NAME="antithesis-${TEST_SETUP}-config" +export DEBUG="${DEBUG:-}" +set -x +. "${AVALANCHE_PATH}"/scripts/lib_test_antithesis_images.sh diff --git a/tests/antithesis/avalanchego/Dockerfile.builder-instrumented b/tests/antithesis/Dockerfile.builder-instrumented similarity index 86% rename from tests/antithesis/avalanchego/Dockerfile.builder-instrumented rename to tests/antithesis/Dockerfile.builder-instrumented index ffc05256e30e..f9e4b2d054e1 100644 --- a/tests/antithesis/avalanchego/Dockerfile.builder-instrumented +++ b/tests/antithesis/Dockerfile.builder-instrumented @@ -9,7 +9,7 @@ FROM docker.io/antithesishq/go-instrumentor AS instrumentor FROM golang:$GO_VERSION-bullseye WORKDIR /build -# Copy and download avalanche dependencies using go mod +# Copy and download dependencies using go mod COPY go.mod . COPY go.sum . RUN go mod download @@ -28,19 +28,19 @@ COPY --from=instrumentor /opt/antithesis /opt/antithesis COPY --from=instrumentor /opt/antithesis/lib /lib # Create the destination output directory for the instrumented code -RUN mkdir -p /avalanchego_instrumented +RUN mkdir -p /instrumented # Park the .git file in a safe location RUN mkdir -p /opt/tmp/ RUN cp -r .git /opt/tmp/ -# Instrument avalanchego +# Instrument the code RUN /opt/antithesis/bin/goinstrumentor \ -stderrthreshold=INFO \ -antithesis /opt/antithesis/instrumentation \ . \ - /avalanchego_instrumented + /instrumented -WORKDIR /avalanchego_instrumented/customer +WORKDIR /instrumented/customer RUN go mod download RUN ln -s /opt/tmp/.git .git diff --git a/tests/antithesis/avalanchego/Dockerfile.builder-uninstrumented b/tests/antithesis/Dockerfile.builder-uninstrumented similarity index 87% rename from tests/antithesis/avalanchego/Dockerfile.builder-uninstrumented rename to tests/antithesis/Dockerfile.builder-uninstrumented index 07d3fe8b882c..4ff06603d96c 100644 --- a/tests/antithesis/avalanchego/Dockerfile.builder-uninstrumented +++ b/tests/antithesis/Dockerfile.builder-uninstrumented @@ -5,7 +5,7 @@ ARG GO_VERSION FROM golang:$GO_VERSION-bullseye WORKDIR /build -# Copy and download avalanche dependencies using go mod +# Copy and download dependencies using go mod COPY go.mod . COPY go.sum . RUN go mod download diff --git a/tests/antithesis/README.md b/tests/antithesis/README.md index 55425652f967..34b0d449a1f6 100644 --- a/tests/antithesis/README.md +++ b/tests/antithesis/README.md @@ -8,14 +8,17 @@ enables discovery and reproduction of anomalous behavior. ## Package details -| Filename | Purpose | -|:---------------|:-----------------------------------------------------------------------------------| -| compose.go | Generates Docker Compose project file and initial database for antithesis testing. | -| config.go | Defines common flags for the workload binary. | -| init_db.go | Initializes initial db state for subnet testing. | -| node_health.go | Helper to check node health. | -| avalanchego/ | Defines an antithesis test setup for avalanchego's primary chains. | -| xsvm/ | Defines an antithesis test setup for the xsvm VM. | +| Filename | Purpose | +|:----------------------------------|:-----------------------------------------------------------------------------------| +| compose.go | Generates Docker Compose project file and initial database for antithesis testing. | +| config.go | Defines common flags for the workload binary. | +| Dockerfile.builder-instrumented | Dockerfile for instrumented builds. | +| Dockerfile.builder-uninstrumented | Dockerfile for uninstrumented builds. | +| config.go | Defines common flags for the workload binary. | +| init_db.go | Initializes initial db state for subnet testing. | +| node_health.go | Helper to check node health. | +| avalanchego/ | Defines an antithesis test setup for avalanchego's primary chains. | +| xsvm/ | Defines an antithesis test setup for the xsvm VM. | ## Instrumentation @@ -140,6 +143,6 @@ can be performed against master or an arbitrary branch: workflow against the desired branch. The branch only determines the CI configuration (the images have already been built), so master is probably fine. Make sure to supply the same `image_tag` that was - provided to the publishing workflow and consider setting - `recipients` to your own email rather than sending the test report - to everyone on the regular distribution list. + provided to the publishing workflow and provide a value for + `recipients` (e.g. your email address) to avoid sending the test + report to everyone on the regular distribution list. diff --git a/tests/antithesis/avalanchego/Dockerfile.node b/tests/antithesis/avalanchego/Dockerfile.node index 2b19adbb93c1..25dd82ead892 100644 --- a/tests/antithesis/avalanchego/Dockerfile.node +++ b/tests/antithesis/avalanchego/Dockerfile.node @@ -1,11 +1,11 @@ -# TAG should identify the builder image -ARG TAG +# BUILDER_IMAGE_TAG should identify the builder image +ARG BUILDER_IMAGE_TAG # ============= Compilation Stage ================ -FROM antithesis-avalanchego-builder:$TAG AS builder +FROM antithesis-avalanchego-builder:$BUILDER_IMAGE_TAG AS builder # The workdir is hard-coded since this Dockerfile is only intended for instrumented builds. -WORKDIR /avalanchego_instrumented/customer +WORKDIR /instrumented/customer # Build avalanchego with race detection (-r) enabled. RUN ./scripts/build.sh -r @@ -18,13 +18,13 @@ COPY --from=builder /build/commit_hash.txt ./commit_hash.txt # Copy the antithesis dependencies into the container RUN mkdir -p /symbols -COPY --from=builder /avalanchego_instrumented/symbols /symbols +COPY --from=builder /instrumented/symbols /symbols COPY --from=builder /opt/antithesis/lib/libvoidstar.so /usr/lib/libvoidstar.so # Use the same path as the uninstrumented node image for consistency WORKDIR /avalanchego/build # Copy the executable into the container -COPY --from=builder /avalanchego_instrumented/customer/build/avalanchego ./avalanchego +COPY --from=builder /instrumented/customer/build/avalanchego ./avalanchego CMD [ "./avalanchego" ] diff --git a/tests/antithesis/avalanchego/Dockerfile.workload b/tests/antithesis/avalanchego/Dockerfile.workload index 4cd37123773e..f098640d6f9b 100644 --- a/tests/antithesis/avalanchego/Dockerfile.workload +++ b/tests/antithesis/avalanchego/Dockerfile.workload @@ -1,11 +1,11 @@ -# TAG should identify the builder image -ARG TAG +# BUILDER_IMAGE_TAG should identify the builder image +ARG BUILDER_IMAGE_TAG -# NODE_IMAGE needs to identify an existing node image and should include the tag -ARG NODE_IMAGE +# AVALANCHEGO_NODE_IMAGE needs to identify an existing node image and should include the tag +ARG AVALANCHEGO_NODE_IMAGE # ============= Compilation Stage ================ -FROM antithesis-avalanchego-builder:$TAG AS builder +FROM antithesis-avalanchego-builder:$BUILDER_IMAGE_TAG AS builder # The builder workdir will vary between instrumented and non-instrumented builders ARG BUILDER_WORKDIR @@ -17,7 +17,7 @@ RUN ./scripts/build_antithesis_avalanchego_workload.sh # ============= Cleanup Stage ================ # Base the workflow on the node image to support bootstrap testing -FROM $NODE_IMAGE AS execution +FROM $AVALANCHEGO_NODE_IMAGE AS execution # The builder workdir will vary between instrumented and non-instrumented builders ARG BUILDER_WORKDIR diff --git a/tests/antithesis/xsvm/Dockerfile.node b/tests/antithesis/xsvm/Dockerfile.node index 67a1aa01fca9..8775ac77994a 100644 --- a/tests/antithesis/xsvm/Dockerfile.node +++ b/tests/antithesis/xsvm/Dockerfile.node @@ -1,11 +1,11 @@ -# TAG should identify the builder image -ARG TAG +# BUILDER_IMAGE_TAG should identify the builder image +ARG BUILDER_IMAGE_TAG # AVALANCHEGO_NODE_IMAGE needs to identify an existing avalanchego node image and should include the tag ARG AVALANCHEGO_NODE_IMAGE # ============= Compilation Stage ================ -FROM antithesis-avalanchego-builder:$TAG AS builder +FROM antithesis-avalanchego-builder:$BUILDER_IMAGE_TAG AS builder # The builder workdir will vary between instrumented and non-instrumented builders ARG BUILDER_WORKDIR diff --git a/tests/antithesis/xsvm/Dockerfile.workload b/tests/antithesis/xsvm/Dockerfile.workload index 1ca2f56b862a..a273cadb823e 100644 --- a/tests/antithesis/xsvm/Dockerfile.workload +++ b/tests/antithesis/xsvm/Dockerfile.workload @@ -1,11 +1,11 @@ -# TAG should identify the builder image -ARG TAG +# BUILDER_IMAGE_TAG should identify the builder image +ARG BUILDER_IMAGE_TAG -# NODE_IMAGE needs to identify an existing node image and should include the tag -ARG NODE_IMAGE +# AVALANCHEGO_NODE_IMAGE needs to identify an existing node image and should include the tag +ARG AVALANCHEGO_NODE_IMAGE # ============= Compilation Stage ================ -FROM antithesis-avalanchego-builder:$TAG AS builder +FROM antithesis-avalanchego-builder:$BUILDER_IMAGE_TAG AS builder # The builder workdir will vary between instrumented and non-instrumented builders ARG BUILDER_WORKDIR @@ -17,7 +17,7 @@ RUN ./scripts/build_antithesis_xsvm_workload.sh # ============= Cleanup Stage ================ # Base the workflow on the node image to support bootstrap testing -FROM $NODE_IMAGE AS execution +FROM $AVALANCHEGO_NODE_IMAGE AS execution # The builder workdir will vary between instrumented and non-instrumented builders ARG BUILDER_WORKDIR