provider/azure: Randomize name in acceptance tests
This should address the failures seen in Travis Build Run #8774. It is likely there are others which also need addressing - they will be addressed on a case-by-case basis as they come up.
This commit is contained in:
parent
8c8b39d15d
commit
ef350af219
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
)
|
)
|
||||||
|
@ -11,16 +12,19 @@ import (
|
||||||
func TestAccAzureHostedServiceBasic(t *testing.T) {
|
func TestAccAzureHostedServiceBasic(t *testing.T) {
|
||||||
name := "azure_hosted_service.foo"
|
name := "azure_hosted_service.foo"
|
||||||
|
|
||||||
|
hostedServiceName := fmt.Sprintf("terraform-testing-service%d", acctest.RandInt())
|
||||||
|
config := fmt.Sprintf(testAccAzureHostedServiceBasic, hostedServiceName)
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccCheckAzureHostedServiceDestroyed,
|
CheckDestroy: testAccCheckAzureHostedServiceDestroyed,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccAzureHostedServiceBasic,
|
Config: config,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAzureHostedServiceExists(name),
|
testAccCheckAzureHostedServiceExists(name),
|
||||||
resource.TestCheckResourceAttr(name, "name", "terraform-testing-service"),
|
resource.TestCheckResourceAttr(name, "name", hostedServiceName),
|
||||||
resource.TestCheckResourceAttr(name, "location", "North Europe"),
|
resource.TestCheckResourceAttr(name, "location", "North Europe"),
|
||||||
resource.TestCheckResourceAttr(name, "ephemeral_contents", "false"),
|
resource.TestCheckResourceAttr(name, "ephemeral_contents", "false"),
|
||||||
resource.TestCheckResourceAttr(name, "description", "very discriptive"),
|
resource.TestCheckResourceAttr(name, "description", "very discriptive"),
|
||||||
|
@ -34,16 +38,21 @@ func TestAccAzureHostedServiceBasic(t *testing.T) {
|
||||||
func TestAccAzureHostedServiceUpdate(t *testing.T) {
|
func TestAccAzureHostedServiceUpdate(t *testing.T) {
|
||||||
name := "azure_hosted_service.foo"
|
name := "azure_hosted_service.foo"
|
||||||
|
|
||||||
|
hostedServiceName := fmt.Sprintf("terraform-testing-service%d", acctest.RandInt())
|
||||||
|
|
||||||
|
basicConfig := fmt.Sprintf(testAccAzureHostedServiceBasic, hostedServiceName)
|
||||||
|
updateConfig := fmt.Sprintf(testAccAzureHostedServiceUpdate, hostedServiceName)
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccCheckAzureHostedServiceDestroyed,
|
CheckDestroy: testAccCheckAzureHostedServiceDestroyed,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccAzureHostedServiceBasic,
|
Config: basicConfig,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAzureHostedServiceExists(name),
|
testAccCheckAzureHostedServiceExists(name),
|
||||||
resource.TestCheckResourceAttr(name, "name", "terraform-testing-service"),
|
resource.TestCheckResourceAttr(name, "name", hostedServiceName),
|
||||||
resource.TestCheckResourceAttr(name, "location", "North Europe"),
|
resource.TestCheckResourceAttr(name, "location", "North Europe"),
|
||||||
resource.TestCheckResourceAttr(name, "ephemeral_contents", "false"),
|
resource.TestCheckResourceAttr(name, "ephemeral_contents", "false"),
|
||||||
resource.TestCheckResourceAttr(name, "description", "very discriptive"),
|
resource.TestCheckResourceAttr(name, "description", "very discriptive"),
|
||||||
|
@ -52,10 +61,10 @@ func TestAccAzureHostedServiceUpdate(t *testing.T) {
|
||||||
},
|
},
|
||||||
|
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccAzureHostedServiceUpdate,
|
Config: updateConfig,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAzureHostedServiceExists(name),
|
testAccCheckAzureHostedServiceExists(name),
|
||||||
resource.TestCheckResourceAttr(name, "name", "terraform-testing-service"),
|
resource.TestCheckResourceAttr(name, "name", hostedServiceName),
|
||||||
resource.TestCheckResourceAttr(name, "location", "North Europe"),
|
resource.TestCheckResourceAttr(name, "location", "North Europe"),
|
||||||
resource.TestCheckResourceAttr(name, "ephemeral_contents", "true"),
|
resource.TestCheckResourceAttr(name, "ephemeral_contents", "true"),
|
||||||
resource.TestCheckResourceAttr(name, "description", "very discriptive"),
|
resource.TestCheckResourceAttr(name, "description", "very discriptive"),
|
||||||
|
@ -105,7 +114,7 @@ func testAccCheckAzureHostedServiceDestroyed(s *terraform.State) error {
|
||||||
|
|
||||||
const testAccAzureHostedServiceBasic = `
|
const testAccAzureHostedServiceBasic = `
|
||||||
resource "azure_hosted_service" "foo" {
|
resource "azure_hosted_service" "foo" {
|
||||||
name = "terraform-testing-service"
|
name = "%s"
|
||||||
location = "North Europe"
|
location = "North Europe"
|
||||||
ephemeral_contents = false
|
ephemeral_contents = false
|
||||||
description = "very discriptive"
|
description = "very discriptive"
|
||||||
|
@ -114,7 +123,7 @@ resource "azure_hosted_service" "foo" {
|
||||||
`
|
`
|
||||||
const testAccAzureHostedServiceUpdate = `
|
const testAccAzureHostedServiceUpdate = `
|
||||||
resource "azure_hosted_service" "foo" {
|
resource "azure_hosted_service" "foo" {
|
||||||
name = "terraform-testing-service"
|
name = "%s"
|
||||||
location = "North Europe"
|
location = "North Europe"
|
||||||
ephemeral_contents = true
|
ephemeral_contents = true
|
||||||
description = "very discriptive"
|
description = "very discriptive"
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
|
|
||||||
"github.com/Azure/azure-sdk-for-go/management"
|
"github.com/Azure/azure-sdk-for-go/management"
|
||||||
"github.com/Azure/azure-sdk-for-go/management/virtualmachine"
|
"github.com/Azure/azure-sdk-for-go/management/virtualmachine"
|
||||||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
)
|
)
|
||||||
|
@ -46,21 +47,25 @@ func TestAccAzureInstance_basic(t *testing.T) {
|
||||||
func TestAccAzureInstance_separateHostedService(t *testing.T) {
|
func TestAccAzureInstance_separateHostedService(t *testing.T) {
|
||||||
var dpmt virtualmachine.DeploymentResponse
|
var dpmt virtualmachine.DeploymentResponse
|
||||||
|
|
||||||
|
hostedServiceName := fmt.Sprintf("terraform-testing-service%d", acctest.RandInt())
|
||||||
|
|
||||||
|
config := fmt.Sprintf(testAccAzureInstance_separateHostedService, hostedServiceName, instanceName, testAccStorageServiceName)
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccCheckAzureInstanceDestroyed(testAccHostedServiceName),
|
CheckDestroy: testAccCheckAzureInstanceDestroyed(testAccHostedServiceName),
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccAzureInstance_separateHostedService,
|
Config: config,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAzureInstanceExists(
|
testAccCheckAzureInstanceExists(
|
||||||
"azure_instance.foo", testAccHostedServiceName, &dpmt),
|
"azure_instance.foo", hostedServiceName, &dpmt),
|
||||||
testAccCheckAzureInstanceBasicAttributes(&dpmt),
|
testAccCheckAzureInstanceBasicAttributes(&dpmt),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"azure_instance.foo", "name", instanceName),
|
"azure_instance.foo", "name", instanceName),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"azure_instance.foo", "hosted_service_name", "terraform-testing-service"),
|
"azure_instance.foo", "hosted_service_name", hostedServiceName),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"azure_instance.foo", "location", "West US"),
|
"azure_instance.foo", "location", "West US"),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
|
@ -441,7 +446,7 @@ resource "azure_instance" "foo" {
|
||||||
}
|
}
|
||||||
}`, instanceName, testAccStorageServiceName)
|
}`, instanceName, testAccStorageServiceName)
|
||||||
|
|
||||||
var testAccAzureInstance_separateHostedService = fmt.Sprintf(`
|
var testAccAzureInstance_separateHostedService = `
|
||||||
resource "azure_hosted_service" "foo" {
|
resource "azure_hosted_service" "foo" {
|
||||||
name = "%s"
|
name = "%s"
|
||||||
location = "West US"
|
location = "West US"
|
||||||
|
@ -464,7 +469,7 @@ resource "azure_instance" "foo" {
|
||||||
public_port = 22
|
public_port = 22
|
||||||
private_port = 22
|
private_port = 22
|
||||||
}
|
}
|
||||||
}`, testAccHostedServiceName, instanceName, testAccStorageServiceName)
|
}`
|
||||||
|
|
||||||
var testAccAzureInstance_advanced = fmt.Sprintf(`
|
var testAccAzureInstance_advanced = fmt.Sprintf(`
|
||||||
resource "azure_virtual_network" "foo" {
|
resource "azure_virtual_network" "foo" {
|
||||||
|
|
Loading…
Reference in New Issue