Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HCPCP-1982 Acceptance Test Partitions #1149

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d61e2d3
HCPCP-1982 Initial test to isolate platform acceptance tests
jasonpilz Dec 10, 2024
96f043c
HCPCP-1982 Remove parallel input for now as this doesn't work cleanly…
jasonpilz Dec 10, 2024
599b96b
HCPCP-1982 Install deps and upload coverage
jasonpilz Dec 10, 2024
a44f17c
HCPCP-1928 Update repository checkout
jasonpilz Dec 10, 2024
5b13e0a
HCPCP-1928 Update test regex for platform
jasonpilz Dec 10, 2024
8ed62b0
HCPCP-1928 Update path to be relative to test package
jasonpilz Dec 10, 2024
420a6a4
HCPCP-1982 Add t.Parallel to sample platform networking tests
jasonpilz Dec 10, 2024
daeea8c
HCPCP-1928 Change platform resource unique name identifier
jasonpilz Dec 10, 2024
0540003
HCPCP-1982 HVN: Aws and Azure use different names
jasonpilz Dec 10, 2024
d659e13
HCPCP-1928 Add Acceptance test action for Vault dedicated
jasonpilz Dec 11, 2024
63c19fd
HCPCP-1928 Update Vault dedicated test names and add t.Parallel()
jasonpilz Dec 11, 2024
067d40a
HCPCP-1928 Spelling adjustment
jasonpilz Dec 11, 2024
ca962d9
HCPCP-1928 Vault: Remove duplicate parallel test
jasonpilz Dec 11, 2024
7c0cbe8
HCPCP-1928 Stylecheck adjustment
jasonpilz Dec 11, 2024
3aaf4b3
HCPCP-1928 Vault & Platform: Add concurreny group to github action fo…
jasonpilz Dec 11, 2024
2affe4d
HCPCP-1928 Update Vault testacc to use unique hvn names
jasonpilz Dec 11, 2024
316362c
Merge branch 'main' of github.com:hashicorp/terraform-provider-hcp in…
jasonpilz Dec 11, 2024
a907364
HCPCP-1928 Add github action to act as orchestrator for all acceptanc…
jasonpilz Dec 11, 2024
d814b46
HCPCP-1928 Update prerelease workflow to use separate unit and accept…
jasonpilz Dec 11, 2024
509487a
HCPCP-1928 Run testacc wf on feature branch so it shows up in UI
jasonpilz Dec 13, 2024
00d23f8
HCPCP-1928 Add event trigger for push on testacc for feature branch
jasonpilz Dec 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions .github/workflows/_testacc_platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: TestAcc Platform

on:
workflow_call:
workflow_dispatch:
pull_request:
# Networking resources still use SDKv2 so we have to target files manually until migrated
paths:
- 'internal/clients/hvn.go'
- 'internal/clients/hvn_route.go'
- 'internal/clients/tgw.go'
- 'internal/clients/peering.go'
- 'internal/providersdkv2/peering*'
- 'internal/providersdkv2/resource_aws_network_peering*'
- 'internal/providersdkv2/resource_azure_peering*'
- 'internal/providersdkv2/resource_aws_transit_gateway_attachment*'
- 'internal/providersdkv2/resource_hvn*'

# This prevents more than one run of this workflow from executing at a time.
# Up to 1 additional run will be queued, with anything futher being cancelled from the queue.
concurrency:
group: testacc-platform
cancel-in-progress: false

jobs:
acceptance_tests:
name: Acceptance Tests
runs-on: ubuntu-latest
# environment: testacc-platform
steps:
- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
token: ${{ secrets.HCP_SDK_PIPELINE_TOKEN }}

- name: Set up Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
cache: true
go-version-file: 'go.mod'
cache-dependency-path: go.sum
id: go

- name: Install Dependencies
env:
GOPRIVATE: 'github.com/hashicorp/*'
run: |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.3
go mod tidy
sudo wget https://github.com/jmespath/jp/releases/latest/download/jp-linux-amd64 -O /usr/local/bin/jp
sudo chmod +x /usr/local/bin/jp

- name: Run 'go mod tidy'
run: |
make depscheck

- name: Get dependencies
run: |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.3
go mod download

- name: Go Build
run: |
go build -v .

- name: Run TestAcc
env:
TF_ACC: 1
HCP_API_HOST: ${{ secrets.HCP_API_HOST }}
HCP_AUTH_URL: ${{ secrets.HCP_AUTH_URL }}
HCP_CLIENT_ID: ${{ secrets.HCP_CLIENT_ID }}
HCP_CLIENT_SECRET: ${{ secrets.HCP_CLIENT_SECRET }}
HCP_ORGANIZATION_ID: ${{ secrets.HCP_ORGANIZATION_ID }}
HCP_PROJECT_ID: ${{ secrets.HCP_PROJECT_ID }}
AWS_REGION: us-west-1
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
AZURE_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
run: |
AWS_OUTPUT=$(aws sts assume-role --role-arn $AWS_ROLE_ARN --role-session-name e2e-test --duration-seconds 43200)

