Skip to content

Commit 9ed9581

Browse files
authored
feat: Exposed the ability to set create, delete and update timeout values in the enterprise DA (#384)
1 parent b2f3bf8 commit 9ed9581

File tree

8 files changed

+121
-50
lines changed

8 files changed

+121
-50
lines changed

ibm_catalog.json

+9
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,15 @@
286286
{
287287
"key": "access_tags"
288288
},
289+
{
290+
"key": "create_timeout"
291+
},
292+
{
293+
"key": "delete_timeout"
294+
},
295+
{
296+
"key": "update_timeout"
297+
},
289298
{
290299
"key": "schemas"
291300
},

modules/fscloud/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ No resources.
2828
|------|-------------|------|---------|:--------:|
2929
| <a name="input_access_tags"></a> [access\_tags](#input\_access\_tags) | The list of access tags associated with the Event Steams instance. | `list(string)` | `[]` | no |
3030
| <a name="input_cbr_rules"></a> [cbr\_rules](#input\_cbr\_rules) | The list of context-based restriction rules to create. | <pre>list(object({<br/> description = string<br/> account_id = string<br/> rule_contexts = list(object({<br/> attributes = optional(list(object({<br/> name = string<br/> value = string<br/> }))) }))<br/> enforcement_mode = string<br/> }))</pre> | `[]` | no |
31+
| <a name="input_create_timeout"></a> [create\_timeout](#input\_create\_timeout) | The timeout value for creating an Event Streams instance. Specify `3h` for an Enterprise plan instance. Add 1 h for each level of non-default throughput. Add 30 min for each level of non-default storage size. | `string` | `"3h"` | no |
32+
| <a name="input_delete_timeout"></a> [delete\_timeout](#input\_delete\_timeout) | The timeout value for deleting an Event Streams instance. | `string` | `"15m"` | no |
3133
| <a name="input_es_name"></a> [es\_name](#input\_es\_name) | The name of the Event Streams instance. | `string` | n/a | yes |
3234
| <a name="input_kms_key_crn"></a> [kms\_key\_crn](#input\_kms\_key\_crn) | The root key CRN of the key management service (Key Protect or Hyper Protect Crypto Services) to use to encrypt the payload data. | `string` | n/a | yes |
3335
| <a name="input_metrics"></a> [metrics](#input\_metrics) | Enhanced metrics to activate, as list of strings. Allowed values: 'topic', 'partition', 'consumers'. | `list(string)` | `[]` | no |
@@ -43,6 +45,7 @@ No resources.
4345
| <a name="input_skip_kms_iam_authorization_policy"></a> [skip\_kms\_iam\_authorization\_policy](#input\_skip\_kms\_iam\_authorization\_policy) | Set to true to skip the creation of an IAM authorization policy that permits all Event Streams database instances in the resource group to read the encryption key from the KMS instance. If set to false, pass in a value for the KMS instance in the kms\_key\_crn variable. In addition, no policy is created if var.kms\_encryption\_enabled is set to false. | `bool` | `false` | no |
4446
| <a name="input_tags"></a> [tags](#input\_tags) | The list of tags associated with the Event Steams instance. | `list(string)` | `[]` | no |
4547
| <a name="input_topics"></a> [topics](#input\_topics) | The list of topics to apply to resources. Only one topic is allowed for Lite plan instances. | <pre>list(object(<br/> {<br/> name = string<br/> partitions = number<br/> config = map(string)<br/> }<br/> ))</pre> | `[]` | no |
48+
| <a name="input_update_timeout"></a> [update\_timeout](#input\_update\_timeout) | The timeout value for updating an Event Streams instance. Specify `1h` for an Enterprise plan instance. Add 1 h for each level of non-default throughput. A 30 min for each level of non-default storage size. | `string` | `"1h"` | no |
4649

4750
### Outputs
4851

modules/fscloud/main.tf

+3
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,7 @@ module "event_streams" {
2020
kms_encryption_enabled = true
2121
mirroring_topic_patterns = var.mirroring_topic_patterns
2222
mirroring = var.mirroring
23+
create_timeout = var.create_timeout
24+
update_timeout = var.update_timeout
25+
delete_timeout = var.delete_timeout
2326
}

modules/fscloud/variables.tf

+18
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,21 @@ variable "mirroring" {
162162
})
163163
default = null
164164
}
165+
166+
variable "create_timeout" {
167+
type = string
168+
description = "The timeout value for creating an Event Streams instance. Specify `3h` for an Enterprise plan instance. Add 1 h for each level of non-default throughput. Add 30 min for each level of non-default storage size."
169+
default = "3h"
170+
}
171+
172+
variable "update_timeout" {
173+
type = string
174+
description = "The timeout value for updating an Event Streams instance. Specify `1h` for an Enterprise plan instance. Add 1 h for each level of non-default throughput. A 30 min for each level of non-default storage size."
175+
default = "1h"
176+
}
177+
178+
variable "delete_timeout" {
179+
type = string
180+
description = "The timeout value for deleting an Event Streams instance."
181+
default = "15m"
182+
}

solutions/enterprise/main.tf

+3
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,7 @@ module "event_streams" {
161161
schema_global_rule = var.schema_global_rule
162162
skip_kms_iam_authorization_policy = var.skip_event_streams_kms_auth_policy
163163
skip_es_s2s_iam_authorization_policy = var.skip_event_streams_s2s_iam_auth_policy
164+
create_timeout = var.create_timeout
165+
update_timeout = var.update_timeout
166+
delete_timeout = var.delete_timeout
164167
}

solutions/enterprise/variables.tf

+18
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,21 @@ variable "ibmcloud_kms_api_key" {
252252
sensitive = true
253253
default = null
254254
}
255+
256+
variable "create_timeout" {
257+
type = string
258+
description = "The timeout value for creating an Event Streams instance. Specify `3h` for an Enterprise plan instance. Add 1 h for each level of non-default throughput. Add 30 min for each level of non-default storage size."
259+
default = "3h"
260+
}
261+
262+
variable "update_timeout" {
263+
type = string
264+
description = "The timeout value for updating an Event Streams instance. Specify `1h` for an Enterprise plan instance. Add 1 h for each level of non-default throughput. A 30 min for each level of non-default storage size."
265+
default = "1h"
266+
}
267+
268+
variable "delete_timeout" {
269+
type = string
270+
description = "The timeout value for deleting an Event Streams instance."
271+
default = "15m"
272+
}

tests/other_test.go

+49-2
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,63 @@ import (
66
"testing"
77

88
"github.com/stretchr/testify/assert"
9+
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testschematic"
910
)
1011

1112
const basicExampleTerraformDir = "examples/basic"
1213

13-
func TestRunDefaultExample(t *testing.T) {
14+
func TestRunBasicExample(t *testing.T) {
1415
t.Parallel()
1516

16-
options := setupOptions(t, "event-streams-default", basicExampleTerraformDir)
17+
options := setupOptions(t, "event-streams-bsc", basicExampleTerraformDir)
1718

1819
output, err := options.RunTestConsistency()
1920
assert.Nil(t, err, "This should not have errored")
2021
assert.NotNil(t, output, "Expected some output")
2122
}
23+
24+
func TestRunCompleteExample(t *testing.T) {
25+
t.Parallel()
26+
27+
options := setupOptions(t, "event-streams-bsc", completeExampleTerraformDir)
28+
29+
output, err := options.RunTestConsistency()
30+
assert.Nil(t, err, "This should not have errored")
31+
assert.NotNil(t, output, "Expected some output")
32+
}
33+
34+
func TestFSCloudInSchematics(t *testing.T) {
35+
t.Parallel()
36+
37+
options := testschematic.TestSchematicOptionsDefault(&testschematic.TestSchematicOptions{
38+
Testing: t,
39+
Prefix: "es-fscloud",
40+
BestRegionYAMLPath: regionSelectionPath,
41+
TarIncludePatterns: []string{
42+
"*.tf",
43+
fsCloudTerraformDir + "/*.tf",
44+
"modules/fscloud/*.tf",
45+
},
46+
/*
47+
Comment out the 'ResourceGroup' input to force this tests to create a unique resource group to ensure tests do
48+
not clash. This is due to the fact that an auth policy may already exist in this resource group since we are
49+
re-using a permanent HPCS instance and a permanent Event Streams instance. By using a new resource group, the auth policy will not already exist
50+
since this module scopes auth policies by resource group.
51+
*/
52+
//ResourceGroup: resourceGroup,
53+
TemplateFolder: fsCloudTerraformDir,
54+
Tags: []string{"test-schematic"},
55+
DeleteWorkspaceOnFail: false,
56+
WaitJobCompleteMinutes: 180,
57+
})
58+
59+
options.TerraformVars = []testschematic.TestSchematicTerraformVar{
60+
{Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true},
61+
{Name: "prefix", Value: options.Prefix, DataType: "string"},
62+
{Name: "kms_key_crn", Value: permanentResources["hpcs_south_root_key_crn"].(string), DataType: "string"},
63+
{Name: "event_streams_source_crn", Value: permanentResources["event_streams_us_south_crn"].(string), DataType: "string"},
64+
}
65+
66+
err := options.RunSchematicTest()
67+
assert.Nil(t, err, "This should not have errored")
68+
}

tests/pr_test.go

+18-48
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,6 @@ func setupOptions(t *testing.T, prefix string, dir string) *testhelper.TestOptio
5050
return options
5151
}
5252

53-
func TestRunUpgradeExample(t *testing.T) {
54-
t.Parallel()
55-
56-
options := setupOptions(t, "event-streams-upg", completeExampleTerraformDir)
57-
58-
output, err := options.RunTestUpgrade()
59-
if !options.UpgradeTestSkipped {
60-
assert.Nil(t, err, "This should not have errored")
61-
assert.NotNil(t, output, "Expected some output")
62-
}
63-
}
64-
6553
func TestRunQuickstartSolution(t *testing.T) {
6654
t.Parallel()
6755

@@ -85,12 +73,10 @@ func TestRunQuickstartSolution(t *testing.T) {
8573
assert.NotNil(t, output, "Expected some output")
8674
}
8775

88-
func TestEnterpriseSolutionInSchematics(t *testing.T) {
89-
t.Parallel()
90-
76+
func setupEnterpriseOptions(t *testing.T, prefix string) *testschematic.TestSchematicOptions {
9177
options := testschematic.TestSchematicOptionsDefault(&testschematic.TestSchematicOptions{
9278
Testing: t,
93-
Prefix: "es-ent",
79+
Prefix: prefix,
9480
BestRegionYAMLPath: regionSelectionPath,
9581
TarIncludePatterns: []string{
9682
"*.tf",
@@ -107,7 +93,7 @@ func TestEnterpriseSolutionInSchematics(t *testing.T) {
10793
TemplateFolder: enterpriseSolutionTerraformDir,
10894
Tags: []string{"test-schematic"},
10995
DeleteWorkspaceOnFail: false,
110-
WaitJobCompleteMinutes: 180,
96+
WaitJobCompleteMinutes: 360,
11197
})
11298

11399
options.TerraformVars = []testschematic.TestSchematicTerraformVar{
@@ -119,44 +105,28 @@ func TestEnterpriseSolutionInSchematics(t *testing.T) {
119105
{Name: "existing_kms_instance_crn", Value: permanentResources["hpcs_south_crn"], DataType: "string"},
120106
{Name: "access_tags", Value: permanentResources["accessTags"], DataType: "list(string)"},
121107
{Name: "resource_tags", Value: options.Tags, DataType: "list(string)"},
108+
// Update the create timeout as it can take longer than the default (3 hours) when running multiple tests in parallel
109+
{Name: "create_timeout", Value: "5h", DataType: "string"},
122110
}
111+
return options
112+
}
113+
114+
// Test for the Enterprise DA
115+
func TestEnterpriseSolutionInSchematics(t *testing.T) {
116+
t.Parallel()
123117

118+
options := setupEnterpriseOptions(t, "es-ent")
124119
err := options.RunSchematicTest()
125120
assert.Nil(t, err, "This should not have errored")
126121
}
127122

128-
func TestFSCloudInSchematics(t *testing.T) {
123+
// Upgrade test for the Enterprise DA
124+
func TestRunUpgradeEnterpriseDA(t *testing.T) {
129125
t.Parallel()
130126

131-
options := testschematic.TestSchematicOptionsDefault(&testschematic.TestSchematicOptions{
132-
Testing: t,
133-
Prefix: "es-fscloud",
134-
BestRegionYAMLPath: regionSelectionPath,
135-
TarIncludePatterns: []string{
136-
"*.tf",
137-
fsCloudTerraformDir + "/*.tf",
138-
"modules/fscloud/*.tf",
139-
},
140-
/*
141-
Comment out the 'ResourceGroup' input to force this tests to create a unique resource group to ensure tests do
142-
not clash. This is due to the fact that an auth policy may already exist in this resource group since we are
143-
re-using a permanent HPCS instance and a permanent Event Streams instance. By using a new resource group, the auth policy will not already exist
144-
since this module scopes auth policies by resource group.
145-
*/
146-
//ResourceGroup: resourceGroup,
147-
TemplateFolder: fsCloudTerraformDir,
148-
Tags: []string{"test-schematic"},
149-
DeleteWorkspaceOnFail: false,
150-
WaitJobCompleteMinutes: 180,
151-
})
152-
153-
options.TerraformVars = []testschematic.TestSchematicTerraformVar{
154-
{Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true},
155-
{Name: "prefix", Value: options.Prefix, DataType: "string"},
156-
{Name: "kms_key_crn", Value: permanentResources["hpcs_south_root_key_crn"].(string), DataType: "string"},
157-
{Name: "event_streams_source_crn", Value: permanentResources["event_streams_us_south_crn"].(string), DataType: "string"},
127+
options := setupEnterpriseOptions(t, "ev-st-upg")
128+
err := options.RunSchematicUpgradeTest()
129+
if !options.UpgradeTestSkipped {
130+
assert.Nil(t, err, "This should not have errored")
158131
}
159-
160-
err := options.RunSchematicTest()
161-
assert.Nil(t, err, "This should not have errored")
162132
}

0 commit comments

Comments
 (0)