From 206c9910588ad5e18a5980a5a4762974e07a95c3 Mon Sep 17 00:00:00 2001 From: cskh Date: Fri, 27 May 2022 14:49:39 -0400 Subject: [PATCH] CTIA-16: add tags to load test resources and run test on PR commit (#13258) - retry destroy terraform resources --- .circleci/config.yml | 6 ++++-- .circleci/terraform/load-test/main.tf | 9 ++++++++- .circleci/terraform/load-test/variables.tf | 6 ++++++ test/load/terraform/variables.tf | 3 +-- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e301448a5..e337b1ab4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -983,6 +983,7 @@ jobs: LOCAL_COMMIT_SHA="<< pipeline.parameters.commit >>" fi echo "export LOCAL_COMMIT_SHA=${LOCAL_COMMIT_SHA}" >> $BASH_ENV + git checkout ${LOCAL_COMMIT_SHA} short_ref=$(git rev-parse --short ${LOCAL_COMMIT_SHA}) echo "export TF_VAR_ami_owners=$LOAD_TEST_AMI_OWNERS" >> $BASH_ENV @@ -1002,7 +1003,8 @@ jobs: working_directory: .circleci/terraform/load-test name: terraform init command: | - echo "commit is ${LOCAL_COMMIT_SHA}" + short_ref=$(git rev-parse --short HEAD) + echo "Testing commit id: $short_ref" terraform init \ -backend-config="bucket=${BUCKET}" \ -backend-config="key=${LOCAL_COMMIT_SHA}" \ @@ -1018,7 +1020,7 @@ jobs: when: always name: terraform destroy command: | - terraform destroy -auto-approve + for i in $(seq 1 5); do terraform destroy -auto-approve && s=0 && break || s=$? && sleep 20; done; (exit $s) - run: *notify-slack-failure # The noop job is a used as a very fast job in the verify-ci workflow because every workflow diff --git a/.circleci/terraform/load-test/main.tf b/.circleci/terraform/load-test/main.tf index 774e19c60..b46645ef2 100644 --- a/.circleci/terraform/load-test/main.tf +++ b/.circleci/terraform/load-test/main.tf @@ -7,10 +7,16 @@ provider "aws" { assume_role { role_arn = var.role_arn } + + default_tags { + tags = { + Environment = "ConsulLoadTest" + } + } } module "load-test" { - source = "github.com/hashicorp/consul/test/load/terraform" + source = "../../../test/load/terraform" vpc_az = ["us-east-2a", "us-east-2b"] vpc_name = var.vpc_name @@ -21,4 +27,5 @@ module "load-test" { ami_owners = var.ami_owners consul_download_url = var.consul_download_url cluster_name = var.cluster_name + cluster_tag_key = var.cluster_tag_key } diff --git a/.circleci/terraform/load-test/variables.tf b/.circleci/terraform/load-test/variables.tf index 9b3849e4e..414cfa84e 100644 --- a/.circleci/terraform/load-test/variables.tf +++ b/.circleci/terraform/load-test/variables.tf @@ -22,3 +22,9 @@ variable "cluster_name" { type = string default = "consul-example" } + +variable "cluster_tag_key" { + description = "The tag the EC2 Instances will look for to automatically discover each other and form a cluster." + type = string + default = "consul-ci-load-test" +} diff --git a/test/load/terraform/variables.tf b/test/load/terraform/variables.tf index 1691983d3..c7b1f71ea 100644 --- a/test/load/terraform/variables.tf +++ b/test/load/terraform/variables.tf @@ -106,6 +106,5 @@ variable "consul_download_url" { variable "consul_version" { type = string description = "Version of the Consul binary to install" - default = "1.9.0" + default = "1.12.0" } -