export AWS_ACCESS_KEY_ID=$(echo $AWS_OUTPUT | jp --unquoted Credentials.AccessKeyId)
export AWS_SECRET_ACCESS_KEY=$(echo $AWS_OUTPUT | jp --unquoted Credentials.SecretAccessKey)
export AWS_SESSION_TOKEN=$(echo $AWS_OUTPUT | jp --unquoted Credentials.SessionToken)

go test ./internal/providersdkv2 \
-v \
-short \
-test.v \
-parallel=10 \
-timeout=360m \
-run=TestAcc_Platform.* \
-coverprofile=testacc-platform.out

go tool cover \
-html=testacc-platform.out \
-o testacc-platform.html

- name: Upload TestAcc Coverage Artifact
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: Test Coverage
path: testacc-platform.html
103 changes: 103 additions & 0 deletions .github/workflows/_testacc_vault.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: TestAcc Vault

on:
workflow_call:
workflow_dispatch:
pull_request:
# Vault resources still use SDKv2 so we have to target files manually until migrated
paths:
- 'internal/clients/vault_cluster.go'
- 'internal/providersdkv2/resource_vault_*'

# This prevents more than one run of this workflow from executing at a time.
# Up to 1 additional run will be queued, with anything futher being cancelled from the queue.
concurrency:
group: testacc-vault
cancel-in-progress: false

jobs:
acceptance_tests:
name: Acceptance Tests
runs-on: ubuntu-latest
# environment: testacc-vault
steps:
- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
token: ${{ secrets.HCP_SDK_PIPELINE_TOKEN }}

- name: Set up Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
cache: true
go-version-file: 'go.mod'
cache-dependency-path: go.sum
id: go

- name: Install Dependencies
env:
GOPRIVATE: 'github.com/hashicorp/*'
run: |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.3
go mod tidy
sudo wget https://github.com/jmespath/jp/releases/latest/download/jp-linux-amd64 -O /usr/local/bin/jp
sudo chmod +x /usr/local/bin/jp

- name: Run 'go mod tidy'
run: |
make depscheck

- name: Get dependencies
run: |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.3
go mod download

- name: Go Build
run: |
go build -v .

- name: Run TestAcc
env:
TF_ACC: 1
HCP_API_HOST: ${{ secrets.HCP_API_HOST }}
HCP_AUTH_URL: ${{ secrets.HCP_AUTH_URL }}
HCP_CLIENT_ID: ${{ secrets.HCP_CLIENT_ID }}
HCP_CLIENT_SECRET: ${{ secrets.HCP_CLIENT_SECRET }}
HCP_ORGANIZATION_ID: ${{ secrets.HCP_ORGANIZATION_ID }}
HCP_PROJECT_ID: ${{ secrets.HCP_PROJECT_ID }}
AWS_REGION: us-west-1
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
AZURE_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
run: |
AWS_OUTPUT=$(aws sts assume-role --role-arn $AWS_ROLE_ARN --role-session-name e2e-test --duration-seconds 43200)

export AWS_ACCESS_KEY_ID=$(echo $AWS_OUTPUT | jp --unquoted Credentials.AccessKeyId)
export AWS_SECRET_ACCESS_KEY=$(echo $AWS_OUTPUT | jp --unquoted Credentials.SecretAccessKey)
export AWS_SESSION_TOKEN=$(echo $AWS_OUTPUT | jp --unquoted Credentials.SessionToken)

go test ./internal/providersdkv2 \
-v \
-short \
-test.v \
-parallel=10 \
-timeout=360m \
-run=TestAcc_Vault.* \
-coverprofile=testacc-vault.out

go tool cover \
-html=testacc-vault.out \
-o testacc-vault.html

- name: Upload TestAcc Coverage Artifact
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: Test Coverage
path: testacc-vault.html
17 changes: 9 additions & 8 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@ on:
description: "Patch Release (default: Minor)"
type: boolean
default: false
skip-tests:
description: "Skip the E2E test suite for break-glass scenarios"
type: boolean
default: false

permissions: write-all

jobs:
run-tests:
test:
name: Run Tests
uses: ./.github/workflows/test.yml
with:
# need to use contains because inputs are null for schedule runs
skip-e2e-tests: ${{ contains(inputs.skip-tests, 'true') }}
secrets: inherit
permissions:
contents: read

testacc:
name: Run Acceptance Tests
uses: ./.github/workflows/testacc.yml
secrets: inherit
permissions:
contents: read
Expand Down
70 changes: 5 additions & 65 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,16 @@
name: Run Tests
name: Test

