From ee9fcab30993fc36c98b1a0080e6ec6acd354900 Mon Sep 17 00:00:00 2001 From: Maru Newby Date: Wed, 1 Jan 2025 23:06:55 -0800 Subject: [PATCH] Use xsvm image for e2e testing --- scripts/build_xsvm_image.sh | 21 +++++++++++++++++++++ scripts/tests.e2e.kube.sh | 4 +++- scripts/tests.e2e.sh | 13 ++++++------- vms/example/xsvm/Dockerfile | 2 +- 4 files changed, 31 insertions(+), 9 deletions(-) create mode 100755 scripts/build_xsvm_image.sh diff --git a/scripts/build_xsvm_image.sh b/scripts/build_xsvm_image.sh new file mode 100755 index 000000000000..bb868de70ecb --- /dev/null +++ b/scripts/build_xsvm_image.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -euo pipefail + +if ! [[ "$0" =~ scripts/build_xsvm_image.sh ]]; then + echo "must be run from repository root" + exit 255 +fi + +# Directory above this script +AVALANCHE_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd ) + +# TODO(marun) This image name should be configurable +DOCKER_IMAGE="localhost:5001/avalanchego" + +# Build the avalancehgo node image +FORCE_TAG_LATEST=1 SKIP_BUILD_RACE=1 DOCKER_IMAGE="${DOCKER_IMAGE}" ./scripts/build_image.sh + +GO_VERSION="$(go list -m -f '{{.GoVersion}}')" +docker buildx build --build-arg GO_VERSION="${GO_VERSION}" --build-arg AVALANCHEGO_NODE_IMAGE="${DOCKER_IMAGE}" \ + -t "${DOCKER_IMAGE}-xsvm" -f "${AVALANCHE_PATH}/vms/example/xsvm/Dockerfile" . diff --git a/scripts/tests.e2e.kube.sh b/scripts/tests.e2e.kube.sh index 594f0f06d155..70caa8b8bc80 100755 --- a/scripts/tests.e2e.kube.sh +++ b/scripts/tests.e2e.kube.sh @@ -14,5 +14,7 @@ fi # TODO(marun) Make the namespace configurable PATH="${PWD}/bin:$PATH" kubectl create namespace tmpnet || true +bash -x ./scripts/build_xsvm_image.sh + # TODO(marun) Is the path still necessary? -KUBECONFIG="$HOME/.kube/config" PATH="${PWD}/bin:$PATH" bash -x ./scripts/tests.e2e.sh --runtime=kube +E2E_SERIAL=1 KUBECONFIG="$HOME/.kube/config" PATH="${PWD}/bin:$PATH" bash -x ./scripts/tests.e2e.sh --runtime=kube --image-name=localhost:5001/avalanchego-xsvm:latest diff --git a/scripts/tests.e2e.sh b/scripts/tests.e2e.sh index 7ad35a1c1c96..87f84c885952 100755 --- a/scripts/tests.e2e.sh +++ b/scripts/tests.e2e.sh @@ -20,17 +20,16 @@ fi # the instructions to build non-portable BLST. source ./scripts/constants.sh -# Enable subnet testing by building xsvm -./scripts/build_xsvm.sh -echo "" - # Ensure an absolute path to avoid dependency on the working directory # of script execution. -AVALANCHEGO_PATH="$(realpath "${AVALANCHEGO_PATH:-./build/avalanchego}")" E2E_ARGS="${*:-}" if ! [[ "${E2E_ARGS}" =~ "--runtime=kube" ]]; then # If not running in kubernetes, use the local avalanchego binary + AVALANCHEGO_PATH="$(realpath "${AVALANCHEGO_PATH:-./build/avalanchego}")" E2E_ARGS+=" --avalanchego-path=${AVALANCHEGO_PATH}" + + # Enable subnet testing by building the xsvm binary + ./scripts/build_xsvm.sh fi ################################# @@ -62,5 +61,5 @@ else fi ################################# -# shellcheck disable=SC2086 -./scripts/ginkgo.sh ${GINKGO_ARGS} -v ./tests/e2e -- "${E2E_ARGS[@]}" "${@}" +# shellcheck disable=SC2086,SC2068 +./scripts/ginkgo.sh ${GINKGO_ARGS} -v ./tests/e2e -- ${E2E_ARGS[@]} diff --git a/vms/example/xsvm/Dockerfile b/vms/example/xsvm/Dockerfile index c3f897f8be40..a07f14867983 100644 --- a/vms/example/xsvm/Dockerfile +++ b/vms/example/xsvm/Dockerfile @@ -25,6 +25,6 @@ RUN ./scripts/build_xsvm.sh FROM $AVALANCHEGO_NODE_IMAGE AS execution # Copy the xsvm binary to the container plugin path -COPY --from=builder $BUILDER_WORKDIR/build/xsvm /avalanchego/build/plugins/v3m4wPxaHpvGr8qfMeyK6PRW3idZrPHmYcMTt7oXdK47yurVH +COPY --from=builder /build/build/xsvm /avalanchego/build/plugins/v3m4wPxaHpvGr8qfMeyK6PRW3idZrPHmYcMTt7oXdK47yurVH # The node image's entrypoint will be reused.