Skip to content

Commit fb6b2d9

Browse files
authored
[antithesis] Refactor existing job to support xsvm test setup (#2976)
1 parent ace88ce commit fb6b2d9

21 files changed

+567
-171
lines changed

.github/workflows/ci.yml

+10
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,16 @@ jobs:
265265
- name: Check image build
266266
shell: bash
267267
run: bash -x scripts/tests.build_image.sh
268+
test_build_antithesis_avalanchego_image:
269+
name: Antithesis avalanchego build
270+
runs-on: ubuntu-latest
271+
steps:
272+
- uses: actions/checkout@v4
273+
- name: Check image build for avalanchego test setup
274+
shell: bash
275+
run: bash -x scripts/tests.build_antithesis_images.sh
276+
env:
277+
TEST_SETUP: avalanchego
268278
govulncheck:
269279
runs-on: ubuntu-latest
270280
name: govulncheck

.github/workflows/publish_antithesis_images.yml

+5-35
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ on:
99
env:
1010
REGISTRY: us-central1-docker.pkg.dev
1111
REPOSITORY: molten-verve-216720/avalanche-repository
12-
NODE_NAME: avalanche-node
13-
WORKLOAD_NAME: workload
14-
CONFIG_NAME: config
15-
TAG: latest
1612

1713
jobs:
1814
antithesis:
@@ -29,35 +25,9 @@ jobs:
2925
username: _json_key
3026
password: ${{ secrets.ANTITHESIS_GAR_JSON_KEY }}
3127

32-
- name: Set the Go version in the environment
33-
# Need an exact version vs the range (~x.x.x) provided by set-go-version-in-env action
34-
run: echo GO_VERSION="$(go list -m -f '{{.GoVersion}}')" >> $GITHUB_ENV
35-
shell: bash
36-
37-
- name: Build node
38-
id: build-node-image
39-
run: |
40-
docker build --build-arg GO_VERSION=${GO_VERSION} -t $REGISTRY/$REPOSITORY/$NODE_NAME:$TAG -f ./tests/antithesis/Dockerfile.node .
41-
echo "name=image::$REGISTRY/$REPOSITORY/$NODE_NAME:$TAG" >> $GITHUB_OUTPUT
42-
env:
43-
GO_VERSION: '${{ env.GO_VERSION }}'
44-
45-
- name: Build workload
46-
id: build-workload-image
47-
run: |
48-
docker build --build-arg GO_VERSION=${GO_VERSION} -t $REGISTRY/$REPOSITORY/$WORKLOAD_NAME:$TAG -f ./tests/antithesis/Dockerfile.workload .
49-
echo "name=image::$REGISTRY/$REPOSITORY/$WORKLOAD_NAME:$TAG" >> $GITHUB_OUTPUT
28+
- name: Build images for avalanchego test setup
29+
run: bash -x ./scripts/build_antithesis_images.sh
5030
env:
51-
GO_VERSION: '${{ env.GO_VERSION }}'
52-
53-
- name: Build config
54-
id: build-config-image
55-
run: |
56-
docker build -t $REGISTRY/$REPOSITORY/$CONFIG_NAME:$TAG -f ./tests/antithesis/Dockerfile.config .
57-
echo "name=image::$REGISTRY/$REPOSITORY/$CONFIG_NAME:$TAG" >> $GITHUB_OUTPUT
58-
59-
- name: Publish images
60-
run: |
61-
docker push ${REGISTRY}/${REPOSITORY}/${NODE_NAME}:${TAG}
62-
docker push ${REGISTRY}/${REPOSITORY}/${WORKLOAD_NAME}:${TAG}
63-
docker push ${REGISTRY}/${REPOSITORY}/${CONFIG_NAME}:${TAG}
31+
IMAGE_PREFIX: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}
32+
TAG: latest
33+
TEST_SETUP: avalanchego

config/viper.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ import (
1515
"github.com/spf13/viper"
1616
)
1717

