Skip to content

Commit 1f9a0b7

Browse files
modular-magicianrileykarson
authored andcommitted
Run AccessContextManager tests serially in CI (hashicorp#259)
1 parent 526447f commit 1f9a0b7

File tree

45 files changed

+75
-50
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+75
-50
lines changed

google-beta/resource_access_context_manager_access_level_test.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import (
88
"github.com/hashicorp/terraform/terraform"
99
)
1010

11-
// Access Context Manager tests need to run serially
12-
func TestAccAccessContextManagerAccessLevel_basic(t *testing.T) {
11+
// Since each test here is acting on the same organization and only one AccessPolicy
12+
// can exist, they need to be ran serially. See AccessPolicy for the test runner.
13+
14+
func testAccAccessContextManagerAccessLevel_basicTest(t *testing.T) {
1315
org := getTestOrgFromEnv(t)
1416

1517
resource.Test(t, resource.TestCase{
@@ -37,7 +39,7 @@ func TestAccAccessContextManagerAccessLevel_basic(t *testing.T) {
3739
})
3840
}
3941

40-
func TestAccAccessContextManagerAccessLevel_full(t *testing.T) {
42+
func testAccAccessContextManagerAccessLevel_fullTest(t *testing.T) {
4143
org := getTestOrgFromEnv(t)
4244

4345
resource.Test(t, resource.TestCase{

google-beta/resource_access_context_manager_access_policy_test.go

+24-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,30 @@ import (
88
"github.com/hashicorp/terraform/terraform"
99
)
1010

11-
// Access Context Manager tests need to run serially
12-
func TestAccAccessContextManagerAccessPolicy_basic(t *testing.T) {
11+
// Since each test here is acting on the same organization and only one AccessPolicy
12+
// can exist, they need to be ran serially
13+
func TestAccAccessContextManager(t *testing.T) {
14+
testCases := map[string]func(t *testing.T){
15+
"access_policy": testAccAccessContextManagerAccessPolicy_basicTest,
16+
"service_perimeter": testAccAccessContextManagerServicePerimeter_basicTest,
17+
"service_perimeter_update": testAccAccessContextManagerServicePerimeter_updateTest,
18+
"access_level": testAccAccessContextManagerAccessLevel_basicTest,
19+
"access_level_full": testAccAccessContextManagerAccessLevel_fullTest,
20+
}
21+
22+
for name, tc := range testCases {
23+
// shadow the tc variable into scope so that when
24+
// the loop continues, if t.Run hasn't executed tc(t)
25+
// yet, we don't have a race condition
26+
// see https://github.com/golang/go/wiki/CommonMistakes#using-goroutines-on-loop-iterator-variables
27+
tc := tc
28+
t.Run(name, func(t *testing.T) {
29+
tc(t)
30+
})
31+
}
32+
}
33+
34+
func testAccAccessContextManagerAccessPolicy_basicTest(t *testing.T) {
1335
org := getTestOrgFromEnv(t)
1436

1537
resource.Test(t, resource.TestCase{

google-beta/resource_access_context_manager_service_perimeter_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ import (
88
"github.com/hashicorp/terraform/terraform"
99
)
1010

11-
// Access Context Manager tests need to run serially
12-
func TestAccAccessContextManagerServicePerimeter_basic(t *testing.T) {
11+
// Since each test here is acting on the same organization and only one AccessPolicy
12+
// can exist, they need to be ran serially. See AccessPolicy for the test runner.
13+
func testAccAccessContextManagerServicePerimeter_basicTest(t *testing.T) {
1314
org := getTestOrgFromEnv(t)
1415

1516
resource.Test(t, resource.TestCase{
@@ -29,7 +30,7 @@ func TestAccAccessContextManagerServicePerimeter_basic(t *testing.T) {
2930
})
3031
}
3132

32-
func TestAccAccessContextManagerServicePerimeter_update(t *testing.T) {
33+
func testAccAccessContextManagerServicePerimeter_updateTest(t *testing.T) {
3334
org := getTestOrgFromEnv(t)
3435

3536
resource.Test(t, resource.TestCase{

website/docs/r/accesscontextmanager_access_level.html.markdown

+1-1

website/docs/r/accesscontextmanager_access_policy.html.markdown

+1-1

website/docs/r/accesscontextmanager_service_perimeter.html.markdown

+1-1

website/docs/r/binaryauthorization_attestor.html.markdown

+1-1

website/docs/r/binaryauthorization_policy.html.markdown

+1-1

website/docs/r/compute_address.html.markdown

+1-1

website/docs/r/compute_autoscaler.html.markdown

+1-1

website/docs/r/compute_backend_bucket.html.markdown

+1-1

website/docs/r/compute_disk.html.markdown

+1-1

website/docs/r/compute_firewall.html.markdown

+1-1

website/docs/r/compute_forwarding_rule.html.markdown

+1-1

website/docs/r/compute_global_address.html.markdown

+1-1

website/docs/r/compute_health_check.html.markdown

+1-1

website/docs/r/compute_http_health_check.html.markdown

+1-1

website/docs/r/compute_https_health_check.html.markdown

+1-1

website/docs/r/compute_interconnect_attachment.html.markdown

+1-1

website/docs/r/compute_region_autoscaler.html.markdown

+1-1

website/docs/r/compute_region_disk.html.markdown

+1-1

website/docs/r/compute_route.html.markdown

+1-1

website/docs/r/compute_router.html.markdown

+1-1

website/docs/r/compute_snapshot.html.markdown

+1-1

website/docs/r/compute_ssl_certificate.html.markdown

+1-1

website/docs/r/compute_ssl_policy.html.markdown

+1-1

website/docs/r/compute_subnetwork.html.markdown

+1-1

website/docs/r/compute_target_http_proxy.html.markdown

+1-1

website/docs/r/compute_target_https_proxy.html.markdown

+1-1

website/docs/r/compute_target_ssl_proxy.html.markdown

+1-1

website/docs/r/compute_target_tcp_proxy.html.markdown

+1-1

website/docs/r/compute_url_map.html.markdown

+1-1

website/docs/r/compute_vpn_gateway.html.markdown

+1-1

website/docs/r/compute_vpn_tunnel.html.markdown

+1-1

website/docs/r/containeranalysis_note.html.markdown

+1-1

website/docs/r/dns_managed_zone.html.markdown

+1-1

website/docs/r/filestore_instance.html.markdown

+1-1

website/docs/r/monitoring_alert_policy.html.markdown

+1-1

website/docs/r/monitoring_group.html.markdown

+1-1

website/docs/r/monitoring_notification_channel.html.markdown

+1-1

website/docs/r/monitoring_uptime_check_config.html.markdown

+1-1

0 commit comments

Comments
 (0)