@@ -31,7 +31,7 @@ func TestAccAiven_kafka(t *testing.T) {
3131 ExpectError : regexp .MustCompile ("tag keys should be unique" ),
3232 },
3333 {
34- Config : testAccKafkaResource (rName ),
34+ Config : testAccKafkaResource (rName , 1 << 30 ), // 1 GiB = 1073741824 bytes
3535 Check : resource .ComposeTestCheckFunc (
3636 acc .TestAccCheckAivenServiceCommonAttributes ("data.aiven_kafka.common" ),
3737 testAccCheckAivenServiceKafkaAttributes ("data.aiven_kafka.common" ),
@@ -50,6 +50,20 @@ func TestAccAiven_kafka(t *testing.T) {
5050 resource .TestCheckResourceAttrSet (resourceName , "service_host" ),
5151 resource .TestCheckResourceAttrSet (resourceName , "service_port" ),
5252 resource .TestCheckResourceAttrSet (resourceName , "service_uri" ),
53+ resource .TestCheckResourceAttr (resourceName , "kafka_user_config.0.kafka.0.log_retention_bytes" , "1073741824" ),
54+ resource .TestCheckResourceAttr (resourceName , "kafka_user_config.0.tiered_storage.0.enabled" , "true" ),
55+ resource .TestCheckResourceAttr (resourceName , "kafka_user_config.0.kafka_diskless.0.enabled" , "false" ),
56+ ),
57+ },
58+ {
59+ // Updates the user config block.
60+ // Proves that when Terraform detects "false" value as "null", we don't send an empty map to the API.
61+ // The "kafka_diskless.enabled" field is "false" here, so we remove the whole "kafka_diskless" block from the request.
62+ Config : testAccKafkaResource (rName , 1 << 29 ), // 0.5 GiB = 536870912 bytes
63+ Check : resource .ComposeTestCheckFunc (
64+ resource .TestCheckResourceAttr (resourceName , "kafka_user_config.0.kafka.0.log_retention_bytes" , "536870912" ),
65+ resource .TestCheckResourceAttr (resourceName , "kafka_user_config.0.tiered_storage.0.enabled" , "true" ),
66+ resource .TestCheckResourceAttr (resourceName , "kafka_user_config.0.kafka_diskless.0.enabled" , "false" ),
5367 ),
5468 },
5569 {
@@ -106,7 +120,7 @@ func TestAccAiven_kafka(t *testing.T) {
106120 })
107121}
108122
109- func testAccKafkaResource (name string ) string {
123+ func testAccKafkaResource (name string , logRetentionBytes int ) string {
110124 return fmt .Sprintf (`
111125data "aiven_project" "foo" {
112126 project = "%s"
@@ -124,13 +138,21 @@ resource "aiven_kafka" "bar" {
124138 kafka_user_config {
125139 kafka {
126140 group_max_session_timeout_ms = 70000
127- log_retention_bytes = 1000000000
141+ log_retention_bytes = %d
128142 }
129143
130144 public_access {
131145 kafka_rest = true
132146 kafka_connect = true
133147 }
148+
149+ tiered_storage {
150+ enabled = true
151+ }
152+
153+ kafka_diskless {
154+ enabled = false
155+ }
134156 }
135157}
136158
@@ -139,7 +161,7 @@ data "aiven_kafka" "common" {
139161 project = aiven_kafka.bar.project
140162
141163 depends_on = [aiven_kafka.bar]
142- }` , acc .ProjectName (), name )
164+ }` , acc .ProjectName (), name , logRetentionBytes )
143165}
144166
145167func testAccKafkaWithoutDefaultACLResource (name string ) string {
0 commit comments