Skip to content

Commit

Permalink
Merge pull request #34 from glarizza/gl/network_tests_randomness
Browse files Browse the repository at this point in the history
Refactor integration tests to include random names
  • Loading branch information
aaron-lane authored Mar 13, 2019
2 parents 1d7ff1e + 79a24cc commit fc7d126
Show file tree
Hide file tree
Showing 33 changed files with 281 additions and 226 deletions.
30 changes: 20 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,50 +84,60 @@ docker_run:
docker run --rm -it \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-e TF_VAR_project_id \
-e PROJECT_ID \
-e SERVICE_ACCOUNT_JSON \
-e RANDOM_STRING_FOR_TESTING \
-v $(CURDIR):/cft/workdir \
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
/bin/bash
/bin/bash -c 'source test/ci_integration.sh && setup_environment && exec /bin/bash'

.PHONY: docker_create
docker_create:
docker run --rm -it \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-e TF_VAR_project_id \
-e PROJECT_ID \
-e SERVICE_ACCOUNT_JSON \
-e RANDOM_STRING_FOR_TESTING \
-v $(CURDIR):/cft/workdir \
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
/bin/bash -c "kitchen create"
/bin/bash -c "source test/ci_integration.sh && setup_environment && kitchen create"

.PHONY: docker_converge
docker_converge:
docker run --rm -it \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-e TF_VAR_project_id \
-e PROJECT_ID \
-e SERVICE_ACCOUNT_JSON \
-e RANDOM_STRING_FOR_TESTING \
-v $(CURDIR):/cft/workdir \
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
/bin/bash -c "kitchen converge && kitchen converge"
/bin/bash -c "source test/ci_integration.sh && setup_environment && kitchen converge && kitchen converge"

.PHONY: docker_verify
docker_verify:
docker run --rm -it \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-e TF_VAR_project_id \
-e PROJECT_ID \
-e SERVICE_ACCOUNT_JSON \
-e RANDOM_STRING_FOR_TESTING \
-v $(CURDIR):/cft/workdir \
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
/bin/bash -c "kitchen verify"
/bin/bash -c "source test/ci_integration.sh && setup_environment && kitchen verify"

.PHONY: docker_destroy
docker_destroy:
docker run --rm -it \
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
-e TF_VAR_project_id \
-e PROJECT_ID \
-e SERVICE_ACCOUNT_JSON \
-e RANDOM_STRING_FOR_TESTING \
-v $(CURDIR):/cft/workdir \
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
/bin/bash -c "kitchen destroy"
/bin/bash -c "source test/ci_integration.sh && setup_environment && kitchen destroy"

.PHONY: test_integration_docker
test_integration_docker: docker_create docker_converge docker_verify docker_destroy
Expand Down
33 changes: 16 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,34 +75,33 @@ Then perform the following commands on the root folder:

[^]: (autogen_docs_start)


## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| delete_default_internet_gateway_routes | If set, ensure that all routes within the network specified whose names begin with 'default-route' and with a next hop of 'default-internet-gateway' are deleted | string | `false` | no |
| network_name | The name of the network being created | string | - | yes |
| project_id | The ID of the project where this VPC will be created | string | - | yes |
| delete\_default\_internet\_gateway\_routes | If set, ensure that all routes within the network specified whose names begin with 'default-route' and with a next hop of 'default-internet-gateway' are deleted | string | `"false"` | no |
| network\_name | The name of the network being created | string | n/a | yes |
| project\_id | The ID of the project where this VPC will be created | string | n/a | yes |
| routes | List of routes being created in this VPC | list | `<list>` | no |
| routing_mode | The network routing mode (default 'GLOBAL') | string | `GLOBAL` | no |
| secondary_ranges | Secondary ranges that will be used in some of the subnets | map | - | yes |
| shared_vpc_host | Makes this project a Shared VPC host if 'true' (default 'false') | string | `false` | no |
| subnets | The list of subnets being created | list | - | yes |
| routing\_mode | The network routing mode (default 'GLOBAL') | string | `"GLOBAL"` | no |
| secondary\_ranges | Secondary ranges that will be used in some of the subnets | map | n/a | yes |
| shared\_vpc\_host | Makes this project a Shared VPC host if 'true' (default 'false') | string | `"false"` | no |
| subnets | The list of subnets being created | list | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| network_name | The name of the VPC being created |
| network_self_link | The URI of the VPC being created |
| network\_name | The name of the VPC being created |
| network\_self\_link | The URI of the VPC being created |
| routes | The routes associated with this VPC |
| subnets_flow_logs | Whether the subnets will have VPC flow logs enabled |
| subnets_ips | The IPs and CIDRs of the subnets being created |
| subnets_names | The names of the subnets being created |
| subnets_private_access | Whether the subnets will have access to Google API's without a public IP |
| subnets_regions | The region where the subnets will be created |
| subnets_secondary_ranges | The secondary ranges associated with these subnets |
| subnets_self_links | The self-links of subnets being created |
| subnets\_flow\_logs | Whether the subnets will have VPC flow logs enabled |
| subnets\_ips | The IPs and CIDRs of the subnets being created |
| subnets\_names | The names of the subnets being created |
| subnets\_private\_access | Whether the subnets will have access to Google API's without a public IP |
| subnets\_regions | The region where the subnets will be created |
| subnets\_secondary\_ranges | The secondary ranges associated with these subnets |
| subnets\_self\_links | The self-links of subnets being created |

[^]: (autogen_docs_end)

Expand Down
20 changes: 10 additions & 10 deletions examples/delete_default_gateway_routes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ This VPC has a single subnet with no secondary ranges, and ensures the default i

