Migrate bigtable-instance tests
This commit is contained in:
parent
5f82938739
commit
461f7780c2
|
@ -32,7 +32,7 @@ module "bigtable-instance" {
|
|||
"roles/bigtable.user" = ["user:viewer@testdomain.com"]
|
||||
}
|
||||
}
|
||||
# tftest modules=1 resources=4
|
||||
# tftest modules=1 resources=4 inventory=simple.yaml
|
||||
```
|
||||
|
||||
### Instance with tables and column families
|
||||
|
@ -65,7 +65,7 @@ module "bigtable-instance" {
|
|||
}
|
||||
}
|
||||
}
|
||||
# tftest modules=1 resources=4
|
||||
# tftest modules=1 resources=4 inventory=columns.yaml
|
||||
```
|
||||
|
||||
### Instance with replication enabled
|
||||
|
@ -88,7 +88,7 @@ module "bigtable-instance" {
|
|||
}
|
||||
}
|
||||
}
|
||||
# tftest modules=1 resources=1
|
||||
# tftest modules=1 resources=1 inventory=replication.yaml
|
||||
```
|
||||
|
||||
### Instance with garbage collection policy
|
||||
|
@ -118,7 +118,7 @@ module "bigtable-instance" {
|
|||
}
|
||||
}
|
||||
}
|
||||
# tftest modules=1 resources=3
|
||||
# tftest modules=1 resources=3 inventory=gc.yaml
|
||||
```
|
||||
|
||||
### Instance with default garbage collection policy
|
||||
|
@ -172,7 +172,7 @@ module "bigtable-instance" {
|
|||
}
|
||||
}
|
||||
}
|
||||
# tftest modules=1 resources=1
|
||||
# tftest modules=1 resources=1 inventory=static.yaml
|
||||
```
|
||||
|
||||
### Instance with autoscaling (based on CPU only)
|
||||
|
@ -198,7 +198,7 @@ module "bigtable-instance" {
|
|||
|
||||
|
||||
}
|
||||
# tftest modules=1 resources=1
|
||||
# tftest modules=1 resources=1 inventory=autoscaling1.yaml
|
||||
```
|
||||
|
||||
### Instance with autoscaling (based on CPU and/or storage)
|
||||
|
@ -222,7 +222,7 @@ module "bigtable-instance" {
|
|||
}
|
||||
}
|
||||
}
|
||||
# tftest modules=1 resources=1
|
||||
# tftest modules=1 resources=1 inventory=autoscaling2.yaml
|
||||
```
|
||||
<!-- BEGIN TFDOC -->
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ module "container_registry" {
|
|||
"roles/storage.admin" = ["group:cicd@example.com"]
|
||||
}
|
||||
}
|
||||
# tftest modules=1 resources=2
|
||||
# tftest modules=1 resources=2 inventory=simple.yaml
|
||||
```
|
||||
<!-- BEGIN TFDOC -->
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
# Copyright 2023 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.
|
||||
|
||||
values:
|
||||
module.bigtable-instance.google_bigtable_instance.default:
|
||||
cluster:
|
||||
- autoscaling_config:
|
||||
- cpu_target: 70
|
||||
max_nodes: 7
|
||||
min_nodes: 3
|
||||
cluster_id: my-cluster
|
||||
storage_type: SSD
|
||||
zone: europe-southwest1-b
|
||||
name: instance
|
||||
project: my-project
|
||||
|
||||
counts:
|
||||
google_bigtable_instance: 1
|
|
@ -0,0 +1,30 @@
|
|||
# Copyright 2023 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.
|
||||
|
||||
values:
|
||||
module.bigtable-instance.google_bigtable_instance.default:
|
||||
cluster:
|
||||
- autoscaling_config:
|
||||
- cpu_target: 70
|
||||
max_nodes: 7
|
||||
min_nodes: 3
|
||||
storage_target: 4096
|
||||
cluster_id: my-cluster
|
||||
storage_type: SSD
|
||||
zone: europe-southwest1-a
|
||||
name: instance
|
||||
project: my-project
|
||||
|
||||
counts:
|
||||
google_bigtable_instance: 1
|
|
@ -0,0 +1,38 @@
|
|||
# Copyright 2023 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.
|
||||
|
||||
values:
|
||||
module.bigtable-instance.google_bigtable_table.default["test2"]:
|
||||
column_family:
|
||||
- family: cf1
|
||||
- family: cf2
|
||||
- family: cf3
|
||||
instance_name: instance
|
||||
name: test2
|
||||
project: my-project
|
||||
split_keys:
|
||||
- a
|
||||
- b
|
||||
- c
|
||||
module.bigtable-instance.google_bigtable_table.default["test3"]:
|
||||
column_family:
|
||||
- family: cf1
|
||||
instance_name: instance
|
||||
name: test3
|
||||
project: my-project
|
||||
split_keys: []
|
||||
|
||||
counts:
|
||||
google_bigtable_instance: 1
|
||||
google_bigtable_table: 3
|
|
@ -0,0 +1,29 @@
|
|||
# Copyright 2023 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.
|
||||
|
||||
values:
|
||||
module.bigtable-instance.google_bigtable_gc_policy.default["0"]:
|
||||
column_family: cf1
|
||||
deletion_policy: ABANDON
|
||||
gc_rules: null
|
||||
instance_name: instance
|
||||
max_age:
|
||||
- duration: 18h
|
||||
max_version: []
|
||||
mode: null
|
||||
project: my-project
|
||||
table: test1
|
||||
|
||||
counts:
|
||||
google_bigtable_gc_policy: 1
|
|
@ -0,0 +1,36 @@
|
|||
# Copyright 2023 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.
|
||||
|
||||
values:
|
||||
module.bigtable-instance.google_bigtable_instance.default:
|
||||
cluster:
|
||||
- autoscaling_config: []
|
||||
cluster_id: first-cluster
|
||||
storage_type: SSD
|
||||
zone: europe-west1-b
|
||||
- autoscaling_config: []
|
||||
cluster_id: second-cluster
|
||||
storage_type: SSD
|
||||
zone: europe-southwest1-a
|
||||
- autoscaling_config: []
|
||||
cluster_id: third-cluster
|
||||
storage_type: SSD
|
||||
zone: us-central1-b
|
||||
deletion_protection: true
|
||||
instance_type: PRODUCTION
|
||||
name: instance
|
||||
project: my-project
|
||||
|
||||
counts:
|
||||
google_bigtable_instance: 1
|
|
@ -0,0 +1,52 @@
|
|||
# Copyright 2023 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.
|
||||
|
||||
values:
|
||||
module.bigtable-instance.google_bigtable_instance.default:
|
||||
cluster:
|
||||
- autoscaling_config: []
|
||||
cluster_id: my-cluster
|
||||
storage_type: SSD
|
||||
zone: europe-west1-b
|
||||
deletion_protection: true
|
||||
instance_type: PRODUCTION
|
||||
name: instance
|
||||
project: my-project
|
||||
module.bigtable-instance.google_bigtable_instance_iam_binding.default["roles/bigtable.user"]:
|
||||
condition: []
|
||||
instance: instance
|
||||
members:
|
||||
- user:viewer@testdomain.com
|
||||
project: my-project
|
||||
role: roles/bigtable.user
|
||||
module.bigtable-instance.google_bigtable_table.default["test1"]:
|
||||
column_family: []
|
||||
instance_name: instance
|
||||
name: test1
|
||||
project: my-project
|
||||
split_keys: []
|
||||
module.bigtable-instance.google_bigtable_table.default["test2"]:
|
||||
column_family: []
|
||||
instance_name: instance
|
||||
name: test2
|
||||
project: my-project
|
||||
split_keys:
|
||||
- a
|
||||
- b
|
||||
- c
|
||||
|
||||
counts:
|
||||
google_bigtable_instance: 1
|
||||
google_bigtable_instance_iam_binding: 1
|
||||
google_bigtable_table: 2
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2022 Google LLC
|
||||
# Copyright 2023 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -11,3 +11,17 @@
|
|||
# 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.
|
||||
|
||||
values:
|
||||
module.bigtable-instance.google_bigtable_instance.default:
|
||||
cluster:
|
||||
- autoscaling_config: []
|
||||
cluster_id: my-cluster
|
||||
num_nodes: 5
|
||||
storage_type: SSD
|
||||
zone: europe-west1-b
|
||||
name: instance
|
||||
project: my-project
|
||||
|
||||
counts:
|
||||
google_bigtable_instance: 1
|
|
@ -1,36 +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 = "../../../../modules/bigtable-instance"
|
||||
project_id = "my-project"
|
||||
name = "test"
|
||||
iam = {
|
||||
"roles/bigtable.user" = ["user:me@example.com"]
|
||||
}
|
||||
tables = {
|
||||
test-1 = {},
|
||||
test-2 = {
|
||||
split_keys = ["a", "b", "c"]
|
||||
}
|
||||
|
||||
}
|
||||
clusters = {
|
||||
test = {
|
||||
zone = var.zone
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,20 +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.
|
||||
*/
|
||||
|
||||
variable "zone" {
|
||||
type = string
|
||||
default = "europe-west1-b"
|
||||
}
|
|
@ -1,42 +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.
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def resources(plan_runner):
|
||||
_, resources = plan_runner()
|
||||
return resources
|
||||
|
||||
|
||||
def test_resource_count(resources):
|
||||
"Test number of resources created."
|
||||
assert len(resources) == 4
|
||||
|
||||
|
||||
def test_iam(resources):
|
||||
"Test IAM binding resources."
|
||||
bindings = [r['values'] for r in resources if r['type']
|
||||
== 'google_bigtable_instance_iam_binding']
|
||||
assert len(bindings) == 1
|
||||
assert bindings[0]['role'] == 'roles/bigtable.user'
|
||||
|
||||
|
||||
def test_tables(resources):
|
||||
"Test table resources."
|
||||
subs = [r['values'] for r in resources if r['type']
|
||||
== 'google_bigtable_table']
|
||||
assert len(subs) == 2
|
||||
assert set(s['name'] for s in subs) == set(['test-1', 'test-2'])
|
Loading…
Reference in New Issue