Skip to content

Commit

Permalink
Run the latest dev consul version in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ishustava committed Apr 13, 2021
1 parent 86c0e00 commit 65883b7
Showing 1 changed file with 55 additions and 12 deletions.
67 changes: 55 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,49 @@ executors:
docker:
- image: docker.mirror.hashicorp.services/circleci/golang:1.14
environment:
TEST_RESULTS: /tmp/test-results # path to where test results are saved
CONSUL_VERSION: 1.9.4 # Consul's OSS version to use in tests
CONSUL_ENT_VERSION: 1.9.4+ent # Consul's enterprise version to use in tests
- TEST_RESULTS: /tmp/test-results # path to where test results are saved
- CONSUL_VERSION: 18decbba9d2ee1d95a740449ba26004c7a11cd77 # Consul's OSS version to use in tests
- CONSUL_ENT_VERSION: 2cd558a9e269d6875efc64be37ef5b1604a6b948 # Consul's enterprise version to use in tests

commands:
get-aws-cli:
steps:
- run:
name: download and install AWS CLI
command: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
echo -e "${AWS_CLI_GPG_KEY}" | gpg --import
curl -o awscliv2.sig https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip.sig
gpg --verify awscliv2.sig awscliv2.zip
unzip awscliv2.zip
sudo ./aws/install
aws-assume-role:
steps:
- run:
name: assume-role aws creds
command: |
# assume role has duration of 15 min (the minimum allowed)
CREDENTIALS="$(aws sts assume-role --duration-seconds 900 --role-arn ${ROLE_ARN} --role-session-name build-${CIRCLE_SHA1} | jq '.Credentials')"
echo "export AWS_ACCESS_KEY_ID=$(echo $CREDENTIALS | jq -r '.AccessKeyId')" >> $BASH_ENV
echo "export AWS_SECRET_ACCESS_KEY=$(echo $CREDENTIALS | jq -r '.SecretAccessKey')" >> $BASH_ENV
echo "export AWS_SESSION_TOKEN=$(echo $CREDENTIALS | jq -r '.SessionToken')" >> $BASH_ENV
install-dev-consul:
description: "Pull a dev version of consul/consul-enterprise for testing"
parameters:
bucket:
type: env_var_name
default: CONSUL_DEV_ARTIFACT_BUCKET # we use the same bucket for oss/ent dev builds (at different paths)
path:
type: env_var_name
sha:
type: env_var_name
steps:
- run:
name: download and install dev consul/consul-enterprise
command: |
aws s3 cp s3://${<< parameters.bucket >>}/${<< parameters.path >>}/${<< parameters.sha >>}.zip /tmp
sudo unzip /tmp/${<< parameters.sha >>}.zip -d /usr/local/bin
consul version
jobs:
go-fmt-and-vet:
Expand Down Expand Up @@ -60,13 +100,15 @@ jobs:
- restore_cache:
keys:
- consul-k8s-modcache-v1-{{ checksum "go.mod" }}
# pull a dev build of consul oss from s3
- get-aws-cli
- aws-assume-role
- install-dev-consul:
path: CONSUL_DEV_ARTIFACT_PATH
sha: CONSUL_VERSION

# run go tests with gotestsum
- run: |
# download and install the consul binary
wget https://releases.hashicorp.com/consul/"${CONSUL_VERSION}"/consul_"${CONSUL_VERSION}"_linux_amd64.zip && \
unzip consul_"${CONSUL_VERSION}"_linux_amd64.zip -d /home/circleci/bin &&
rm consul_"${CONSUL_VERSION}"_linux_amd64.zip
PACKAGE_NAMES=$(go list ./...)
gotestsum --junitfile $TEST_RESULTS/gotestsum-report.xml -- -p 4 $PACKAGE_NAMES
Expand All @@ -88,13 +130,14 @@ jobs:
- restore_cache:
keys:
- consul-k8s-modcache-v1-{{ checksum "go.mod" }}
# pull a dev build of consul ent from s3
- get-aws-cli
- aws-assume-role
- install-dev-consul:
path: CONSUL_ENT_DEV_ARTIFACT_PATH
sha: CONSUL_ENT_VERSION

# run go tests with gotestsum
- run: |
# download and install the consul binary
wget https://releases.hashicorp.com/consul/"${CONSUL_ENT_VERSION}"/consul_"${CONSUL_ENT_VERSION}"_linux_amd64.zip && \
unzip consul_"${CONSUL_ENT_VERSION}"_linux_amd64.zip -d /home/circleci/bin &&
rm consul_"${CONSUL_ENT_VERSION}"_linux_amd64.zip
- run: |
PACKAGE_NAMES=$(go list ./...)
gotestsum --junitfile $TEST_RESULTS/gotestsum-report.xml -- -tags=enterprise -p 4 $PACKAGE_NAMES
Expand Down

0 comments on commit 65883b7

Please sign in to comment.