[^]: (autogen_docs_start)


## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| project_id | The project ID to host the network in | string | - | yes |
| network\_name | The name of the VPC network being created | string | n/a | yes |
| project\_id | The project ID to host the network in | string | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| network_name | The name of the VPC being created |
| network_self_link | The URI of the VPC being created |
| network\_name | The name of the VPC being created |
| network\_self\_link | The URI of the VPC being created |
| routes | The routes associated with this VPC |
| subnets_flow_logs | Whether the subnets will have VPC flow logs enabled |
| subnets_ips | The IP and cidrs of the subnets being created |
| subnets_names | The names of the subnets being created |
| subnets_private_access | Whether the subnets will have access to Google API's without a public IP |
| subnets_regions | The region where subnets will be created |
| subnets_secondary_ranges | The secondary ranges associated with these subnets |
| subnets\_flow\_logs | Whether the subnets will have VPC flow logs enabled |
| subnets\_ips | The IP and cidrs of the subnets being created |
| subnets\_names | The names of the subnets being created |
| subnets\_private\_access | Whether the subnets will have access to Google API's without a public IP |
| subnets\_regions | The region where subnets will be created |
| subnets\_secondary\_ranges | The secondary ranges associated with these subnets |

[^]: (autogen_docs_end)
14 changes: 4 additions & 10 deletions examples/delete_default_gateway_routes/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,24 @@
*/

locals {
network_name = "test-network-${random_string.random_suffix.result}"
}

resource "random_string" "random_suffix" {
length = 4
upper = "false"
special = "false"
subnet_01 = "${var.network_name}-subnet-01"
}

module "test-vpc-module" {
source = "../../"
project_id = "${var.project_id}"
network_name = "${local.network_name}"
network_name = "${var.network_name}"
delete_default_internet_gateway_routes = "true"

subnets = [
{
subnet_name = "subnet-41"
subnet_name = "${local.subnet_01}"
subnet_ip = "10.20.30.0/24"
subnet_region = "us-west1"
},
]

secondary_ranges = {
subnet-41 = []
"${local.subnet_01}" = []
}
}
4 changes: 4 additions & 0 deletions examples/delete_default_gateway_routes/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@
variable "project_id" {
description = "The project ID to host the network in"
}

variable "network_name" {
description = "The name of the VPC network being created"
}
41 changes: 21 additions & 20 deletions examples/multi_vpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,35 @@ This example configures a host network project with two separate networks.

[^]: (autogen_docs_start)


## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| project_id | The project ID to host the network in | string | - | yes |
| network\_01\_name | The name of the first VPC network being created | string | n/a | yes |
| network\_02\_name | The name of the second VPC network being created | string | n/a | yes |
| project\_id | The project ID to host the network in | string | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| network_01_name | The name of the VPC network-01 |
| network_01_routes | The routes associated with network-01 |
| network_01_self_link | The URI of the VPC network-01 |
| network_01_subnets | The names of the subnets being created on network-01 |
| network_01_subnets_flow_logs | Whether the subnets will have VPC flow logs enabled |
| network_01_subnets_ips | The IP and cidrs of the subnets being created on network-01 |
| network_01_subnets_private_access | Whether the subnets will have access to Google API's without a public IP on network-01 |
| network_01_subnets_regions | The region where the subnets will be created on network-01 |
| network_01_subnets_secondary_ranges | The secondary ranges associated with these subnets on network-01 |
| network_02_name | The name of the VPC network-02 |
| network_02_routes | The routes associated with network-02 |
| network_02_self_link | The URI of the VPC network-02 |
| network_02_subnets | The names of the subnets being created on network-02 |
| network_02_subnets_flow_logs | Whether the subnets will have VPC flow logs enabled |
| network_02_subnets_ips | The IP and cidrs of the subnets being created on network-02 |
| network_02_subnets_private_access | Whether the subnets will have access to Google API's without a public IP on network-02 |
| network_02_subnets_regions | The region where the subnets will be created on network-02 |
| network_02_subnets_secondary_ranges | The secondary ranges associated with these subnets on network-02 |
| network\_01\_name | The name of the VPC network-01 |
| network\_01\_routes | The routes associated with network-01 |
| network\_01\_self\_link | The URI of the VPC network-01 |
| network\_01\_subnets | The names of the subnets being created on network-01 |
| network\_01\_subnets\_flow\_logs | Whether the subnets will have VPC flow logs enabled |
| network\_01\_subnets\_ips | The IP and cidrs of the subnets being created on network-01 |
| network\_01\_subnets\_private\_access | Whether the subnets will have access to Google API's without a public IP on network-01 |
| network\_01\_subnets\_regions | The region where the subnets will be created on network-01 |
| network\_01\_subnets\_secondary\_ranges | The secondary ranges associated with these subnets on network-01 |
| network\_02\_name | The name of the VPC network-02 |
| network\_02\_routes | The routes associated with network-02 |
| network\_02\_self\_link | The URI of the VPC network-02 |
| network\_02\_subnets | The names of the subnets being created on network-02 |
| network\_02\_subnets\_flow\_logs | Whether the subnets will have VPC flow logs enabled |
| network\_02\_subnets\_ips | The IP and cidrs of the subnets being created on network-02 |
| network\_02\_subnets\_private\_access | Whether the subnets will have access to Google API's without a public IP on network-02 |
| network\_02\_subnets\_regions | The region where the subnets will be created on network-02 |
| network\_02\_subnets\_secondary\_ranges | The secondary ranges associated with these subnets on network-02 |

[^]: (autogen_docs_end)
Loading

0 comments on commit fc7d126

Please sign in to comment.