Skip to content

Commit c5fb565

Browse files
HCE-665: Add E2E Tests (#421)
* add temp workflow * add changelog * test aws workflow * test jp * format * set region * export vars * test aws peering * test all the things * try failed test * change timeout * skip performance replication tests for now * get e2e tests ready for push * remove download
1 parent 1b1b708 commit c5fb565

File tree

4 files changed

+48
-7
lines changed

4 files changed

+48
-7
lines changed

.changelog/421.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:improvement
2+
Add E2E tests to auto release pipeline
3+
```

.github/workflows/prerelease.yml

+39-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
name: Prerelease
22

33
on:
4-
## Uncomment when ready to actually release this thing with automated tests.
54
# Run Every Wednesday at 12:00 AM UTC
6-
# schedule:
7-
# - cron: '0 0 * * 3'
5+
schedule:
6+
- cron: '0 0 * * 3'
87
workflow_dispatch:
98

109
permissions: write-all
@@ -36,22 +35,57 @@ jobs:
3635
git config user.name "hashicorp-cloud"
3736
git config user.email "hashicorp-cloud@hashicorp.com"
3837
39-
- name: Install Go Binaries
38+
- name: Install Dependencies
4039
env:
4140
GOPRIVATE: 'github.com/hashicorp/*'
4241
run: |
4342
go install github.com/hashicorp/go-changelog/cmd/changelog-build@6ec9be372335f39c5df27e232c3669db7f5183a5
4443
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.49.0
44+
go mod tidy
45+
sudo wget https://github.com/jmespath/jp/releases/latest/download/jp-linux-amd64 -O /usr/local/bin/jp
46+
sudo chmod +x /usr/local/bin/jp
4547
4648
- name: Run Unit Tests and Linter
4749
run: make test-ci
4850

49-
- name: Upload Coverage Artifact
51+
- name: Upload Unit Test Coverage Artifact
5052
uses: actions/upload-artifact@v3
5153
with:
5254
name: Test Coverage
5355
path: coverage.html
5456

57+
- name: Run E2E Tests
58+
env:
59+
HCP_API_HOST: ${{ secrets.HCP_API_HOST }}
60+
HCP_AUTH_URL: ${{ secrets.HCP_AUTH_URL }}
61+
HCP_CLIENT_ID: ${{ secrets.HCP_CLIENT_ID }}
62+
HCP_CLIENT_SECRET: ${{ secrets.HCP_CLIENT_SECRET }}
63+
64+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
65+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
66+
AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }}
67+
AWS_REGION: us-west-1
68+
69+
AZURE_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
70+
AZURE_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
71+
72+
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
73+
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
74+
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
75+
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
76+
run: |
77+
AWS_OUTPUT=$(aws sts assume-role --role-arn $AWS_ROLE_ARN --role-session-name e2e-test --duration-seconds 43200)
78+
export AWS_ACCESS_KEY_ID=$(echo $AWS_OUTPUT | jp --unquoted Credentials.AccessKeyId)
79+
export AWS_SECRET_ACCESS_KEY=$(echo $AWS_OUTPUT | jp --unquoted Credentials.SecretAccessKey)
80+
export AWS_SESSION_TOKEN=$(echo $AWS_OUTPUT | jp --unquoted Credentials.SessionToken)
81+
make testacc-ci
82+
83+
- name: Upload E2E Coverage Artifact
84+
uses: actions/upload-artifact@v3
85+
with:
86+
name: Test Coverage
87+
path: coverage-e2e.html
88+
5589
- name: Release New Version
5690
env:
5791
GOPRIVATE: 'github.com/hashicorp/*'

GNUmakefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ testacc-ci: fmtcheck
6161
echo "See the contributing guide for more information: https://github.com/hashicorp/terraform-provider-hcp/blob/main/contributing/writing-tests.md"; \
6262
exit 1; \
6363
fi
64-
TF_ACC=1 go test -coverprofile=coverage.out $(TEST) -v $(TESTARGS) -timeout 210m
65-
go tool cover -html=coverage.out -o coverage.html
64+
TF_ACC=1 go test -short -coverprofile=coverage-e2e.out $(TEST) -v $(TESTARGS) -timeout 360m
65+
go tool cover -html=coverage-e2e.out -o coverage-e2e.html
6666

6767
depscheck:
6868
@echo "==> Checking source code with go mod tidy..."

internal/provider/resource_vault_cluster_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,10 @@ resource "hcp_hvn" "hvn2" {
308308
}
309309

310310
func TestAccPerformanceReplication_Validations(t *testing.T) {
311+
// These tests seem to be flaky in GitHub Actions so for now we will skip them in CI until we can solve the issue
312+
if testing.Short() {
313+
t.Skip("skipping test in short mode (CI).")
314+
}
311315
hvn1ResourceName := "hcp_hvn.hvn1"
312316
hvn2ResourceName := "hcp_hvn.hvn2"
313317
primaryVaultResourceName := "hcp_vault_cluster.c1"

0 commit comments

Comments
 (0)