-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[antithesis] Add initial test setup (#1166)
* [antithesis] Propose initial test setup * fixup: Simplify generation of docker compose artifacts * fixup: Ensure images will be pushed * fixup: Update to use refactored antithesis tooling from avalanchego * fixup: Update workload to use tmpnet * fixup: Add workload sanity check to CI job * fixup: Resolved workload errors * fixup: Generate deterministic keys * fixup: Fix invocation of gen_antithesis_compose_config * fixup: Update to use StoppedTimer * fixup: Respond to review feedback * fixup: Move embedded comment out of trigger action * fixup: Get image build test passing * fixup: Update how runtime plugin dir is provided * fixup: Update avalanchego version
- Loading branch information
Showing
20 changed files
with
581 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Publish Antithesis Images | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- master | ||
|
||
env: | ||
REGISTRY: us-central1-docker.pkg.dev | ||
REPOSITORY: molten-verve-216720/avalanche-repository | ||
|
||
jobs: | ||
antithesis: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Login to GAR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: _json_key | ||
password: ${{ secrets.ANTITHESIS_GAR_JSON_KEY }} | ||
|
||
- name: Build and publish images | ||
run: bash -x ./scripts/build_antithesis_images.sh | ||
env: | ||
IMAGE_PREFIX: ${{ env.REGISTRY }}/${{ env.REPOSITORY }} | ||
IMAGE_TAG: latest |
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,40 @@ | ||
name: Trigger Antithesis | ||
|
||
on: | ||
# TODO(marun) Add a schedule | ||
workflow_dispatch: | ||
inputs: | ||
duration: | ||
description: 'The duration (in hours) to run the test for' | ||
default: '0.5' | ||
required: true | ||
type: string | ||
recipients: | ||
description: 'Comma-seperated email addresses to send the test report to' | ||
required: true | ||
type: string | ||
image_tag: | ||
description: 'The image tag to target' | ||
default: latest | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
antithesis: | ||
name: Run Antithesis | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: antithesishq/[email protected] | ||
with: | ||
notebook_name: avalanche | ||
tenant: avalanche | ||
username: ${{ secrets.ANTITHESIS_USERNAME }} | ||
password: ${{ secrets.ANTITHESIS_PASSWORD }} | ||
github_token: ${{ secrets.ANTITHESIS_GH_PAT }} | ||
config_image: antithesis-subnet-evm-config:${{ github.event.inputs.image_tag || 'latest' }} | ||
images: antithesis-subnet-evm-workload:${{ github.event.inputs.image_tag || 'latest' }};antithesis-subnet-evm-node:${{ github.event.inputs.image_tag || 'latest' }} | ||
email_recipients: ${{ github.event.inputs.recipients || secrets.ANTITHESIS_RECIPIENTS }} | ||
# Duration is in hours | ||
additional_parameters: |- | ||
custom.duration=${{ github.event.inputs.duration || '11.25' }} | ||
custom.workload=subnet-evm |
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,77 @@ | ||
#!/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> IMAGE_TAG=latest ./scripts/build_antithesis_images.sh # Specify a prefix to enable image push and use a specific tag | ||
|
||
# Directory above this script | ||
SUBNET_EVM_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd ) | ||
|
||
# Allow configuring the clone path to point to a shared and/or existing clone of the avalanchego repo | ||
AVALANCHEGO_CLONE_PATH="${AVALANCHEGO_CLONE_PATH:-${SUBNET_EVM_PATH}/avalanchego}" | ||
|
||
# Assume it's necessary to build the avalanchego node image from source | ||
# TODO(marun) Support use of a released node image if using a release version of avalanchego | ||
|
||
source "${SUBNET_EVM_PATH}"/scripts/versions.sh | ||
source "${SUBNET_EVM_PATH}"/scripts/constants.sh | ||
|
||
echo "checking out target avalanchego version ${AVALANCHE_VERSION}" | ||
if [[ -d "${AVALANCHEGO_CLONE_PATH}" ]]; then | ||
echo "updating existing clone" | ||
cd "${AVALANCHEGO_CLONE_PATH}" | ||
git fetch | ||
else | ||
echo "creating new clone" | ||
git clone https://github.com/ava-labs/avalanchego.git "${AVALANCHEGO_CLONE_PATH}" | ||
cd "${AVALANCHEGO_CLONE_PATH}" | ||
fi | ||
# Branch will be reset to $AVALANCHE_VERSION if it already exists | ||
git checkout -B "test-${AVALANCHE_VERSION}" "${AVALANCHE_VERSION}" | ||
cd "${SUBNET_EVM_PATH}" | ||
|
||
AVALANCHEGO_COMMIT_HASH="$(git --git-dir="${AVALANCHEGO_CLONE_PATH}/.git" rev-parse HEAD)" | ||
AVALANCHEGO_IMAGE_TAG="${AVALANCHEGO_COMMIT_HASH::8}" | ||
|
||
# Build avalanchego node image in the clone path | ||
pushd "${AVALANCHEGO_CLONE_PATH}" > /dev/null | ||
NODE_ONLY=1 TEST_SETUP=avalanchego IMAGE_TAG="${AVALANCHEGO_IMAGE_TAG}" bash -x "${AVALANCHEGO_CLONE_PATH}"/scripts/build_antithesis_images.sh | ||
popd > /dev/null | ||
|
||
# Specifying an image prefix will ensure the image is pushed after build | ||
IMAGE_PREFIX="${IMAGE_PREFIX:-}" | ||
|
||
IMAGE_TAG="${IMAGE_TAG:-}" | ||
if [[ -z "${IMAGE_TAG}" ]]; then | ||
# Default to tagging with the commit hash | ||
source "${SUBNET_EVM_PATH}"/scripts/constants.sh | ||
IMAGE_TAG="${SUBNET_EVM_COMMIT::8}" | ||
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}}')" | ||
|
||
# Import common functions used to build images for antithesis test setups | ||
# shellcheck source=/dev/null | ||
source "${AVALANCHEGO_CLONE_PATH}"/scripts/lib_build_antithesis_images.sh | ||
|
||
build_antithesis_builder_image "${GO_VERSION}" "antithesis-subnet-evm-builder:${IMAGE_TAG}" "${AVALANCHEGO_CLONE_PATH}" "${SUBNET_EVM_PATH}" | ||
|
||
# Ensure avalanchego and subnet-evm binaries are available to create an initial db state that includes subnets. | ||
"${AVALANCHEGO_CLONE_PATH}"/scripts/build.sh | ||
"${SUBNET_EVM_PATH}"/scripts/build.sh | ||
|
||
echo "Generating compose configuration" | ||
gen_antithesis_compose_config "${IMAGE_TAG}" "${SUBNET_EVM_PATH}/tests/antithesis/gencomposeconfig" \ | ||
"${SUBNET_EVM_PATH}/build/antithesis" \ | ||
"AVALANCHEGO_PATH=${AVALANCHEGO_CLONE_PATH}/build/avalanchego \ | ||
AVALANCHEGO_PLUGIN_DIR=${DEFAULT_PLUGIN_DIR}" | ||
|
||
build_antithesis_images "${GO_VERSION}" "${IMAGE_PREFIX}" "antithesis-subnet-evm" "${IMAGE_TAG}" \ | ||
"${AVALANCHEGO_IMAGE_TAG}" "${SUBNET_EVM_PATH}/tests/antithesis/Dockerfile" \ | ||
"${SUBNET_EVM_PATH}/Dockerfile" "${SUBNET_EVM_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# Directory above this script | ||
SUBNET_EVM_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd ) | ||
# Load the constants | ||
source "$SUBNET_EVM_PATH"/scripts/constants.sh | ||
|
||
echo "Building Workload..." | ||
go build -o "$SUBNET_EVM_PATH/build/workload" "$SUBNET_EVM_PATH/tests/antithesis/"*.go |
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
Oops, something went wrong.