Skip to content

Commit 2d55098

Browse files
INTMDB-858: Move mongodbatlas_cluster_outage_simulation acceptance tests to use cloud-dev (#1217)
1 parent 5aa1db7 commit 2d55098

7 files changed

+153
-67
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: 'Acceptance Tests'
2+
3+
on:
4+
workflow_dispatch: {}
5+
workflow_call:
6+
inputs:
7+
parent-event-name: # we want to run the cluster_outage_simulation acceptance tests when the worflow is run in master (push)
8+
required: true
9+
type: string
10+
11+
jobs:
12+
authorize:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: octokit/[email protected]
16+
with:
17+
route: GET /repos/:repository/collaborators/${{ github.actor }}
18+
repository: ${{ github.repository }}
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
22+
change-detection:
23+
needs: [ authorize ]
24+
runs-on: ubuntu-latest
25+
permissions:
26+
pull-requests: read
27+
repository-projects: read
28+
outputs:
29+
cluster_outage_simulation: ${{ steps.filter.outputs.cluster_outage_simulation }}
30+
steps:
31+
- uses: actions/checkout@v3
32+
if: ${{ github.event_name == 'push' }}
33+
- uses: dorny/paths-filter@v2
34+
id: filter
35+
with:
36+
filters: |
37+
cluster_outage_simulation:
38+
- 'mongodbatlas/**cluster_outage_simulation**.go'
39+
40+
cluster_outage_simulation:
41+
needs: [ change-detection ]
42+
if: ${{ needs.change-detection.outputs.cluster_outage_simulation == 'true' || github.event_name == 'workflow_dispatch' || inputs.parent-event-name == 'push' }}
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@v3
47+
- name: Set up Go
48+
uses: actions/setup-go@v4
49+
with:
50+
go-version: "1.20"
51+
- name: Acceptance Tests
52+
env:
53+
MONGODB_ATLAS_PUBLIC_KEY: ${{ secrets.MONGODB_ATLAS_PUBLIC_KEY_CLOUD_DEV }}
54+
MONGODB_ATLAS_PRIVATE_KEY: ${{ secrets.MONGODB_ATLAS_PRIVATE_KEY_CLOUD_DEV }}
55+
MONGODB_ATLAS_ORG_ID: ${{ vars.MONGODB_ATLAS_ORG_ID_CLOUD_DEV }}
56+
MONGODB_ATLAS_BASE_URL: ${{ vars.MONGODB_ATLAS_BASE_URL }}
57+
TF_ACC: 1
58+
TF_LOG: DEBUG
59+
TEST_REGEX: "^TestAccOutageSimulationCluster"
60+
run: make testacc

.github/workflows/code-health.yml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ on:
44
push:
55
branches:
66
- master
7-
pull_request:
7+
pull_request: {}
8+
workflow_dispatch: {}
89

910
jobs:
1011
build:
@@ -40,19 +41,36 @@ jobs:
4041
uses: actions/setup-go@v4
4142
with:
4243
go-version: "1.20"
43-
- name: website lint
44-
run: make tools && make website-lint
45-
- name: actionlint
46-
run: make tools && actionlint -verbose -color
4744
- name: golangci-lint
4845
uses: golangci/[email protected]
4946
with:
5047
version: v1.52.2
5148
args: --timeout 9m0s
49+
website-lint:
50+
runs-on: ubuntu-latest
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@v3
54+
- name: Install Go
55+
uses: actions/setup-go@v4
56+
with:
57+
go-version: "1.20"
58+
- name: website lint
59+
run: make tools && make website-lint
5260
shellcheck:
5361
runs-on: ubuntu-latest
5462
steps:
5563
- uses: actions/checkout@v3
5664
- name: Run ShellCheck
5765
uses: bewuethr/shellcheck-action@v2
66+
call-accettance-tests-workflow:
67+
needs: [build, lint, shellcheck, unit-test, website-lint]
68+
secrets: inherit
69+
permissions:
70+
contents: write
71+
pull-requests: read
72+
repository-projects: read
73+
uses: ./.github/workflows/acceptance-tests.yml
74+
with:
75+
parent-event-name: ${{ github.event_name }}
5876

GNUmakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ GITTAG=$(shell git describe --always --tags)
1515
VERSION=$(GITTAG:v%=%)
1616
LINKER_FLAGS=-s -w -X 'github.com/mongodb/terraform-provider-mongodbatlas/version.ProviderVersion=${VERSION}'
1717

18-
GOLANGCI_VERSION=v1.46.2
18+
GOLANGCI_VERSION=v1.52.2
1919

2020
export PATH := $(shell go env GOPATH)/bin:$(PATH)
2121
export SHELL := env PATH=$(PATH) /bin/bash
@@ -37,7 +37,7 @@ test: fmtcheck
3737
.PHONY: testacc
3838
testacc: fmtcheck
3939
@$(eval VERSION=acc)
40-
TF_ACC=1 go test $(TEST) -run '$(TEST_REGEX)' -v -parallel 5 $(TESTARGS) -timeout $(ACCTEST_TIMEOUT) -cover -ldflags="$(LINKER_FLAGS)"
40+
TF_ACC=1 go test $(TEST) -run '$(TEST_REGEX)' -v -parallel 20 $(TESTARGS) -timeout $(ACCTEST_TIMEOUT) -cover -ldflags="$(LINKER_FLAGS)"
4141

4242
.PHONY: testaccgov
4343
testaccgov: fmtcheck

mongodbatlas/data_source_mongodbatlas_cluster_outage_simulation_test.go

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestAccOutageSimulationClusterDS_SingleRegion_basic(t *testing.T) {
1919
)
2020

2121
resource.ParallelTest(t, resource.TestCase{
22-
PreCheck: func() { testAccPreCheck(t) },
22+
PreCheck: func() { testAccPreCheckBasic(t) },
2323
ProviderFactories: testAccProviderFactories,
2424
CheckDestroy: testAccCheckMongoDBAtlasClusterOutageSimulationDestroy,
2525
Steps: []resource.TestStep{
@@ -38,6 +38,35 @@ func TestAccOutageSimulationClusterDS_SingleRegion_basic(t *testing.T) {
3838
})
3939
}
4040

41+
func TestAccOutageSimulationClusterDS_MultiRegion_basic(t *testing.T) {
42+
SkipTestExtCred(t)
43+
var (
44+
dataSourceName = "data.mongodbatlas_cluster_outage_simulation.test"
45+
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
46+
projectName = acctest.RandomWithPrefix("test-acc-project")
47+
clusterName = acctest.RandomWithPrefix("test-acc-cluster")
48+
)
49+
50+
resource.ParallelTest(t, resource.TestCase{
51+
PreCheck: func() { testAccPreCheckBasic(t) },
52+
ProviderFactories: testAccProviderFactories,
53+
CheckDestroy: testAccCheckMongoDBAtlasClusterOutageSimulationDestroy,
54+
Steps: []resource.TestStep{
55+
{
56+
Config: testAccDataSourceMongoDBAtlasClusterOutageSimulationConfigDSMultiRegion(projectName, orgID, clusterName),
57+
Check: resource.ComposeTestCheckFunc(
58+
resource.TestCheckResourceAttr(dataSourceName, "cluster_name", clusterName),
59+
resource.TestCheckResourceAttrSet(dataSourceName, "project_id"),
60+
resource.TestCheckResourceAttrSet(dataSourceName, "outage_filters.#"),
61+
resource.TestCheckResourceAttrSet(dataSourceName, "start_request_date"),
62+
resource.TestCheckResourceAttrSet(dataSourceName, "simulation_id"),
63+
resource.TestCheckResourceAttrSet(dataSourceName, "state"),
64+
),
65+
},
66+
},
67+
})
68+
}
69+
4170
func testAccDataSourceMongoDBAtlasClusterOutageSimulationConfigDSSingleRegion(projectName, orgID, clusterName string) string {
4271
return fmt.Sprintf(`
4372
resource "mongodbatlas_project" "outage_project" {
@@ -73,35 +102,6 @@ func testAccDataSourceMongoDBAtlasClusterOutageSimulationConfigDSSingleRegion(pr
73102
`, projectName, orgID, clusterName)
74103
}
75104

76-
func TestAccOutageSimulationClusterDS_MultiRegion_basic(t *testing.T) {
77-
SkipTestExtCred(t)
78-
var (
79-
dataSourceName = "data.mongodbatlas_cluster_outage_simulation.test"
80-
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
81-
projectName = acctest.RandomWithPrefix("test-acc-project")
82-
clusterName = acctest.RandomWithPrefix("test-acc-cluster")
83-
)
84-
85-
resource.ParallelTest(t, resource.TestCase{
86-
PreCheck: func() { testAccPreCheck(t) },
87-
ProviderFactories: testAccProviderFactories,
88-
CheckDestroy: testAccCheckMongoDBAtlasClusterOutageSimulationDestroy,
89-
Steps: []resource.TestStep{
90-
{
91-
Config: testAccDataSourceMongoDBAtlasClusterOutageSimulationConfigDSMultiRegion(projectName, orgID, clusterName),
92-
Check: resource.ComposeTestCheckFunc(
93-
resource.TestCheckResourceAttr(dataSourceName, "cluster_name", clusterName),
94-
resource.TestCheckResourceAttrSet(dataSourceName, "project_id"),
95-
resource.TestCheckResourceAttrSet(dataSourceName, "outage_filters.#"),
96-
resource.TestCheckResourceAttrSet(dataSourceName, "start_request_date"),
97-
resource.TestCheckResourceAttrSet(dataSourceName, "simulation_id"),
98-
resource.TestCheckResourceAttrSet(dataSourceName, "state"),
99-
),
100-
},
101-
},
102-
})
103-
}
104-
105105
func testAccDataSourceMongoDBAtlasClusterOutageSimulationConfigDSMultiRegion(projectName, orgID, clusterName string) string {
106106
return fmt.Sprintf(`
107107
resource "mongodbatlas_project" "outage_project" {

mongodbatlas/provider_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ func testAccPreCheck(tb testing.TB) {
4848
}
4949
}
5050

51+
func testAccPreCheckBasic(tb testing.TB) {
52+
if os.Getenv("MONGODB_ATLAS_PUBLIC_KEY") == "" ||
53+
os.Getenv("MONGODB_ATLAS_PRIVATE_KEY") == "" ||
54+
os.Getenv("MONGODB_ATLAS_ORG_ID") == "" {
55+
tb.Fatal("`MONGODB_ATLAS_PUBLIC_KEY`, `MONGODB_ATLAS_PRIVATE_KEY`, and `MONGODB_ATLAS_ORG_ID` must be set for acceptance testing")
56+
}
57+
}
58+
5159
func testAccPreCheckGov(tb testing.TB) {
5260
if os.Getenv("MONGODB_ATLAS_PUBLIC_KEY") == "" ||
5361
os.Getenv("MONGODB_ATLAS_PRIVATE_KEY") == "" ||

mongodbatlas/resource_mongodbatlas_cluster_outage_simulation_test.go

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func TestAccOutageSimulationCluster_SingleRegion_basic(t *testing.T) {
2121
)
2222

2323
resource.ParallelTest(t, resource.TestCase{
24-
PreCheck: func() { testAccPreCheck(t) },
24+
PreCheck: func() { testAccPreCheckBasic(t) },
2525
ProviderFactories: testAccProviderFactories,
2626
CheckDestroy: testAccCheckMongoDBAtlasClusterOutageSimulationDestroy,
2727
Steps: []resource.TestStep{
@@ -40,33 +40,6 @@ func TestAccOutageSimulationCluster_SingleRegion_basic(t *testing.T) {
4040
})
4141
}
4242

43-
func testAccDataSourceMongoDBAtlasClusterOutageSimulationConfigSingleRegion(projectName, orgID, clusterName string) string {
44-
return fmt.Sprintf(`
45-
resource "mongodbatlas_project" "outage_project" {
46-
name = "%s"
47-
org_id = "%s"
48-
}
49-
50-
resource "mongodbatlas_cluster" "atlas_cluster" {
51-
project_id = mongodbatlas_project.outage_project.id
52-
provider_name = "AWS"
53-
name = "%s"
54-
backing_provider_name = "AWS"
55-
provider_region_name = "US_EAST_1"
56-
provider_instance_size_name = "M10"
57-
}
58-
59-
resource "mongodbatlas_cluster_outage_simulation" "test_outage" {
60-
project_id = mongodbatlas_project.outage_project.id
61-
cluster_name = mongodbatlas_cluster.atlas_cluster.name
62-
outage_filters {
63-
cloud_provider = "AWS"
64-
region_name = "US_EAST_1"
65-
}
66-
}
67-
`, projectName, orgID, clusterName)
68-
}
69-
7043
func TestAccOutageSimulationCluster_MultiRegion_basic(t *testing.T) {
7144
SkipTestExtCred(t)
7245
var (
@@ -77,7 +50,7 @@ func TestAccOutageSimulationCluster_MultiRegion_basic(t *testing.T) {
7750
)
7851

7952
resource.ParallelTest(t, resource.TestCase{
80-
PreCheck: func() { testAccPreCheck(t) },
53+
PreCheck: func() { testAccPreCheckBasic(t) },
8154
ProviderFactories: testAccProviderFactories,
8255
CheckDestroy: testAccCheckMongoDBAtlasClusterOutageSimulationDestroy,
8356
Steps: []resource.TestStep{
@@ -96,6 +69,33 @@ func TestAccOutageSimulationCluster_MultiRegion_basic(t *testing.T) {
9669
})
9770
}
9871

72+
func testAccDataSourceMongoDBAtlasClusterOutageSimulationConfigSingleRegion(projectName, orgID, clusterName string) string {
73+
return fmt.Sprintf(`
74+
resource "mongodbatlas_project" "outage_project" {
75+
name = "%s"
76+
org_id = "%s"
77+
}
78+
79+
resource "mongodbatlas_cluster" "atlas_cluster" {
80+
project_id = mongodbatlas_project.outage_project.id
81+
provider_name = "AWS"
82+
name = "%s"
83+
backing_provider_name = "AWS"
84+
provider_region_name = "US_EAST_1"
85+
provider_instance_size_name = "M10"
86+
}
87+
88+
resource "mongodbatlas_cluster_outage_simulation" "test_outage" {
89+
project_id = mongodbatlas_project.outage_project.id
90+
cluster_name = mongodbatlas_cluster.atlas_cluster.name
91+
outage_filters {
92+
cloud_provider = "AWS"
93+
region_name = "US_EAST_1"
94+
}
95+
}
96+
`, projectName, orgID, clusterName)
97+
}
98+
9999
func testAccDataSourceMongoDBAtlasClusterOutageSimulationConfigMultiRegion(projectName, orgID, clusterName string) string {
100100
return fmt.Sprintf(`
101101
resource "mongodbatlas_project" "outage_project" {

website/docs/r/federated_database_instance.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,4 @@ In addition to all arguments above, the following attributes are exported:
180180
$ terraform import mongodbatlas_federated_database_instance.example 1112222b3bf99403840e8934--test--s3-test
181181
```
182182

183-
See [MongoDB Atlas API](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Data-Federation) Documentation for more information.
183+
See [MongoDB Atlas API](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Data-Federation) Documentation for more information.

0 commit comments

Comments
 (0)