Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tencentcloud/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,25 @@ const (
defaultEMRSgId = "sg-mag8k2fj"
)

//ckafka
const (
defaultKafkaInstanceId = "ckafka-vv7wpvae"
defaultKafkaVpcId = "vpc-68vi2d3h"
defaultKafkaSubnetId = "subnet-ob6clqwk"
)

const defaultKafkaVariable = `
variable "instance_id" {
default = "` + defaultKafkaInstanceId + `"
}
variable "vpc_id" {
default = "` + defaultKafkaVpcId + `"
}
variable "subnet_id" {
default = "` + defaultKafkaSubnetId + `"
}
`

// Tke Exclusive Network Environment
const (
tkeExclusiveVpcId = "vpc-391sv4w3"
Expand Down
35 changes: 33 additions & 2 deletions tencentcloud/data_source_tc_ckafka_acls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
func TestAccTencentCloudCkafkaAclsDataSource(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_PREPAY) },
Providers: testAccProviders,
CheckDestroy: testAccCheckCkafkaAclDestroy,
Steps: []resource.TestStep{
Expand All @@ -29,7 +29,38 @@ func TestAccTencentCloudCkafkaAclsDataSource(t *testing.T) {
})
}

const testAccTencentCloudDataSourceCkafkaAcl = testAccCkafkaAcl + `
const testAccTencentCloudDataSourceCkafkaAcl = defaultKafkaVariable + `
resource "tencentcloud_ckafka_user" "foo" {
instance_id = var.instance_id
account_name = "tf-test-acl-data"
password = "test1234"
}

resource "tencentcloud_ckafka_topic" "kafka_topic_acl" {
instance_id = var.instance_id
topic_name = "ckafka-topic-acl-data-test"
replica_num = 2
partition_num = 1
note = "test topic"
enable_white_list = true
ip_white_list = ["192.168.1.1"]
clean_up_policy = "delete"
sync_replica_min_num = 1
unclean_leader_election_enable = false
segment = 86400000
retention = 60000
}

resource "tencentcloud_ckafka_acl" foo {
instance_id = var.instance_id
resource_type = "TOPIC"
resource_name = tencentcloud_ckafka_topic.kafka_topic_acl.topic_name
operation_type = "WRITE"
permission_type = "ALLOW"
host = "10.10.10.0"
principal = tencentcloud_ckafka_user.foo.account_name
}

data "tencentcloud_ckafka_acls" "foo" {
instance_id = tencentcloud_ckafka_acl.foo.instance_id
resource_type = tencentcloud_ckafka_acl.foo.resource_type
Expand Down
22 changes: 11 additions & 11 deletions tencentcloud/data_source_tc_ckafka_topics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccTencentCloudCkafkaTopicDataSource(t *testing.T) {
func TestAccTencentCloudCKafkaTopicDataSource(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_PREPAY) },
Providers: testAccProviders,
CheckDestroy: testAccTencentCloudKafkaTopicDestory,
Steps: []resource.TestStep{
{
Config: testAccTencentCloudCkafkaTopicDataSourceConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckKafkaTopicInstanceExists("tencentcloud_ckafka_topic.kafka_topic"),
resource.TestCheckResourceAttr("data.tencentcloud_ckafka_topics.kafka_topics", "instance_id", "ckafka-f9ife4zz"),
resource.TestCheckResourceAttr("data.tencentcloud_ckafka_topics.kafka_topics", "instance_id", "ckafka-vv7wpvae"),
resource.TestCheckResourceAttr("data.tencentcloud_ckafka_topics.kafka_topics", "instance_list.#", "1"),
resource.TestCheckResourceAttr("data.tencentcloud_ckafka_topics.kafka_topics", "instance_list.0.topic_name", "ckafkaTopic-tf-test"),
resource.TestCheckResourceAttr("data.tencentcloud_ckafka_topics.kafka_topics", "instance_list.0.partition_num", "1"),
Expand All @@ -29,21 +29,21 @@ func TestAccTencentCloudCkafkaTopicDataSource(t *testing.T) {
resource.TestCheckResourceAttr("data.tencentcloud_ckafka_topics.kafka_topics", "instance_list.0.clean_up_policy", "delete"),
resource.TestCheckResourceAttr("data.tencentcloud_ckafka_topics.kafka_topics", "instance_list.0.sync_replica_min_num", "1"),
resource.TestCheckResourceAttrSet("data.tencentcloud_ckafka_topics.kafka_topics", "instance_list.0.unclean_leader_election_enable"),
resource.TestCheckResourceAttr("data.tencentcloud_ckafka_topics.kafka_topics", "instance_list.0.segment", "3600000"),
resource.TestCheckResourceAttr("data.tencentcloud_ckafka_topics.kafka_topics", "instance_list.0.segment", "86400000"),
resource.TestCheckResourceAttr("data.tencentcloud_ckafka_topics.kafka_topics", "instance_list.0.retention", "60000"),
resource.TestCheckResourceAttr("data.tencentcloud_ckafka_topics.foo", "instance_list.#", "2"),
resource.TestCheckResourceAttrSet("data.tencentcloud_ckafka_topics.foo", "instance_list.1.partition_num"),
resource.TestCheckResourceAttrSet("data.tencentcloud_ckafka_topics.foo", "instance_list.1.replica_num"),
resource.TestCheckResourceAttrSet("data.tencentcloud_ckafka_topics.foo", "instance_list.1.create_time"),
resource.TestCheckResourceAttr("data.tencentcloud_ckafka_topics.foo", "instance_list.#", "1"),
resource.TestCheckResourceAttrSet("data.tencentcloud_ckafka_topics.foo", "instance_list.0.partition_num"),
resource.TestCheckResourceAttrSet("data.tencentcloud_ckafka_topics.foo", "instance_list.0.replica_num"),
resource.TestCheckResourceAttrSet("data.tencentcloud_ckafka_topics.foo", "instance_list.0.create_time"),
),
},
},
})
}

