Skip to content

Commit 3d0e73d

Browse files
authored
refactor: Replace old integration tests for blueprint (#276)
* refactor: adjust examples * refactor: adjust fixtures * feat: (Blueprint) mssql ha module * feat: (Blueprint) mssql public module * feat: (Blueprint) mysql ha module * feat: (Blueprint) mysql private module * feat: (Blueprint) mysql public module * feat: (Blueprint) postegresql ha module * feat: (Blueprint) postegresql public module * feat: (Blueprint) postegresql public iam module * feat: go mod update * feat: remove kitchen + refactor cloudbuild * fix: mysql hd users count * refactor: change test discovery to CLI * refactor: hardcode test's
1 parent 0d53d9f commit 3d0e73d

File tree

35 files changed

+1844
-1566
lines changed

35 files changed

+1844
-1566
lines changed

build/int.cloudbuild.yaml

Lines changed: 78 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -21,143 +21,139 @@ steps:
2121
- 'TF_VAR_org_id=$_ORG_ID'
2222
- 'TF_VAR_folder_id=$_FOLDER_ID'
2323
- 'TF_VAR_billing_account=$_BILLING_ACCOUNT'
24-
- id: create-all
24+
- id: init-all
2525
waitFor:
2626
- prepare
2727
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
28-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do create']
28+
args: ['/bin/bash', '-c', 'cft test run all --stage init --verbose']
2929

30-
- id: converge-postgresql-public-local
30+
- id: apply mssql-ha-local
3131
waitFor:
32-
- create-all
32+
- init-all
3333
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
34-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge postgresql-public-local']
35-
timeout: 3600s
36-
- id: verify-postgresql-public-local
34+
args: ['/bin/bash', '-c', 'cft test run TestMsSqlHaModule --stage apply --verbose']
35+
- id: verify mssql-ha-local
3736
waitFor:
38-
- converge-postgresql-public-local
37+
- apply mssql-ha-local
3938
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
40-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify postgresql-public-local']
41-
- id: destroy-postgresql-public-local
39+
args: ['/bin/bash', '-c', 'cft test run TestMsSqlHaModule --stage verify --verbose']
40+
- id: teardown mssql-ha-local
4241
waitFor:
43-
- verify-postgresql-public-local
42+
- verify mssql-ha-local
4443
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
45-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy postgresql-public-local']
46-
timeout: 1800s
44+
args: ['/bin/bash', '-c', 'cft test run TestMsSqlHaModule --stage teardown --verbose']
4745

48-
- id: converge-postgresql-public-iam-local
46+
- id: apply mssql-public-local
4947
waitFor:
50-
- create-all
48+
- init-all
5149
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
52-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge postgresql-public-iam-local']
53-
timeout: 3600s
54-
- id: verify-postgresql-public-iam-local
50+
args: ['/bin/bash', '-c', 'cft test run TestMsSqlPublicModule --stage apply --verbose']
51+
- id: verify mssql-public-local
5552
waitFor:
56-
- converge-postgresql-public-iam-local
53+
- apply mssql-public-local
5754
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
58-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify postgresql-public-iam-local']
59-
- id: destroy-postgresql-public-iam-local
55+
args: ['/bin/bash', '-c', 'cft test run TestMsSqlPublicModule --stage verify --verbose']
56+
- id: teardown mssql-public-local
6057
waitFor:
61-
- verify-postgresql-public-iam-local
58+
- verify mssql-public-local
6259
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
63-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy postgresql-public-iam-local']
64-
timeout: 1800s
60+
args: ['/bin/bash', '-c', 'cft test run TestMsSqlPublicModule --stage teardown --verbose']
6561

66-
- id: converge-mssql-public-local
62+
- id: apply mysql-ha-local
6763
waitFor:
68-
- create-all
64+
- init-all
6965
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
70-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge mssql-public-local']
71-
timeout: 3600s
72-
- id: verify-mssql-public-local
66+
args: ['/bin/bash', '-c', 'cft test run TestMySqlHaModule --stage apply --verbose']
67+
- id: verify mysql-ha-local
7368
waitFor:
74-
- converge-mssql-public-local
69+
- apply mysql-ha-local
7570
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
76-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify mssql-public-local']
77-
- id: destroy-mssql-public-local
71+
args: ['/bin/bash', '-c', 'cft test run TestMySqlHaModule --stage verify --verbose']
72+
- id: teardown mysql-ha-local
7873
waitFor:
79-
- verify-mssql-public-local
74+
- verify mysql-ha-local
8075
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
81-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy mssql-public-local']
82-
timeout: 1800s
76+
args: ['/bin/bash', '-c', 'cft test run TestMySqlHaModule --stage teardown --verbose']
8377

84-
- id: mysql-public
78+
- id: apply mysql-private-local
8579
waitFor:
86-
- prepare
80+
- init-all
81+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
82+
args: ['/bin/bash', '-c', 'cft test run TestMySqlPrivateModule --stage apply --verbose']
83+
- id: verify mysql-private-local
84+
waitFor:
85+
- apply mysql-private-local
86+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
87+
args: ['/bin/bash', '-c', 'cft test run TestMySqlPrivateModule --stage verify --verbose']
88+
- id: teardown mysql-private-local
89+
waitFor:
90+
- verify mysql-private-local
8791
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
88-
args: ['/bin/bash', '-c', 'cft test run TestMySqlPublicModule --verbose']
92+
args: ['/bin/bash', '-c', 'cft test run TestMySqlPrivateModule --stage teardown --verbose']
8993

90-
- id: converge-mysql-ha-local
94+
- id: apply mysql-public-local
9195
waitFor:
92-
- create-all
96+
- init-all
9397
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
94-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge mysql-ha-local']
95-
timeout: 3600s
96-
- id: verify-mysql-ha-local
98+
args: ['/bin/bash', '-c', 'cft test run TestMySqlPublicModule --stage apply --verbose']
99+
- id: verify mysql-public-local
97100
waitFor:
98-
- converge-mysql-ha-local
101+
- apply mysql-public-local
99102
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
100-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify mysql-ha-local']
101-
- id: destroy-mysql-ha-local
103+
args: ['/bin/bash', '-c', 'cft test run TestMySqlPublicModule --stage verify --verbose']
104+
- id: teardown mysql-public-local
102105
waitFor:
103-
- verify-mysql-ha-local
106+
- verify mysql-public-local
104107
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
105-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy mysql-ha-local']
106-
timeout: 1800s
108+
args: ['/bin/bash', '-c', 'cft test run TestMySqlPublicModule --stage teardown --verbose']
107109

108-
- id: converge-postgresql-ha-local
110+
- id: apply postgresql-ha-local
109111
waitFor:
110-
- create-all
112+
- init-all
111113
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
112-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge postgresql-ha-local']
113-
timeout: 3600s
114-
- id: verify-postgresql-ha-local
114+
args: ['/bin/bash', '-c', 'cft test run TestPostgreSqlHaModule --stage apply --verbose']
115+
- id: verify postgresql-ha-local
115116
waitFor:
116-
- converge-postgresql-ha-local
117+
- apply postgresql-ha-local
117118
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
118-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify postgresql-ha-local']
119-
- id: destroy-postgresql-ha-local
119+
args: ['/bin/bash', '-c', 'cft test run TestPostgreSqlHaModule --stage verify --verbose']
120+
- id: teardown postgresql-ha-local
120121
waitFor:
121-
- verify-postgresql-ha-local
122+
- verify postgresql-ha-local
122123
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
123-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy postgresql-ha-local']
124-
timeout: 1800s
124+
args: ['/bin/bash', '-c', 'cft test run TestPostgreSqlHaModule --stage teardown --verbose']
125125

126-
- id: converge-mssql-ha-local
126+
- id: apply postgresql-public-local
127127
waitFor:
128-
- create-all
128+
- init-all
129129
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
130-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge mssql-ha-local']
131-
timeout: 3600s
132-
- id: verify-mssql-ha-local
130+
args: ['/bin/bash', '-c', 'cft test run TestPostgreSqlPublicModule --stage apply --verbose']
131+
- id: verify postgresql-public-local
133132
waitFor:
134-
- converge-mssql-ha-local
133+
- apply postgresql-public-local
135134
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
136-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify mssql-ha-local']
137-
- id: destroy-mssql-ha-local
135+
args: ['/bin/bash', '-c', 'cft test run TestPostgreSqlPublicModule --stage verify --verbose']
136+
- id: teardown postgresql-public-local
138137
waitFor:
139-
- verify-mssql-ha-local
138+
- verify postgresql-public-local
140139
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
141-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy mssql-ha-local']
142-
timeout: 1800s
140+
args: ['/bin/bash', '-c', 'cft test run TestPostgreSqlPublicModule --stage teardown --verbose']
143141

144-
- id: converge-mysql-private-local
142+
- id: apply postgresql-public-iam-local
145143
waitFor:
146-
- create-all
144+
- init-all
147145
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
148-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge mysql-private-local']
149-
timeout: 3600s
150-
- id: verify-mysql-private-local
146+
args: ['/bin/bash', '-c', 'cft test run TestPostgreSqlPublicIamModule --stage apply --verbose']
147+
- id: verify postgresql-public-iam-local
151148
waitFor:
152-
- converge-mysql-private-local
149+
- apply postgresql-public-iam-local
153150
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
154-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify mysql-private-local']
155-
- id: destroy-mysql-private-local
151+
args: ['/bin/bash', '-c', 'cft test run TestPostgreSqlPublicIamModule --stage verify --verbose']
152+
- id: teardown postgresql-public-iam-local
156153
waitFor:
157-
- verify-mysql-private-local
154+
- verify postgresql-public-iam-local
158155
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
159-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy mysql-private-local']
160-
timeout: 1800s
156+
args: ['/bin/bash', '-c', 'cft test run TestPostgreSqlPublicIamModule --stage teardown --verbose']
161157

162158
tags:
163159
- 'ci'

examples/postgresql-ha/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module "pg" {
3838
region = "us-central1"
3939

4040
// Master configurations
41-
tier = "db-custom-2-13312"
41+
tier = "db-custom-1-3840"
4242
zone = "us-central1-c"
4343
availability_type = "REGIONAL"
4444
maintenance_window_day = 7
@@ -81,7 +81,7 @@ module "pg" {
8181
{
8282
name = "0"
8383
zone = "us-central1-a"
84-
tier = "db-custom-2-13312"
84+
tier = "db-custom-1-3840"
8585
ip_configuration = local.read_replica_ip_configuration
8686
database_flags = [{ name = "autovacuum", value = "off" }]
8787
disk_autoresize = null
@@ -93,7 +93,7 @@ module "pg" {
9393
{
9494
name = "1"
9595
zone = "us-central1-b"
96-
tier = "db-custom-2-13312"
96+
tier = "db-custom-1-3840"
9797
ip_configuration = local.read_replica_ip_configuration
9898
database_flags = [{ name = "autovacuum", value = "off" }]
9999
disk_autoresize = null
@@ -105,7 +105,7 @@ module "pg" {
105105
{
106106
name = "2"
107107
zone = "us-central1-c"
108-
tier = "db-custom-2-13312"
108+
tier = "db-custom-1-3840"
109109
ip_configuration = local.read_replica_ip_configuration
110110
database_flags = [{ name = "autovacuum", value = "off" }]
111111
disk_autoresize = null

examples/postgresql-public-iam/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module "postgresql-db" {
2323
project_id = var.project_id
2424
zone = "us-central1-c"
2525
region = "us-central1"
26-
tier = "db-custom-2-13312"
26+
tier = "db-custom-1-3840"
2727

2828
deletion_protection = false
2929

@@ -37,7 +37,7 @@ module "postgresql-db" {
3737
database_flags = [
3838
{
3939
name = "cloudsql.iam_authentication"
40-
value = "On"
40+
value = "on"
4141
},
4242
]
4343

examples/postgresql-public/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module "postgresql-db" {
2323
project_id = var.project_id
2424
zone = "us-central1-c"
2525
region = "us-central1"
26-
tier = "db-custom-2-13312"
26+
tier = "db-custom-1-3840"
2727

2828
deletion_protection = false
2929

kitchen.yml

Lines changed: 0 additions & 76 deletions
This file was deleted.

test/fixtures/mssql-ha/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ module "mssql" {
4444
deletion_protection = false
4545

4646
// Master configurations
47-
tier = "db-custom-2-13312"
47+
tier = "db-custom-1-3840"
4848
availability_type = "REGIONAL"
4949
maintenance_window_day = 7
5050
maintenance_window_hour = 12
@@ -53,7 +53,7 @@ module "mssql" {
5353
database_flags = [
5454
{
5555
name = "default trace enabled"
56-
value = false
56+
value = "off"
5757
},
5858
]
5959

test/fixtures/mysql-ha/outputs.tf

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,3 @@ output "name" {
2525
output "authorized_network" {
2626
value = module.example.authorized_network
2727
}
28-
29-
output "replicas" {
30-
value = module.example.replicas
31-
sensitive = true
32-
}
33-
34-
output "instances" {
35-
value = module.example.instances
36-
sensitive = true
37-
}

0 commit comments

Comments
 (0)