Skip to content

Commit 6581cc7

Browse files
Merge pull request #154 from dimitarproynov/refactor_unit_tests
Introduce GitHub actions to run lite E2E test on push and unit tests on pull request
2 parents d74f849 + d971306 commit 6581cc7

File tree

6 files changed

+76
-8
lines changed

6 files changed

+76
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Terraform Provider Acceptance Tests Lite
2+
on:
3+
#Every day at 08:00 UTC
4+
schedule:
5+
- cron: '0 8 * * *'
6+
push:
7+
permissions:
8+
# Permission for checking out code
9+
contents: read
10+
jobs:
11+
# Lite acceptance tests run on zerocloud provider only, which makes them really fast,
12+
# but with limited coverage
13+
acceptance_lite:
14+
name: Acceptance Tests Lite (Terraform ${{ matrix.terraform-version }})
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
terraform-version:
20+
- '1.1.*'
21+
- '1.2.*'
22+
steps:
23+
- uses: actions/checkout@v3
24+
- uses: actions/setup-go@v3
25+
with:
26+
go-version: '1.19'
27+
- uses: hashicorp/setup-terraform@v2
28+
with:
29+
terraform_version: ${{ matrix.terraform-version }}
30+
terraform_wrapper: false
31+
- run: make testacc TESTARGS="-run=TestAccResourceVmcSddc_Zerocloud"
32+
env:
33+
TF_ACC: '1'
34+
API_TOKEN: ${{ secrets.API_TOKEN }}
35+
AWS_ACCOUNT_NUMBER: ${{ secrets.AWS_ACCOUNT_NUMBER }}
36+
CSP_URL: ${{ secrets.CSP_URL }}
37+
ORG_DISPLAY_NAME: ${{ secrets.ORG_DISPLAY_NAME }}
38+
ORG_ID: ${{ secrets.ORG_ID }}
39+
TEST_SDDC_ID: ${{ secrets.TEST_SDDC_ID }}
40+
TEST_SDDC_NAME: ${{ secrets.TEST_SDDC_NAME }}
41+
VMC_URL: ${{ secrets.VMC_URL }}

.github/workflows/golangci-lint.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ jobs:
66
name: lint
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v2
9+
- uses: actions/checkout@v3
1010
- name: golangci-lint
11-
uses: golangci/golangci-lint-action@v2
11+
uses: golangci/golangci-lint-action@v3
1212
with:
1313
version: v1.49.0
1414
args: --issues-exit-code=1

.github/workflows/release.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ jobs:
1010
steps:
1111
-
1212
name: Checkout
13-
uses: actions/checkout@v2
13+
uses: actions/checkout@v3
1414
with:
1515
fetch-depth: 0
1616
-
1717
name: Set up Go
18-
uses: actions/setup-go@v2
18+
uses: actions/setup-go@v3
1919
with:
2020
go-version: 1.19.1
2121
-
2222
name: golangci-lint
23-
uses: golangci/golangci-lint-action@v2
23+
uses: golangci/golangci-lint-action@v3
2424
with:
2525
version: v1.49.0
2626
args: --issues-exit-code=1

.github/workflows/unit_tests.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Terraform VMC Unit Tests
2+
on:
3+
pull_request:
4+
jobs:
5+
unit:
6+
name: Unit Tests
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
- uses: actions/setup-go@v3
11+
with:
12+
go-version: '1.19'
13+
- run: make test

README.md

+16-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Terraform to work with [VMware Cloud on AWS](https://vmc.vmware.com/).
77

88

99
- [Terraform](https://www.terraform.io/downloads.html) 0.12+
10-
- [Go](https://golang.org/doc/install) 1.16 (to build the provider plugin)
10+
- [Go](https://golang.org/doc/install) 1.19 (to build the provider plugin)
1111

1212

1313
# Building the Provider
@@ -115,11 +115,18 @@ provider.
115115
Set required environment variables based as per your infrastructure settings
116116

117117
```sh
118+
$ # API token provided from CSP with at least "Organization Member" role and service role
119+
$ # on "VMware Cloud on AWS" service that is allowed to deploy SDDCs.
118120
$ export API_TOKEN=xxx
121+
$ # Id of a VMC Org in which test SDDC are (to be) placed
119122
$ export ORG_ID=xxxx
123+
$ # Id of an existing SDDC used for SDDC data source (import) test
120124
$ export TEST_SDDC_ID=xxx
125+
$ # Name of above SDDC
121126
$ export TEST_SDDC_NAME=xxx
127+
$ # NSX URL of a non-ZEROCLOUD SDDC, used for real IP testing
122128
$ export NSXT_REVERSE_PROXY_URL=xxx
129+
$ # Account number of a connected to the above Org AWS account, required for test SDDC deployment
123130
$ export AWS_ACCOUNT_NUMBER=xxx
124131
```
125132

@@ -137,8 +144,15 @@ If you want to run against a specific set of tests, run make testacc with the TE
137144
$ make testacc TESTARGS="-run=TestAccResourceVmcSddc_basic"
138145
```
139146

147+
Additionally, limited set of acceptance tests can be ran with the ZEROCLOUD cloud provider, which is much faster and cheaper,
148+
while providing decent API coverage:
149+
150+
```sh
151+
$ make testacc TESTARGS="-run=TestAccResourceVmcSddc_Zerocloud"
152+
```
153+
140154
# License
141155

142-
Copyright 2019 VMware, Inc.
156+
Copyright 2019-2022 VMware, Inc.
143157

144158
The Terraform provider for VMware Cloud on AWS is available under [MPL2.0 license](https://github.com/vmware/terraform-provider-vmc/blob/master/LICENSE).

vmc/provider.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func Provider() *schema.Provider {
4242
"org_id": {
4343
Type: schema.TypeString,
4444
Required: true,
45-
DefaultFunc: schema.EnvDefaultFunc("ORG_ID", nil),
45+
DefaultFunc: schema.EnvDefaultFunc(OrgID, nil),
4646
},
4747
"vmc_url": {
4848
Type: schema.TypeString,

0 commit comments

Comments
 (0)