Skip to content

Commit

Permalink
schema and test fix for instance group manager action
Browse files Browse the repository at this point in the history
  • Loading branch information
deepaksibm committed Jan 24, 2022
1 parent e588feb commit ccd5135
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func ResourceIBMISInstanceGroupManagerAction() *schema.Resource {
ValidateFunc: validate.InvokeValidator("ibm_is_instance_group_manager_action", "membership_count"),
Description: "The number of members the instance group should have at the scheduled time.",
ConflictsWith: []string{"target_manager", "max_membership_count", "min_membership_count"},
AtLeastOneOf: []string{"target_manager", "membership_count"},
},

"max_membership_count": {
Expand All @@ -103,6 +104,7 @@ func ResourceIBMISInstanceGroupManagerAction() *schema.Resource {
Description: "The unique identifier for this instance group manager of type autoscale.",
ConflictsWith: []string{"membership_count"},
RequiredWith: []string{"min_membership_count", "max_membership_count"},
AtLeastOneOf: []string{"target_manager", "membership_count"},
},

"target_manager_name": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,15 @@ func TestAccIBMISInstanceGroupManagerAction_basic_autoscale(t *testing.T) {
instanceGroupManager := fmt.Sprintf("testinstancegroupmanager%d", randInt)
instanceGroupManagerAutoscale := fmt.Sprintf("testinstancegroupmanagerautoscale%d", randInt)
instanceGroupManagerAction := fmt.Sprintf("testinstancegroupmanageraction%d", randInt)
instanceGroupManagerPolicyAction := fmt.Sprintf("testinstancegroupmanagerpolicy%d", randInt)

resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
CheckDestroy: testAccCheckIBMISInstanceGroupManagerActionDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckIBMISInstanceGroupManagerActionAutoscaleConfig(vpcName, subnetName, sshKeyName, publicKey, templateName, instanceGroupName, instanceGroupManager, instanceGroupManagerAutoscale, instanceGroupManagerAction),
Config: testAccCheckIBMISInstanceGroupManagerActionAutoscaleConfig(vpcName, subnetName, sshKeyName, publicKey, templateName, instanceGroupName, instanceGroupManager, instanceGroupManagerAutoscale, instanceGroupManagerPolicyAction, instanceGroupManagerAction),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"ibm_is_instance_group_manager.instance_group_manager", "name", instanceGroupManager),
Expand Down Expand Up @@ -136,7 +137,7 @@ func testAccCheckIBMISInstanceGroupManagerActionConfig(vpcName, subnetName, sshK
resource "ibm_is_instance_template" "instancetemplate1" {
name = "%s"
image = "r006-14140f94-fcc4-11e9-96e7-a72723715315"
image = "%s"
profile = "bx2-8x32"
primary_network_interface {
Expand Down Expand Up @@ -170,11 +171,11 @@ func testAccCheckIBMISInstanceGroupManagerActionConfig(vpcName, subnetName, sshK
membership_count = 1
}
`, vpcName, subnetName, sshKeyName, publicKey, templateName, instanceGroupName, instanceGroupManager, instanceGroupManagerAction)
`, vpcName, subnetName, sshKeyName, publicKey, templateName, acc.IsImage, instanceGroupName, instanceGroupManager, instanceGroupManagerAction)

}

func testAccCheckIBMISInstanceGroupManagerActionAutoscaleConfig(vpcName, subnetName, sshKeyName, publicKey, templateName, instanceGroupName, instanceGroupManager, instanceGroupManagerAutoscale, instanceGroupManagerAction string) string {
func testAccCheckIBMISInstanceGroupManagerActionAutoscaleConfig(vpcName, subnetName, sshKeyName, publicKey, templateName, instanceGroupName, instanceGroupManager, instanceGroupManagerAutoscale, instanceGroupManagerPolicyAction, instanceGroupManagerAction string) string {
return fmt.Sprintf(`
provider "ibm" {
generation = 2
Expand All @@ -198,7 +199,7 @@ func testAccCheckIBMISInstanceGroupManagerActionAutoscaleConfig(vpcName, subnetN
resource "ibm_is_instance_template" "instancetemplate1" {
name = "%s"
image = "r006-14140f94-fcc4-11e9-96e7-a72723715315"
image = "%s"
profile = "bx2-8x32"
primary_network_interface {
Expand Down Expand Up @@ -241,7 +242,7 @@ func testAccCheckIBMISInstanceGroupManagerActionAutoscaleConfig(vpcName, subnetN
metric_type = "cpu"
metric_value = 70
policy_type = "target"
name = "instancegrouppolicysunitha"
name = "%s"
}
resource "ibm_is_instance_group_manager_action" "instance_group_manager_action" {
Expand All @@ -254,6 +255,6 @@ func testAccCheckIBMISInstanceGroupManagerActionAutoscaleConfig(vpcName, subnetN
max_membership_count = 2
}
`, vpcName, subnetName, sshKeyName, publicKey, templateName, instanceGroupName, instanceGroupManager, instanceGroupManagerAutoscale, instanceGroupManagerAction)
`, vpcName, subnetName, sshKeyName, publicKey, templateName, acc.IsImage, instanceGroupName, instanceGroupManager, instanceGroupManagerAutoscale, instanceGroupManagerPolicyAction, instanceGroupManagerAction)

}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Review the argument references that you can specify for your resource.
- `max_membership_count` - (Optional, Integer) The maximum number of members the instance group should have at the scheduled time.
- `min_membership_count` - (Optional, Integer) The minimum number of members the instance group should have at the scheduled time. Default value is set to 1.
- `name` - (Optional, String) The user-defined name for this instance group manager action. Names must be unique within the instance group manager.
- `run_at` - (Optional, String) The date and time that is specified for the scheduled action. The format is in ISO 8601 format. Example: 2024-03-05T15:31:50.701Z or 2024-03-05T15:31:50.701+8:00.
- `run_at` - (Optional, String) The date and time that is specified for the scheduled action. The format is in ISO 8601 format. Example: 2024-03-05T15:31:50.701Z or 2024-03-06T15:31:50.701+8:00.
- `target_manager` - (Optional, String) The unique identifier for this instance group manager of type autoscale.


Expand Down

0 comments on commit ccd5135

Please sign in to comment.