Skip to content

Commit

Permalink
tests: switching to use managed disks to allow us to scale to larger …
Browse files Browse the repository at this point in the history
…nodes
  • Loading branch information
tombuildsstuff committed Jan 31, 2019
1 parent 5c3bb59 commit 3c771e5
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 140 deletions.
119 changes: 46 additions & 73 deletions azurerm/resource_arm_autoscale_setting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"net/http"
"testing"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
Expand All @@ -14,9 +13,8 @@ import (
func TestAccAzureRMAutoScaleSetting_basic(t *testing.T) {
resourceName := "azurerm_autoscale_setting.test"
ri := tf.AccRandTimeInt()
rs := acctest.RandString(6)
location := testLocation()
config := testAccAzureRMAutoScaleSetting_basic(ri, rs, location)
config := testAccAzureRMAutoScaleSetting_basic(ri, location)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down Expand Up @@ -47,9 +45,8 @@ func TestAccAzureRMAutoScaleSetting_basic(t *testing.T) {
func TestAccAzureRMAutoScaleSetting_multipleProfiles(t *testing.T) {
resourceName := "azurerm_autoscale_setting.test"
ri := tf.AccRandTimeInt()
rs := acctest.RandString(6)
location := testLocation()
config := testAccAzureRMAutoScaleSetting_multipleProfiles(ri, rs, location)
config := testAccAzureRMAutoScaleSetting_multipleProfiles(ri, location)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -73,7 +70,6 @@ func TestAccAzureRMAutoScaleSetting_multipleProfiles(t *testing.T) {
func TestAccAzureRMAutoScaleSetting_update(t *testing.T) {
resourceName := "azurerm_autoscale_setting.test"
ri := tf.AccRandTimeInt()
rs := acctest.RandString(6)
location := testLocation()

resource.ParallelTest(t, resource.TestCase{
Expand All @@ -82,18 +78,18 @@ func TestAccAzureRMAutoScaleSetting_update(t *testing.T) {
CheckDestroy: testCheckAzureRMAutoScaleSettingDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMAutoScaleSetting_capacity(ri, rs, location, 1, 3, 2),
Config: testAccAzureRMAutoScaleSetting_capacity(ri, location, 1, 3, 2),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAutoScaleSettingExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "enabled", "false"),
resource.TestCheckResourceAttr(resourceName, "profile.#", "1"),
resource.TestCheckResourceAttr(resourceName, "profile.0.capacity.0.minimum", "1"),
resource.TestCheckResourceAttr(resourceName, "profile.0.capacity.0.maximum", "2"),
resource.TestCheckResourceAttr(resourceName, "profile.0.capacity.0.default", "4"),
resource.TestCheckResourceAttr(resourceName, "profile.0.capacity.0.maximum", "3"),
resource.TestCheckResourceAttr(resourceName, "profile.0.capacity.0.default", "2"),
),
},
{
Config: testAccAzureRMAutoScaleSetting_capacity(ri, rs, location, 2, 4, 3),
Config: testAccAzureRMAutoScaleSetting_capacity(ri, location, 2, 4, 3),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAutoScaleSettingExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "enabled", "false"),
Expand All @@ -104,7 +100,7 @@ func TestAccAzureRMAutoScaleSetting_update(t *testing.T) {
),
},
{
Config: testAccAzureRMAutoScaleSetting_capacity(ri, rs, location, 2, 45, 3),
Config: testAccAzureRMAutoScaleSetting_capacity(ri, location, 2, 45, 3),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAutoScaleSettingExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "enabled", "false"),
Expand All @@ -121,7 +117,6 @@ func TestAccAzureRMAutoScaleSetting_update(t *testing.T) {
func TestAccAzureRMAutoScaleSetting_multipleRules(t *testing.T) {
resourceName := "azurerm_autoscale_setting.test"
ri := tf.AccRandTimeInt()
rs := acctest.RandString(6)
location := testLocation()

resource.ParallelTest(t, resource.TestCase{
Expand All @@ -130,7 +125,7 @@ func TestAccAzureRMAutoScaleSetting_multipleRules(t *testing.T) {
CheckDestroy: testCheckAzureRMAutoScaleSettingDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMAutoScaleSetting_basic(ri, rs, location),
Config: testAccAzureRMAutoScaleSetting_basic(ri, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAutoScaleSettingExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "enabled", "true"),
Expand All @@ -142,7 +137,7 @@ func TestAccAzureRMAutoScaleSetting_multipleRules(t *testing.T) {
),
},
{
Config: testAccAzureRMAutoScaleSetting_multipleRules(ri, rs, location),
Config: testAccAzureRMAutoScaleSetting_multipleRules(ri, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAutoScaleSettingExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "enabled", "true"),
Expand All @@ -161,7 +156,6 @@ func TestAccAzureRMAutoScaleSetting_multipleRules(t *testing.T) {
func TestAccAzureRMAutoScaleSetting_customEmails(t *testing.T) {
resourceName := "azurerm_autoscale_setting.test"
ri := tf.AccRandTimeInt()
rs := acctest.RandString(6)
location := testLocation()

resource.ParallelTest(t, resource.TestCase{
Expand All @@ -170,7 +164,7 @@ func TestAccAzureRMAutoScaleSetting_customEmails(t *testing.T) {
CheckDestroy: testCheckAzureRMAutoScaleSettingDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMAutoScaleSetting_email(ri, rs, location),
Config: testAccAzureRMAutoScaleSetting_email(ri, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAutoScaleSettingExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "notification.#", "1"),
Expand All @@ -180,7 +174,7 @@ func TestAccAzureRMAutoScaleSetting_customEmails(t *testing.T) {
),
},
{
Config: testAccAzureRMAutoScaleSetting_emailUpdated(ri, rs, location),
Config: testAccAzureRMAutoScaleSetting_emailUpdated(ri, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAutoScaleSettingExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "notification.#", "1"),
Expand All @@ -197,9 +191,8 @@ func TestAccAzureRMAutoScaleSetting_customEmails(t *testing.T) {
func TestAccAzureRMAutoScaleSetting_recurrence(t *testing.T) {
resourceName := "azurerm_autoscale_setting.test"
ri := tf.AccRandTimeInt()
rs := acctest.RandString(6)
location := testLocation()
config := testAccAzureRMAutoScaleSetting_recurrence(ri, rs, location)
config := testAccAzureRMAutoScaleSetting_recurrence(ri, location)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down Expand Up @@ -229,7 +222,6 @@ func TestAccAzureRMAutoScaleSetting_recurrence(t *testing.T) {
func TestAccAzureRMAutoScaleSetting_recurrenceUpdate(t *testing.T) {
resourceName := "azurerm_autoscale_setting.test"
ri := tf.AccRandTimeInt()
rs := acctest.RandString(6)
location := testLocation()

resource.ParallelTest(t, resource.TestCase{
Expand All @@ -238,7 +230,7 @@ func TestAccAzureRMAutoScaleSetting_recurrenceUpdate(t *testing.T) {
CheckDestroy: testCheckAzureRMAutoScaleSettingDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMAutoScaleSetting_recurrence(ri, rs, location),
Config: testAccAzureRMAutoScaleSetting_recurrence(ri, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAutoScaleSettingExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "notification.#", "1"),
Expand All @@ -251,7 +243,7 @@ func TestAccAzureRMAutoScaleSetting_recurrenceUpdate(t *testing.T) {
),
},
{
Config: testAccAzureRMAutoScaleSetting_recurrenceUpdated(ri, rs, location),
Config: testAccAzureRMAutoScaleSetting_recurrenceUpdated(ri, location),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAutoScaleSettingExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "profile.0.recurrence.#", "1"),
Expand All @@ -270,9 +262,8 @@ func TestAccAzureRMAutoScaleSetting_recurrenceUpdate(t *testing.T) {
func TestAccAzureRMAutoScaleSetting_fixedDate(t *testing.T) {
resourceName := "azurerm_autoscale_setting.test"
ri := tf.AccRandTimeInt()
rs := acctest.RandString(6)
location := testLocation()
config := testAccAzureRMAutoScaleSetting_fixedDate(ri, rs, location)
config := testAccAzureRMAutoScaleSetting_fixedDate(ri, location)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down Expand Up @@ -354,8 +345,8 @@ func testCheckAzureRMAutoScaleSettingDestroy(s *terraform.State) error {
return nil
}

func testAccAzureRMAutoScaleSetting_basic(rInt int, rString string, location string) string {
template := testAccAzureRMAutoScaleSetting_template(rInt, rString, location)
func testAccAzureRMAutoScaleSetting_basic(rInt int, location string) string {
template := testAccAzureRMAutoScaleSetting_template(rInt, location)
return fmt.Sprintf(`
%s
Expand Down Expand Up @@ -398,8 +389,8 @@ resource "azurerm_autoscale_setting" "test" {
`, template, rInt)
}

func testAccAzureRMAutoScaleSetting_multipleProfiles(rInt int, rString string, location string) string {
template := testAccAzureRMAutoScaleSetting_template(rInt, rString, location)
func testAccAzureRMAutoScaleSetting_multipleProfiles(rInt int, location string) string {
template := testAccAzureRMAutoScaleSetting_template(rInt, location)
return fmt.Sprintf(`
%s
Expand Down Expand Up @@ -485,8 +476,8 @@ resource "azurerm_autoscale_setting" "test" {
`, template, rInt)
}

func testAccAzureRMAutoScaleSetting_multipleRules(rInt int, rString string, location string) string {
template := testAccAzureRMAutoScaleSetting_template(rInt, rString, location)
func testAccAzureRMAutoScaleSetting_multipleRules(rInt int, location string) string {
template := testAccAzureRMAutoScaleSetting_template(rInt, location)
return fmt.Sprintf(`
%s
Expand Down Expand Up @@ -550,8 +541,8 @@ resource "azurerm_autoscale_setting" "test" {
`, template, rInt)
}

func testAccAzureRMAutoScaleSetting_capacity(rInt int, rString string, location string, min int, max int, defaultVal int) string {
template := testAccAzureRMAutoScaleSetting_template(rInt, rString, location)
func testAccAzureRMAutoScaleSetting_capacity(rInt int, location string, min int, max int, defaultVal int) string {
template := testAccAzureRMAutoScaleSetting_template(rInt, location)
return fmt.Sprintf(`
%s
Expand Down Expand Up @@ -595,8 +586,8 @@ resource "azurerm_autoscale_setting" "test" {
`, template, rInt, defaultVal, min, max)
}

func testAccAzureRMAutoScaleSetting_email(rInt int, rString string, location string) string {
template := testAccAzureRMAutoScaleSetting_template(rInt, rString, location)
func testAccAzureRMAutoScaleSetting_email(rInt int, location string) string {
template := testAccAzureRMAutoScaleSetting_template(rInt, location)
return fmt.Sprintf(`
%s
Expand Down Expand Up @@ -647,8 +638,8 @@ resource "azurerm_autoscale_setting" "test" {
`, template, rInt, rInt)
}

func testAccAzureRMAutoScaleSetting_emailUpdated(rInt int, rString string, location string) string {
template := testAccAzureRMAutoScaleSetting_template(rInt, rString, location)
func testAccAzureRMAutoScaleSetting_emailUpdated(rInt int, location string) string {
template := testAccAzureRMAutoScaleSetting_template(rInt, location)
return fmt.Sprintf(`
%s
Expand Down Expand Up @@ -699,8 +690,8 @@ resource "azurerm_autoscale_setting" "test" {
`, template, rInt, rInt, rInt)
}

func testAccAzureRMAutoScaleSetting_recurrence(rInt int, rString string, location string) string {
template := testAccAzureRMAutoScaleSetting_template(rInt, rString, location)
func testAccAzureRMAutoScaleSetting_recurrence(rInt int, location string) string {
template := testAccAzureRMAutoScaleSetting_template(rInt, location)
return fmt.Sprintf(`
%s
Expand Down Expand Up @@ -743,8 +734,8 @@ resource "azurerm_autoscale_setting" "test" {
`, template, rInt)
}

func testAccAzureRMAutoScaleSetting_recurrenceUpdated(rInt int, rString string, location string) string {
template := testAccAzureRMAutoScaleSetting_template(rInt, rString, location)
func testAccAzureRMAutoScaleSetting_recurrenceUpdated(rInt int, location string) string {
template := testAccAzureRMAutoScaleSetting_template(rInt, location)
return fmt.Sprintf(`
%s
Expand Down Expand Up @@ -787,8 +778,8 @@ resource "azurerm_autoscale_setting" "test" {
`, template, rInt)
}

func testAccAzureRMAutoScaleSetting_fixedDate(rInt int, rString string, location string) string {
template := testAccAzureRMAutoScaleSetting_template(rInt, rString, location)
func testAccAzureRMAutoScaleSetting_fixedDate(rInt int, location string) string {
template := testAccAzureRMAutoScaleSetting_template(rInt, location)
return fmt.Sprintf(`
%s
Expand Down Expand Up @@ -817,7 +808,7 @@ resource "azurerm_autoscale_setting" "test" {
`, template, rInt)
}

func testAccAzureRMAutoScaleSetting_template(rInt int, rString string, location string) string {
func testAccAzureRMAutoScaleSetting_template(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
Expand All @@ -838,35 +829,17 @@ resource "azurerm_subnet" "test" {
address_prefix = "10.0.2.0/24"
}
resource "azurerm_storage_account" "test" {
name = "accsa%s"
resource_group_name = "${azurerm_resource_group.test.name}"
location = "${azurerm_resource_group.test.location}"
account_tier = "Standard"
account_replication_type = "LRS"
tags {
environment = "staging"
}
}
resource "azurerm_storage_container" "test" {
name = "vhds"
resource_group_name = "${azurerm_resource_group.test.name}"
storage_account_name = "${azurerm_storage_account.test.name}"
container_access_type = "private"
}
resource "azurerm_virtual_machine_scale_set" "test" {
name = "acctvmss-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
upgrade_policy_mode = "Manual"
name = "acctvmss-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
upgrade_policy_mode = "Automatic"
single_placement_group = "false"
sku {
name = "Standard_F2"
name = "Standard_DS1_v2"
tier = "Standard"
capacity = 2
capacity = 30
}
os_profile {
Expand All @@ -887,10 +860,10 @@ resource "azurerm_virtual_machine_scale_set" "test" {
}
storage_profile_os_disk {
name = "osDiskProfile"
caching = "ReadWrite"
create_option = "FromImage"
vhd_containers = ["${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}"]
name = ""
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "StandardSSD_LRS"
}
storage_profile_image_reference {
Expand All @@ -900,5 +873,5 @@ resource "azurerm_virtual_machine_scale_set" "test" {
version = "latest"
}
}
`, rInt, location, rInt, rString, rInt, rInt, rInt)
`, rInt, location, rInt, rInt, rInt, rInt)
}
Loading

0 comments on commit 3c771e5

Please sign in to comment.