Skip to content

Commit 9db9f90

Browse files
authored
v1.6.1 - Conditionally ignore serverless connection string changes (#953)
* Made regional mode tests serial so they wouldn't conflict * Conditionally ignoring connection_string changes on serverless tests. * Fixed a typo in documentation and ignoring connection strings where necessary for now
1 parent 7b73d34 commit 9db9f90

12 files changed

+53
-51
lines changed

mongodbatlas/data_source_mongodbatlas_private_endpoint_regional_mode_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func TestAccNetworkDSPrivateEndpointRegionalMode_basic(t *testing.T) {
1515
resourceName := "mongodbatlas_private_endpoint_regional_mode.test"
1616
projectID := os.Getenv("MONGODB_ATLAS_NETWORK_PROJECT_ID")
1717

18-
resource.ParallelTest(t, resource.TestCase{
18+
resource.Test(t, resource.TestCase{
1919
PreCheck: func() { testAccPreCheck(t) },
2020
ProviderFactories: testAccProviderFactories,
2121
Steps: []resource.TestStep{

mongodbatlas/data_source_mongodbatlas_serverless_instance_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ func testAccMongoDBAtlasServerlessInstanceDSConfig(projectID, name string) strin
4646
project_id = mongodbatlas_serverless_instance.test.project_id
4747
}
4848
49-
`, testAccMongoDBAtlasServerlessInstanceConfig(projectID, name))
49+
`, testAccMongoDBAtlasServerlessInstanceConfig(projectID, name, true))
5050
}

mongodbatlas/data_source_mongodbatlas_serverless_instances_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ func testAccMongoDBAtlasServerlessInstancesDSConfig(projectID, name string) stri
4444
data "mongodbatlas_serverless_instances" "data_serverless" {
4545
project_id = mongodbatlas_serverless_instance.test.project_id
4646
}
47-
`, testAccMongoDBAtlasServerlessInstanceConfig(projectID, name))
47+
`, testAccMongoDBAtlasServerlessInstanceConfig(projectID, name, true))
4848
}

mongodbatlas/resource_mongodbatlas_private_endpoint_regional_mode_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestAccNetworkRSPrivateEndpointRegionalMode_conn(t *testing.T) {
3939

4040
dependencies := []string{clusterResource, clusterDataSource, endpointResources}
4141

42-
resource.ParallelTest(t, resource.TestCase{
42+
resource.Test(t, resource.TestCase{
4343
PreCheck: func() { testAccPreCheck(t) },
4444
ProviderFactories: testAccProviderFactories,
4545
CheckDestroy: testAccCheckMongoDBAtlasPrivateEndpointRegionalModeDestroy,
@@ -76,7 +76,7 @@ func TestAccNetworkRSPrivateEndpointRegionalMode_basic(t *testing.T) {
7676
projectID = os.Getenv("MONGODB_ATLAS_NETWORK_PROJECT_ID")
7777
)
7878

79-
resource.ParallelTest(t, resource.TestCase{
79+
resource.Test(t, resource.TestCase{
8080
PreCheck: func() { testAccPreCheck(t) },
8181
ProviderFactories: testAccProviderFactories,
8282
CheckDestroy: testAccCheckMongoDBAtlasPrivateEndpointRegionalModeDestroy,

mongodbatlas/resource_mongodbatlas_privatelink_endpoint_serverless_test.go

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ import (
1212

1313
func TestAccNetworkRSPrivateLinkEndpointServerless_basic(t *testing.T) {
1414
var (
15-
resourceName = "mongodbatlas_privatelink_endpoint_serverless.test"
16-
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")
17-
instanceName = "serverlessplink"
18-
commentOrigin = "this is a comment for serverless private link endpoint"
15+
resourceName = "mongodbatlas_privatelink_endpoint_serverless.test"
16+
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")
17+
instanceName = "serverlessplink"
1918
)
2019

2120
resource.ParallelTest(t, resource.TestCase{
@@ -24,7 +23,7 @@ func TestAccNetworkRSPrivateLinkEndpointServerless_basic(t *testing.T) {
2423
CheckDestroy: testAccCheckMongoDBAtlasPrivateLinkEndpointServerlessDestroy,
2524
Steps: []resource.TestStep{
2625
{
27-
Config: testAccMongoDBAtlasPrivateLinkEndpointServerlessConfig(projectID, instanceName, commentOrigin),
26+
Config: testAccMongoDBAtlasPrivateLinkEndpointServerlessConfig(projectID, instanceName, true),
2827
Check: resource.ComposeTestCheckFunc(
2928
testAccCheckMongoDBAtlasPrivateLinkEndpointServerlessExists(resourceName),
3029
resource.TestCheckResourceAttr(resourceName, "instance_name", instanceName),
@@ -36,28 +35,28 @@ func TestAccNetworkRSPrivateLinkEndpointServerless_basic(t *testing.T) {
3635

3736
func TestAccNetworkRSPrivateLinkEndpointServerless_importBasic(t *testing.T) {
3837
var (
39-
resourceName = "mongodbatlas_privatelink_endpoint_serverless.test"
40-
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")
41-
instanceName = "serverlessimport"
42-
commentOrigin = "this is a comment for serverless private link endpoint"
38+
resourceName = "mongodbatlas_privatelink_endpoint_serverless.test"
39+
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")
40+
instanceName = "serverlessimport"
4341
)
4442
resource.ParallelTest(t, resource.TestCase{
4543
PreCheck: func() { testAccPreCheck(t) },
4644
ProviderFactories: testAccProviderFactories,
4745
CheckDestroy: testAccCheckMongoDBAtlasPrivateLinkEndpointServerlessDestroy,
4846
Steps: []resource.TestStep{
4947
{
50-
Config: testAccMongoDBAtlasPrivateLinkEndpointServerlessConfig(projectID, instanceName, commentOrigin),
48+
Config: testAccMongoDBAtlasPrivateLinkEndpointServerlessConfig(projectID, instanceName, true),
5149
Check: resource.ComposeTestCheckFunc(
5250
resource.TestCheckResourceAttr(resourceName, "instance_name", instanceName),
5351
),
5452
},
5553
{
56-
Config: testAccMongoDBAtlasPrivateLinkEndpointServerlessConfig(projectID, instanceName, commentOrigin),
57-
ResourceName: resourceName,
58-
ImportStateIdFunc: testAccCheckMongoDBAtlasPrivateLinkEndpointServerlessImportStateIDFunc(resourceName),
59-
ImportState: true,
60-
ImportStateVerify: true,
54+
Config: testAccMongoDBAtlasPrivateLinkEndpointServerlessConfig(projectID, instanceName, false),
55+
ResourceName: resourceName,
56+
ImportStateIdFunc: testAccCheckMongoDBAtlasPrivateLinkEndpointServerlessImportStateIDFunc(resourceName),
57+
ImportState: true,
58+
ImportStateVerify: true,
59+
ImportStateVerifyIgnore: []string{"connection_strings_private_endpoint_srv"},
6160
},
6261
},
6362
})
@@ -82,25 +81,17 @@ func testAccCheckMongoDBAtlasPrivateLinkEndpointServerlessDestroy(state *terrafo
8281
return nil
8382
}
8483

85-
func testAccMongoDBAtlasPrivateLinkEndpointServerlessConfig(projectID, instanceName, comment string) string {
84+
func testAccMongoDBAtlasPrivateLinkEndpointServerlessConfig(projectID, instanceName string, ignoreConnectionStrings bool) string {
8685
return fmt.Sprintf(`
8786
8887
resource "mongodbatlas_privatelink_endpoint_serverless" "test" {
89-
project_id = "%[1]s"
88+
project_id = mongodbatlas_serverless_instance.test.project_id
9089
instance_name = mongodbatlas_serverless_instance.test.name
9190
provider_name = "AWS"
92-
}
93-
94-
resource "mongodbatlas_serverless_instance" "test" {
95-
project_id = "%[1]s"
96-
name = "%[2]s"
97-
provider_settings_backing_provider_name = "AWS"
98-
provider_settings_provider_name = "SERVERLESS"
99-
provider_settings_region_name = "US_EAST_1"
100-
continuous_backup_enabled = true
10191
}
10292
103-
`, projectID, instanceName, comment)
93+
%s
94+
`, testAccMongoDBAtlasServerlessInstanceConfig(projectID, instanceName, ignoreConnectionStrings))
10495
}
10596

10697
func testAccCheckMongoDBAtlasPrivateLinkEndpointServerlessExists(resourceName string) resource.TestCheckFunc {

mongodbatlas/resource_mongodbatlas_serverless_instance.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ func returnServerlessInstanceSchema() map[string]*schema.Schema {
107107
"connection_strings_private_endpoint_srv": {
108108
Type: schema.TypeList,
109109
Computed: true,
110-
Optional: true,
111110
Elem: &schema.Schema{
112111
Type: schema.TypeString,
113112
},

mongodbatlas/resource_mongodbatlas_serverless_instance_test.go

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func TestAccClusterRSServerlessInstance_basic(t *testing.T) {
2525
CheckDestroy: testAccCheckMongoDBAtlasServerlessInstanceDestroy,
2626
Steps: []resource.TestStep{
2727
{
28-
Config: testAccMongoDBAtlasServerlessInstanceConfig(projectID, instanceName),
28+
Config: testAccMongoDBAtlasServerlessInstanceConfig(projectID, instanceName, true),
2929
Check: resource.ComposeTestCheckFunc(
3030
testAccCheckMongoDBAtlasServerlessInstanceExists(resourceName, &serverlessInstance),
3131
resource.TestCheckResourceAttr(resourceName, "project_id", projectID),
@@ -50,7 +50,7 @@ func TestAccClusterRSServerlessInstance_importBasic(t *testing.T) {
5050
CheckDestroy: testAccCheckMongoDBAtlasServerlessInstanceDestroy,
5151
Steps: []resource.TestStep{
5252
{
53-
Config: testAccMongoDBAtlasServerlessInstanceConfig(projectID, instanceName),
53+
Config: testAccMongoDBAtlasServerlessInstanceConfig(projectID, instanceName, true),
5454
},
5555
{
5656
ResourceName: resourceName,
@@ -119,17 +119,29 @@ func testAccCheckMongoDBAtlasServerlessInstanceImportStateIDFunc(resourceName st
119119
}
120120
}
121121

122-
func testAccMongoDBAtlasServerlessInstanceConfig(projectID, name string) string {
122+
func testAccMongoDBAtlasServerlessInstanceConfig(projectID, name string, ignoreConnectionStrings bool) string {
123+
lifecycle := ""
124+
125+
if ignoreConnectionStrings {
126+
lifecycle = `
127+
128+
lifecycle {
129+
ignore_changes = [connection_strings_private_endpoint_srv]
130+
}
131+
`
132+
}
133+
123134
return fmt.Sprintf(`
124135
resource "mongodbatlas_serverless_instance" "test" {
125-
project_id = "%[1]s"
126-
name = "%[2]s"
127-
128-
provider_settings_backing_provider_name = "AWS"
129-
provider_settings_provider_name = "SERVERLESS"
130-
provider_settings_region_name = "US_EAST_1"
131-
continuous_backup_enabled = true
132-
}
136+
project_id = "%[1]s"
137+
name = "%[2]s"
138+
139+
provider_settings_backing_provider_name = "AWS"
140+
provider_settings_provider_name = "SERVERLESS"
141+
provider_settings_region_name = "US_EAST_1"
142+
continuous_backup_enabled = true
143+
%[3]s
144+
}
133145
134-
`, projectID, name)
146+
`, projectID, name, lifecycle)
135147
}

website/docs/r/cloud_provider_snapshot.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ On-demand snapshots happen immediately, unlike scheduled snapshots which occur a
5454
* `cluster_name` - (Required) The name of the Atlas cluster that contains the snapshots you want to retrieve.
5555
* `description` - (Required) Description of the on-demand snapshot.
5656
* `retention_in_days` - (Required) The number of days that Atlas should retain the on-demand snapshot. Must be at least 1.
57-
* `timeout`- (Optional) The duration of time to wait to finish the on-demand snapshot. The timeout value is definded by a signed sequence of decimal numbers with an time unit suffix such as: `1h45m`, `300s`, `10m`, .... The valid time units are: `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`. Default value for the timeout is `10m`
57+
* `timeout`- (Optional) The duration of time to wait to finish the on-demand snapshot. The timeout value is defined by a signed sequence of decimal numbers with an time unit suffix such as: `1h45m`, `300s`, `10m`, .... The valid time units are: `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`. Default value for the timeout is `10m`
5858

5959
## Attributes Reference
6060

website/docs/r/privatelink_endpoint.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ resource "mongodbatlas_privatelink_endpoint" "test" {
4040
* `provider_name` - (Required) Name of the cloud provider for which you want to create the private endpoint service. Atlas accepts `AWS`, `AZURE` or `GCP`.
4141
* `region` - (Required) Cloud provider region in which you want to create the private endpoint connection.
4242
Accepted values are: [AWS regions](https://docs.atlas.mongodb.com/reference/amazon-aws/#amazon-aws), [AZURE regions](https://docs.atlas.mongodb.com/reference/microsoft-azure/#microsoft-azure) and [GCP regions](https://docs.atlas.mongodb.com/reference/google-gcp/#std-label-google-gcp)
43-
* `timeouts`- (Optional) The duration of time to wait for Private Endpoint to be created or deleted. The timeout value is definded by a signed sequence of decimal numbers with an time unit suffix such as: `1h45m`, `300s`, `10m`, .... The valid time units are: `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`. The default timeout for Private Endpoint create & delete is `1h`. Learn more about timeouts [here](https://www.terraform.io/plugin/sdkv2/resources/retries-and-customizable-timeouts).
43+
* `timeouts`- (Optional) The duration of time to wait for Private Endpoint to be created or deleted. The timeout value is defined by a signed sequence of decimal numbers with an time unit suffix such as: `1h45m`, `300s`, `10m`, .... The valid time units are: `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`. The default timeout for Private Endpoint create & delete is `1h`. Learn more about timeouts [here](https://www.terraform.io/plugin/sdkv2/resources/retries-and-customizable-timeouts).
4444

4545

4646
## Attributes Reference

website/docs/r/privatelink_endpoint_serverless.html.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ resource "mongodbatlas_privatelink_endpoint_serverless" "test" {
2424
instance_name = mongodbatlas_serverless_instance.test.name
2525
provider_name = "AWS"
2626
}
27-
27+
2828
resource "mongodbatlas_serverless_instance" "test" {
2929
project_id = "<PROJECT_ID>"
3030
name = "test-db"
@@ -51,7 +51,7 @@ In addition to all arguments above, the following attributes are exported:
5151
* `cloud_provider_endpoint_id` - Unique string that identifies the private endpoint's network interface.
5252
* `comment` - Human-readable string to associate with this private endpoint.
5353
* `status` - Human-readable label that indicates the current operating status of the private endpoint. Values include: RESERVATION_REQUESTED, RESERVED, INITIATING, AVAILABLE, FAILED, DELETING.
54-
* `timeouts`- (Optional) The duration of time to wait for Private Endpoint Service to be created or deleted. The timeout value is definded by a signed sequence of decimal numbers with an time unit suffix such as: `1h45m`, `300s`, `10m`, .... The valid time units are: `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`. The default timeout for Private Endpoint create & delete is `2h`. Learn more about timeouts [here](https://www.terraform.io/plugin/sdkv2/resources/retries-and-customizable-timeouts).
54+
* `timeouts`- (Optional) The duration of time to wait for Private Endpoint Service to be created or deleted. The timeout value is defined by a signed sequence of decimal numbers with an time unit suffix such as: `1h45m`, `300s`, `10m`, .... The valid time units are: `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`. The default timeout for Private Endpoint create & delete is `2h`. Learn more about timeouts [here](https://www.terraform.io/plugin/sdkv2/resources/retries-and-customizable-timeouts).
5555

5656
## Import
5757

0 commit comments

Comments
 (0)