on:
workflow_call:
inputs:
acc-test-pattern:
type: string
default: 'Test.*'
skip-e2e-tests:
description: "Skip the E2E test suite"
type: boolean
default: false
workflow_dispatch:
inputs:
acc-test-pattern:
type: string
default: 'Test.*'
skip-e2e-tests:
description: "Skip the E2E test suite"
type: boolean
default: false

concurrency: acceptance-testing-environment
pull_request:

permissions:
contents: read

jobs:
run-tests:
name: Run Tests
unit-tests:
name: Run Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
Expand All @@ -49,8 +32,6 @@ jobs:
run: |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.3
go mod tidy
sudo wget https://github.com/jmespath/jp/releases/latest/download/jp-linux-amd64 -O /usr/local/bin/jp
sudo chmod +x /usr/local/bin/jp

- name: Run Unit Tests and Linter
run: make test-ci
Expand All @@ -60,44 +41,3 @@ jobs:
with:
name: Test Coverage
path: coverage.html

- name: Warn If Non-default Pattern
if: inputs.acc-test-pattern != 'Test.*'
run: |
echo "## WARNING: Some tests may have been skipped!" >> $GITHUB_STEP_SUMMARY
echo "The default acceptance test pattern is \`Test.*\`, but it was overridden with \`${{ inputs.acc-test-pattern }}\`." >> $GITHUB_STEP_SUMMARY

- name: Run E2E Tests
if: ${{ !inputs.skip-e2e-tests }}
env:
HCP_API_HOST: ${{ secrets.HCP_API_HOST }}
HCP_AUTH_URL: ${{ secrets.HCP_AUTH_URL }}
HCP_CLIENT_ID: ${{ secrets.HCP_CLIENT_ID }}
HCP_CLIENT_SECRET: ${{ secrets.HCP_CLIENT_SECRET }}
HCP_ORGANIZATION_ID: ${{ secrets.HCP_ORGANIZATION_ID }}
HCP_PROJECT_ID: ${{ secrets.HCP_PROJECT_ID }}

AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }}
AWS_REGION: us-west-1

AZURE_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
AZURE_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}

ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
run: |
AWS_OUTPUT=$(aws sts assume-role --role-arn $AWS_ROLE_ARN --role-session-name e2e-test --duration-seconds 43200)
export AWS_ACCESS_KEY_ID=$(echo $AWS_OUTPUT | jp --unquoted Credentials.AccessKeyId)
export AWS_SECRET_ACCESS_KEY=$(echo $AWS_OUTPUT | jp --unquoted Credentials.SecretAccessKey)
export AWS_SESSION_TOKEN=$(echo $AWS_OUTPUT | jp --unquoted Credentials.SessionToken)
make testacc-ci TESTARGS='-run=${{ inputs.acc-test-pattern }} -test.v'

- name: Upload E2E Coverage Artifact
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: Test Coverage
path: coverage-e2e.html
25 changes: 25 additions & 0 deletions .github/workflows/testacc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: TestAcc

on:
workflow_call:
workflow_dispatch:
pull_request:
branches:
- 'jasonpilz/testacc'
push:
branches:
- 'jasonpilz/testacc'

# This prevents more than one run of this workflow from executing at a time.
# Up to 1 additional run will be queued, with anything futher being cancelled from the queue.
concurrency:
group: testacc
cancel-in-progress: false

jobs:
testacc_platform:
name: TestAcc Platform
uses: ./.github/workflows/_testacc_platform.yml
testacc_vault:
name: TestAcc Vault
uses: ./.github/workflows/_testacc_vault.yml
3 changes: 3 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ testacc: fmtcheck
fi
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout $(TIMEOUT) -parallel=10

testacc-platform: fmtcheck
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout $(TIMEOUT) -parallel=10

testacc-ci: fmtcheck
@if [ "$(TESTARGS)" = "-run=TestAccXXX" ]; then \
echo ""; \
Expand Down
6 changes: 3 additions & 3 deletions internal/providersdkv2/resource_aws_network_peering_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"context"
"fmt"
"testing"
"time"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"
Expand All @@ -16,7 +15,7 @@ import (

var (
// using unique names for AWS resource to make debugging easier
hvnPeeringUniqueAWSName = fmt.Sprintf("hcp-provider-test-%s", time.Now().Format("200601021504"))
hvnPeeringUniqueAWSName = testAccUniqueNameWithPrefix("platform-hvn-peer")
testAccAwsPeeringConfig = fmt.Sprintf(`
provider "aws" {
region = "us-west-2"
Expand Down Expand Up @@ -79,7 +78,8 @@ var (
`, hvnPeeringUniqueAWSName)
)

func TestAccAwsPeering(t *testing.T) {
func TestAcc_Platform_Peering_Aws(t *testing.T) {
t.Parallel()
resourceName := "hcp_aws_network_peering.peering"

resource.Test(t, resource.TestCase{
Expand Down
Loading
Loading