@@ -10,6 +10,7 @@ import (
1010 "github.com/elastic/terraform-provider-elasticstack/internal/acctest"
1111 "github.com/elastic/terraform-provider-elasticstack/internal/versionutils"
1212 "github.com/hashicorp/go-version"
13+ sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
1314 "github.com/hashicorp/terraform-plugin-testing/helper/resource"
1415)
1516
@@ -29,14 +30,15 @@ var (
2930
3031func TestSyntheticPrivateLocationResource (t * testing.T ) {
3132 resourceId := "elasticstack_kibana_synthetics_private_location.test"
33+ randomSuffix := sdkacctest .RandStringFromCharSet (4 , sdkacctest .CharSetAlphaNum )
3234 resource .Test (t , resource.TestCase {
3335 PreCheck : func () { acctest .PreCheck (t ) },
3436 ProtoV6ProviderFactories : acctest .Providers ,
3537 Steps : []resource.TestStep {
3638 // Create and Read testing
3739 {
3840 SkipFunc : versionutils .CheckIfVersionIsUnsupported (minKibanaPrivateLocationAPIVersion ),
39- Config : testConfig ("testacc" , "test_policy" ) + `
41+ Config : testConfig ("testacc" , "test_policy" , randomSuffix ) + `
4042resource "elasticstack_kibana_synthetics_private_location" "test" {
4143 label = "pl-test-label"
4244 agent_policy_id = elasticstack_fleet_agent_policy.test_policy.policy_id
@@ -63,7 +65,7 @@ resource "elasticstack_kibana_synthetics_private_location" "test" {
6365 ResourceName : resourceId ,
6466 ImportState : true ,
6567 ImportStateVerify : true ,
66- Config : testConfig ("testacc" , "test_policy" ) + `
68+ Config : testConfig ("testacc" , "test_policy" , randomSuffix ) + `
6769resource "elasticstack_kibana_synthetics_private_location" "test" {
6870 label = "pl-test-label"
6971 agent_policy_id = elasticstack_fleet_agent_policy.test_policy.policy_id
@@ -78,7 +80,7 @@ resource "elasticstack_kibana_synthetics_private_location" "test" {
7880 // Update and Read testing
7981 {
8082 SkipFunc : versionutils .CheckIfVersionIsUnsupported (minKibanaPrivateLocationAPIVersion ),
81- Config : testConfig ("default" , "test_policy_default" ) + `
83+ Config : testConfig ("default" , "test_policy_default" , randomSuffix ) + `
8284resource "elasticstack_kibana_synthetics_private_location" "test" {
8385 label = "pl-test-label-2"
8486 agent_policy_id = elasticstack_fleet_agent_policy.test_policy_default.policy_id
@@ -103,7 +105,7 @@ resource "elasticstack_kibana_synthetics_private_location" "test" {
103105 // Update and Read testing
104106 {
105107 SkipFunc : versionutils .CheckIfVersionIsUnsupported (minKibanaPrivateLocationAPIVersion ),
106- Config : testConfig ("default" , "test_policy_default" ) + `
108+ Config : testConfig ("default" , "test_policy_default" , randomSuffix ) + `
107109resource "elasticstack_kibana_synthetics_private_location" "test" {
108110 label = "pl-test-label-2"
109111 agent_policy_id = elasticstack_fleet_agent_policy.test_policy_default.policy_id
@@ -119,7 +121,7 @@ resource "elasticstack_kibana_synthetics_private_location" "test" {
119121 // Update and Read testing
120122 {
121123 SkipFunc : versionutils .CheckIfVersionIsUnsupported (minKibanaPrivateLocationAPIVersion ),
122- Config : testConfig ("default" , "test_policy_default" ) + `
124+ Config : testConfig ("default" , "test_policy_default" , randomSuffix ) + `
123125resource "elasticstack_kibana_synthetics_private_location" "test" {
124126 label = "pl-test-label-2"
125127 agent_policy_id = elasticstack_fleet_agent_policy.test_policy_default.policy_id
@@ -139,7 +141,7 @@ resource "elasticstack_kibana_synthetics_private_location" "test" {
139141 // Update and Read testing
140142 {
141143 SkipFunc : versionutils .CheckIfVersionIsUnsupported (minKibanaPrivateLocationAPIVersion ),
142- Config : testConfig ("default" , "test_policy_default" ) + `
144+ Config : testConfig ("default" , "test_policy_default" , randomSuffix ) + `
143145resource "elasticstack_kibana_synthetics_private_location" "test" {
144146 label = "pl-test-label-2"
145147 agent_policy_id = elasticstack_fleet_agent_policy.test_policy_default.policy_id
@@ -162,15 +164,15 @@ resource "elasticstack_kibana_synthetics_private_location" "test" {
162164 })
163165}
164166
165- func testConfig (namespace , agentPolicy string ) string {
167+ func testConfig (namespace , agentPolicy , randomSuffix string ) string {
166168 return providerConfig + fmt .Sprintf (`
167169resource "elasticstack_fleet_agent_policy" "%s" {
168- name = "Private Location Agent Policy - %s"
170+ name = "Private Location Agent Policy - %s - %s "
169171 namespace = "%s"
170172 description = "TestPrivateLocationResource Agent Policy"
171173 monitor_logs = true
172174 monitor_metrics = true
173175 skip_destroy = false
174176}
175- ` , agentPolicy , agentPolicy , namespace )
177+ ` , agentPolicy , agentPolicy , randomSuffix , namespace )
176178}
0 commit comments