Skip to content

Commit

Permalink
Merge pull request #1327 from GoogleCloudPlatform/jccb/migrate-tests
Browse files Browse the repository at this point in the history
Migrate more tests
  • Loading branch information
juliocc authored Apr 17, 2023
2 parents 9072c34 + e8ff508 commit c28f7e6
Show file tree
Hide file tree
Showing 86 changed files with 1,384 additions and 1,605 deletions.
14 changes: 7 additions & 7 deletions modules/bigtable-instance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module "bigtable-instance" {
"roles/bigtable.user" = ["user:[email protected]"]
}
}
# tftest modules=1 resources=4
# tftest modules=1 resources=4 inventory=simple.yaml
```

### Instance with tables and column families
Expand Down Expand Up @@ -65,7 +65,7 @@ module "bigtable-instance" {
}
}
}
# tftest modules=1 resources=4
# tftest modules=1 resources=4 inventory=columns.yaml
```

### Instance with replication enabled
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -222,7 +222,7 @@ module "bigtable-instance" {
}
}
}
# tftest modules=1 resources=1
# tftest modules=1 resources=1 inventory=autoscaling2.yaml
```
<!-- BEGIN TFDOC -->

Expand Down
2 changes: 1 addition & 1 deletion modules/cloud-identity-group/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module "group" {
"[email protected]"
]
}
# tftest modules=1 resources=4
# tftest modules=1 resources=4 inventory=members.yaml
```

### Group with managers
Expand Down
29 changes: 26 additions & 3 deletions modules/cloudsql-instance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module "db" {
database_version = "POSTGRES_13"
tier = "db-g1-small"
}
# tftest modules=3 resources=9
# tftest modules=3 resources=9 inventory=simple.yaml
```

## Cross-regional read replica
Expand All @@ -50,6 +50,7 @@ module "db" {
source = "./fabric/modules/cloudsql-instance"
project_id = var.project_id
network = var.vpc.self_link
prefix = "myprefix"
name = "db"
region = "europe-west1"
database_version = "POSTGRES_13"
Expand All @@ -60,7 +61,7 @@ module "db" {
replica2 = { region = "us-central1", encryption_key_name = null }
}
}
# tftest modules=1 resources=3
# tftest modules=1 resources=3 inventory=replicas.yaml
```

## Custom flags, databases and users
Expand Down Expand Up @@ -91,7 +92,7 @@ module "db" {
user2 = "mypassword"
}
}
# tftest modules=1 resources=6
# tftest modules=1 resources=6 inventory=custom.yaml
```

### CMEK encryption
Expand Down Expand Up @@ -140,6 +141,28 @@ module "db" {
# tftest modules=3 resources=10
```

### Enable public IP

Use `ipv_enabled` to create instances with a public IP.

```hcl
module "db" {
source = "./fabric/modules/cloudsql-instance"
project_id = var.project_id
network = var.vpc.self_link
name = "db"
region = "europe-west1"
tier = "db-g1-small"
database_version = "MYSQL_8_0"
ipv4_enabled = true
replicas = {
replica1 = { region = "europe-west3", encryption_key_name = null }
}
}
# tftest modules=1 resources=2 inventory=public-ip.yaml
```

<!-- BEGIN TFDOC -->

## Variables
Expand Down
2 changes: 1 addition & 1 deletion modules/container-registry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module "container_registry" {
"roles/storage.admin" = ["group:[email protected]"]
}
}
# tftest modules=1 resources=2
# tftest modules=1 resources=2 inventory=simple.yaml
```
<!-- BEGIN TFDOC -->

Expand Down
2 changes: 1 addition & 1 deletion modules/endpoints/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module "endpoint" {
]
}
}
# tftest modules=1 resources=2 files=openapi
# tftest modules=1 resources=2 files=openapi inventory=simple.yaml
```

```yaml
Expand Down
22 changes: 20 additions & 2 deletions modules/logging-bucket/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module "bucket" {
parent = var.project_id
id = "mybucket"
}
# tftest modules=1 resources=1
# tftest modules=1 resources=1 inventory=project.yaml
```


