From aea24f24f87f688f402556a643d2d652a1c76fed Mon Sep 17 00:00:00 2001 From: Ludovico Magnocavallo Date: Mon, 12 Sep 2022 11:54:18 +0200 Subject: [PATCH] fix blueprint tests --- blueprints/gke/multitenant-fleet/README.md | 7 +- tests/blueprints/foundations/__init__.py | 13 ---- .../foundations/business_units/__init__.py | 13 ---- .../business_units/fixture/main.tf | 23 ------- .../business_units/fixture/variables.tf | 35 ---------- .../foundations/business_units/test_plan.py | 19 ------ .../foundations/environments/__init__.py | 13 ---- .../foundations/environments/fixture/main.tf | 28 -------- .../environments/fixture/variables.tf | 66 ------------------- .../foundations/environments/test_plan.py | 51 -------------- tests/blueprints/gke/__init__.py | 0 .../binauthz/__init__.py | 0 .../binauthz/fixture/main.tf | 2 +- .../binauthz/fixture/variables.tf | 0 .../binauthz/test_plan.py | 0 .../__init__.py | 0 .../fixture/main.tf | 2 +- .../fixture/variables.tf | 0 .../test_plan.py | 0 19 files changed, 5 insertions(+), 267 deletions(-) delete mode 100644 tests/blueprints/foundations/__init__.py delete mode 100644 tests/blueprints/foundations/business_units/__init__.py delete mode 100644 tests/blueprints/foundations/business_units/fixture/main.tf delete mode 100644 tests/blueprints/foundations/business_units/fixture/variables.tf delete mode 100644 tests/blueprints/foundations/business_units/test_plan.py delete mode 100644 tests/blueprints/foundations/environments/__init__.py delete mode 100644 tests/blueprints/foundations/environments/fixture/main.tf delete mode 100644 tests/blueprints/foundations/environments/fixture/variables.tf delete mode 100644 tests/blueprints/foundations/environments/test_plan.py create mode 100644 tests/blueprints/gke/__init__.py rename tests/blueprints/{cloud_operations => gke}/binauthz/__init__.py (100%) rename tests/blueprints/{cloud_operations => gke}/binauthz/fixture/main.tf (90%) rename tests/blueprints/{cloud_operations => gke}/binauthz/fixture/variables.tf (100%) rename tests/blueprints/{cloud_operations => gke}/binauthz/test_plan.py (100%) rename tests/blueprints/{cloud_operations => gke}/multi_cluster_mesh_gke_fleet_api/__init__.py (100%) rename tests/blueprints/{cloud_operations => gke}/multi_cluster_mesh_gke_fleet_api/fixture/main.tf (90%) rename tests/blueprints/{cloud_operations => gke}/multi_cluster_mesh_gke_fleet_api/fixture/variables.tf (100%) rename tests/blueprints/{cloud_operations => gke}/multi_cluster_mesh_gke_fleet_api/test_plan.py (100%) diff --git a/blueprints/gke/multitenant-fleet/README.md b/blueprints/gke/multitenant-fleet/README.md index dd6d97ff..68909b82 100644 --- a/blueprints/gke/multitenant-fleet/README.md +++ b/blueprints/gke/multitenant-fleet/README.md @@ -45,7 +45,7 @@ The following example shows how to deploy a single cluster and a single node poo ```hcl module "gke" { - source = "./fabric/blueprints/gke-serverless/multitenant-fleet/" + source = "./fabric/blueprints/gke/multitenant-fleet/" project_id = var.project_id billing_account_id = var.billing_account_id folder_id = var.folder_id @@ -106,10 +106,9 @@ The first cluster `cluster-euw1` defines the mandatory configuration parameters On the other hand, the second cluster (`cluster-euw3`) defines its own configuration by providing a value to the `overrides` key. - ```hcl module "gke" { - source = "./fabric/blueprints/gke-serverless/multitenant-fleet/" + source = "./fabric/blueprints/gke/multitenant-fleet/" project_id = var.project_id billing_account_id = var.billing_account_id folder_id = var.folder_id @@ -200,7 +199,7 @@ This example deploys two clusters and configures several GKE Fleet features: ```hcl module "gke" { - source = "./fabric/blueprints/gke-serverless/multitenant-fleet/" + source = "./fabric/blueprints/gke/multitenant-fleet/" project_id = var.project_id billing_account_id = var.billing_account_id folder_id = var.folder_id diff --git a/tests/blueprints/foundations/__init__.py b/tests/blueprints/foundations/__init__.py deleted file mode 100644 index 6d6d1266..00000000 --- a/tests/blueprints/foundations/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2022 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. diff --git a/tests/blueprints/foundations/business_units/__init__.py b/tests/blueprints/foundations/business_units/__init__.py deleted file mode 100644 index 6d6d1266..00000000 --- a/tests/blueprints/foundations/business_units/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2022 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. diff --git a/tests/blueprints/foundations/business_units/fixture/main.tf b/tests/blueprints/foundations/business_units/fixture/main.tf deleted file mode 100644 index 2609c1c9..00000000 --- a/tests/blueprints/foundations/business_units/fixture/main.tf +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright 2022 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 "test" { - source = "../../../../../blueprints/foundations/business-units" - billing_account_id = var.billing_account_id - organization_id = var.organization_id - prefix = var.prefix - root_node = var.root_node -} diff --git a/tests/blueprints/foundations/business_units/fixture/variables.tf b/tests/blueprints/foundations/business_units/fixture/variables.tf deleted file mode 100644 index a8997595..00000000 --- a/tests/blueprints/foundations/business_units/fixture/variables.tf +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2022 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 -# -# https://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. - -variable "billing_account_id" { - type = string - default = "1234-5678-9012" -} - -variable "organization_id" { - type = string - default = "organizations/1234567890" -} - -variable "prefix" { - description = "Prefix used for resources that need unique names." - type = string - default = "test" -} - -variable "root_node" { - description = "Root node for the new hierarchy, either 'organizations/org_id' or 'folders/folder_id'." - type = string - default = "folders/1234567890" -} diff --git a/tests/blueprints/foundations/business_units/test_plan.py b/tests/blueprints/foundations/business_units/test_plan.py deleted file mode 100644 index 816d514b..00000000 --- a/tests/blueprints/foundations/business_units/test_plan.py +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2022 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. - -def test_resources(e2e_plan_runner): - "Test that plan works and the numbers of resources is as expected." - modules, resources = e2e_plan_runner() - assert len(modules) == 8 - assert len(resources) == 83 diff --git a/tests/blueprints/foundations/environments/__init__.py b/tests/blueprints/foundations/environments/__init__.py deleted file mode 100644 index 6d6d1266..00000000 --- a/tests/blueprints/foundations/environments/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2022 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. diff --git a/tests/blueprints/foundations/environments/fixture/main.tf b/tests/blueprints/foundations/environments/fixture/main.tf deleted file mode 100644 index 21832e9d..00000000 --- a/tests/blueprints/foundations/environments/fixture/main.tf +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright 2022 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 "test" { - source = "../../../../../blueprints/foundations/environments" - billing_account_id = var.billing_account_id - environments = var.environments - iam_audit_viewers = var.iam_audit_viewers - iam_shared_owners = var.iam_shared_owners - iam_terraform_owners = var.iam_terraform_owners - iam_xpn_config = var.iam_xpn_config - organization_id = var.organization_id - prefix = var.prefix - root_node = var.root_node -} diff --git a/tests/blueprints/foundations/environments/fixture/variables.tf b/tests/blueprints/foundations/environments/fixture/variables.tf deleted file mode 100644 index 48ce5fde..00000000 --- a/tests/blueprints/foundations/environments/fixture/variables.tf +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright 2022 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 -# -# https://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. - -variable "billing_account_id" { - type = string - default = "1234-5678-9012" -} - -variable "environments" { - type = list(string) - default = ["test", "prod"] -} - -variable "iam_audit_viewers" { - type = list(string) - default = ["user:audit-1@example.org", "user:audit2@example.org"] -} - -variable "iam_shared_owners" { - type = list(string) - default = ["user:shared-1@example.org", "user:shared-2@example.org"] -} - -variable "iam_terraform_owners" { - type = list(string) - default = ["user:tf-1@example.org", "user:tf-2@example.org"] -} - -variable "iam_xpn_config" { - type = object({ - grant = bool - target_org = bool - }) - default = { - grant = true - target_org = false - } -} - -variable "organization_id" { - type = string - default = "" -} - -variable "prefix" { - description = "Prefix used for resources that need unique names." - type = string - default = "test" -} - -variable "root_node" { - description = "Root node for the new hierarchy, either 'organizations/org_id' or 'folders/folder_id'." - type = string - default = "folders/1234567890" -} diff --git a/tests/blueprints/foundations/environments/test_plan.py b/tests/blueprints/foundations/environments/test_plan.py deleted file mode 100644 index 7e8762df..00000000 --- a/tests/blueprints/foundations/environments/test_plan.py +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright 2022 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. - - -def test_folder_roles(e2e_plan_runner): - "Test folder roles." - modules, _ = e2e_plan_runner(refresh=False) - for env in ['test', 'prod']: - resources = modules[f'module.test.module.environment-folders["{env}"]'] - folders = [r for r in resources if r['type'] == 'google_folder'] - assert len(folders) == 1 - folder = folders[0] - assert folder['values']['display_name'] == env - - bindings = [r['index'] - for r in resources if r['type'] == 'google_folder_iam_binding'] - assert len(bindings) == 5 - - -def test_org_roles(e2e_plan_runner): - "Test folder roles." - tf_vars = { - 'organization_id': 'organizations/123', - 'iam_xpn_config': '{grant = true, target_org = true}' - } - modules, _ = e2e_plan_runner(refresh=False, **tf_vars) - for env in ['test', 'prod']: - resources = modules[f'module.test.module.environment-folders["{env}"]'] - folder_bindings = [r['index'] - for r in resources if r['type'] == 'google_folder_iam_binding'] - assert len(folder_bindings) == 4 - - resources = modules[f'module.test.module.tf-service-accounts["{env}"]'] - org_bindings = [r for r in resources - if r['type'] == 'google_organization_iam_member'] - assert len(org_bindings) == 2 - assert {b['values']['role'] for b in org_bindings} == { - 'roles/resourcemanager.organizationViewer', - 'roles/compute.xpnAdmin' - } diff --git a/tests/blueprints/gke/__init__.py b/tests/blueprints/gke/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/blueprints/cloud_operations/binauthz/__init__.py b/tests/blueprints/gke/binauthz/__init__.py similarity index 100% rename from tests/blueprints/cloud_operations/binauthz/__init__.py rename to tests/blueprints/gke/binauthz/__init__.py diff --git a/tests/blueprints/cloud_operations/binauthz/fixture/main.tf b/tests/blueprints/gke/binauthz/fixture/main.tf similarity index 90% rename from tests/blueprints/cloud_operations/binauthz/fixture/main.tf rename to tests/blueprints/gke/binauthz/fixture/main.tf index c815e658..eefdacc8 100644 --- a/tests/blueprints/cloud_operations/binauthz/fixture/main.tf +++ b/tests/blueprints/gke/binauthz/fixture/main.tf @@ -15,7 +15,7 @@ */ module "test" { - source = "../../../../../blueprints/cloud-operations/binauthz" + source = "../../../../../blueprints/gke/binauthz" project_create = var.project_create project_id = var.project_id } diff --git a/tests/blueprints/cloud_operations/binauthz/fixture/variables.tf b/tests/blueprints/gke/binauthz/fixture/variables.tf similarity index 100% rename from tests/blueprints/cloud_operations/binauthz/fixture/variables.tf rename to tests/blueprints/gke/binauthz/fixture/variables.tf diff --git a/tests/blueprints/cloud_operations/binauthz/test_plan.py b/tests/blueprints/gke/binauthz/test_plan.py similarity index 100% rename from tests/blueprints/cloud_operations/binauthz/test_plan.py rename to tests/blueprints/gke/binauthz/test_plan.py diff --git a/tests/blueprints/cloud_operations/multi_cluster_mesh_gke_fleet_api/__init__.py b/tests/blueprints/gke/multi_cluster_mesh_gke_fleet_api/__init__.py similarity index 100% rename from tests/blueprints/cloud_operations/multi_cluster_mesh_gke_fleet_api/__init__.py rename to tests/blueprints/gke/multi_cluster_mesh_gke_fleet_api/__init__.py diff --git a/tests/blueprints/cloud_operations/multi_cluster_mesh_gke_fleet_api/fixture/main.tf b/tests/blueprints/gke/multi_cluster_mesh_gke_fleet_api/fixture/main.tf similarity index 90% rename from tests/blueprints/cloud_operations/multi_cluster_mesh_gke_fleet_api/fixture/main.tf rename to tests/blueprints/gke/multi_cluster_mesh_gke_fleet_api/fixture/main.tf index 3db317d9..47524fa5 100644 --- a/tests/blueprints/cloud_operations/multi_cluster_mesh_gke_fleet_api/fixture/main.tf +++ b/tests/blueprints/gke/multi_cluster_mesh_gke_fleet_api/fixture/main.tf @@ -15,7 +15,7 @@ */ module "test" { - source = "../../../../../blueprints/cloud-operations/multi-cluster-mesh-gke-fleet-api" + source = "../../../../../blueprints/gke/multi-cluster-mesh-gke-fleet-api" billing_account_id = var.billing_account_id parent = var.parent host_project_id = var.host_project_id diff --git a/tests/blueprints/cloud_operations/multi_cluster_mesh_gke_fleet_api/fixture/variables.tf b/tests/blueprints/gke/multi_cluster_mesh_gke_fleet_api/fixture/variables.tf similarity index 100% rename from tests/blueprints/cloud_operations/multi_cluster_mesh_gke_fleet_api/fixture/variables.tf rename to tests/blueprints/gke/multi_cluster_mesh_gke_fleet_api/fixture/variables.tf diff --git a/tests/blueprints/cloud_operations/multi_cluster_mesh_gke_fleet_api/test_plan.py b/tests/blueprints/gke/multi_cluster_mesh_gke_fleet_api/test_plan.py similarity index 100% rename from tests/blueprints/cloud_operations/multi_cluster_mesh_gke_fleet_api/test_plan.py rename to tests/blueprints/gke/multi_cluster_mesh_gke_fleet_api/test_plan.py