18+
const EnvPrefix = "avago"
19+
20+
var DashesToUnderscores = strings.NewReplacer("-", "_")
21+
1822
// BuildViper returns the viper environment from parsing config file from
1923
// default search paths and any parsed command line flags
2024
func BuildViper(fs *pflag.FlagSet, args []string) (*viper.Viper, error) {
@@ -27,8 +31,8 @@ func BuildViper(fs *pflag.FlagSet, args []string) (*viper.Viper, error) {
2731

2832
v := viper.New()
2933
v.AutomaticEnv()
30-
v.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
31-
v.SetEnvPrefix("avago")
34+
v.SetEnvKeyReplacer(DashesToUnderscores)
35+
v.SetEnvPrefix(EnvPrefix)
3236
if err := v.BindPFlags(fs); err != nil {
3337
return nil, err
3438
}

go.mod

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ require (
1313
github.com/ava-labs/ledger-avalanche/go v0.0.0-20231102202641-ae2ebdaeac34
1414
github.com/btcsuite/btcd/btcutil v1.1.3
1515
github.com/cockroachdb/pebble v0.0.0-20230906160148-46873a6a7a06
16+
github.com/compose-spec/compose-go v1.20.2
1617
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0
1718
github.com/ethereum/go-ethereum v1.13.2
1819
github.com/google/btree v1.1.2
@@ -65,6 +66,7 @@ require (
6566
google.golang.org/grpc v1.62.0
6667
google.golang.org/protobuf v1.33.0
6768
gopkg.in/natefinch/lumberjack.v2 v2.0.0
69+
gopkg.in/yaml.v3 v3.0.1
6870
)
6971

7072
require (
@@ -85,7 +87,10 @@ require (
8587
github.com/crate-crypto/go-kzg-4844 v0.3.0 // indirect
8688
github.com/davecgh/go-spew v1.1.1 // indirect
8789
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
90+
github.com/distribution/reference v0.5.0 // indirect
8891
github.com/dlclark/regexp2 v1.7.0 // indirect
92+
github.com/docker/go-connections v0.4.0 // indirect
93+
github.com/docker/go-units v0.5.0 // indirect
8994
github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127 // indirect
9095
github.com/ethereum/c-kzg-4844 v0.3.1 // indirect
9196
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect
@@ -119,10 +124,12 @@ require (
119124
github.com/mattn/go-colorable v0.1.13 // indirect
120125
github.com/mattn/go-isatty v0.0.16 // indirect
121126
github.com/mattn/go-runewidth v0.0.9 // indirect
127+
github.com/mattn/go-shellwords v1.0.12 // indirect
122128
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
123129
github.com/mitchellh/pointerstructure v1.2.0 // indirect
124130
github.com/mmcloughlin/addchain v0.4.0 // indirect
125131
github.com/olekukonko/tablewriter v0.0.5 // indirect
132+
github.com/opencontainers/go-digest v1.0.0 // indirect
126133
github.com/pelletier/go-toml v1.9.5 // indirect
127134
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
128135
github.com/pkg/errors v0.9.1 // indirect
@@ -132,6 +139,7 @@ require (
132139
github.com/rogpeppe/go-internal v1.10.0 // indirect
133140
github.com/russross/blackfriday/v2 v2.1.0 // indirect
134141
github.com/sanity-io/litter v1.5.1 // indirect
142+
github.com/sirupsen/logrus v1.9.0 // indirect
135143
github.com/spf13/afero v1.8.2 // indirect
136144
github.com/spf13/jwalterweatherman v1.1.0 // indirect
137145
github.com/status-im/keycard-go v0.2.0 // indirect
@@ -153,6 +161,5 @@ require (
153161
google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80 // indirect
154162
gopkg.in/ini.v1 v1.67.0 // indirect
155163
gopkg.in/yaml.v2 v2.4.0 // indirect
156-
gopkg.in/yaml.v3 v3.0.1 // indirect
157164
rsc.io/tmplfunc v0.0.3 // indirect
158165
)

go.sum

+17
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ github.com/cockroachdb/pebble v0.0.0-20230906160148-46873a6a7a06/go.mod h1:bynZ3
126126
github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ=
127127
github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
128128
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM=
129+
github.com/compose-spec/compose-go v1.20.2 h1:u/yfZHn4EaHGdidrZycWpxXgFffjYULlTbRfJ51ykjQ=
130+
github.com/compose-spec/compose-go v1.20.2/go.mod h1:+MdqXV4RA7wdFsahh/Kb8U0pAJqkg7mr4PM9tFKU8RM=
129131
github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ=
130132
github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI=
131133
github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M=
@@ -154,9 +156,15 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2U
154156
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
155157
github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4=
156158
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
159+
github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0=
160+
github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
157161
github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
158162
github.com/dlclark/regexp2 v1.7.0 h1:7lJfhqlPssTb1WQx4yvTHN0uElPEv52sbaECrAQxjAo=
159163
github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
164+
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
165+
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
166+
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
167+
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
160168
github.com/dop251/goja v0.0.0-20211022113120-dc8c55024d06/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk=
161169
github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127 h1:qwcF+vdFrvPSEUDSX5RVoRccG8a5DhOdWdQ4zN62zzo=
162170
github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127/go.mod h1:QMWlm50DNe14hD7t24KEqZuUdC9sOTy8W6XbCU1mlw4=
@@ -408,6 +416,8 @@ github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peK
408416
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
409417
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
410418
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
419+
github.com/mattn/go-shellwords v1.0.12 h1:M2zGm7EW6UQJvDeQxo4T51eKPurbeFbe8WtebGE2xrk=
420+
github.com/mattn/go-shellwords v1.0.12/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=
411421
github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw=
412422
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
413423
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
@@ -460,6 +470,8 @@ github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAl
460470
github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro=
461471
github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg=
462472
github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ=
473+
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
474+
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
463475
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
464476
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
465477
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
@@ -505,6 +517,8 @@ github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAm
505517
github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
506518
github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
507519
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
520+
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
521+
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
508522
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
509523
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
510524
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
@@ -808,6 +822,7 @@ golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBc
808822
golang.org/x/sys v0.0.0-20220405052023-b1e9470b6e64/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
809823
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
810824
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
825+
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
811826
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
812827
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
813828
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -1033,6 +1048,8 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
10331048
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
10341049
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
10351050
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
1051+
gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY=
1052+
gotest.tools/v3 v3.5.0/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
10361053
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
10371054
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
10381055
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

scripts/build_antithesis_workload.sh renamed to scripts/build_antithesis_avalanchego_workload.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ AVALANCHE_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd )
88
source "$AVALANCHE_PATH"/scripts/constants.sh
99

1010
echo "Building Workload..."
11-
go build -o "$AVALANCHE_PATH/build/workload" "$AVALANCHE_PATH/tests/antithesis/"*.go
11+
go build -o "$AVALANCHE_PATH/build/antithesis-avalanchego-workload" "$AVALANCHE_PATH/tests/antithesis/avalanchego/"*.go

scripts/build_antithesis_images.sh

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
# Builds docker images for antithesis testing.
6+
7+
# e.g.,
8+
# ./scripts/build_antithesis_images.sh # Build local images
9+
# IMAGE_PREFIX=<registry>/<repo> TAG=latest ./scripts/build_antithesis_images.sh # Specify a prefix to enable image push and use a specific tag
10+
11+
# Directory above this script
12+
AVALANCHE_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd )
13+
14+
# Specifying an image prefix will ensure the image is pushed after build
15+
IMAGE_PREFIX="${IMAGE_PREFIX:-}"
16+
17+
TAG="${TAG:-}"
18+
if [[ -z "${TAG}" ]]; then
19+
# Default to tagging with the commit hash
20+
source "${AVALANCHE_PATH}"/scripts/constants.sh
21+
TAG="${commit_hash}"
22+
fi
23+
24+
# The dockerfiles don't specify the golang version to minimize the changes required to bump
25+
# the version. Instead, the golang version is provided as an argument.
26+
GO_VERSION="$(go list -m -f '{{.GoVersion}}')"
27+
28+
function build_images {
29+
local test_setup=$1
30+
local uninstrumented_node_dockerfile=$2
31+
32+
# Define image names
33+
local base_image_name="antithesis-${test_setup}"
34+
if [[ -n "${IMAGE_PREFIX}" ]]; then
35+
base_image_name="${IMAGE_PREFIX}/${base_image_name}"
36+
fi
37+
local node_image_name="${base_image_name}-node:${TAG}"
38+
local workload_image_name="${base_image_name}-workload:${TAG}"
39+
local config_image_name="${base_image_name}-config:${TAG}"
40+
41+
# Define dockerfiles
42+
local base_dockerfile="${AVALANCHE_PATH}/tests/antithesis/${test_setup}/Dockerfile"
43+
local node_dockerfile="${base_dockerfile}.node"
44+
if [[ "$(go env GOARCH)" == "arm64" ]]; then
45+
# Antithesis instrumentation is only supported on amd64. On apple silicon (arm64), the
46+
# uninstrumented Dockerfile will be used to build the node image to enable local test
47+
# development.
48+
node_dockerfile="${uninstrumented_node_dockerfile}"
49+
fi
50+
51+
# Define default build command
52+
local docker_cmd="docker buildx build --build-arg GO_VERSION=${GO_VERSION}"
53+
54+
# Build node image first to allow the config and workload image builds to use it.
55+
${docker_cmd} -t "${node_image_name}" -f "${node_dockerfile}" "${AVALANCHE_PATH}"
56+
${docker_cmd} --build-arg NODE_IMAGE="${node_image_name}" -t "${workload_image_name}" -f "${base_dockerfile}.workload" "${AVALANCHE_PATH}"
57+
${docker_cmd} --build-arg IMAGE_TAG="${TAG}" -t "${config_image_name}" -f "${base_dockerfile}.config" "${AVALANCHE_PATH}"
58+
}
59+
60+
TEST_SETUP="${TEST_SETUP:-}"
61+
if [[ "${TEST_SETUP}" == "avalanchego" ]]; then
62+
build_images avalanchego "${AVALANCHE_PATH}/Dockerfile"
63+
else
64+
echo "TEST_SETUP must be set. Valid values are 'avalanchego'"
65+
exit 255
66+
fi

scripts/build_test.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ EXCLUDED_TARGETS="| grep -v /mocks | grep -v proto | grep -v tests/e2e | grep -v
1111

1212
GOOS=$(go env GOOS)
1313
if [[ "$GOOS" == "windows" ]]; then
14-
# tmpnet is not compatible with windows
15-
EXCLUDED_TARGETS="${EXCLUDED_TARGETS} | grep -v tests/fixture"
14+
# tmpnet and antithesis tests (which depend on tmpnet) are not compatible with windows
15+
EXCLUDED_TARGETS="${EXCLUDED_TARGETS} | grep -v tests/fixture | grep -v tests/antithesis"
1616
fi
1717

1818
TEST_TARGETS="$(eval "go list ./... ${EXCLUDED_TARGETS}")"
+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
# Validates the construction of the antithesis images for a test setup specified by TEST_SETUP.
6+
#
7+
# 1. Building the antithesis test image
8+
# 2. Extracting the docker compose configuration from the image
9+
# 3. Running the workload and its target network without error for a minute
10+
# 4. Stopping the workload and its target network
11+
#
12+
13+
AVALANCHE_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd )
14+
15+
# Discover the default tag that will be used for the image
16+
source "${AVALANCHE_PATH}"/scripts/constants.sh
17+
export TAG="${commit_hash}"
18+
19+
# Build the images for the specified test setup
20+
export TEST_SETUP="${TEST_SETUP:-}"
21+
bash -x "${AVALANCHE_PATH}"/scripts/build_antithesis_images.sh
22+
23+
# Create a container from the config image to extract compose configuration from
24+
IMAGE_NAME="antithesis-${TEST_SETUP}-config"
25+
CONTAINER_NAME="tmp-${IMAGE_NAME}"
26+
docker create --name "${CONTAINER_NAME}" "${IMAGE_NAME}:${TAG}" /bin/true
27+
28+
# Create a temporary directory to write the compose configuration to
29+
TMPDIR="$(mktemp -d)"
30+
COMPOSE_FILE="${TMPDIR}/docker-compose.yml"
31+
COMPOSE_CMD="docker-compose -f ${COMPOSE_FILE}"
32+
33+
# Ensure cleanup
34+
function cleanup {
35+
echo "removing temporary container"
36+
docker rm "${CONTAINER_NAME}"
37+
echo "stopping and removing the docker compose project"
38+
${COMPOSE_CMD} down --volumes
39+
echo "removing temporary dir"
40+
rm -rf "${TMPDIR}"
41+
}
42+
trap cleanup EXIT
43+
44+
# Copy the docker-compose.yml file out of the container
45+
docker cp "${CONTAINER_NAME}":/docker-compose.yml "${COMPOSE_FILE}"
46+
47+
# Copy the volume paths out of the container
48+
docker cp "${CONTAINER_NAME}":/volumes "${TMPDIR}/"
49+
50+
# Run the docker compose project for one minute without error
51+
${COMPOSE_CMD} up -d
52+
sleep 60
53+
if ${COMPOSE_CMD} ps -q | xargs docker inspect -f '{{ .State.Status }}' | grep -v 'running'; then
54+
echo "An error occurred."
55+
exit 255
56+
fi
57+
58+
# Success!

tests/antithesis/Dockerfile.config

-3
This file was deleted.

0 commit comments

Comments
 (0)