Skip to content

Commit 6024bb7

Browse files
author
Gonzalo Servat
committed
Split the tests to avoid breaking the addSslPolicy test
1 parent bd9a48c commit 6024bb7

File tree

1 file changed

+139
-31
lines changed

1 file changed

+139
-31
lines changed

mmv1/third_party/terraform/services/compute/resource_compute_region_target_https_proxy_test.go.erb

+139-31
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,6 @@ func TestAccComputeRegionTargetHttpsProxy_addSslPolicy_withForwardingRule(t *tes
387387
func testAccComputeRegionTargetHttpsProxy_withForwardingRule(context map[string]interface{}) string {
388388
return acctest.Nprintf(`
389389
resource "google_compute_forwarding_rule" "default-https" {
390-
<% unless version == 'ga' -%>
391-
provider = google-beta
392-
<% end -%>
393390
project = "%{project_id}"
394391
region = "us-central1"
395392
name = "https-frwd-rule-%{resource_suffix}"
@@ -405,9 +402,6 @@ resource "google_compute_forwarding_rule" "default-https" {
405402
}
406403

407404
resource "google_compute_region_backend_service" "default" {
408-
<% unless version == 'ga' -%>
409-
provider = google-beta
410-
<% end -%>
411405
project = "%{project_id}"
412406
region = "us-central1"
413407
name = "backend-service-%{resource_suffix}"
@@ -442,9 +436,6 @@ resource "google_compute_region_backend_service" "default" {
442436
}
443437

444438
resource "google_compute_region_health_check" "default" {
445-
<% unless version == 'ga' -%>
446-
provider = google-beta
447-
<% end -%>
448439
project = "%{project_id}"
449440
region = "us-central1"
450441
name = "hc-%{resource_suffix}"
@@ -460,9 +451,6 @@ resource "google_compute_region_health_check" "default" {
460451
}
461452

462453
resource "google_compute_region_target_https_proxy" "default-https" {
463-
<% unless version == 'ga' -%>
464-
provider = google-beta
465-
<% end -%>
466454
project = "%{project_id}"
467455
region = "us-central1"
468456
name = "https-proxy-%{resource_suffix}"
@@ -471,47 +459,32 @@ resource "google_compute_region_target_https_proxy" "default-https" {
471459
}
472460

473461
resource "google_compute_region_url_map" "default-https" {
474-
<% unless version == 'ga' -%>
475-
provider = google-beta
476-
<% end -%>
477462
project = "%{project_id}"
478463
region = "us-central1"
479464
name = "lb-%{resource_suffix}"
480465
default_service = google_compute_region_backend_service.default.id
481466
}
482467

483468
resource "google_compute_region_ssl_certificate" "foobar0" {
484-
<% unless version == 'ga' -%>
485-
provider = google-beta
486-
<% end -%>
487469
name = "httpsproxy-test-cert0-%{resource_suffix}"
488470
description = "very descriptive"
489471
private_key = file("test-fixtures/test.key")
490472
certificate = file("test-fixtures/test.crt")
491473
}
492474

493475
resource "google_compute_network" "ilb_network" {
494-
<% unless version == 'ga' -%>
495-
provider = google-beta
496-
<% end -%>
497476
name = "tf-test-l4-ilb-network-%{resource_suffix}"
498477
auto_create_subnetworks = false
499478
}
500479

501480
resource "google_compute_subnetwork" "ilb_subnet" {
502-
<% unless version == 'ga' -%>
503-
provider = google-beta
504-
<% end -%>
505481
name = "tf-test-l4-ilb-subnet-%{resource_suffix}"
506482
ip_cidr_range = "10.0.1.0/24"
507483
region = "us-central1"
508484
network = google_compute_network.ilb_network.id
509485
}
510486

511487
resource "google_compute_subnetwork" "ilb_subnet2" {
512-
<% unless version == 'ga' -%>
513-
provider = google-beta
514-
<% end -%>
515488
name = "tf-test-l4-ilb-subnet2-%{resource_suffix}"
516489
ip_cidr_range = "10.142.0.0/20"
517490
region = "us-central1"
@@ -521,9 +494,6 @@ resource "google_compute_subnetwork" "ilb_subnet2" {
521494
}
522495

523496
resource "google_compute_address" "consumer_address" {
524-
<% unless version == 'ga' -%>
525-
provider = google-beta
526-
<% end -%>
527497
name = "tf-test-website-ip-%{resource_suffix}-1"
528498
region = "us-central1"
529499
subnetwork = google_compute_subnetwork.ilb_subnet.id
@@ -676,7 +646,7 @@ func TestAccComputeRegionTargetHttpsProxy_addServerTlsPolicy_withForwardingRule(
676646
CheckDestroy: testAccCheckComputeTargetHttpsProxyDestroyProducer(t),
677647
Steps: []resource.TestStep{
678648
{
679-
Config: testAccComputeRegionTargetHttpsProxy_withForwardingRule(context),
649+
Config: testAccComputeRegionTargetHttpsProxy_withForwardingRule_withoutServerTlsPolicy(context),
680650
},
681651
{
682652
ResourceName: "google_compute_region_target_https_proxy.default-https",
@@ -695,6 +665,144 @@ func TestAccComputeRegionTargetHttpsProxy_addServerTlsPolicy_withForwardingRule(
695665
})
696666
}
697667

668+
func testAccComputeRegionTargetHttpsProxy_withForwardingRule_withoutServerTlsPolicy(context map[string]interface{}) string {
669+
return acctest.Nprintf(`
670+
resource "google_compute_forwarding_rule" "default-https" {
671+
provider = google-beta
672+
673+
project = "%{project_id}"
674+
region = "us-central1"
675+
name = "https-frwd-rule-%{resource_suffix}"
676+
load_balancing_scheme = "INTERNAL_MANAGED"
677+
target = google_compute_region_target_https_proxy.default-https.self_link
678+
network = google_compute_network.ilb_network.name
679+
subnetwork = google_compute_subnetwork.ilb_subnet.name
680+
ip_address = google_compute_address.consumer_address.id
681+
ip_protocol = "TCP"
682+
port_range = "443"
683+
allow_global_access = "true"
684+
depends_on = [google_compute_subnetwork.ilb_subnet2]
685+
}
686+
687+
resource "google_compute_region_backend_service" "default" {
688+
provider = google-beta
689+
690+
project = "%{project_id}"
691+
region = "us-central1"
692+
name = "backend-service-%{resource_suffix}"
693+
protocol = "HTTPS"
694+
port_name = "https-server"
695+
load_balancing_scheme = "INTERNAL_MANAGED"
696+
session_affinity = "HTTP_COOKIE"
697+
health_checks = [google_compute_region_health_check.default.self_link]
698+
locality_lb_policy = "RING_HASH"
699+
700+
# websocket handling: https://stackoverflow.com/questions/63822612/websocket-connection-being-closed-on-google-compute-engine
701+
timeout_sec = 600
702+
703+
consistent_hash {
704+
http_cookie {
705+
ttl {
706+
# 24hr cookie ttl
707+
seconds = 86400
708+
nanos = null
709+
}
710+
name = "X-CLIENT-SESSION"
711+
path = null
712+
}
713+
http_header_name = null
714+
minimum_ring_size = 1024
715+
}
716+
717+
log_config {
718+
enable = true
719+
sample_rate = 1.0
720+
}
721+
}
722+
723+
resource "google_compute_region_health_check" "default" {
724+
provider = google-beta
725+
726+
project = "%{project_id}"
727+
region = "us-central1"
728+
name = "hc-%{resource_suffix}"
729+
timeout_sec = 5
730+
check_interval_sec = 30
731+
healthy_threshold = 3
732+
unhealthy_threshold = 3
733+
734+
https_health_check {
735+
port = 443
736+
request_path = "/health"
737+
}
738+
}
739+
740+
resource "google_compute_region_target_https_proxy" "default-https" {
741+
provider = google-beta
742+
743+
project = "%{project_id}"
744+
region = "us-central1"
745+
name = "https-proxy-%{resource_suffix}"
746+
url_map = google_compute_region_url_map.default-https.self_link
747+
ssl_certificates = [google_compute_region_ssl_certificate.foobar0.self_link]
748+
}
749+
750+
resource "google_compute_region_url_map" "default-https" {
751+
provider = google-beta
752+
753+
project = "%{project_id}"
754+
region = "us-central1"
755+
name = "lb-%{resource_suffix}"
756+
default_service = google_compute_region_backend_service.default.id
757+
}
758+
759+
resource "google_compute_region_ssl_certificate" "foobar0" {
760+
provider = google-beta
761+
762+
name = "httpsproxy-test-cert0-%{resource_suffix}"
763+
description = "very descriptive"
764+
private_key = file("test-fixtures/test.key")
765+
certificate = file("test-fixtures/test.crt")
766+
}
767+
768+
resource "google_compute_network" "ilb_network" {
769+
provider = google-beta
770+
771+
name = "tf-test-l4-ilb-network-%{resource_suffix}"
772+
auto_create_subnetworks = false
773+
}
774+
775+
resource "google_compute_subnetwork" "ilb_subnet" {
776+
provider = google-beta
777+
778+
name = "tf-test-l4-ilb-subnet-%{resource_suffix}"
779+
ip_cidr_range = "10.0.1.0/24"
780+
region = "us-central1"
781+
network = google_compute_network.ilb_network.id
782+
}
783+
784+
resource "google_compute_subnetwork" "ilb_subnet2" {
785+
provider = google-beta
786+
787+
name = "tf-test-l4-ilb-subnet2-%{resource_suffix}"
788+
ip_cidr_range = "10.142.0.0/20"
789+
region = "us-central1"
790+
purpose = "REGIONAL_MANAGED_PROXY"
791+
role = "ACTIVE"
792+
network = google_compute_network.ilb_network.id
793+
}
794+
795+
resource "google_compute_address" "consumer_address" {
796+
provider = google-beta
797+
798+
name = "tf-test-website-ip-%{resource_suffix}-1"
799+
region = "us-central1"
800+
subnetwork = google_compute_subnetwork.ilb_subnet.id
801+
address_type = "INTERNAL"
802+
}
803+
`, context)
804+
}
805+
698806
func testAccComputeRegionTargetHttpsProxy_withForwardingRule_withServerTlsPolicy(context map[string]interface{}) string {
699807
return acctest.Nprintf(`
700808

0 commit comments

Comments
 (0)