Skip to content

Commit 1082975

Browse files
committed
tests: integration test for configuration changes
This tests the scenario where we change and remove topic configuration properties.
1 parent 310688c commit 1082975

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

examples/datasource/main.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ data "redpanda_cluster" "test" {
77
id = var.cluster_id
88
}
99

10+
resource "redpanda_topic" "test" {
11+
name = var.topic_name
12+
partition_count = var.partition_count
13+
replication_factor = var.replication_factor
14+
cluster_api_url = data.redpanda_cluster.test.cluster_api_url
15+
allow_deletion = true
16+
configuration = var.topic_config
17+
}
18+
1019
resource "redpanda_user" "test" {
1120
name = var.user_name
1221
password = var.user_pw
@@ -25,6 +34,12 @@ resource "redpanda_acl" "test" {
2534
cluster_api_url = data.redpanda_cluster.test.cluster_api_url
2635
}
2736

37+
variable "topic_config" {
38+
default = {
39+
"cleanup.policy" = "compact"
40+
"compression.type" = "snappy"
41+
}
42+
}
2843
variable "user_name" {
2944
default = "test-username"
3045
}

redpanda/tests/acceptance_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const (
2828
networkResourceName = "redpanda_network.test"
2929
clusterResourceName = "redpanda_cluster.test"
3030
userResourceName = "redpanda_user.test"
31+
topicResourceName = "redpanda_topic.test"
3132
aclResourceName = "redpanda_acl.test"
3233
)
3334

@@ -604,6 +605,14 @@ func TestAccResourcesWithDataSources(t *testing.T) {
604605
maps.Copy(origTestCaseVars, providerCfgIDSecretVars)
605606
origTestCaseVars["cluster_id"] = config.StringVariable(os.Getenv("CLUSTER_ID"))
606607
origTestCaseVars["user_name"] = config.StringVariable(name)
608+
origTestCaseVars["topic_name"] = config.StringVariable(name)
609+
610+
updateTestCaseVars := make(map[string]config.Variable)
611+
maps.Copy(updateTestCaseVars, origTestCaseVars)
612+
// Change 1, remove other
613+
updateTestCaseVars["topic_config"] = config.MapVariable(map[string]config.Variable{
614+
"compression.type": config.StringVariable("gzip"),
615+
})
607616

608617
c, err := newClients(ctx, clientID, clientSecret, "ign")
609618
if err != nil {
@@ -618,6 +627,15 @@ func TestAccResourcesWithDataSources(t *testing.T) {
618627
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
619628
Check: resource.ComposeAggregateTestCheckFunc(
620629
resource.TestCheckResourceAttr(userResourceName, "name", name),
630+
resource.TestCheckResourceAttr(topicResourceName, "name", name),
631+
),
632+
},
633+
{
634+
ConfigFile: config.StaticFile(dataSourcesTest),
635+
ConfigVariables: updateTestCaseVars,
636+
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
637+
Check: resource.ComposeAggregateTestCheckFunc(
638+
resource.TestCheckResourceAttr(topicResourceName, "configuration.compression.type", "gzip"),
621639
),
622640
},
623641
{

0 commit comments

Comments
 (0)