Skip to content

Commit

Permalink
feat: Exposed the ability to set create, delete and update timeout va…
Browse files Browse the repository at this point in the history
…lues in the enterprise DA (#384)
  • Loading branch information
ocofaigh authored Mar 7, 2025
1 parent b2f3bf8 commit 9ed9581
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 50 deletions.
9 changes: 9 additions & 0 deletions ibm_catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,15 @@
{
"key": "access_tags"
},
{
"key": "create_timeout"
},
{
"key": "delete_timeout"
},
{
"key": "update_timeout"
},
{
"key": "schemas"
},
Expand Down
3 changes: 3 additions & 0 deletions modules/fscloud/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ No resources.
|------|-------------|------|---------|:--------:|
| <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 |
| <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 |
| <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 |
| <a name="input_delete_timeout"></a> [delete\_timeout](#input\_delete\_timeout) | The timeout value for deleting an Event Streams instance. | `string` | `"15m"` | no |
| <a name="input_es_name"></a> [es\_name](#input\_es\_name) | The name of the Event Streams instance. | `string` | n/a | yes |
| <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 |
| <a name="input_metrics"></a> [metrics](#input\_metrics) | Enhanced metrics to activate, as list of strings. Allowed values: 'topic', 'partition', 'consumers'. | `list(string)` | `[]` | no |
Expand All @@ -43,6 +45,7 @@ No resources.
| <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 |
| <a name="input_tags"></a> [tags](#input\_tags) | The list of tags associated with the Event Steams instance. | `list(string)` | `[]` | no |
| <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 |
| <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 |

### Outputs

Expand Down
3 changes: 3 additions & 0 deletions modules/fscloud/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ module "event_streams" {
kms_encryption_enabled = true
mirroring_topic_patterns = var.mirroring_topic_patterns
mirroring = var.mirroring
create_timeout = var.create_timeout
update_timeout = var.update_timeout
delete_timeout = var.delete_timeout
}
18 changes: 18 additions & 0 deletions modules/fscloud/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,21 @@ variable "mirroring" {
})
default = null
}

variable "create_timeout" {
type = string
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."
default = "3h"
}

variable "update_timeout" {
type = string
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."
default = "1h"
}

variable "delete_timeout" {
type = string
description = "The timeout value for deleting an Event Streams instance."
default = "15m"
}
3 changes: 3 additions & 0 deletions solutions/enterprise/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,7 @@ module "event_streams" {
schema_global_rule = var.schema_global_rule
skip_kms_iam_authorization_policy = var.skip_event_streams_kms_auth_policy
skip_es_s2s_iam_authorization_policy = var.skip_event_streams_s2s_iam_auth_policy
create_timeout = var.create_timeout
update_timeout = var.update_timeout
delete_timeout = var.delete_timeout
}
18 changes: 18 additions & 0 deletions solutions/enterprise/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,21 @@ variable "ibmcloud_kms_api_key" {
sensitive = true
default = null
}

variable "create_timeout" {
type = string
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."
default = "3h"
}

variable "update_timeout" {
type = string
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."
default = "1h"
}

variable "delete_timeout" {
type = string
description = "The timeout value for deleting an Event Streams instance."
default = "15m"
}
51 changes: 49 additions & 2 deletions tests/other_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,63 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testschematic"
)

const basicExampleTerraformDir = "examples/basic"

func TestRunDefaultExample(t *testing.T) {
func TestRunBasicExample(t *testing.T) {
t.Parallel()

options := setupOptions(t, "event-streams-default", basicExampleTerraformDir)
options := setupOptions(t, "event-streams-bsc", basicExampleTerraformDir)

output, err := options.RunTestConsistency()
assert.Nil(t, err, "This should not have errored")
assert.NotNil(t, output, "Expected some output")
}

func TestRunCompleteExample(t *testing.T) {
t.Parallel()

options := setupOptions(t, "event-streams-bsc", completeExampleTerraformDir)

output, err := options.RunTestConsistency()
assert.Nil(t, err, "This should not have errored")
assert.NotNil(t, output, "Expected some output")
}

func TestFSCloudInSchematics(t *testing.T) {
t.Parallel()

options := testschematic.TestSchematicOptionsDefault(&testschematic.TestSchematicOptions{
Testing: t,
Prefix: "es-fscloud",
BestRegionYAMLPath: regionSelectionPath,
TarIncludePatterns: []string{
"*.tf",
fsCloudTerraformDir + "/*.tf",
"modules/fscloud/*.tf",
},
/*
Comment out the 'ResourceGroup' input to force this tests to create a unique resource group to ensure tests do
not clash. This is due to the fact that an auth policy may already exist in this resource group since we are
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
since this module scopes auth policies by resource group.
*/
//ResourceGroup: resourceGroup,
TemplateFolder: fsCloudTerraformDir,
Tags: []string{"test-schematic"},
DeleteWorkspaceOnFail: false,
WaitJobCompleteMinutes: 180,
})

options.TerraformVars = []testschematic.TestSchematicTerraformVar{
{Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true},
{Name: "prefix", Value: options.Prefix, DataType: "string"},
{Name: "kms_key_crn", Value: permanentResources["hpcs_south_root_key_crn"].(string), DataType: "string"},
{Name: "event_streams_source_crn", Value: permanentResources["event_streams_us_south_crn"].(string), DataType: "string"},
}

err := options.RunSchematicTest()
assert.Nil(t, err, "This should not have errored")
}
66 changes: 18 additions & 48 deletions tests/pr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,6 @@ func setupOptions(t *testing.T, prefix string, dir string) *testhelper.TestOptio
return options
}

func TestRunUpgradeExample(t *testing.T) {
t.Parallel()

options := setupOptions(t, "event-streams-upg", completeExampleTerraformDir)

output, err := options.RunTestUpgrade()
if !options.UpgradeTestSkipped {
assert.Nil(t, err, "This should not have errored")
assert.NotNil(t, output, "Expected some output")
}
}

func TestRunQuickstartSolution(t *testing.T) {
t.Parallel()

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

func TestEnterpriseSolutionInSchematics(t *testing.T) {
t.Parallel()

func setupEnterpriseOptions(t *testing.T, prefix string) *testschematic.TestSchematicOptions {
options := testschematic.TestSchematicOptionsDefault(&testschematic.TestSchematicOptions{
Testing: t,
Prefix: "es-ent",
Prefix: prefix,
BestRegionYAMLPath: regionSelectionPath,
TarIncludePatterns: []string{
"*.tf",
Expand All @@ -107,7 +93,7 @@ func TestEnterpriseSolutionInSchematics(t *testing.T) {
TemplateFolder: enterpriseSolutionTerraformDir,
Tags: []string{"test-schematic"},
DeleteWorkspaceOnFail: false,
WaitJobCompleteMinutes: 180,
WaitJobCompleteMinutes: 360,
})

options.TerraformVars = []testschematic.TestSchematicTerraformVar{
Expand All @@ -119,44 +105,28 @@ func TestEnterpriseSolutionInSchematics(t *testing.T) {
{Name: "existing_kms_instance_crn", Value: permanentResources["hpcs_south_crn"], DataType: "string"},
{Name: "access_tags", Value: permanentResources["accessTags"], DataType: "list(string)"},
{Name: "resource_tags", Value: options.Tags, DataType: "list(string)"},
// Update the create timeout as it can take longer than the default (3 hours) when running multiple tests in parallel
{Name: "create_timeout", Value: "5h", DataType: "string"},
}
return options
}

// Test for the Enterprise DA
func TestEnterpriseSolutionInSchematics(t *testing.T) {
t.Parallel()

options := setupEnterpriseOptions(t, "es-ent")
err := options.RunSchematicTest()
assert.Nil(t, err, "This should not have errored")
}

func TestFSCloudInSchematics(t *testing.T) {
// Upgrade test for the Enterprise DA
func TestRunUpgradeEnterpriseDA(t *testing.T) {
t.Parallel()

options := testschematic.TestSchematicOptionsDefault(&testschematic.TestSchematicOptions{
Testing: t,
Prefix: "es-fscloud",
BestRegionYAMLPath: regionSelectionPath,
TarIncludePatterns: []string{
"*.tf",
fsCloudTerraformDir + "/*.tf",
"modules/fscloud/*.tf",
},
/*
Comment out the 'ResourceGroup' input to force this tests to create a unique resource group to ensure tests do
not clash. This is due to the fact that an auth policy may already exist in this resource group since we are
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
since this module scopes auth policies by resource group.
*/
//ResourceGroup: resourceGroup,
TemplateFolder: fsCloudTerraformDir,
Tags: []string{"test-schematic"},
DeleteWorkspaceOnFail: false,
WaitJobCompleteMinutes: 180,
})

options.TerraformVars = []testschematic.TestSchematicTerraformVar{
{Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true},
{Name: "prefix", Value: options.Prefix, DataType: "string"},
{Name: "kms_key_crn", Value: permanentResources["hpcs_south_root_key_crn"].(string), DataType: "string"},
{Name: "event_streams_source_crn", Value: permanentResources["event_streams_us_south_crn"].(string), DataType: "string"},
options := setupEnterpriseOptions(t, "ev-st-upg")
err := options.RunSchematicUpgradeTest()
if !options.UpgradeTestSkipped {
assert.Nil(t, err, "This should not have errored")
}

err := options.RunSchematicTest()
assert.Nil(t, err, "This should not have errored")
}

0 comments on commit 9ed9581

Please sign in to comment.