const testAccTencentCloudCkafkaTopicDataSourceConfig = `
const testAccTencentCloudCkafkaTopicDataSourceConfig = defaultKafkaVariable + `
resource "tencentcloud_ckafka_topic" "kafka_topic" {
instance_id = "ckafka-f9ife4zz"
instance_id = var.instance_id
topic_name = "ckafkaTopic-tf-test"
replica_num = 2
partition_num = 1
Expand All @@ -53,7 +53,7 @@ resource "tencentcloud_ckafka_topic" "kafka_topic" {
clean_up_policy = "delete"
sync_replica_min_num = 1
unclean_leader_election_enable = false
segment = 3600000
segment = 86400000
retention = 60000
}

Expand Down
10 changes: 5 additions & 5 deletions tencentcloud/data_source_tc_ckafka_users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
func TestAccTencentCloudCkafkaUsersDataSource(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_PREPAY) },
Providers: testAccProviders,
CheckDestroy: testAccCheckCkafkaUserDestroy,
Steps: []resource.TestStep{
Expand All @@ -18,7 +18,7 @@ func TestAccTencentCloudCkafkaUsersDataSource(t *testing.T) {
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckCkafkaUserExists("tencentcloud_ckafka_user.foo"),
resource.TestCheckResourceAttrSet("data.tencentcloud_ckafka_users.foo", "instance_id"),
resource.TestCheckResourceAttr("data.tencentcloud_ckafka_users.foo", "user_list.0.account_name", "test"),
resource.TestCheckResourceAttr("data.tencentcloud_ckafka_users.foo", "user_list.0.account_name", "test1"),
resource.TestCheckResourceAttrSet("data.tencentcloud_ckafka_users.foo", "user_list.0.create_time"),
resource.TestCheckResourceAttrSet("data.tencentcloud_ckafka_users.foo", "user_list.0.update_time"),
),
Expand All @@ -27,10 +27,10 @@ func TestAccTencentCloudCkafkaUsersDataSource(t *testing.T) {
})
}

const testAccTencentCloudDataSourceCkafkaUser = `
const testAccTencentCloudDataSourceCkafkaUser = defaultKafkaVariable + `
resource "tencentcloud_ckafka_user" "foo" {
instance_id = "ckafka-f9ife4zz"
account_name = "test"
instance_id = var.instance_id
account_name = "test1"
password = "test1234"
}

Expand Down
31 changes: 26 additions & 5 deletions tencentcloud/resource_tc_ckafka_acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

func TestAccTencentCloudCkafkaAcl(t *testing.T) {
func TestAccTencentCloudCkafkaAclResource(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_PREPAY) },
Providers: testAccProviders,
CheckDestroy: testAccCheckCkafkaAclDestroy,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -89,11 +89,32 @@ func testAccCheckCkafkaAclDestroy(s *terraform.State) error {
return nil
}

const testAccCkafkaAcl = testAccCkafkaUser + `
const testAccCkafkaAcl = defaultKafkaVariable + `
resource "tencentcloud_ckafka_user" "foo" {
instance_id = var.instance_id
account_name = "tf-test-acl-resource"
password = "test1234"
}

resource "tencentcloud_ckafka_topic" "kafka_topic_acl" {
instance_id = var.instance_id
topic_name = "ckafka-topic-acl-test"
replica_num = 2
partition_num = 1
note = "test topic"
enable_white_list = true
ip_white_list = ["192.168.1.1"]
clean_up_policy = "delete"
sync_replica_min_num = 1
unclean_leader_election_enable = false
segment = 86400000
retention = 60000
}

resource "tencentcloud_ckafka_acl" foo {
instance_id = "ckafka-f9ife4zz"
instance_id = var.instance_id
resource_type = "TOPIC"
resource_name = "topic-tf-test"
resource_name = tencentcloud_ckafka_topic.kafka_topic_acl.topic_name
operation_type = "WRITE"
permission_type = "ALLOW"
host = "10.10.10.0"
Expand Down
8 changes: 7 additions & 1 deletion tencentcloud/resource_tc_ckafka_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ func resourceTencentCloudCkafkaInstanceCreate(d *schema.ResourceData, meta inter
}
return resource.RetryableError(fmt.Errorf("create ckafka instance task is processing"))
})
if err != nil {
return err
}
d.SetId(*instanceId)

// modify instance attributes
Expand Down Expand Up @@ -669,7 +672,7 @@ func resourceTencentCLoudCkafkaInstanceDelete(d *schema.ResourceData, meta inter
err := resource.Retry(writeRetryTimeout, func() *resource.RetryError {
_, err := service.client.UseCkafkaClient().DeleteInstancePre(request)
if err != nil {
retryError(err, "UnsupportedOperation")
return retryError(err, "UnsupportedOperation")
}
return nil
})
Expand All @@ -687,5 +690,8 @@ func resourceTencentCLoudCkafkaInstanceDelete(d *schema.ResourceData, meta inter
}
return resource.RetryableError(fmt.Errorf("delete ckafka instance task is processing"))
})
if err != nil {
return err
}
return nil
}
Loading