ci: add nightly load testing on master (#9693)

This commit is contained in:
Alvin Huang 2021-02-03 15:59:37 -05:00 committed by GitHub
parent c030c632a2
commit a0842ce955
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 30 additions and 9 deletions

View File

@ -909,45 +909,55 @@ jobs:
- run: - run:
name: setup TF_VARs name: setup TF_VARs
command: | command: |
short_ref=$(git rev-parse --short << pipeline.parameters.commit>>) # if pipeline.parameters.commit="" it was not triggered/set through the API
# so we use the latest commit from _this_ branch. This is the case for nightly tests.
if [ "<< pipeline.parameters.commit >>" = "" ]; then
LOCAL_COMMIT_SHA=$(git rev-parse HEAD)
else
LOCAL_COMMIT_SHA="<< pipeline.parameters.commit >>"
fi
echo "export LOCAL_COMMIT_SHA=${LOCAL_COMMIT_SHA}" >> $BASH_ENV
short_ref=$(git rev-parse --short ${LOCAL_COMMIT_SHA})
echo "export TF_VAR_ami_owners=$LOAD_TEST_AMI_OWNERS" >> $BASH_ENV echo "export TF_VAR_ami_owners=$LOAD_TEST_AMI_OWNERS" >> $BASH_ENV
echo "export TF_VAR_vpc_name=$short_ref" >> $BASH_ENV echo "export TF_VAR_vpc_name=$short_ref" >> $BASH_ENV
echo "export TF_VAR_cluster_name=$short_ref" >> $BASH_ENV echo "export TF_VAR_cluster_name=$short_ref" >> $BASH_ENV
echo "export TF_VAR_consul_download_url=https://${S3_ARTIFACT_BUCKET}.s3.${AWS_DEFAULT_REGION}.amazonaws.com/${S3_ARTIFACT_PATH}/<< pipeline.parameters.commit>>.zip" >> $BASH_ENV echo "export TF_VAR_consul_download_url=https://${S3_ARTIFACT_BUCKET}.s3.${AWS_DEFAULT_REGION}.amazonaws.com/${S3_ARTIFACT_PATH}/${LOCAL_COMMIT_SHA}.zip" >> $BASH_ENV
- run: - run:
name: wait for dev build from test-integrations workflow name: wait for dev build from test-integrations workflow
shell: /usr/bin/env bash -euo pipefail -c shell: /usr/bin/env bash -euo pipefail -c
command: | command: |
echo "curl-ing https://${S3_ARTIFACT_BUCKET}.s3.${AWS_DEFAULT_REGION}.amazonaws.com/${S3_ARTIFACT_PATH}/<< pipeline.parameters.commit>>.zip" echo "curl-ing https://${S3_ARTIFACT_BUCKET}.s3.${AWS_DEFAULT_REGION}.amazonaws.com/${S3_ARTIFACT_PATH}/${LOCAL_COMMIT_SHA}.zip"
until [ $SECONDS -ge 300 ] && exit 1; do until [ $SECONDS -ge 300 ] && exit 1; do
curl -o /dev/null --fail --silent "https://${S3_ARTIFACT_BUCKET}.s3.${AWS_DEFAULT_REGION}.amazonaws.com/${S3_ARTIFACT_PATH}/<< pipeline.parameters.commit>>.zip" && exit curl -o /dev/null --fail --silent "https://${S3_ARTIFACT_BUCKET}.s3.${AWS_DEFAULT_REGION}.amazonaws.com/${S3_ARTIFACT_PATH}/${LOCAL_COMMIT_SHA}.zip" && exit
echo -n "." echo -n "."
sleep 2 sleep 2
done done
- run: - run:
working_directory: .circleci/terraform/load-test working_directory: .circleci/terraform/load-test
name: terraform init name: terraform init
shell: /usr/bin/env bash -euo pipefail -c
command: | command: |
source $BASH_ENV echo "commit is ${LOCAL_COMMIT_SHA}"
echo "commit is << pipeline.parameters.commit >>"
terraform init \ terraform init \
-backend-config="bucket=${BUCKET}" \ -backend-config="bucket=${BUCKET}" \
-backend-config="key=<< pipeline.parameters.commit >>" \ -backend-config="key=${LOCAL_COMMIT_SHA}" \
-backend-config="region=${AWS_DEFAULT_REGION}" \ -backend-config="region=${AWS_DEFAULT_REGION}" \
-backend-config="role_arn=${ROLE_ARN_LOAD_TEST}" -backend-config="role_arn=${ROLE_ARN_LOAD_TEST}"
- run: - run:
working_directory: .circleci/terraform/load-test working_directory: .circleci/terraform/load-test
name: run terraform apply name: run terraform apply
shell: /usr/bin/env bash -euo pipefail -c
command: | command: |
source $BASH_ENV
terraform apply -auto-approve terraform apply -auto-approve
- run: - run:
working_directory: .circleci/terraform/load-test working_directory: .circleci/terraform/load-test
when: always when: always
name: terraform destroy name: terraform destroy
shell: /usr/bin/env bash -euo pipefail -c
command: | command: |
source $BASH_ENV
terraform destroy -auto-approve terraform destroy -auto-approve
- run: *notify-slack-failure
workflows: workflows:
version: 2 version: 2
@ -1111,3 +1121,14 @@ workflows:
when: << pipeline.parameters.trigger-load-test >> when: << pipeline.parameters.trigger-load-test >>
jobs: jobs:
- load-test - load-test
nightly-jobs:
triggers:
- schedule:
cron: "0 4 * * *" # 4AM UTC <> 12AM EST <> 9PM PST should have no impact
filters:
branches:
only:
- master
jobs:
- load-test