Skip to content

test-command

test-command #377

Workflow file for this run

name: Pull Request Test Handler
on:
repository_dispatch:
types:
- test-command
env:
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}
GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }}
GOOGLE_REGION: ${{ secrets.GOOGLE_REGION }}
GOOGLE_ZONE: ${{ secrets.GOOGLE_ZONE }}
jobs:
public_active_active:
name: Run tf-test on Public Active/Active
if: ${{ contains(github.event.client_payload.slash_command.args.unnamed.all, 'all') || contains(github.event.client_payload.slash_command.args.unnamed.all, 'public-active-active')}}
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
env:
WORK_DIR_PATH: ./tests/public-active-active
K6_WORK_DIR_PATH: ./tests/tfe-load-test
steps:
- name: Create URL to the run output
id: vars
run: echo ::set-output name=run-url::https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
- name: Checkout Pull Request Branch
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
with:
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
ref: ${{ github.event.client_payload.pull_request.head.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: false
- name: Set Terraform Module Source
working-directory: ${{ env.WORK_DIR_PATH }}
env:
LOGIN: ${{ github.event.client_payload.pull_request.head.repo.owner.login }}
NAME: ${{ github.event.client_payload.pull_request.head.repo.name }}
SHA: ${{ github.event.client_payload.pull_request.head.sha }}
run: |
sed --in-place "s/source = \"..\/..\"/source = \"github.com\/$LOGIN\/$NAME?ref=$SHA\"/" main.tf
sed --in-place "s/source = \"..\/..\/fixtures\/test_proxy\"/source = \"github.com\/$LOGIN\/$NAME\/\/fixtures\/test_proxy?ref=$SHA\"/" main.tf
- name: Checkout TFE Load Test
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
with:
path: ${{ env.K6_WORK_DIR_PATH }}
repository: hashicorp/tfe-load-test
token: ${{ secrets.GH_TFE_LOAD_TEST_TOKEN }}
persist-credentials: false
- name: Install required tools
working-directory: ${{ env.K6_WORK_DIR_PATH }}
env:
K6_URL: https://github.com/loadimpact/k6/releases/download/v0.31.1/k6-v0.31.1-linux64.tar.gz
run: |
sudo apt-get install jq
curl -L $K6_URL | tar -xz --strip-components=1
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
cli_config_credentials_hostname: 'app.terraform.io'
cli_config_credentials_token: ${{ secrets.PUBLIC_ACTIVE_ACTIVE_TFC_TOKEN }}
terraform_version: 1.1.7
terraform_wrapper: true
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@e30db14379863a8c79331b04a9969f4c1e225e0b # v1.1.1
- name: Terraform Init
id: init
working-directory: ${{ env.WORK_DIR_PATH }}
run: terraform init -input=false -no-color
- name: Write Terraform Variables
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
iact_subnet=$( dig +short @resolver1.opendns.com myip.opendns.com )
cat <<EOF > github.auto.tfvars
iact_subnet_list = ["$iact_subnet/32"]
consolidated_services_enabled = true
tfe = {
hostname = "${{ secrets.TFE_HOSTNAME }}"
organization = "${{ secrets.TFE_ORGANIZATION }}"
token = "${{ secrets.TFE_TOKEN }}"
workspace = "${{ secrets.TFE_WORKSPACE }}"
}
EOF
- name: Terraform Validate
id: validate
working-directory: ${{ env.WORK_DIR_PATH }}
run: terraform validate -no-color
- name: Terraform Apply
id: apply
working-directory: ${{ env.WORK_DIR_PATH }}
run: terraform apply -auto-approve -input=false -no-color
- name: Retrieve Health Check URL
id: retrieve-health-check-url
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
terraform output -no-color -raw health_check_url
- name: Wait For TFE
id: wait-for-tfe
timeout-minutes: 25
run: |
echo "Curling \`health_check_url\` for a return status of 200..."
while ! curl -sfS --max-time 5 "${{ steps.retrieve-health-check-url.outputs.stdout }}"; do sleep 5; done
- name: Retrieve TFE URL
id: retrieve-tfe-url
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
terraform output -no-color -raw tfe_url
- name: Retrieve IACT URL
id: retrieve-iact-url
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
terraform output -no-color -raw iact_url
- name: Retrieve IACT
id: retrieve-iact
run: |
token=$(curl --fail --retry 15 --verbose "${{ steps.retrieve-iact-url.outputs.stdout }}")
echo "::set-output name=token::$token"
- name: Retrieve Initial Admin User URL
id: retrieve-initial-admin-user-url
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
terraform output -no-color -raw initial_admin_user_url
- name: Create Admin in TFE
id: create-admin
env:
TFE_PASSWORD: ${{ secrets.TFE_PASSWORD }}
IAU_URL: ${{ steps.retrieve-initial-admin-user-url.outputs.stdout }}
IACT: ${{ steps.retrieve-iact.outputs.token }}
run: |
echo \
'{"username": "test", "email": "[email protected]", "password": "$TFE_PASSWORD"}' \
> ./payload.json
response=$( \
curl \
--fail \
--retry 15 \
--verbose \
--header 'Content-Type: application/json' \
--data @./payload.json \
"$IAU_URL"?token="$IACT")
echo "::set-output name=response::$response"
- name: Retrieve Admin Token
id: retrieve-admin-token
env:
RESPONSE: ${{ steps.create-admin.outputs.response }}
run: |
token=$(echo "$RESPONSE" | jq --raw-output '.token')
echo "::set-output name=token::$token"
- name: Run k6 Smoke Test
id: run-smoke-test
working-directory: ${{ env.K6_WORK_DIR_PATH }}
env:
K6_PATHNAME: "./k6"
TFE_URL: "${{ steps.retrieve-tfe-url.outputs.stdout }}"
TFE_API_TOKEN: "${{ steps.retrieve-admin-token.outputs.token }}"
TFE_EMAIL: [email protected]
run: |
make smoke-test
- name: Terraform Destroy
id: destroy
if: ${{ always() && github.event.client_payload.slash_command.args.named.destroy != 'false' }}
working-directory: ${{ env.WORK_DIR_PATH }}
env:
TFE_HOSTNAME: ${{ secrets.TFE_HOSTNAME }}
TFE_TOKEN: ${{ secrets.TFE_TOKEN }}
run: terraform destroy -auto-approve -input=false -no-color
- name: Update comment
if: ${{ always() }}
uses: peter-evans/create-or-update-comment@c6c9a1a66007646a28c153e2a8580a5bad27bcfa # v3.0.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
${{ format('### {0} Terraform Public Active/Active Test Report', job.status == 'success' && ':white_check_mark:' || ':x:') }}
${{ format(':link: [Action Summary Page]({0})', steps.vars.outputs.run-url) }}
${{ format('- {0} Terraform Init', steps.init.outcome == 'success' && ':white_check_mark:' || ':x:') }}
${{ format('- {0} Terraform Validate', steps.validate.outcome == 'success' && ':white_check_mark:' || ':x:') }}
${{ format('- {0} Terraform Apply', steps.apply.outcome == 'success' && ':white_check_mark:' || ':x:') }}
${{ format('- {0} Run k6 Smoke Test', steps.run-smoke-test.outcome == 'success' && ':white_check_mark:' || ':x:') }}
${{ github.event.client_payload.slash_command.args.named.destroy != 'false' && format('- {0} Terraform Destroy', steps.destroy.outcome == 'success' && ':white_check_mark:' || ':x:') || '' }}
private_active_active:
name: Run tf-test on Private Active/Active
if: ${{ contains(github.event.client_payload.slash_command.args.unnamed.all, 'all') || contains(github.event.client_payload.slash_command.args.unnamed.all, 'private-active-active') }}
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
env:
WORK_DIR_PATH: ./tests/private-active-active
K6_WORK_DIR_PATH: ./tests/tfe-load-test
steps:
- name: Create URL to the run output
id: vars
run: echo ::set-output name=run-url::https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
- name: Checkout Pull Request Branch
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
with:
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
ref: ${{ github.event.client_payload.pull_request.head.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: false
- name: Set Terraform Module Source
working-directory: ${{ env.WORK_DIR_PATH }}
env:
LOGIN: ${{ github.event.client_payload.pull_request.head.repo.owner.login }}
NAME: ${{ github.event.client_payload.pull_request.head.repo.name }}
SHA: ${{ github.event.client_payload.pull_request.head.sha }}
run: |
sed --in-place "s/source = \"..\/..\"/source = \"github.com\/$LOGIN\/$NAME?ref=$SHA\"/" main.tf
sed --in-place "s/source = \"..\/..\/fixtures\/test_proxy\"/source = \"github.com\/$LOGIN\/$NAME\/\/fixtures\/test_proxy?ref=$SHA\"/" main.tf
- name: Checkout TFE Load Test
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
with:
path: ${{ env.K6_WORK_DIR_PATH }}
repository: hashicorp/tfe-load-test
token: ${{ secrets.GH_TFE_LOAD_TEST_TOKEN }}
persist-credentials: false
- name: Install required tools
working-directory: ${{ env.K6_WORK_DIR_PATH }}
env:
K6_URL: https://github.com/loadimpact/k6/releases/download/v0.31.1/k6-v0.31.1-linux64.tar.gz
run: |
sudo apt-get install jq
curl -L $K6_URL | tar -xz --strip-components=1
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
cli_config_credentials_hostname: 'app.terraform.io'
cli_config_credentials_token: ${{ secrets.PRIVATE_ACTIVE_ACTIVE_TFC_TOKEN }}
terraform_version: 1.1.7
terraform_wrapper: true
- name: Authenticate to GCP
id: auth
uses: google-github-actions/auth@35b0e87d162680511bf346c299f71c9c5c379033 # v1.1.1
with:
credentials_json: ${{ secrets.GCP_TUNNELING_CREDENTIALS }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@e30db14379863a8c79331b04a9969f4c1e225e0b # v1.1.1
- name: Terraform Init
id: init
working-directory: ${{ env.WORK_DIR_PATH }}
run: terraform init -input=false -no-color
- name: Write Terraform Variables
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
cat <<EOF > github.auto.tfvars
iact_subnet_list = ["( dig +short @resolver1.opendns.com myip.opendns.com )/32"]
tfe = {
hostname = "${{ secrets.TFE_HOSTNAME }}"
organization = "${{ secrets.TFE_ORGANIZATION }}"
token = "${{ secrets.TFE_TOKEN }}"
workspace = "${{ secrets.TFE_WORKSPACE }}"
}
EOF
- name: Terraform Validate
id: validate
working-directory: ${{ env.WORK_DIR_PATH }}
run: terraform validate -no-color
- name: Terraform Apply
id: apply
working-directory: ${{ env.WORK_DIR_PATH }}
run: terraform apply -auto-approve -input=false -no-color
- name: Retrieve Health Check URL
id: retrieve-health-check-url
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
terraform output -no-color -raw health_check_url
- name: Retrieve Instance Name
id: retrieve-instance-name
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
terraform output -no-color -raw proxy_instance_name
- name: Retrieve Instance Zone
id: retrieve-instance-zone
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
terraform output -no-color -raw proxy_instance_zone
- name: Increasing the TCP Upload Bandwidth
id: increasing-the-tcp-upload-bandwidth-paa
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
$(gcloud info --format="value(basic.python_location)") -m pip install numpy
export CLOUDSDK_PYTHON_SITEPACKAGES=1
- name: Start SOCKS5 Proxy
env:
INSTANCE_NAME: ${{ steps.retrieve-instance-name.outputs.stdout }}
INSTANCE_ZONE: ${{ steps.retrieve-instance-zone.outputs.stdout }}
run: |
gcloud compute ssh \
--quiet \
--ssh-key-expire-after="1440m" \
--tunnel-through-iap \
--zone="$INSTANCE_ZONE" \
"$INSTANCE_NAME" \
-- -f -N -p 22 -D localhost:5000
- name: Wait For TFE
id: wait-for-tfe
timeout-minutes: 25
env:
HEALTH_CHECK_URL: ${{ steps.retrieve-health-check-url.outputs.stdout }}
run: |
echo "Curling \`health_check_url\` for a return status of 200..."
while ! curl \
-sfS --max-time 5 --proxy socks5://localhost:5000 \
$HEALTH_CHECK_URL; \
do sleep 5; done
- name: Retrieve TFE URL
id: retrieve-tfe-url
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
terraform output -no-color -raw tfe_url
- name: Retrieve IACT URL
id: retrieve-iact-url
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
terraform output -no-color -raw iact_url
- name: Retrieve IACT
id: retrieve-iact
run: |
token=$(curl --fail --retry 15 --verbose --proxy socks5://localhost:5000 "${{ steps.retrieve-iact-url.outputs.stdout }}")
echo "::set-output name=token::$token"
- name: Retrieve Initial Admin User URL
id: retrieve-initial-admin-user-url
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
terraform output -no-color -raw initial_admin_user_url
- name: Create Admin in TFE
id: create-admin
env:
TFE_PASSWORD: ${{ secrets.TFE_PASSWORD }}
IAU_URL: ${{ steps.retrieve-initial-admin-user-url.outputs.stdout }}
IACT_TOKEN: ${{ steps.retrieve-iact.outputs.token }}
run: |
echo \
'{"username": "test", "email": "[email protected]", "password": "$TFE_PASSWORD"}' \
> ./payload.json
response=$( \
curl \
--fail \
--retry 15 \
--verbose \
--header 'Content-Type: application/json' \
--data @./payload.json \
--proxy socks5://localhost:5000 \
"$IAU_URL"?token="$IACT_TOKEN")
echo "::set-output name=response::$response"
- name: Retrieve Admin Token
id: retrieve-admin-token
env:
RESPONSE: ${{ steps.create-admin.outputs.response }}
run: |
token=$(echo "$RESPONSE" | jq --raw-output '.token')
echo "::set-output name=token::$token"
- name: Run k6 Smoke Test
id: run-smoke-test
working-directory: ${{ env.K6_WORK_DIR_PATH }}
env:
K6_PATHNAME: "./k6"
TFE_URL: "${{ steps.retrieve-tfe-url.outputs.stdout }}"
TFE_API_TOKEN: "${{ steps.retrieve-admin-token.outputs.token }}"
TFE_EMAIL: [email protected]
http_proxy: socks5://localhost:5000/
https_proxy: socks5://localhost:5000/
run: |
make smoke-test
- name: Terraform Destroy
id: destroy
if: ${{ always() && github.event.client_payload.slash_command.args.named.destroy != 'false' }}
working-directory: ${{ env.WORK_DIR_PATH }}
run: terraform destroy -auto-approve -input=false -no-color
- name: Update comment
if: ${{ always() }}
uses: peter-evans/create-or-update-comment@c6c9a1a66007646a28c153e2a8580a5bad27bcfa # v3.0.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
${{ format('### {0} Terraform Private Active/Active Test Report', job.status == 'success' && ':white_check_mark:' || ':x:') }}
${{ format(':link: [Action Summary Page]({0})', steps.vars.outputs.run-url) }}
${{ format('- {0} Terraform Init', steps.init.outcome == 'success' && ':white_check_mark:' || ':x:') }}
${{ format('- {0} Terraform Validate', steps.validate.outcome == 'success' && ':white_check_mark:' || ':x:') }}
${{ format('- {0} Terraform Apply', steps.apply.outcome == 'success' && ':white_check_mark:' || ':x:') }}
${{ format('- {0} Run k6 Smoke Test', steps.run-smoke-test.outcome == 'success' && ':white_check_mark:' || ':x:') }}
${{ github.event.client_payload.slash_command.args.named.destroy != 'false' && format('- {0} Terraform Destroy', steps.destroy.outcome == 'success' && ':white_check_mark:' || ':x:') || '' }}
private_tcp_active_active:
name: Run tf-test on Private TCP Active/Active
if: ${{ contains(github.event.client_payload.slash_command.args.unnamed.all, 'all') || contains(github.event.client_payload.slash_command.args.unnamed.all, 'private-tcp-active-active') }}
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
env:
WORK_DIR_PATH: ./tests/private-tcp-active-active
K6_WORK_DIR_PATH: ./tests/tfe-load-test
steps:
- name: Create URL to the run output
id: vars
run: echo ::set-output name=run-url::https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
- name: Checkout Pull Request Branch
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
with:
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
ref: ${{ github.event.client_payload.pull_request.head.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: false
- name: Set Terraform Module Source
working-directory: ${{ env.WORK_DIR_PATH }}
env:
LOGIN: ${{ github.event.client_payload.pull_request.head.repo.owner.login }}
NAME: ${{ github.event.client_payload.pull_request.head.repo.name }}
SHA: ${{ github.event.client_payload.pull_request.head.sha }}
run: |
sed --in-place "s/source = \"..\/..\"/source = \"github.com\/$LOGIN\/$NAME?ref=$SHA\"/" main.tf
sed --in-place "s/source = \"..\/..\/fixtures\/test_proxy\"/source = \"github.com\/$LOGIN\/$NAME\/\/fixtures\/test_proxy?ref=$SHA\"/" main.tf
- name: Checkout TFE Load Test
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
with:
path: ${{ env.K6_WORK_DIR_PATH }}
repository: hashicorp/tfe-load-test
token: ${{ secrets.GH_TFE_LOAD_TEST_TOKEN }}
persist-credentials: false
- name: Install required tools
working-directory: ${{ env.K6_WORK_DIR_PATH }}
env:
K6_URL: https://github.com/loadimpact/k6/releases/download/v0.31.1/k6-v0.31.1-linux64.tar.gz
run: |
sudo apt-get install jq
curl -L $K6_URL | tar -xz --strip-components=1
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
cli_config_credentials_hostname: 'app.terraform.io'
cli_config_credentials_token: ${{ secrets.PRIVATE_TCP_ACTIVE_ACTIVE_TFC_TOKEN }}
terraform_version: 1.1.7
terraform_wrapper: true
- name: Authenticate to GCP
id: auth
uses: google-github-actions/auth@35b0e87d162680511bf346c299f71c9c5c379033 # v1.1.1
with:
credentials_json: ${{ secrets.GCP_TUNNELING_CREDENTIALS }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@e30db14379863a8c79331b04a9969f4c1e225e0b # v1.1.1
- name: Terraform Init
id: init
working-directory: ${{ env.WORK_DIR_PATH }}
run: terraform init -input=false -no-color
- name: Write Terraform Variables
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
iact_subnet=$( dig +short @resolver1.opendns.com myip.opendns.com )
cat <<EOF > github.auto.tfvars
iact_subnet_list = ["$iact_subnet/32"]
consolidated_services_enabled = true
tfe = {
hostname = "${{ secrets.TFE_HOSTNAME }}"
organization = "${{ secrets.TFE_ORGANIZATION }}"
token = "${{ secrets.TFE_TOKEN }}"
workspace = "${{ secrets.TFE_WORKSPACE }}"
}
EOF
- name: Terraform Validate
id: validate
working-directory: ${{ env.WORK_DIR_PATH }}
run: terraform validate -no-color
- name: Terraform Apply
id: apply
working-directory: ${{ env.WORK_DIR_PATH }}
run: terraform apply -auto-approve -input=false -no-color
- name: Retrieve Health Check URL
id: retrieve-health-check-url
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
terraform output -no-color -raw health_check_url
- name: Retrieve Instance Name
id: retrieve-instance-name
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
terraform output -no-color -raw proxy_instance_name
- name: Retrieve Instance Zone
id: retrieve-instance-zone
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
terraform output -no-color -raw proxy_instance_zone
- name: Increasing the TCP Upload Bandwidth
id: increasing-the-tcp-upload-bandwidth-ptaa
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
$(gcloud info --format="value(basic.python_location)") -m pip install numpy
export CLOUDSDK_PYTHON_SITEPACKAGES=1
- name: Start SOCKS5 Proxy
env:
INSTANCE_NAME: ${{ steps.retrieve-instance-name.outputs.stdout }}
INSTANCE_ZONE: ${{ steps.retrieve-instance-zone.outputs.stdout }}
run: |
gcloud compute ssh \
--quiet \
--ssh-key-expire-after="1440m" \
--tunnel-through-iap \
--zone="$INSTANCE_ZONE" \
"$INSTANCE_NAME" \
-- \
-o 'ServerAliveInterval 5' \
-o 'ServerAliveCountMax 3' \
-f -N -p 22 -D localhost:5000
- name: Wait For TFE
id: wait-for-tfe
timeout-minutes: 25
env:
HEALTH_CHECK_URL: ${{ steps.retrieve-health-check-url.outputs.stdout }}
run: |
echo "Curling \`health_check_url\` for a return status of 200..."
while ! curl \
-sfS --max-time 5 --proxy socks5://localhost:5000 \
$HEALTH_CHECK_URL; \
do sleep 5; done
- name: Retrieve TFE URL
id: retrieve-tfe-url
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
terraform output -no-color -raw tfe_url
- name: Retrieve IACT URL
id: retrieve-iact-url
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
terraform output -no-color -raw iact_url
- name: Retrieve IACT
id: retrieve-iact
run: |
token=$(curl --fail --retry 15 --verbose --proxy socks5://localhost:5000 "${{ steps.retrieve-iact-url.outputs.stdout }}")
echo "::set-output name=token::$token"
- name: Retrieve Initial Admin User URL
id: retrieve-initial-admin-user-url
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
terraform output -no-color -raw initial_admin_user_url
- name: Create Admin in TFE
id: create-admin
env:
TFE_PASSWORD: ${{ secrets.TFE_PASSWORD }}
IAU_URL: ${{ steps.retrieve-initial-admin-user-url.outputs.stdout }}
IACT_TOKEN: ${{ steps.retrieve-iact.outputs.token }}
run: |
echo \
'{"username": "test", "email": "[email protected]", "password": "$TFE_PASSWORD"}' \
> ./payload.json
response=$( \
curl \
--fail \
--retry 5 \
--verbose \
--header 'Content-Type: application/json' \
--data @./payload.json \
--proxy socks5://localhost:5000 \
"$IAU_URL"?token="$IACT_TOKEN")
echo "::set-output name=response::$response"
- name: Retrieve Admin Token
id: retrieve-admin-token
env:
RESPONSE: ${{ steps.create-admin.outputs.response }}
run: |
token=$(echo "$RESPONSE" | jq --raw-output '.token')
echo "::set-output name=token::$token"
- name: Run k6 Smoke Test
id: run-smoke-test
working-directory: ${{ env.K6_WORK_DIR_PATH }}
env:
K6_PATHNAME: "./k6"
TFE_URL: "${{ steps.retrieve-tfe-url.outputs.stdout }}"
TFE_API_TOKEN: "${{ steps.retrieve-admin-token.outputs.token }}"
TFE_EMAIL: [email protected]
http_proxy: socks5://localhost:5000/
https_proxy: socks5://localhost:5000/
run: |
make smoke-test
- name: Terraform Destroy
id: destroy
if: ${{ always() && github.event.client_payload.slash_command.args.named.destroy != 'false' }}
working-directory: ${{ env.WORK_DIR_PATH }}
run: terraform destroy -auto-approve -input=false -no-color
- name: Update comment
if: ${{ always() }}
uses: peter-evans/create-or-update-comment@c6c9a1a66007646a28c153e2a8580a5bad27bcfa # v3.0.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
${{ format('### {0} Terraform Private TCP Active/Active Test Report', job.status == 'success' && ':white_check_mark:' || ':x:') }}
${{ format(':link: [Action Summary Page]({0})', steps.vars.outputs.run-url) }}
${{ format('- {0} Terraform Init', steps.init.outcome == 'success' && ':white_check_mark:' || ':x:') }}
${{ format('- {0} Terraform Validate', steps.validate.outcome == 'success' && ':white_check_mark:' || ':x:') }}
${{ format('- {0} Terraform Apply', steps.apply.outcome == 'success' && ':white_check_mark:' || ':x:') }}
${{ format('- {0} Run k6 Smoke Test', steps.run-smoke-test.outcome == 'success' && ':white_check_mark:' || ':x:') }}
${{ github.event.client_payload.slash_command.args.named.destroy != 'false' && format('- {0} Terraform Destroy', steps.destroy.outcome == 'success' && ':white_check_mark:' || ':x:') || '' }}
standalone-mounted-disk:
name: Run tf-test on Standalone Mounted Disk
if: ${{ contains(github.event.client_payload.slash_command.args.unnamed.all, 'all') || contains(github.event.client_payload.slash_command.args.unnamed.all, 'standalone-mounted-disk') }}
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
env:
WORK_DIR_PATH: ./tests/standalone-mounted-disk
K6_WORK_DIR_PATH: ./tests/tfe-load-test
steps:
- name: Create URL to the run output
id: vars
run: echo ::set-output name=run-url::https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
- name: Checkout Pull Request Branch
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
with:
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
ref: ${{ github.event.client_payload.pull_request.head.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: false
- name: Set Terraform Module Source
working-directory: ${{ env.WORK_DIR_PATH }}
env:
LOGIN: ${{ github.event.client_payload.pull_request.head.repo.owner.login }}
NAME: ${{ github.event.client_payload.pull_request.head.repo.name }}
SHA: ${{ github.event.client_payload.pull_request.head.sha }}
run: |
sed --in-place "s/source = \"..\/..\"/source = \"github.com\/$LOGIN\/$NAME?ref=$SHA\"/" main.tf
sed --in-place "s/source = \"..\/..\/fixtures\/test_proxy\"/source = \"github.com\/$LOGIN\/$NAME\/\/fixtures\/test_proxy?ref=$SHA\"/" main.tf
- name: Create Terraform Backend to google-standalone-mounted-disk TFC Workspace
working-directory: ${{ env.WORK_DIR_PATH }}
env:
TFC_ORGANIZATION: ${{ secrets.TFC_ORGANIZATION }}
run: |
cat <<EOF > backend.tf
terraform {
backend "remote" {
organization = "$TFC_ORGANIZATION"
workspaces {
name = "google-standalone-mounted-disk"
}
}
}
EOF
- name: Checkout TFE Load Test
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
with:
path: ${{ env.K6_WORK_DIR_PATH }}
repository: hashicorp/tfe-load-test
token: ${{ secrets.GH_TFE_LOAD_TEST_TOKEN }}
persist-credentials: false
- name: Install required tools
working-directory: ${{ env.K6_WORK_DIR_PATH }}
env:
K6_URL: https://github.com/loadimpact/k6/releases/download/v0.31.1/k6-v0.31.1-linux64.tar.gz
run: |
sudo apt-get install jq
curl -L $K6_URL | tar -xz --strip-components=1
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
cli_config_credentials_hostname: 'app.terraform.io'
cli_config_credentials_token: ${{ secrets.STANDALONE_MOUNTED_DISK_TFC_TOKEN }}
terraform_version: 1.1.7
terraform_wrapper: true
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@e30db14379863a8c79331b04a9969f4c1e225e0b # v1.1.1
- name: Terraform Init
id: init
working-directory: ${{ env.WORK_DIR_PATH }}
run: terraform init -input=false -no-color
- name: Write Terraform Variables
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
iact_subnet=$( dig +short @resolver1.opendns.com myip.opendns.com )
cat <<EOF > github.auto.tfvars
iact_subnet_list = ["$iact_subnet/32"]
consolidated_services_enabled = true
tfe = {
hostname = "${{ secrets.TFE_HOSTNAME }}"
organization = "${{ secrets.TFE_ORGANIZATION }}"
token = "${{ secrets.TFE_TOKEN }}"
workspace = "${{ secrets.TFE_WORKSPACE }}"
}
EOF
- name: Terraform Validate
id: validate
working-directory: ${{ env.WORK_DIR_PATH }}
run: terraform validate -no-color
- name: Terraform Apply
id: apply
working-directory: ${{ env.WORK_DIR_PATH }}
run: terraform apply -auto-approve -input=false -no-color
- name: Retrieve Health Check URL
id: retrieve-health-check-url
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
terraform output -no-color -raw health_check_url
- name: Wait For TFE
id: wait-for-tfe
timeout-minutes: 25
run: |
echo "Curling \`health_check_url\` for a return status of 200..."
while ! curl -sfS --max-time 5 "${{ steps.retrieve-health-check-url.outputs.stdout }}"; do sleep 5; done
- name: Retrieve TFE URL
id: retrieve-tfe-url
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
terraform output -no-color -raw tfe_url
- name: Retrieve IACT URL
id: retrieve-iact-url
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
terraform output -no-color -raw iact_url
- name: Retrieve IACT
id: retrieve-iact
run: |
token=$(curl --fail --retry 15 --verbose "${{ steps.retrieve-iact-url.outputs.stdout }}")
echo "::set-output name=token::$token"
- name: Retrieve Initial Admin User URL
id: retrieve-initial-admin-user-url
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
terraform output -no-color -raw initial_admin_user_url
- name: Create Admin in TFE
id: create-admin
env:
TFE_PASSWORD: ${{ secrets.TFE_PASSWORD }}
IAU_URL: ${{ steps.retrieve-initial-admin-user-url.outputs.stdout }}
IACT: ${{ steps.retrieve-iact.outputs.token }}
run: |
echo \
'{"username": "test", "email": "[email protected]", "password": "$TFE_PASSWORD"}' \
> ./payload.json
response=$( \
curl \
--fail \
--retry 15 \
--verbose \
--header 'Content-Type: application/json' \
--data @./payload.json \
"$IAU_URL"?token="$IACT")
echo "::set-output name=response::$response"
- name: Retrieve Admin Token
id: retrieve-admin-token
env:
RESPONSE: ${{ steps.create-admin.outputs.response }}
run: |
token=$(echo "$RESPONSE" | jq --raw-output '.token')
echo "::set-output name=token::$token"
- name: Run k6 Smoke Test
id: run-smoke-test
working-directory: ${{ env.K6_WORK_DIR_PATH }}
env:
K6_PATHNAME: "./k6"
TFE_URL: "${{ steps.retrieve-tfe-url.outputs.stdout }}"
TFE_API_TOKEN: "${{ steps.retrieve-admin-token.outputs.token }}"
TFE_EMAIL: [email protected]
run: |
make smoke-test
- name: Terraform Destroy
id: destroy
if: ${{ always() && github.event.client_payload.slash_command.args.named.destroy != 'false' }}
working-directory: ${{ env.WORK_DIR_PATH }}
env:
TFE_HOSTNAME: ${{ secrets.TFE_HOSTNAME }}
TFE_TOKEN: ${{ secrets.TFE_TOKEN }}
run: terraform destroy -auto-approve -input=false -no-color
- name: Update comment
if: ${{ always() }}
uses: peter-evans/create-or-update-comment@c6c9a1a66007646a28c153e2a8580a5bad27bcfa # v3.0.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
${{ format('### {0} Terraform Standalone Mounted Disk Test Report', job.status == 'success' && ':white_check_mark:' || ':x:') }}
${{ format(':link: [Action Summary Page]({0})', steps.vars.outputs.run-url) }}
${{ format('- {0} Terraform Init', steps.init.outcome == 'success' && ':white_check_mark:' || ':x:') }}
${{ format('- {0} Terraform Validate', steps.validate.outcome == 'success' && ':white_check_mark:' || ':x:') }}
${{ format('- {0} Terraform Apply', steps.apply.outcome == 'success' && ':white_check_mark:' || ':x:') }}
${{ format('- {0} Run k6 Smoke Test', steps.run-smoke-test.outcome == 'success' && ':white_check_mark:' || ':x:') }}
${{ github.event.client_payload.slash_command.args.named.destroy != 'false' && format('- {0} Terraform Destroy', steps.destroy.outcome == 'success' && ':white_check_mark:' || ':x:') || '' }}
standalone-external-rhel8-worker:
name: Run tf-test on Standalone External RHEL8 Worker
if: ${{ contains(github.event.client_payload.slash_command.args.unnamed.all, 'all') || contains(github.event.client_payload.slash_command.args.unnamed.all, 'standalone-external-rhel8-worker') }}
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
env:
WORK_DIR_PATH: ./tests/standalone-external-rhel8-worker
K6_WORK_DIR_PATH: ./tests/tfe-load-test
steps:
- name: Create URL to the run output
id: vars
run: echo ::set-output name=run-url::https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
- name: Checkout Pull Request Branch
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
with:
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
ref: ${{ github.event.client_payload.pull_request.head.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: false
- name: Set Terraform Module Source
working-directory: ${{ env.WORK_DIR_PATH }}
env:
LOGIN: ${{ github.event.client_payload.pull_request.head.repo.owner.login }}
NAME: ${{ github.event.client_payload.pull_request.head.repo.name }}
SHA: ${{ github.event.client_payload.pull_request.head.sha }}
run: |
sed --in-place "s/source = \"..\/..\"/source = \"github.com\/$LOGIN\/$NAME?ref=$SHA\"/" main.tf
sed --in-place "s/source = \"..\/..\/fixtures\/test_proxy\"/source = \"github.com\/$LOGIN\/$NAME\/\/fixtures\/test_proxy?ref=$SHA\"/" main.tf
- name: Create Terraform Backend to google-standalone-external-rhel8-worker TFC Workspace
working-directory: ${{ env.WORK_DIR_PATH }}
env:
TFC_ORGANIZATION: ${{ secrets.TFC_ORGANIZATION }}
run: |
cat <<EOF > backend.tf
terraform {
backend "remote" {
organization = "$TFC_ORGANIZATION"
workspaces {
name = "google-standalone-external-rhel8-worker"
}
}
}
EOF
- name: Checkout TFE Load Test
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
with:
path: ${{ env.K6_WORK_DIR_PATH }}
repository: hashicorp/tfe-load-test
token: ${{ secrets.GH_TFE_LOAD_TEST_TOKEN }}
persist-credentials: false
- name: Install required tools
working-directory: ${{ env.K6_WORK_DIR_PATH }}
env:
K6_URL: https://github.com/loadimpact/k6/releases/download/v0.31.1/k6-v0.31.1-linux64.tar.gz
run: |
sudo apt-get install jq
curl -L $K6_URL | tar -xz --strip-components=1
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
cli_config_credentials_hostname: 'app.terraform.io'
cli_config_credentials_token: ${{ secrets.STANDALONE_EXTERNAL_RHEL8_WORKER_TFC_TOKEN }}
terraform_version: 1.1.7
terraform_wrapper: true
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@e30db14379863a8c79331b04a9969f4c1e225e0b # v1.1.1
- name: Terraform Init
id: init
working-directory: ${{ env.WORK_DIR_PATH }}
run: terraform init -input=false -no-color
- name: Write Terraform Variables
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
iact_subnet=$( dig +short @resolver1.opendns.com myip.opendns.com )
cat <<EOF > github.auto.tfvars
iact_subnet_list = ["$iact_subnet/32"]
consolidated_services_enabled = true
tfe = {
hostname = "${{ secrets.TFE_HOSTNAME }}"
organization = "${{ secrets.TFE_ORGANIZATION }}"
token = "${{ secrets.TFE_TOKEN }}"
workspace = "${{ secrets.TFE_WORKSPACE }}"
}
EOF
- name: Terraform Validate
id: validate
working-directory: ${{ env.WORK_DIR_PATH }}
run: terraform validate -no-color
- name: Terraform Apply
id: apply
working-directory: ${{ env.WORK_DIR_PATH }}
run: terraform apply -auto-approve -input=false -no-color
- name: Retrieve Health Check URL
id: retrieve-health-check-url
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
terraform output -no-color -raw health_check_url
- name: Wait For TFE
id: wait-for-tfe
timeout-minutes: 25
run: |
echo "Curling \`health_check_url\` for a return status of 200..."
while ! curl -sfS --max-time 5 "${{ steps.retrieve-health-check-url.outputs.stdout }}"; do sleep 5; done
- name: Retrieve TFE URL
id: retrieve-tfe-url
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
terraform output -no-color -raw tfe_url
- name: Retrieve IACT URL
id: retrieve-iact-url
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
terraform output -no-color -raw iact_url
- name: Retrieve IACT
id: retrieve-iact
run: |
token=$(curl --fail --retry 15 --verbose "${{ steps.retrieve-iact-url.outputs.stdout }}")
echo "::set-output name=token::$token"
- name: Retrieve Initial Admin User URL
id: retrieve-initial-admin-user-url
working-directory: ${{ env.WORK_DIR_PATH }}
run: |
terraform output -no-color -raw initial_admin_user_url
- name: Create Admin in TFE
id: create-admin
env:
TFE_PASSWORD: ${{ secrets.TFE_PASSWORD }}
IAU_URL: ${{ steps.retrieve-initial-admin-user-url.outputs.stdout }}
IACT: ${{ steps.retrieve-iact.outputs.token }}
run: |
echo \
'{"username": "test", "email": "[email protected]", "password": "$TFE_PASSWORD"}' \
> ./payload.json
response=$( \
curl \
--fail \
--retry 15 \
--verbose \
--header 'Content-Type: application/json' \
--data @./payload.json \
"$IAU_URL"?token="$IACT")
echo "::set-output name=response::$response"
- name: Retrieve Admin Token
id: retrieve-admin-token
env:
RESPONSE: ${{ steps.create-admin.outputs.response }}
run: |
token=$(echo "$RESPONSE" | jq --raw-output '.token')
echo "::set-output name=token::$token"
- name: Run k6 Smoke Test
id: run-smoke-test
working-directory: ${{ env.K6_WORK_DIR_PATH }}
env:
K6_PATHNAME: "./k6"
TFE_URL: "${{ steps.retrieve-tfe-url.outputs.stdout }}"
TFE_API_TOKEN: "${{ steps.retrieve-admin-token.outputs.token }}"
TFE_EMAIL: [email protected]
run: |
make smoke-test
- name: Terraform Destroy
id: destroy
if: ${{ always() && github.event.client_payload.slash_command.args.named.destroy != 'false' }}
working-directory: ${{ env.WORK_DIR_PATH }}
env:
TFE_HOSTNAME: ${{ secrets.TFE_HOSTNAME }}
TFE_TOKEN: ${{ secrets.TFE_TOKEN }}
run: terraform destroy -auto-approve -input=false -no-color
- name: Update comment
if: ${{ always() }}
uses: peter-evans/create-or-update-comment@c6c9a1a66007646a28c153e2a8580a5bad27bcfa # v3.0.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
${{ format('### {0} Terraform Standalone External RHEL8 Worker Test Report', job.status == 'success' && ':white_check_mark:' || ':x:') }}
${{ format(':link: [Action Summary Page]({0})', steps.vars.outputs.run-url) }}
${{ format('- {0} Terraform Init', steps.init.outcome == 'success' && ':white_check_mark:' || ':x:') }}
${{ format('- {0} Terraform Validate', steps.validate.outcome == 'success' && ':white_check_mark:' || ':x:') }}
${{ format('- {0} Terraform Apply', steps.apply.outcome == 'success' && ':white_check_mark:' || ':x:') }}
${{ format('- {0} Run k6 Smoke Test', steps.run-smoke-test.outcome == 'success' && ':white_check_mark:' || ':x:') }}
${{ github.event.client_payload.slash_command.args.named.destroy != 'false' && format('- {0} Terraform Destroy', steps.destroy.outcome == 'success' && ':white_check_mark:' || ':x:') || '' }}