Skip to content

Commit

Permalink
resource/alicloud_rocketmq_instance: fix internet_spec property assig…
Browse files Browse the repository at this point in the history
…nment dependency.
  • Loading branch information
ChenHanZhang committed Dec 18, 2023
1 parent 8963a72 commit a0148f2
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 3 deletions.
6 changes: 3 additions & 3 deletions alicloud/resource_alicloud_rocketmq_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,11 @@ func resourceAliCloudRocketmqInstanceCreate(d *schema.ResourceData, meta interfa
internetInfo["flowOutType"] = nodeNative3
}
nodeNative4, _ := jsonpath.Get("$[0].internet_info[0].flow_out_bandwidth", v)
if nodeNative4 != "" {
if nodeNative4 != "" && internetInfo["internetSpec"] == "enable" {
internetInfo["flowOutBandwidth"] = nodeNative4
}
nodeNative5, _ := jsonpath.Get("$[0].internet_info[0].ip_whitelist", v)
if nodeNative5 != "" {
if nodeNative5 != "" && internetInfo["internetSpec"] == "enable" {
internetInfo["ipWhitelist"] = nodeNative5
}
objectDataLocalMap["internetInfo"] = internetInfo
Expand Down Expand Up @@ -795,7 +795,7 @@ func resourceAliCloudRocketmqInstanceDelete(d *schema.ResourceData, meta interfa
}

rocketmqServiceV2 := RocketmqServiceV2{client}
stateConf := BuildStateConf([]string{}, []string{}, d.Timeout(schema.TimeoutDelete), 1*time.Minute, rocketmqServiceV2.RocketmqInstanceStateRefreshFunc(d.Id(), "status", []string{}))
stateConf := BuildStateConf([]string{}, []string{}, d.Timeout(schema.TimeoutDelete), 5*time.Minute, rocketmqServiceV2.RocketmqInstanceStateRefreshFunc(d.Id(), "status", []string{}))
if _, err := stateConf.WaitForState(); err != nil {
return WrapErrorf(err, IdMsg, d.Id())
}
Expand Down
88 changes: 88 additions & 0 deletions alicloud/resource_alicloud_rocketmq_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,94 @@ func testSweepRocketMq(region string) error {
return nil
}

func TestAccAliCloudRocketmqInstance_bugfix(t *testing.T) {
var v map[string]interface{}
resourceId := "alicloud_rocketmq_instance.default"
ra := resourceAttrInit(resourceId, AlicloudRocketmqInstanceMap4101)
rc := resourceCheckInitWithDescribeMethod(resourceId, &v, func() interface{} {
return &RocketmqServiceV2{testAccProvider.Meta().(*connectivity.AliyunClient)}
}, "DescribeRocketmqInstance")
rac := resourceAttrCheckInit(rc, ra)
testAccCheck := rac.resourceAttrMapUpdateSet()
rand := acctest.RandIntRange(10000, 99999)
name := fmt.Sprintf("tf-testacc%srocketmqinstance%d", defaultRegionToTest, rand)
testAccConfig := resourceTestAccConfigFunc(resourceId, name, AlicloudRocketmqInstanceBasicDependence4101)
resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
testAccPreCheckWithRegions(t, true, connectivity.RocketMQSupportRegions)
},
IDRefreshName: resourceId,
Providers: testAccProviders,
CheckDestroy: rac.checkResourceDestroy(),
Steps: []resource.TestStep{
{
Config: testAccConfig(map[string]interface{}{
"instance_name": name,
"product_info": []map[string]interface{}{
{
"msg_process_spec": "rmq.p2.4xlarge",
"send_receive_ratio": "0.3",
"message_retention_time": "70",
},
},
"service_code": "rmq",
"series_code": "professional",
"network_info": []map[string]interface{}{
{
"vpc_info": []map[string]interface{}{
{
"vpc_id": "${alicloud_vpc.createVPC.id}",
"vswitch_id": "${alicloud_vswitch.createVSwitch.id}",
},
},
"internet_info": []map[string]interface{}{
{
"internet_spec": "disable",
"flow_out_type": "uninvolved",
},
},
},
},
"payment_type": "PayAsYouGo",
"sub_series_code": "cluster_ha",
"remark": "自动化测试购买使用11",
"resource_group_id": "${data.alicloud_resource_manager_resource_groups.default.ids.0}",
"software": []map[string]interface{}{
{
"maintain_time": "02:00-06:00",
},
},
"tags": map[string]string{
"Created": "TF",
"For": "Test",
},
}),
Check: resource.ComposeTestCheckFunc(
testAccCheck(map[string]string{
"instance_name": name,
"service_code": "rmq",
"series_code": "professional",
"payment_type": "PayAsYouGo",
"sub_series_code": "cluster_ha",
"remark": "自动化测试购买使用11",
"resource_group_id": CHECKSET,
"tags.%": "2",
"tags.Created": "TF",
"tags.For": "Test",
}),
),
},
{
ResourceName: resourceId,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{},
},
},
})
}

// Test Rocketmq Instance. >>> Resource test cases, automatically generated.
// Case 4665
func TestAccAliCloudRocketmqInstance_basic4665(t *testing.T) {
Expand Down

0 comments on commit a0148f2

Please sign in to comment.