-
Notifications
You must be signed in to change notification settings - Fork 784
feat: add task for in-cluster load test #4007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
f58ff3a
01248dc
62c0ec9
bb4b582
7f9bc71
ae297ad
4f63437
8c66465
387e4ef
d9fdb87
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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}} | ||
|
||
|
@@ -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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggest passing arguments as per the example of other kind-using scripts. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 - |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,5 +101,9 @@ func (s *MetricsServer) GenerateMonitoringConfig(monitoringLabels map[string]str | |
return "", err | ||
} | ||
|
||
if err := os.MkdirAll(filepath.Dir(collectorFilePath), 0o755); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
} |
Uh oh!
There was an error while loading. Please reload this page.