From 277777d1c700bb29e151a7877925fd0fb0aa761f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wiktor=20Niesiob=C4=99dzki?= Date: Tue, 23 Jan 2024 16:34:45 +0100 Subject: [PATCH] Fix DNS E2E test + add one to net-lb-app-int-cross-region (#1993) * Fix DNS E2E test + add one to net-lb-app-int-cross-region * Update README.md * Fix inventory for tests * Fix tests * Fix number of resources --------- Co-authored-by: Julio Castillo --- modules/dns/README.md | 29 +++++++--------- modules/net-lb-app-int-cross-region/README.md | 14 ++++---- tests/fixtures/net-lb-app-int-cross-region.tf | 34 +++++++++++++++++++ .../dns/examples/routing-policies.yaml | 28 +++------------ 4 files changed, 58 insertions(+), 47 deletions(-) create mode 100644 tests/fixtures/net-lb-app-int-cross-region.tf diff --git a/modules/dns/README.md b/modules/dns/README.md index ced680f1..7798a659 100644 --- a/modules/dns/README.md +++ b/modules/dns/README.md @@ -90,26 +90,16 @@ module "private-dns" { } "A geo2" = { geo_routing = [ - { location = "europe-west1", health_checked_targets = [ + { location = var.region, health_checked_targets = [ { - load_balancer_type = "globalL7ilb", - ip_address = "10.10.2.3", - port = "80", - ip_protocol = "tcp", + load_balancer_type = "globalL7ilb" + ip_address = module.net-lb-app-int-cross-region.addresses[var.region] + port = "80" + ip_protocol = "tcp" network_url = var.vpc.self_link project = var.project_id } - ] }, - { location = "europe-west2", health_checked_targets = [ - { - load_balancer_type = "globalL7ilb", - ip_address = "10.10.3.3", - port = "80", - ip_protocol = "tcp", - network_url = var.vpc.self_link - project = var.project_id - } - ] }, + ] } ] } "A wrr" = { @@ -122,7 +112,7 @@ module "private-dns" { } } } -# tftest modules=1 resources=5 inventory=routing-policies.yaml e2e +# tftest modules=4 resources=12 fixtures=fixtures/net-lb-app-int-cross-region.tf,fixtures/compute-mig.tf inventory=routing-policies.yaml e2e ``` ### Reverse Lookup Zone @@ -184,4 +174,9 @@ module "public-dns" { | [name](outputs.tf#L32) | The DNS zone name. | | | [name_servers](outputs.tf#L37) | The DNS zone name servers. | | | [zone](outputs.tf#L42) | DNS zone resource. | | + +## Fixtures + +- [compute-mig.tf](../../tests/fixtures/compute-mig.tf) +- [net-lb-app-int-cross-region.tf](../../tests/fixtures/net-lb-app-int-cross-region.tf) diff --git a/modules/net-lb-app-int-cross-region/README.md b/modules/net-lb-app-int-cross-region/README.md index 21df46d7..a58d4007 100644 --- a/modules/net-lb-app-int-cross-region/README.md +++ b/modules/net-lb-app-int-cross-region/README.md @@ -22,6 +22,7 @@ Due to the complexity of the underlying resources, changes to the configuration - [Files](#files) - [Variables](#variables) - [Outputs](#outputs) +- [Fixtures](#fixtures) ### Minimal Example @@ -36,21 +37,18 @@ module "ilb-l7" { backend_service_configs = { default = { backends = [{ - group = "projects/myprj/zones/europe-west1-a/instanceGroups/my-ig-ew1" - }, { - group = "projects/myprj/zones/europe-west2-a/instanceGroups/my-ig-ew4" + group = module.compute-mig.group_manager.instance_group }] } } vpc_config = { network = var.vpc.self_link subnetworks = { - europe-west1 = var.subnet1.self_link - europe-west4 = var.subnet2.self_link + (var.region) = var.subnet.self_link } } } -# tftest modules=1 resources=6 +# tftest modules=3 resources=7 fixtures=fixtures/compute-mig.tf e2e ``` An HTTPS ILB needs a few additional fields: @@ -774,4 +772,8 @@ module "ilb-l7" { | [neg_ids](outputs.tf#L61) | Autogenerated network endpoint group ids. | | | [psc_neg_ids](outputs.tf#L68) | Autogenerated PSC network endpoint group ids. | | | [regional_neg_ids](outputs.tf#L75) | Autogenerated regional network endpoint group ids. | | + +## Fixtures + +- [compute-mig.tf](../../tests/fixtures/compute-mig.tf) diff --git a/tests/fixtures/net-lb-app-int-cross-region.tf b/tests/fixtures/net-lb-app-int-cross-region.tf new file mode 100644 index 00000000..5fb42b54 --- /dev/null +++ b/tests/fixtures/net-lb-app-int-cross-region.tf @@ -0,0 +1,34 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# requires fixtures/fixtures/compute-mig.tf + +module "net-lb-app-int-cross-region" { + source = "./fabric/modules/net-lb-app-int-cross-region" + name = "ilb-test" + project_id = var.project_id + backend_service_configs = { + default = { + backends = [{ + group = module.compute-mig.group_manager.instance_group + }] + } + } + vpc_config = { + network = var.vpc.self_link + subnetworks = { + (var.region) = var.subnet.self_link + } + } +} \ No newline at end of file diff --git a/tests/modules/dns/examples/routing-policies.yaml b/tests/modules/dns/examples/routing-policies.yaml index d508665f..22757475 100644 --- a/tests/modules/dns/examples/routing-policies.yaml +++ b/tests/modules/dns/examples/routing-policies.yaml @@ -64,28 +64,8 @@ values: routing_policy: - enable_geo_fencing: null geo: - - health_checked_targets: - - internal_load_balancers: - - ip_address: 10.10.2.3 - ip_protocol: tcp - load_balancer_type: globalL7ilb - network_url: projects/xxx/global/networks/aaa - port: '80' - project: project-id - region: null - location: europe-west1 - rrdatas: null - - health_checked_targets: - - internal_load_balancers: - - ip_address: 10.10.3.3 - ip_protocol: tcp - load_balancer_type: globalL7ilb - network_url: projects/xxx/global/networks/aaa - port: '80' - project: project-id - region: null - location: europe-west2 - rrdatas: null + - location: europe-west8 + rrdatas: null primary_backup: [] wrr: [] rrdatas: null @@ -128,5 +108,5 @@ values: counts: google_dns_managed_zone: 1 google_dns_record_set: 4 - modules: 1 - resources: 5 \ No newline at end of file + modules: 4 + resources: 12 \ No newline at end of file