Skip to content

Acceptance Tests (GKE) #463

Acceptance Tests (GKE)

Acceptance Tests (GKE) #463

name: Acceptance Tests (GKE)
on:
workflow_dispatch:
inputs:
region:
description: The GKE region
default: northamerica-northeast1
zone:
description: The GKE zone
default: northamerica-northeast1-a
clusterVersion:
description: The GKE cluster version
default: 1.27
nodeCount:
description: The number of cluster nodes to provision
default: 1
instanceType:
description: The type of GKE instance to use for cluster nodes
default: e2-standard-2
parallelRuns:
description: The maximum number of tests to run simultaneously
default: 8
runTests:
description: The regex passed to the -run option of `go test`
default: "^TestAcc"
terraformVersion:
description: Terraform version
default: 1.7.5
schedule:
- cron: '0 23 * * *'
env:
GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }}
GOOGLE_REGION: ${{ github.event.inputs.region || 'northamerica-northeast1' }}
GOOGLE_ZONE: ${{github.event.inputs.zone || 'northamerica-northeast1-a' }}
USE_GKE_GCLOUD_AUTH_PLUGIN: True
KUBE_CONFIG_PATH: ${{ github.workspace }}/kubernetes/test-infra/gke/kubeconfig
PARALLEL_RUNS: ${{ github.event.inputs.parallelRuns || '8' }}
TERRAFORM_VERSION: ${{ github.event.inputs.terraformVersion || '1.10.1' }}
TF_VAR_cluster_version: ${{ github.event.inputs.clusterVersion || '1.29' }}
TF_VAR_node_count: ${{ github.event.inputs.nodeCount || '1' }}
TF_VAR_instance_type: ${{ github.event.inputs.instanceType || 'e2-standard-2' }}
jobs:
acceptance_tests_gke:
if: ${{ github.repository_owner == 'hashicorp' }}
runs-on: custom-linux-medium
steps:
- name: Checkout repository
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Set up Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@55bd3a7c6e2ae7cf1877fd1ccb9d54c0503c457c # v2.1.2
with:
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}
access_token_lifetime: '14400s'
- name: Set up gcloud SDK
uses: google-github-actions/setup-gcloud@98ddc00a17442e89a24bbf282954a3b65ce6d200 # v2.1.0
with:
install_components: 'beta,gke-gcloud-auth-plugin'
- name: Initialize gcloud SDK
run: |
gcloud init
gcloud info
- name: Install Terraform
uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0
with:
terraform_version: ${{ env.TERRAFORM_VERSION }}
terraform_wrapper: false
- name: Provision GKE Cluster
working-directory: ${{ github.workspace }}/kubernetes/test-infra/gke
run: |
terraform init
terraform apply -auto-approve
- name: Run Acceptance Test Suite
env:
TESTARGS: -run ${{ github.event.inputs.runTests || '^TestAcc' }}
# Do not set TF_ACC_TERRAFORM_PATH or TF_ACC_TERRAFORM_VERSION.
# In this case, the framework will search for the Terraform CLI binary based on the operating system PATH.
# Eventually, it will use the one we set up.
# More information: https://developer.hashicorp.com/terraform/plugin/sdkv2/testing/acceptance-tests#terraform-cli-installation-behaviors
run: |
make testacc
make frameworkacc
- name: Destroy GKE cluster
if: always() # we should destroy the cluster even if the tests fail
working-directory: ${{ github.workspace }}/kubernetes/test-infra/gke
run: |
terraform destroy -auto-approve