Skip to content

Commit

Permalink
test(rms): segment the target ID to ensure smooth execution of test c…
Browse files Browse the repository at this point in the history
…ases
  • Loading branch information
profoundwu committed Jan 6, 2025
1 parent bbac193 commit e28c775
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
16 changes: 12 additions & 4 deletions huaweicloud/services/acceptance/acceptance.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ var (
HW_RAM_SHARE_INVITATION_ID = os.Getenv("HW_RAM_SHARE_INVITATION_ID")
HW_RAM_SHARE_ID = os.Getenv("HW_RAM_SHARE_ID")

HW_RMS_TARGET_ID = os.Getenv("HW_RMS_TARGET_ID")
HW_RMS_TARGET_ID_FOR_FGS = os.Getenv("HW_RMS_TARGET_ID")
HW_RMS_TARGET_ID_FOR_RFS = os.Getenv("HW_RMS_TARGET_ID_FOR_RFS")

HW_CDN_DOMAIN_NAME = os.Getenv("HW_CDN_DOMAIN_NAME")
// `HW_CDN_CERT_DOMAIN_NAME` Configure the domain name environment variable of the certificate type.
Expand Down Expand Up @@ -1129,9 +1130,16 @@ func TestAccPreCheckRAMSharedPrincipalsQueryFields(t *testing.T) {
}

// lintignore:AT003
func TestAccPreCheckRMSTargetID(t *testing.T) {
if HW_RMS_TARGET_ID == "" {
t.Skip("HW_RMS_TARGET_ID must be set for the acceptance tests.")
func TestAccPreCheckRMSTargetIDForFGS(t *testing.T) {
if HW_RMS_TARGET_ID_FOR_FGS == "" {
t.Skip("HW_RMS_TARGET_ID_FOR_FGS must be set for the acceptance tests.")
}
}

// lintignore:AT003
func TestAccPreCheckRMSTargetIDForRFS(t *testing.T) {
if HW_RMS_TARGET_ID_FOR_RFS == "" {
t.Skip("HW_RMS_TARGET_ID_FOR_RFS must be set for the acceptance tests.")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestAccDataSourceRemediationExecutionStatuses_basic(t *testing.T) {
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
acceptance.TestAccPreCheck(t)
acceptance.TestAccPreCheckRMSTargetID(t)
acceptance.TestAccPreCheckRMSTargetIDForFGS(t)
},
ProviderFactories: acceptance.TestAccProviderFactories,
Steps: []resource.TestStep{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestAccResourceRmsRemediationConfiguration_basic(t *testing.T) {
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
acceptance.TestAccPreCheck(t)
acceptance.TestAccPreCheckRMSTargetID(t)
acceptance.TestAccPreCheckRMSTargetIDForRFS(t)
},
ProviderFactories: acceptance.TestAccProviderFactories,
CheckDestroy: rc.CheckResourceDestroy(),
Expand All @@ -53,7 +53,7 @@ func TestAccResourceRmsRemediationConfiguration_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
rc.CheckResourceExists(),
resource.TestCheckResourceAttr(resourceName, "target_type", "rfs"),
resource.TestCheckResourceAttr(resourceName, "target_id", acceptance.HW_RMS_TARGET_ID),
resource.TestCheckResourceAttr(resourceName, "target_id", acceptance.HW_RMS_TARGET_ID_FOR_RFS),
resource.TestCheckResourceAttr(resourceName, "resource_parameter.0.resource_id", "file_prefix"),
resource.TestCheckResourceAttr(resourceName, "static_parameter.0.var_key", "bucket_name"),
resource.TestCheckResourceAttr(resourceName, "auth_type", "agency"),
Expand All @@ -68,7 +68,7 @@ func TestAccResourceRmsRemediationConfiguration_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
rc.CheckResourceExists(),
resource.TestCheckResourceAttr(resourceName, "target_type", "rfs"),
resource.TestCheckResourceAttr(resourceName, "target_id", acceptance.HW_RMS_TARGET_ID),
resource.TestCheckResourceAttr(resourceName, "target_id", acceptance.HW_RMS_TARGET_ID_FOR_RFS),
resource.TestCheckResourceAttr(resourceName, "resource_parameter.0.resource_id", "file_prefix"),
resource.TestCheckResourceAttr(resourceName, "static_parameter.0.var_key", "bucket_name"),
resource.TestCheckResourceAttr(resourceName, "static_parameter.1.var_key", "compress_type"),
Expand Down Expand Up @@ -110,7 +110,7 @@ resource "huaweicloud_rms_remediation_configuration" "test" {
auth_value = "test_RFS_CTS"
maximum_attempts = 5
retry_attempt_seconds = 3600
}`, testResourceRmsRemediationConfiguration_base(), acceptance.HW_RMS_TARGET_ID)
}`, testResourceRmsRemediationConfiguration_base(), acceptance.HW_RMS_TARGET_ID_FOR_RFS)
}

func testResourceRmsRemediationConfiguration_update() string {
Expand Down Expand Up @@ -139,7 +139,7 @@ resource "huaweicloud_rms_remediation_configuration" "test" {
auth_value = "test_RFS_CTS"
maximum_attempts = 6
retry_attempt_seconds = 60
}`, testResourceRmsRemediationConfiguration_base(), acceptance.HW_RMS_TARGET_ID)
}`, testResourceRmsRemediationConfiguration_base(), acceptance.HW_RMS_TARGET_ID_FOR_RFS)
}

func testResourceRmsRemediationConfiguration_base() string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestAccResourceRemediationException_basic(t *testing.T) {
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
acceptance.TestAccPreCheck(t)
acceptance.TestAccPreCheckRMSTargetID(t)
acceptance.TestAccPreCheckRMSTargetIDForFGS(t)
},
ProviderFactories: acceptance.TestAccProviderFactories,
CheckDestroy: rc.CheckResourceDestroy(),
Expand Down Expand Up @@ -164,5 +164,5 @@ resource "huaweicloud_rms_remediation_configuration" "test" {
provisioner "local-exec" {
command = "sleep 10"
}
}`, name, acceptance.HW_REGION_NAME, acceptance.HW_RMS_TARGET_ID)
}`, name, acceptance.HW_REGION_NAME, acceptance.HW_RMS_TARGET_ID_FOR_FGS)
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestAccResourceRemediationExecution_basic(t *testing.T) {
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
acceptance.TestAccPreCheck(t)
acceptance.TestAccPreCheckRMSTargetID(t)
acceptance.TestAccPreCheckRMSTargetIDForFGS(t)
},
ProviderFactories: acceptance.TestAccProviderFactories,
CheckDestroy: nil,
Expand All @@ -33,7 +33,7 @@ func TestAccResourceRemediationExecution_specifyResources(t *testing.T) {
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
acceptance.TestAccPreCheck(t)
acceptance.TestAccPreCheckRMSTargetID(t)
acceptance.TestAccPreCheckRMSTargetIDForFGS(t)
},
ProviderFactories: acceptance.TestAccProviderFactories,
CheckDestroy: nil,
Expand Down Expand Up @@ -142,5 +142,5 @@ resource "huaweicloud_rms_remediation_configuration" "test" {
provisioner "local-exec" {
command = "sleep 15"
}
}`, name, acceptance.HW_REGION_NAME, acceptance.HW_RMS_TARGET_ID)
}`, name, acceptance.HW_REGION_NAME, acceptance.HW_RMS_TARGET_ID_FOR_FGS)
}

0 comments on commit e28c775

Please sign in to comment.