Skip to content

Commit 65c9967

Browse files
authored
test: new host model with 4G memory PITR (#449)
1 parent a8d8073 commit 65c9967

File tree

8 files changed

+32
-15
lines changed

8 files changed

+32
-15
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ To attach access management tags to resources in this module, you need the follo
8383
| [ibm_resource_tag.postgresql_tag](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_tag) | resource |
8484
| [time_sleep.wait_for_authorization_policy](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
8585
| [ibm_database_connection.database_connection](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/data-sources/database_connection) | data source |
86+
| [ibm_database_point_in_time_recovery.source_db_earliest_pitr_time](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/data-sources/database_point_in_time_recovery) | data source |
8687

8788
### Inputs
8889

@@ -106,7 +107,7 @@ To attach access management tags to resources in this module, you need the follo
106107
| <a name="input_name"></a> [name](#input\_name) | The name to give the Postgresql instance. | `string` | n/a | yes |
107108
| <a name="input_pg_version"></a> [pg\_version](#input\_pg\_version) | Version of the PostgreSQL instance. If no value is passed, the current preferred version of IBM Cloud Databases is used. | `string` | `null` | no |
108109
| <a name="input_pitr_id"></a> [pitr\_id](#input\_pitr\_id) | (Optional) The ID of the source deployment PostgreSQL instance that you want to recover back to. The PostgreSQL instance is expected to be in an up and in running state. | `string` | `null` | no |
109-
| <a name="input_pitr_time"></a> [pitr\_time](#input\_pitr\_time) | (Optional) The timestamp in UTC format (%Y-%m-%dT%H:%M:%SZ) for any time in the last 7 days that you want to restore to. To retrieve the timestamp, run the command (ibmcloud cdb postgresql earliest-pitr-timestamp <deployment name or CRN>). For more info on Point-in-time Recovery, see https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-pitr | `string` | `null` | no |
110+
| <a name="input_pitr_time"></a> [pitr\_time](#input\_pitr\_time) | (Optional) The timestamp in UTC format (%Y-%m-%dT%H:%M:%SZ) for any time in the last 7 days that you want to restore to. If empty string ("") is passed, earliest\_point\_in\_time\_recovery\_time will be used as pitr\_time. To retrieve the timestamp, run the command (ibmcloud cdb postgresql earliest-pitr-timestamp <deployment name or CRN>). For more info on Point-in-time Recovery, see https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-pitr | `string` | `null` | no |
110111
| <a name="input_region"></a> [region](#input\_region) | The region where you want to deploy your instance. | `string` | `"us-south"` | no |
111112
| <a name="input_remote_leader_crn"></a> [remote\_leader\_crn](#input\_remote\_leader\_crn) | A CRN of the leader database to make the replica(read-only) deployment. The leader database is created by a database deployment with the same service ID. A read-only replica is set up to replicate all of your data from the leader deployment to the replica deployment by using asynchronous replication. For more information, see https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-read-only-replicas | `string` | `null` | no |
112113
| <a name="input_resource_group_id"></a> [resource\_group\_id](#input\_resource\_group\_id) | The resource group ID where the PostgreSQL instance will be created. | `string` | n/a | yes |
@@ -128,6 +129,7 @@ To attach access management tags to resources in this module, you need the follo
128129
| <a name="output_guid"></a> [guid](#output\_guid) | Postgresql instance guid |
129130
| <a name="output_hostname"></a> [hostname](#output\_hostname) | Database connection hostname |
130131
| <a name="output_id"></a> [id](#output\_id) | Postgresql instance id |
132+
| <a name="output_pitr_time"></a> [pitr\_time](#output\_pitr\_time) | Postgresql instance id |
131133
| <a name="output_port"></a> [port](#output\_port) | Database connection port |
132134
| <a name="output_service_credentials_json"></a> [service\_credentials\_json](#output\_service\_credentials\_json) | Service credentials json map |
133135
| <a name="output_service_credentials_object"></a> [service\_credentials\_object](#output\_service\_credentials\_object) | Service credentials object |

examples/pitr/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ module "postgresql_db_pitr" {
1818
region = var.region
1919
resource_tags = var.resource_tags
2020
access_tags = var.access_tags
21-
member_memory_mb = 3072
21+
member_memory_mb = 12288
2222
member_disk_mb = 15360
23-
member_cpu_count = 9
23+
member_cpu_count = var.member_cpu_count
2424
member_host_flavor = "multitenant"
2525
members = var.members
2626
pg_version = var.pg_version
2727
pitr_id = var.pitr_id
28-
pitr_time = var.pitr_time == "" ? " " : var.pitr_time
28+
pitr_time = var.pitr_time
2929

3030
}

examples/pitr/outputs.tf

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
# Outputs
33
##############################################################################
44

5+
output "pitr_time" {
6+
description = "PITR timestamp in UTC format (%Y-%m-%dT%H:%M:%SZ) used to create PITR instance"
7+
value = module.postgresql_db_pitr.pitr_time
8+
}
59
output "pitr_postgresql_db_id" {
610
description = "PITR Postgresql instance id"
711
value = module.postgresql_db_pitr.id
@@ -11,8 +15,3 @@ output "pitr_postgresql_db_version" {
1115
description = "PITR Postgresql instance version"
1216
value = module.postgresql_db_pitr.version
1317
}
14-
15-
output "pitr_time" {
16-
description = "PITR timestamp in UTC format (%Y-%m-%dT%H:%M:%SZ) used to create PITR instance"
17-
value = var.pitr_time
18-
}

examples/pitr/variables.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,16 @@ variable "pitr_id" {
4545

4646
variable "pitr_time" {
4747
type = string
48-
description = "The timestamp in UTC format (%Y-%m-%dT%H:%M:%SZ) for any time in the last 7 days that you want to restore to. If empty string (\"\") or spaced string (\" \") is passed, latest_point_in_time_recovery_time will be used as pitr_time. To retrieve the timestamp, run the command (ibmcloud cdb postgresql earliest-pitr-timestamp <deployment name or CRN>). For more info on Point-in-time Recovery, see https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-pitr"
48+
description = "The timestamp in UTC format (%Y-%m-%dT%H:%M:%SZ) for any time in the last 7 days that you want to restore to. If empty string (\"\") is passed, earliest_in_time_recovery_time will be used as pitr_time. To retrieve the timestamp, run the command (ibmcloud cdb postgresql earliest-pitr-timestamp <deployment name or CRN>). For more info on Point-in-time Recovery, see https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-pitr"
4949
}
5050

5151
variable "members" {
5252
type = number
5353
description = "Allocated number of members. Members must be same or higher than the source deployment PostgreSQL instance."
5454
default = 2
5555
}
56+
57+
variable "member_cpu_count" {
58+
type = number
59+
description = "Allocated dedicated CPU per member. For shared CPU, set to 0. [Learn more](https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-resources-scaling)"
60+
}

main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,8 @@ data "ibm_database_connection" "database_connection" {
278278
user_id = ibm_database.postgresql_db.adminuser
279279
user_type = "database"
280280
}
281+
282+
data "ibm_database_point_in_time_recovery" "source_db_earliest_pitr_time" {
283+
count = var.pitr_time != "" ? 0 : 1
284+
deployment_id = var.pitr_id
285+
}

outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,8 @@ output "certificate_base64" {
5959
value = data.ibm_database_connection.database_connection.postgres[0].certificate[0].certificate_base64
6060
sensitive = true
6161
}
62+
63+
output "pitr_time" {
64+
description = "Postgresql instance id"
65+
value = var.pitr_time != "" ? var.pitr_time : data.ibm_database_point_in_time_recovery.source_db_earliest_pitr_time[0].earliest_point_in_time_recovery_time
66+
}

tests/other_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ func TestRunPointInTimeRecoveryDBExample(t *testing.T) {
3939
ResourceGroup: resourceGroup,
4040
Region: fmt.Sprint(permanentResources["postgresqlPITRRegion"]),
4141
TerraformVars: map[string]interface{}{
42-
"pitr_id": permanentResources["postgresqlPITRCrn"],
43-
"pitr_time": " ",
44-
"pg_version": permanentResources["postgresqlPITRVersion"],
45-
"members": "3", // Lock members to 3 as the permanent postgres instances has 3 members
42+
"pitr_id": permanentResources["postgresqlPITRCrn"],
43+
"pitr_time": "", // if blank string is passed, earliest_point_in_time_recovery_time will be used to restore
44+
"pg_version": permanentResources["postgresqlPITRVersion"],
45+
"members": "3", // Lock members to 3 as the permanent postgres instances has 3 members
46+
"member_cpu_count": 0, // Lock cpu to 0 as the permanent postgres instances has 0 cpu
4647
},
4748
CloudInfoService: sharedInfoSvc,
4849
})

variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,6 @@ variable "pitr_id" {
353353

354354
variable "pitr_time" {
355355
type = string
356-
description = "(Optional) The timestamp in UTC format (%Y-%m-%dT%H:%M:%SZ) for any time in the last 7 days that you want to restore to. To retrieve the timestamp, run the command (ibmcloud cdb postgresql earliest-pitr-timestamp <deployment name or CRN>). For more info on Point-in-time Recovery, see https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-pitr"
356+
description = "(Optional) The timestamp in UTC format (%Y-%m-%dT%H:%M:%SZ) for any time in the last 7 days that you want to restore to. If empty string (\"\") is passed, earliest_point_in_time_recovery_time will be used as pitr_time. To retrieve the timestamp, run the command (ibmcloud cdb postgresql earliest-pitr-timestamp <deployment name or CRN>). For more info on Point-in-time Recovery, see https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-pitr"
357357
default = null
358358
}

0 commit comments

Comments
 (0)