Browse Source

CTIA-16: add tags to load test resources and run test on PR commit (#13258)

- retry destroy terraform resources
pull/13200/head
cskh 3 years ago committed by GitHub
parent
commit
9e7e363627
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      .circleci/config.yml
  2. 9
      .circleci/terraform/load-test/main.tf
  3. 6
      .circleci/terraform/load-test/variables.tf
  4. 3
      test/load/terraform/variables.tf

6
.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

9
.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
}

6
.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"
}

3
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"
}

Loading…
Cancel
Save