Skip to content

Commit

Permalink
testcase: Deprecated alicloud_arms_remote_write, alicloud_arms_remote…
Browse files Browse the repository at this point in the history
…_writes testcase
  • Loading branch information
MrWolong authored and ChenHanZhang committed Dec 13, 2024
1 parent b054d37 commit 31c36a2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
25 changes: 13 additions & 12 deletions alicloud/data_source_alicloud_arms_remote_writes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,36 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
)

func TestAccAlicloudArmsRemoteWritesDataSource(t *testing.T) {
// data source alicloud_arms_remote_writes has been deprecated from version 1.228.0
func SkipTestAccAliCloudArmsRemoteWritesDataSource(t *testing.T) {
rand := acctest.RandIntRange(0, 10)
idsConf := dataSourceTestAccConfig{
existConfig: testAccCheckAlicloudArmsRemoteWritesDataSourceName(rand, map[string]string{
existConfig: testAccCheckAliCloudArmsRemoteWritesDataSourceName(rand, map[string]string{
"ids": `["${alicloud_arms_remote_write.default.id}"]`,
}),
fakeConfig: testAccCheckAlicloudArmsRemoteWritesDataSourceName(rand, map[string]string{
fakeConfig: testAccCheckAliCloudArmsRemoteWritesDataSourceName(rand, map[string]string{
"ids": `["${alicloud_arms_remote_write.default.id}_fake"]`,
}),
}
nameRegexConf := dataSourceTestAccConfig{
existConfig: testAccCheckAlicloudArmsRemoteWritesDataSourceName(rand, map[string]string{
existConfig: testAccCheckAliCloudArmsRemoteWritesDataSourceName(rand, map[string]string{
"name_regex": `"${alicloud_arms_remote_write.default.remote_write_name}"`,
}),
fakeConfig: testAccCheckAlicloudArmsRemoteWritesDataSourceName(rand, map[string]string{
fakeConfig: testAccCheckAliCloudArmsRemoteWritesDataSourceName(rand, map[string]string{
"name_regex": `"${alicloud_arms_remote_write.default.remote_write_name}_fake"`,
}),
}
allConf := dataSourceTestAccConfig{
existConfig: testAccCheckAlicloudArmsRemoteWritesDataSourceName(rand, map[string]string{
existConfig: testAccCheckAliCloudArmsRemoteWritesDataSourceName(rand, map[string]string{
"ids": `["${alicloud_arms_remote_write.default.id}"]`,
"name_regex": `"${alicloud_arms_remote_write.default.remote_write_name}"`,
}),
fakeConfig: testAccCheckAlicloudArmsRemoteWritesDataSourceName(rand, map[string]string{
fakeConfig: testAccCheckAliCloudArmsRemoteWritesDataSourceName(rand, map[string]string{
"ids": `["${alicloud_arms_remote_write.default.id}_fake"]`,
"name_regex": `"${alicloud_arms_remote_write.default.remote_write_name}_fake"`,
}),
}
var existAlicloudArmsRemoteWritesDataSourceNameMapFunc = func(rand int) map[string]string {
var existAliCloudArmsRemoteWritesDataSourceNameMapFunc = func(rand int) map[string]string {
return map[string]string{
"ids.#": "1",
"names.#": "1",
Expand All @@ -47,7 +48,7 @@ func TestAccAlicloudArmsRemoteWritesDataSource(t *testing.T) {
"remote_writes.0.remote_write_yaml": "remote_write:\n- name: ArmsRemoteWrite\n url: http://47.96.227.137:8080/prometheus/xxx/yyy/cn-hangzhou/api/v3/write\n basic_auth: {username: 666, password: '******'}\n write_relabel_configs:\n - source_labels: [instance_id]\n separator: ;\n regex: si-6e2ca86444db4e55a7c1\n replacement: $1\n action: keep\n",
}
}
var fakeAlicloudArmsRemoteWritesDataSourceNameMapFunc = func(rand int) map[string]string {
var fakeAliCloudArmsRemoteWritesDataSourceNameMapFunc = func(rand int) map[string]string {
return map[string]string{
"ids.#": "0",
"names.#": "0",
Expand All @@ -56,16 +57,16 @@ func TestAccAlicloudArmsRemoteWritesDataSource(t *testing.T) {
}
var alicloudArmsRemoteWritesCheckInfo = dataSourceAttr{
resourceId: "data.alicloud_arms_remote_writes.default",
existMapFunc: existAlicloudArmsRemoteWritesDataSourceNameMapFunc,
fakeMapFunc: fakeAlicloudArmsRemoteWritesDataSourceNameMapFunc,
existMapFunc: existAliCloudArmsRemoteWritesDataSourceNameMapFunc,
fakeMapFunc: fakeAliCloudArmsRemoteWritesDataSourceNameMapFunc,
}
preCheck := func() {
testAccPreCheck(t)
}
alicloudArmsRemoteWritesCheckInfo.dataSourceTestCheckWithPreCheck(t, rand, preCheck, idsConf, nameRegexConf, allConf)
}

func testAccCheckAlicloudArmsRemoteWritesDataSourceName(rand int, attrMap map[string]string) string {
func testAccCheckAliCloudArmsRemoteWritesDataSourceName(rand int, attrMap map[string]string) string {
var pairs []string
for k, v := range attrMap {
pairs = append(pairs, k+" = "+v)
Expand Down
11 changes: 6 additions & 5 deletions alicloud/resource_alicloud_arms_remote_write_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccAlicloudArmsRemoteWrite_basic0(t *testing.T) {
// resource alicloud_arms_remote_writes has been deprecated from version 1.228.0
func SkipTestAccAliCloudArmsRemoteWrite_basic0(t *testing.T) {
var v map[string]interface{}
resourceId := "alicloud_arms_remote_write.default"
ra := resourceAttrInit(resourceId, AlicloudArmsRemoteWriteMap)
ra := resourceAttrInit(resourceId, AliCloudArmsRemoteWriteMap)
rc := resourceCheckInitWithDescribeMethod(resourceId, &v, func() interface{} {
return &ArmsService{testAccProvider.Meta().(*connectivity.AliyunClient)}
}, "DescribeArmsRemoteWrite")
rac := resourceAttrCheckInit(rc, ra)
testAccCheck := rac.resourceAttrMapUpdateSet()
rand := acctest.RandIntRange(10, 99)
name := fmt.Sprintf("tf-testacc-ArmsRW%d", rand)
testAccConfig := resourceTestAccConfigFunc(resourceId, name, AlicloudArmsRemoteWriteBasicDependence0)
testAccConfig := resourceTestAccConfigFunc(resourceId, name, AliCloudArmsRemoteWriteBasicDependence0)
resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
Expand Down Expand Up @@ -60,11 +61,11 @@ func TestAccAlicloudArmsRemoteWrite_basic0(t *testing.T) {
})
}

var AlicloudArmsRemoteWriteMap = map[string]string{
var AliCloudArmsRemoteWriteMap = map[string]string{
"remote_write_name": CHECKSET,
}

func AlicloudArmsRemoteWriteBasicDependence0(name string) string {
func AliCloudArmsRemoteWriteBasicDependence0(name string) string {
return fmt.Sprintf(`
variable "name" {
default = "%s"
Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/arms_prometheis.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This data source provides the Arms Prometheis of the current Alibaba Cloud user.

-> **NOTE:** Available since v1.203.0.

-> **DEPRECATED:** This resource has been renamed to [alicloud_ecs_disk](https://www.terraform.io/docs/providers/alicloud/d/arms_prometheus) from version 1.214.0.
-> **DEPRECATED:** This data source has been renamed to [alicloud_arms_prometheus](https://www.terraform.io/docs/providers/alicloud/d/arms_prometheus) from version 1.214.0.

## Example Usage

Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/arms_remote_writes.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This data source provides the Arms Remote Writes of the current Alibaba Cloud us

-> **NOTE:** Available since v1.204.0.

-> **DEPRECATED:** This resource has been deprecated since v1.228.0.
-> **DEPRECATED:** This data source has been deprecated since v1.228.0.

## Example Usage

Expand Down

0 comments on commit 31c36a2

Please sign in to comment.