Skip to content
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ tasks:
- task: generate-load-contract-bindings
- task: build
- cmd: go run ./tests/load/c/main --avalanchego-path=./build/avalanchego {{.CLI_ARGS}}

test-load-kube:
desc: Runs load tests against a network deployed to kube
cmds:
cmds:
- task: generate-load-contract-bindings
- cmd: bash -x ./scripts/tests.load.kube.sh {{.CLI_ARGS}}

Expand All @@ -244,6 +244,10 @@ tasks:
cmds:
- cmd: go run ./tests/load/c/main --runtime=kube --kube-use-exclusive-scheduling {{.CLI_ARGS}}

test-load-kind-cluster:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe choose a name more reflective of the test running inside the cluster? 'kind cluster' isn't very specific.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: d9fdb87

desc: Runs load tests within a kind cluster
cmd: bash -x ./scripts/tests.load.kind.sh

test-unit:
desc: Runs unit tests
# Invoking with bash ensures compatibility with CI execution on Windows
Expand Down
7 changes: 5 additions & 2 deletions scripts/build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ set -euo pipefail
# DOCKER_IMAGE=avaplatform/avalanchego ./scripts/build_image.sh # Build and push multi-arch image to docker hub
# DOCKER_IMAGE=localhost:5001/avalanchego ./scripts/build_image.sh # Build and push multi-arch image to private registry
# DOCKER_IMAGE=localhost:5001/avalanchego FORCE_TAG_LATEST=1 ./scripts/build_image.sh # Build and push image to private registry with tag `latest`
# DOCKERFILE="./Dockerfile" ./scripts/build_image.sh # Build image with a custom Dockerfile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(No action required) Why is it desirable to customize this build script instead of following the example of scripts/build_bootstrap_monitor_image.sh?

Note that a compiled binary is suggested rather than using 'go run' at runtime.


# Multi-arch builds require Docker Buildx and QEMU. buildx should be enabled by
# default in the version of docker included with Ubuntu 22.04, and qemu can be
Expand All @@ -35,6 +36,8 @@ SKIP_BUILD_RACE="${SKIP_BUILD_RACE:-}"
# Force tagging as latest even if not the master branch
FORCE_TAG_LATEST="${FORCE_TAG_LATEST:-}"

DOCKERFILE="${DOCKERFILE:-$AVALANCHE_PATH/Dockerfile}"

# Load the constants
source "$AVALANCHE_PATH"/scripts/constants.sh
source "$AVALANCHE_PATH"/scripts/git_commit.sh
Expand Down Expand Up @@ -108,12 +111,12 @@ fi

echo "Building Docker Image with tags: $DOCKER_IMAGE:$commit_hash , $DOCKER_IMAGE:$image_tag"
${DOCKER_CMD} -t "$DOCKER_IMAGE:$commit_hash" -t "$DOCKER_IMAGE:$image_tag" \
"$AVALANCHE_PATH" -f "$AVALANCHE_PATH/Dockerfile"
"$AVALANCHE_PATH" -f "$DOCKERFILE"

if [[ -z "${SKIP_BUILD_RACE}" ]]; then
echo "Building Docker Image with tags (race detector): $DOCKER_IMAGE:$commit_hash-r , $DOCKER_IMAGE:$image_tag-r"
${DOCKER_CMD} --build-arg="RACE_FLAG=-r" -t "$DOCKER_IMAGE:$commit_hash-r" -t "$DOCKER_IMAGE:$image_tag-r" \
"$AVALANCHE_PATH" -f "$AVALANCHE_PATH/Dockerfile"
"$AVALANCHE_PATH" -f "$DOCKERFILE"
fi

# Only tag the latest image for the master branch when images are pushed to a registry
Expand Down
81 changes: 81 additions & 0 deletions scripts/tests.load.kind.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/usr/bin/env bash

set -euo pipefail

if ! [[ "$0" =~ scripts/tests.load.kind.sh ]]; then
echo "must be run from repository root"
exit 255
fi

# Start kind cluster
./scripts/start_kind_cluster.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest passing arguments as per the example of other kind-using scripts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: 387e4ef


# Build docker image for load test
DOCKERFILE="./tests/load/c/Dockerfile.loadtest"
DOCKER_IMAGE="localhost:5001/avalanchego"
SKIP_BUILD_RACE=1
DOCKERFILE="$DOCKERFILE" DOCKER_IMAGE="$DOCKER_IMAGE" SKIP_BUILD_RACE="$SKIP_BUILD_RACE" ./scripts/build_image.sh

# Construct pod manifest
source ./scripts/git_commit.sh

POD_MANIFEST=$(cat << EOF
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: load-test
namespace: tmpnet

---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: load-test
namespace: tmpnet
rules:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(No action required) How did you arrive at these permissions?

- apiGroups: ["apps"]
resources: ["statefulsets"]
verbs: ["create", "delete", "get", "list", "patch", "update", "watch"]
- apiGroups: ["apps"]
resources: ["statefulsets/scale"]
verbs: ["get", "patch", "update"]
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["services"]
verbs: ["create", "delete", "get", "list", "patch", "update", "watch"]

---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: load-test
namespace: tmpnet
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: load-test
subjects:
- kind: ServiceAccount
name: load-test
namespace: tmpnet

---
apiVersion: v1
kind: Pod
metadata:
name: load-test
namespace: tmpnet
spec:
serviceAccountName: load-test
containers:
- name: load-test
image: $DOCKER_IMAGE:$commit_hash
restartPolicy: Never
EOF
)

# Deploy pod to cluster
echo "$POD_MANIFEST" | kubectl apply --context kind-kind -f -
13 changes: 13 additions & 0 deletions tests/load/c/Dockerfile.loadtest
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# The version is supplied as a build argument rather than hard-coded
# to minimize the cost of version changes.
ARG GO_VERSION=INVALID # This value is not intended to be used but silences a warning

FROM --platform=$BUILDPLATFORM golang:$GO_VERSION-bookworm

WORKDIR /build

# Copy entire source into container
COPY . .

# Set default command
CMD go run ./tests/load/c/main --runtime=kube
4 changes: 4 additions & 0 deletions tests/load/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,9 @@ func (s *MetricsServer) GenerateMonitoringConfig(monitoringLabels map[string]str
return "", err
}

if err := os.MkdirAll(filepath.Dir(collectorFilePath), 0o755); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this addition might avoid an error, the fact that the path does not exist is a symptom of a larger problem: collection is not being configured in the pod. Given the requirement to label test workload metrics with network uuid, which isn't known at the time of pod deployment, I think deployment of local prometheus collector would be suggested so that tmpnet configure it. That would mean setting the collector credentials to the pod - easy enough - but also ensuring the availability of a compatible version of prometheus so that tmpnet could start it.

Maybe coordinate with Elvis to see what the timeline is for getting ARC online? Other than as a learning exercise, I'm less convinced of the wisdom of supporting pod-based workloads if it requires not just publishing an image and that image being complex to build. CI-launched tests won't need to publish images, and don't need extra work to support workload monitoring. Local iteration would likely be easier to support via enabling external access to nodes via a proxy instead of forwarding.

return "", err
}

return collectorFilePath, os.WriteFile(collectorFilePath, config, perms.ReadWrite)
}