fix blueprint tests

This commit is contained in:
Ludovico Magnocavallo 2022-09-12 11:54:18 +02:00
parent 02ff697fd7
commit aea24f24f8
19 changed files with 5 additions and 267 deletions

View File

@ -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

View File

@ -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.

View File

@ -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.

View File

@ -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
}

View File

@ -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"
}

View File

@ -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

View File

@ -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.

View File

@ -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
}

View File

@ -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"
}

View File

@ -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'
}

View File

View File

@ -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
}

View File

@ -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