Skip to content

Commit

Permalink
Push antithesis images (#2864)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph authored Mar 22, 2024
1 parent 95edd92 commit 27bea09
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 2 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/publish_antithesis_images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Publish Antithesis Images

on:
workflow_dispatch:
push:
branches:
- master

env:
REGISTRY: us-central1-docker.pkg.dev
REPOSITORY: molten-verve-216720/avalanche-repository
NODE_NAME: avalanche-node
WORKLOAD_NAME: workload
CONFIG_NAME: config
TAG: latest

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 node
id: build-node-image
run: |
docker build -t $REGISTRY/$REPOSITORY/$NODE_NAME:$TAG -f ./tests/antithesis/Dockerfile.node .
echo "name=image::$REGISTRY/$REPOSITORY/$NODE_NAME:$TAG" >> $GITHUB_OUTPUT
- name: Build workload
id: build-workload-image
run: |
docker build -t $REGISTRY/$REPOSITORY/$WORKLOAD_NAME:$TAG -f ./tests/antithesis/Dockerfile.workload .
echo "name=image::$REGISTRY/$REPOSITORY/$WORKLOAD_NAME:$TAG" >> $GITHUB_OUTPUT
- name: Build config
id: build-config-image
run: |
docker build -t $REGISTRY/$REPOSITORY/$CONFIG_NAME:$TAG -f ./tests/antithesis/Dockerfile.config .
echo "name=image::$REGISTRY/$REPOSITORY/$CONFIG_NAME:$TAG" >> $GITHUB_OUTPUT
- name: Publish images
run: |
docker push ${REGISTRY}/${REPOSITORY}/${NODE_NAME}:${TAG}
docker push ${REGISTRY}/${REPOSITORY}/${WORKLOAD_NAME}:${TAG}
docker push ${REGISTRY}/${REPOSITORY}/${CONFIG_NAME}:${TAG}
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Changes to the minimum golang version must also be replicated in
# scripts/build_avalanche.sh
# tests/antithesis/Dockerfile.node
# tests/antithesis/Dockerfile.workload
# Dockerfile (here)
# README.md
# go.mod
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module github.com/ava-labs/avalanchego

// Changes to the minimum golang version must also be replicated in
// scripts/build_avalanche.sh
// tests/antithesis/Dockerfile.node
// tests/antithesis/Dockerfile.workload
// Dockerfile
// README.md
// go.mod (here, only major.minor can be specified)
Expand Down
11 changes: 11 additions & 0 deletions scripts/build_antithesis_workload.sh
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
AVALANCHE_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd )
# Load the constants
source "$AVALANCHE_PATH"/scripts/constants.sh

echo "Building Workload..."
go build -o "$AVALANCHE_PATH/build/workload" "$AVALANCHE_PATH/tests/antithesis/"*.go
2 changes: 2 additions & 0 deletions scripts/build_avalanche.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ done

# Changes to the minimum golang version must also be replicated in
# scripts/build_avalanche.sh (here)
# tests/antithesis/Dockerfile.node
# tests/antithesis/Dockerfile.workload
# Dockerfile
# README.md
# go.mod
Expand Down
3 changes: 3 additions & 0 deletions tests/antithesis/Dockerfile.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM scratch

COPY ./tests/antithesis/docker-compose.yml /docker-compose.yml
64 changes: 64 additions & 0 deletions tests/antithesis/Dockerfile.node
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Antithesis: Getting the Antithesis golang instrumentation library
FROM docker.io/antithesishq/go-instrumentor AS instrumentor

# Changes to the minimum golang version must also be replicated in
# scripts/build_avalanche.sh
# tests/antithesis/Dockerfile.node (here)
# Dockerfile
# README.md
# go.mod
# ============= Compilation Stage ================
FROM golang:1.21.8-bullseye AS builder

WORKDIR /build
# Copy and download avalanche dependencies using go mod
COPY go.mod .
COPY go.sum .
RUN go mod download

# Copy the code into the container
COPY . .

# Keep the commit hash to easily verify the exact version that is running
RUN git rev-parse HEAD > ./commit_hash.txt

# Copy the instrumentor and supporting files to their correct locations
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

# Park the .git file in a safe location
RUN mkdir -p /opt/tmp/
RUN cp -r .git /opt/tmp/

# Instrument avalanchego
RUN /opt/antithesis/bin/goinstrumentor \
-stderrthreshold=INFO \
-antithesis /opt/antithesis/instrumentation \
. \
/avalanchego_instrumented

WORKDIR /avalanchego_instrumented/customer
RUN go mod download
RUN ln -s /opt/tmp/.git .git

# Build avalanchego with race detection (-r) enabled.
RUN ./scripts/build.sh -r

# ============= Cleanup Stage ================
FROM debian:11-slim AS execution

# Copy identifying information into the container
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 /opt/antithesis/lib/libvoidstar.so /usr/lib/libvoidstar.so

# Copy the executable into the container
COPY --from=builder /avalanchego_instrumented/customer/build/avalanchego ./avalanchego

CMD [ "./avalanchego" ]
29 changes: 29 additions & 0 deletions tests/antithesis/Dockerfile.workload
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Changes to the minimum golang version must also be replicated in
# scripts/build_avalanche.sh
# tests/antithesis/Dockerfile.node
# tests/antithesis/Dockerfile.workload (here)
# Dockerfile
# README.md
# go.mod
# ============= Compilation Stage ================
FROM golang:1.21.8-bullseye AS builder

WORKDIR /build
# Copy and download avalanche dependencies using go mod
COPY go.mod .
COPY go.sum .
RUN go mod download

# Copy the code into the container
COPY . .

# Build the workload
RUN ./scripts/build_antithesis_workload.sh

# ============= Cleanup Stage ================
FROM debian:11-slim AS execution

# Copy the executable into the container
COPY --from=builder /build/build/workload ./workload

CMD [ "./workload" ]
3 changes: 1 addition & 2 deletions tests/antithesis/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ services:
# workload waits until cluster is up, issues 5 transactions, and the intializes the wallet. THEN we start fuzzing
workload:
container_name: workload
entrypoint: [ "./antithesis-workload" ]
image: workload:latest
environment: {
AVAWL_URIS: "http://10.0.20.3:9650 http://10.0.20.4:9650 http://10.0.20.5:9650 http://10.0.20.6:9650 http://10.0.20.7:9650"
Expand Down Expand Up @@ -117,4 +116,4 @@ services:
AVAGO_STAKING_SIGNER_KEY_FILE_CONTENT: "QXZhbGFuY2hlTG9jYWxOZXR3b3JrVmFsaWRhdG9yMDU="
}
networks:
avalanche-testnet: { ipv4_address: 10.0.20.7 }
avalanche-testnet: { ipv4_address: 10.0.20.7 }

0 comments on commit 27bea09

Please sign in to comment.