Add end-to-end tests for net-address

This commit is contained in:
Wiktor Niesiobędzki 2024-01-06 10:39:42 +00:00 committed by Wiktor Niesiobędzki
parent 0e39676c99
commit 8afdf66a09
4 changed files with 64 additions and 19 deletions

View File

@ -12,14 +12,17 @@ module "addresses" {
project_id = var.project_id
external_addresses = {
one = { region = "europe-west1" }
two = { region = "europe-west2" }
two = {
region = "europe-west2"
tier = "STANDARD"
}
}
global_addresses = {
app-1 = {}
app-2 = {}
}
}
# tftest modules=1 resources=4 inventory=external.yaml
# tftest modules=1 resources=4 inventory=external.yaml e2e
```
### Internal addresses
@ -35,13 +38,13 @@ module "addresses" {
subnetwork = var.subnet.self_link
}
ilb-2 = {
address = "10.0.0.2"
address = "10.0.16.2"
region = var.region
subnetwork = var.subnet.self_link
}
}
}
# tftest modules=1 resources=2 inventory=internal.yaml
# tftest modules=1 resources=2 inventory=internal.yaml e2e
```
### IPv6 addresses
@ -55,7 +58,7 @@ module "addresses" {
external_addresses = {
nlb = {
region = var.region
subnetwork = var.subnet.self_link
subnetwork = module.vpc.subnets["${var.region}/ipv6-external"].self_link
ipv6 = {
endpoint_type = "NETLB"
}
@ -66,16 +69,16 @@ module "addresses" {
ipv6 = {}
purpose = "SHARED_LOADBALANCER_VIP"
region = var.region
subnetwork = var.subnet.self_link
subnetwork = module.vpc.subnets["${var.region}/ipv6-internal"].self_link
}
vm = {
ipv6 = {}
region = var.region
subnetwork = var.subnet.self_link
subnetwork = module.vpc.subnets["${var.region}/ipv6-internal"].self_link
}
}
}
# tftest modules=1 resources=3 inventory=ipv6.yaml
# tftest modules=2 resources=8 fixtures=fixtures/net-vpc-ipv6.tf inventory=ipv6.yaml e2e
```
### PSA addresses
@ -92,7 +95,7 @@ module "addresses" {
}
}
}
# tftest modules=1 resources=1 inventory=psa.yaml
# tftest modules=1 resources=1 inventory=psa.yaml e2e
```
### PSC addresses
@ -112,7 +115,7 @@ module "addresses" {
}
}
}
# tftest modules=1 resources=2 inventory=psc.yaml
# tftest modules=1 resources=2 inventory=psc.yaml e2e
```
# IPSec Interconnect addresses
@ -136,20 +139,20 @@ module "addresses" {
}
}
}
# tftest modules=1 resources=2 inventory=ipsec-interconnect.yaml
# tftest modules=1 resources=2 inventory=ipsec-interconnect.yaml e2e
```
<!-- BEGIN TFDOC -->
## Variables
| name | description | type | required | default |
|---|---|:---:|:---:|:---:|
| [project_id](variables.tf#L84) | Project where the addresses will be created. | <code>string</code> | ✓ | |
| [project_id](variables.tf#L83) | Project where the addresses will be created. | <code>string</code> | ✓ | |
| [external_addresses](variables.tf#L17) | Map of external addresses, keyed by name. | <code title="map&#40;object&#40;&#123;&#10; region &#61; string&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; ipv6 &#61; optional&#40;object&#40;&#123;&#10; endpoint_type &#61; string&#10; &#125;&#41;&#41;&#10; labels &#61; optional&#40;map&#40;string&#41;, &#123;&#125;&#41;&#10; name &#61; optional&#40;string&#41;&#10; tier &#61; optional&#40;string&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [global_addresses](variables.tf#L39) | List of global addresses to create. | <code title="map&#40;object&#40;&#123;&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; ipv6 &#61; optional&#40;map&#40;string&#41;&#41; &#35; To be left empty for ipv6&#10; name &#61; optional&#40;string&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [internal_addresses](variables.tf#L49) | Map of internal addresses to create, keyed by name. | <code title="map&#40;object&#40;&#123;&#10; region &#61; string&#10; subnetwork &#61; string&#10; address &#61; optional&#40;string&#41;&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; ipv6 &#61; optional&#40;map&#40;string&#41;&#41; &#35; To be left empty for ipv6&#10; labels &#61; optional&#40;map&#40;string&#41;&#41;&#10; name &#61; optional&#40;string&#41;&#10; purpose &#61; optional&#40;string&#41;&#10; tier &#61; optional&#40;string&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [ipsec_interconnect_addresses](variables.tf#L65) | Map of internal addresses used for HPA VPN over Cloud Interconnect. | <code title="map&#40;object&#40;&#123;&#10; region &#61; string&#10; address &#61; string&#10; network &#61; string&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; name &#61; optional&#40;string&#41;&#10; prefix_length &#61; number&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [psa_addresses](variables.tf#L89) | Map of internal addresses used for Private Service Access. | <code title="map&#40;object&#40;&#123;&#10; address &#61; string&#10; network &#61; string&#10; prefix_length &#61; number&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; name &#61; optional&#40;string&#41;&#10;&#10;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [psc_addresses](variables.tf#L102) | Map of internal addresses used for Private Service Connect. | <code title="map&#40;object&#40;&#123;&#10; address &#61; string&#10; network &#61; string&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; name &#61; optional&#40;string&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [internal_addresses](variables.tf#L49) | Map of internal addresses to create, keyed by name. | <code title="map&#40;object&#40;&#123;&#10; region &#61; string&#10; subnetwork &#61; string&#10; address &#61; optional&#40;string&#41;&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; ipv6 &#61; optional&#40;map&#40;string&#41;&#41; &#35; To be left empty for ipv6&#10; labels &#61; optional&#40;map&#40;string&#41;&#41;&#10; name &#61; optional&#40;string&#41;&#10; purpose &#61; optional&#40;string&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [ipsec_interconnect_addresses](variables.tf#L64) | Map of internal addresses used for HPA VPN over Cloud Interconnect. | <code title="map&#40;object&#40;&#123;&#10; region &#61; string&#10; address &#61; string&#10; network &#61; string&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; name &#61; optional&#40;string&#41;&#10; prefix_length &#61; number&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [psa_addresses](variables.tf#L88) | Map of internal addresses used for Private Service Access. | <code title="map&#40;object&#40;&#123;&#10; address &#61; string&#10; network &#61; string&#10; prefix_length &#61; number&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; name &#61; optional&#40;string&#41;&#10;&#10;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [psc_addresses](variables.tf#L101) | Map of internal addresses used for Private Service Connect. | <code title="map&#40;object&#40;&#123;&#10; address &#61; string&#10; network &#61; string&#10; description &#61; optional&#40;string, &#34;Terraform managed.&#34;&#41;&#10; name &#61; optional&#40;string&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
## Outputs
@ -161,4 +164,8 @@ module "addresses" {
| [ipsec_interconnect_addresses](outputs.tf#L41) | Allocated internal addresses for HA VPN over Cloud Interconnect. | |
| [psa_addresses](outputs.tf#L49) | Allocated internal addresses for PSA endpoints. | |
| [psc_addresses](outputs.tf#L57) | Allocated internal addresses for PSC endpoints. | |
## Fixtures
- [net-vpc-ipv6.tf](../../tests/fixtures/net-vpc-ipv6.tf)
<!-- END TFDOC -->

40
tests/fixtures/net-vpc-ipv6.tf vendored Normal file
View File

@ -0,0 +1,40 @@
# 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.
module "vpc" {
source = "./fabric/modules/net-vpc"
project_id = var.project_id
name = "fixture-net-vpc-external"
ipv6_config = {
enable_ula_internal = true
}
subnets = [
{
ip_cidr_range = "192.168.0.0/24"
name = "ipv6-external"
region = var.region
ipv6 = {
access_type = "EXTERNAL"
}
},
{
ip_cidr_range = "192.168.1.0/24"
name = "ipv6-internal"
region = var.region
ipv6 = {
access_type = "INTERNAL"
}
},
]
}

View File

@ -23,7 +23,7 @@ values:
region: europe-west8
subnetwork: subnet_self_link
module.addresses.google_compute_address.internal["ilb-2"]:
address: 10.0.0.2
address: 10.0.16.2
address_type: INTERNAL
labels: null
name: ilb-2

View File

@ -29,7 +29,6 @@ values:
project: project-id
purpose: SHARED_LOADBALANCER_VIP
region: europe-west8
subnetwork: subnet_self_link
module.addresses.google_compute_address.internal["vm"]:
address_type: INTERNAL
ip_version: IPV6
@ -38,7 +37,6 @@ values:
network: null
project: project-id
region: europe-west8
subnetwork: subnet_self_link
counts:
google_compute_address: 3