Expand All @@ -37,7 +37,25 @@ module "bucket-default" {
id = "_Default"
retention = 10
}
# tftest modules=2 resources=2
# tftest modules=2 resources=2 inventory=retention.yaml
```

### Organization and billing account buckets
```hcl
module "bucket-organization" {
source = "./fabric/modules/logging-bucket"
parent_type = "organization"
parent = "organizations/012345"
id = "mybucket"
}
module "bucket-billing-account" {
source = "./fabric/modules/logging-bucket"
parent_type = "billing_account"
parent = "012345"
id = "mybucket"
}
# tftest modules=2 resources=2 inventory=org-ba.yaml
```
<!-- BEGIN TFDOC -->

Expand Down
6 changes: 3 additions & 3 deletions modules/pubsub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module "pubsub" {
"roles/pubsub.subscriber" = ["user:[email protected]"]
}
}
# tftest modules=1 resources=3
# tftest modules=1 resources=3 inventory=simple.yaml
```

### Topic with schema
Expand Down Expand Up @@ -48,7 +48,7 @@ module "topic_with_schema" {
})
}
}
# tftest modules=1 resources=2
# tftest modules=1 resources=2 inventory=schema.yaml
```

### Subscriptions
Expand All @@ -74,7 +74,7 @@ module "pubsub" {
}
}
}
# tftest modules=1 resources=3
# tftest modules=1 resources=3 inventory=subscriptions.yaml
```

### Push subscriptions
Expand Down
4 changes: 2 additions & 2 deletions modules/secret-manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module "secret-manager" {
}
}
}
# tftest modules=1 resources=4
# tftest modules=1 resources=4 inventory=iam.yaml
```

### Secret versions
Expand All @@ -70,7 +70,7 @@ module "secret-manager" {
}
}
}
# tftest modules=1 resources=5
# tftest modules=1 resources=5 inventory=versions.yaml
```
<!-- BEGIN TFDOC -->

Expand Down
6 changes: 3 additions & 3 deletions modules/service-directory/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module "service-directory" {
]
}
}
# tftest modules=1 resources=2
# tftest modules=1 resources=2 inventory=simple.yaml
```

### Services with IAM and endpoints
Expand Down Expand Up @@ -50,7 +50,7 @@ module "service-directory" {
"one/second" = { address = "127.0.0.2", port = 80, metadata = {} }
}
}
# tftest modules=1 resources=5
# tftest modules=1 resources=5 inventory=services.yaml
```

### DNS based zone
Expand Down Expand Up @@ -85,7 +85,7 @@ module "dns-sd" {
client_networks = [var.vpc.self_link]
service_directory_namespace = module.service-directory.id
}
# tftest modules=2 resources=5
# tftest modules=2 resources=5 inventory=dns.yaml
```
<!-- BEGIN TFDOC -->

Expand Down
4 changes: 2 additions & 2 deletions modules/source-repository/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module "repo" {
"roles/source.reader" = ["user:[email protected]"]
}
}
# tftest modules=1 resources=2
# tftest modules=1 resources=2 inventory=simple.yaml
```

### Repository with Cloud Build trigger
Expand All @@ -41,7 +41,7 @@ module "repo" {
}
}
}
# tftest modules=1 resources=2
# tftest modules=1 resources=2 inventory=trigger.yaml
```

<!-- TFDOC OPTS files:1 -->
Expand Down
10 changes: 5 additions & 5 deletions modules/vpc-sc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module "test" {
title = "vpcsc-policy"
}
}
# tftest modules=1 resources=1
# tftest modules=1 resources=1 inventory=access-policy.yaml
```

If you need the module to create a scoped policy for you, specify 'scopes' of the policy in the `access_policy_create` variable:
Expand All @@ -46,7 +46,7 @@ module "test" {
scopes = ["folders/456789"]
}
}
# tftest modules=1 resources=1
# tftest modules=1 resources=1 inventory=scoped-access-policy.yaml
```

### Access levels
Expand All @@ -72,7 +72,7 @@ module "test" {
}
}
}
# tftest modules=1 resources=2
# tftest modules=1 resources=2 inventory=access-levels.yaml
```

### Service perimeters
Expand Down Expand Up @@ -103,7 +103,7 @@ module "test" {
}
}
}
# tftest modules=1 resources=2
# tftest modules=1 resources=2 inventory=bridge.yaml
```

#### Regular type
Expand Down Expand Up @@ -172,7 +172,7 @@ module "test" {
}
}
}
# tftest modules=1 resources=3
# tftest modules=1 resources=3 inventory=regular.yaml
```

## Notes
Expand Down
29 changes: 29 additions & 0 deletions tests/modules/bigtable_instance/examples/autoscaling1.yaml
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions tests/modules/bigtable_instance/examples/autoscaling2.yaml
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit c28f7e6

Please sign in to comment.