Skip to content

Commit

Permalink
chore(load): update scripts to use artifact registry (#792)
Browse files Browse the repository at this point in the history
* update the load test scripts to use artifact registry instead of container registry
* update python dependencies

Closes: #SYNC-4199
  • Loading branch information
Trinaa authored Oct 31, 2024
1 parent 50ab4a0 commit d64178f
Show file tree
Hide file tree
Showing 9 changed files with 1,154 additions and 1,161 deletions.
2 changes: 1 addition & 1 deletion tests/integration/async_push_test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ async def send_notification(
log.debug(f" headers: {headers}")
async with httpx.AsyncClient() as httpx_client:
resp = await httpx_client.request(
method=method, url=url.geturl(), content=body, headers=headers
method=method, url=url.geturl(), content=body, headers=headers, timeout=30
)
log.debug(f"{method} Response ({resp.status_code}): {resp.text}")
assert resp.status_code == status, f"Expected {status}, got {resp.status_code}"
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/push_test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ def send_notification(
method: str = "POST"
log.debug(f"{method} body: {body}")
log.debug(f" headers: {headers}")
resp = httpx.request(method=method, url=url.geturl(), content=body, headers=headers)
resp = httpx.request(
method=method, url=url.geturl(), content=body, headers=headers, timeout=30
)
log.debug(f"{method} Response ({resp.status_code}): {resp.text}")
assert resp.status_code == status, f"Expected {status}, got {resp.status_code}"
self.notif_response = resp
Expand Down
4 changes: 2 additions & 2 deletions tests/load/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ functionality as SSH is not supported in this environment.
* To apply new changes to an existing GCP Cluster, execute the `setup_k8s.sh` file and
select the **setup** option.
* This option will consider the local commit history, creating new containers and
deploying them (see [Container Registry][16])
deploying them (see [Artifact Registry][16])

### Run Test Session

Expand Down Expand Up @@ -412,6 +412,6 @@ are set in step 1, the load test will stop automatically.
[13]: https://docs.locust.io/en/stable/writing-a-locustfile.html#wait-time
[14]: https://docs.locust.io/en/stable/writing-a-locustfile.html#task-decorator
[15]: https://console.cloud.google.com/home/dashboard?q=search&referrer=search&project=spheric-keel-331521&cloudshell=false
[16]: https://console.cloud.google.com/gcr/images/spheric-keel-331521/global/locust-autopush?project=spheric-keel-331521
[16]: https://console.cloud.google.com/artifacts/docker/spheric-keel-331521/us-central1/autopush?project=spheric-keel-331521
[17]: https://earthangel-b40313e5.influxcloud.net/d/do4mmwcVz/autopush-gcp?orgId=1&refresh=1m
[18]: https://console.cloud.google.com/kubernetes/list/overview?cloudshell=false&project=spheric-keel-331521
4 changes: 2 additions & 2 deletions tests/load/cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
steps:
- name: "gcr.io/cloud-builders/docker"
args: ["build", "-t", "gcr.io/$PROJECT_ID/locust-autopush:$TAG_NAME", "-f", "./tests/load/Dockerfile", "."]
images: ["gcr.io/$PROJECT_ID/locust-autopush:$TAG_NAME"]
args: ["build", "-t", "us-central1-docker.pkg.dev/$PROJECT_ID/autopush/locust-autopush:$TAG_NAME", "-f", "./tests/load/Dockerfile", "."]
images: ["us-central1-docker.pkg.dev/$PROJECT_ID/autopush/locust-autopush:$TAG_NAME"]
2 changes: 1 addition & 1 deletion tests/load/kubernetes-config/locust-master-controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
spec:
containers:
- name: locust-master
image: gcr.io/[PROJECT_ID]/locust-autopush:[LOCUST_IMAGE_TAG]
image: us-central1-docker.pkg.dev/[PROJECT_ID]/autopush/locust-autopush:[LOCUST_IMAGE_TAG]
env:
- name: LOCUST_MODE_MASTER
value: "true"
Expand Down
2 changes: 1 addition & 1 deletion tests/load/kubernetes-config/locust-worker-controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
node-pool: locust-workers
containers:
- name: locust-worker
image: gcr.io/[PROJECT_ID]/locust-autopush:[LOCUST_IMAGE_TAG]
image: us-central1-docker.pkg.dev/[PROJECT_ID]/autopush/locust-autopush:[LOCUST_IMAGE_TAG]
env:
- name: LOCUST_MODE_WORKER
value: "true"
Expand Down
10 changes: 6 additions & 4 deletions tests/load/setup_k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ GCLOUD=$(which gcloud)
SED=$(which sed)
KUBECTL=$(which kubectl)
GOOGLE_CLOUD_PROJECT=$(gcloud config get-value project)
REPOSITORY_ID='autopush'
IMAGE_NAME='locust-autopush'
CLUSTER='autopush-locust-load-test'
TARGET='https://updates-autopush.stage.mozaws.net'
SCOPE='https://www.googleapis.com/auth/cloud-platform'
Expand Down Expand Up @@ -65,10 +67,10 @@ SetupGksCluster()
$GCLOUD container clusters get-credentials $CLUSTER --region $REGION --project $GOOGLE_CLOUD_PROJECT

# Build Docker Images
echo -e "==================== Build the Docker image and store it in your project's container registry. Tag with the latest commit hash "
echo -e "==================== Build the Docker image and store it in your project's artifact registry. Tag with the latest commit hash "
$GCLOUD builds submit --config=./tests/load/cloudbuild.yaml --substitutions=TAG_NAME=$LOCUST_IMAGE_TAG
echo -e "==================== Verify that the Docker image is in your project's container repository"
$GCLOUD container images list | grep locust-autopush
echo -e "==================== Verify that the Docker image is in your project's artifact repository"
$GCLOUD artifacts docker tags list "$REGION-docker.pkg.dev/$GOOGLE_CLOUD_PROJECT/$REPOSITORY_ID/$IMAGE_NAME" | grep $LOCUST_IMAGE_TAG

# Deploying the Locust master and worker nodes
echo -e "==================== Update Kubernetes Manifests "
Expand All @@ -77,7 +79,7 @@ SetupGksCluster()
$SED -i -e "s|replicas:.*|replicas: $WORKER_COUNT|" $AUTOPUSH_DIRECTORY/$WORKER_FILE
for file in $MASTER_FILE $WORKER_FILE
do
$SED -i -e "s|image:.*|image: gcr.io/$GOOGLE_CLOUD_PROJECT/locust-autopush:$LOCUST_IMAGE_TAG|" $AUTOPUSH_DIRECTORY/$file
$SED -i -e "s|image:.*|image: $REGION-docker.pkg.dev/$GOOGLE_CLOUD_PROJECT/$REPOSITORY_ID/$IMAGE_NAME:$LOCUST_IMAGE_TAG|" "$AUTOPUSH_DIRECTORY/$file"
SetEnvironmentVariables $AUTOPUSH_DIRECTORY/$file
done

Expand Down
Loading

0 comments on commit d64178f

Please sign in to comment.