provider/google: Fix collisions in SQL instance acctests
This commit is contained in:
parent
adf4280aff
commit
4c6c5f5798
|
@ -20,6 +20,7 @@ import (
|
||||||
|
|
||||||
func TestAccGoogleSqlDatabaseInstance_basic(t *testing.T) {
|
func TestAccGoogleSqlDatabaseInstance_basic(t *testing.T) {
|
||||||
var instance sqladmin.DatabaseInstance
|
var instance sqladmin.DatabaseInstance
|
||||||
|
databaseID := genRandInt()
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
@ -27,7 +28,8 @@ func TestAccGoogleSqlDatabaseInstance_basic(t *testing.T) {
|
||||||
CheckDestroy: testAccGoogleSqlDatabaseInstanceDestroy,
|
CheckDestroy: testAccGoogleSqlDatabaseInstanceDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testGoogleSqlDatabaseInstance_basic,
|
Config: fmt.Sprintf(
|
||||||
|
testGoogleSqlDatabaseInstance_basic, databaseID),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckGoogleSqlDatabaseInstanceExists(
|
testAccCheckGoogleSqlDatabaseInstanceExists(
|
||||||
"google_sql_database_instance.instance", &instance),
|
"google_sql_database_instance.instance", &instance),
|
||||||
|
@ -41,6 +43,7 @@ func TestAccGoogleSqlDatabaseInstance_basic(t *testing.T) {
|
||||||
|
|
||||||
func TestAccGoogleSqlDatabaseInstance_settings_basic(t *testing.T) {
|
func TestAccGoogleSqlDatabaseInstance_settings_basic(t *testing.T) {
|
||||||
var instance sqladmin.DatabaseInstance
|
var instance sqladmin.DatabaseInstance
|
||||||
|
databaseID := genRandInt()
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
@ -48,7 +51,8 @@ func TestAccGoogleSqlDatabaseInstance_settings_basic(t *testing.T) {
|
||||||
CheckDestroy: testAccGoogleSqlDatabaseInstanceDestroy,
|
CheckDestroy: testAccGoogleSqlDatabaseInstanceDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testGoogleSqlDatabaseInstance_settings,
|
Config: fmt.Sprintf(
|
||||||
|
testGoogleSqlDatabaseInstance_settings, databaseID),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckGoogleSqlDatabaseInstanceExists(
|
testAccCheckGoogleSqlDatabaseInstanceExists(
|
||||||
"google_sql_database_instance.instance", &instance),
|
"google_sql_database_instance.instance", &instance),
|
||||||
|
@ -62,6 +66,7 @@ func TestAccGoogleSqlDatabaseInstance_settings_basic(t *testing.T) {
|
||||||
|
|
||||||
func TestAccGoogleSqlDatabaseInstance_settings_upgrade(t *testing.T) {
|
func TestAccGoogleSqlDatabaseInstance_settings_upgrade(t *testing.T) {
|
||||||
var instance sqladmin.DatabaseInstance
|
var instance sqladmin.DatabaseInstance
|
||||||
|
databaseID := genRandInt()
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
@ -69,7 +74,8 @@ func TestAccGoogleSqlDatabaseInstance_settings_upgrade(t *testing.T) {
|
||||||
CheckDestroy: testAccGoogleSqlDatabaseInstanceDestroy,
|
CheckDestroy: testAccGoogleSqlDatabaseInstanceDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testGoogleSqlDatabaseInstance_basic,
|
Config: fmt.Sprintf(
|
||||||
|
testGoogleSqlDatabaseInstance_basic, databaseID),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckGoogleSqlDatabaseInstanceExists(
|
testAccCheckGoogleSqlDatabaseInstanceExists(
|
||||||
"google_sql_database_instance.instance", &instance),
|
"google_sql_database_instance.instance", &instance),
|
||||||
|
@ -78,7 +84,8 @@ func TestAccGoogleSqlDatabaseInstance_settings_upgrade(t *testing.T) {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testGoogleSqlDatabaseInstance_settings,
|
Config: fmt.Sprintf(
|
||||||
|
testGoogleSqlDatabaseInstance_settings, databaseID),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckGoogleSqlDatabaseInstanceExists(
|
testAccCheckGoogleSqlDatabaseInstanceExists(
|
||||||
"google_sql_database_instance.instance", &instance),
|
"google_sql_database_instance.instance", &instance),
|
||||||
|
@ -92,6 +99,7 @@ func TestAccGoogleSqlDatabaseInstance_settings_upgrade(t *testing.T) {
|
||||||
|
|
||||||
func TestAccGoogleSqlDatabaseInstance_settings_downgrade(t *testing.T) {
|
func TestAccGoogleSqlDatabaseInstance_settings_downgrade(t *testing.T) {
|
||||||
var instance sqladmin.DatabaseInstance
|
var instance sqladmin.DatabaseInstance
|
||||||
|
databaseID := genRandInt()
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
@ -99,7 +107,8 @@ func TestAccGoogleSqlDatabaseInstance_settings_downgrade(t *testing.T) {
|
||||||
CheckDestroy: testAccGoogleSqlDatabaseInstanceDestroy,
|
CheckDestroy: testAccGoogleSqlDatabaseInstanceDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testGoogleSqlDatabaseInstance_settings,
|
Config: fmt.Sprintf(
|
||||||
|
testGoogleSqlDatabaseInstance_settings, databaseID),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckGoogleSqlDatabaseInstanceExists(
|
testAccCheckGoogleSqlDatabaseInstanceExists(
|
||||||
"google_sql_database_instance.instance", &instance),
|
"google_sql_database_instance.instance", &instance),
|
||||||
|
@ -108,7 +117,8 @@ func TestAccGoogleSqlDatabaseInstance_settings_downgrade(t *testing.T) {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testGoogleSqlDatabaseInstance_basic,
|
Config: fmt.Sprintf(
|
||||||
|
testGoogleSqlDatabaseInstance_basic, databaseID),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckGoogleSqlDatabaseInstanceExists(
|
testAccCheckGoogleSqlDatabaseInstanceExists(
|
||||||
"google_sql_database_instance.instance", &instance),
|
"google_sql_database_instance.instance", &instance),
|
||||||
|
@ -319,9 +329,7 @@ func testAccGoogleSqlDatabaseInstanceDestroy(s *terraform.State) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var databaseId = genRandInt()
|
var testGoogleSqlDatabaseInstance_basic = `
|
||||||
|
|
||||||
var testGoogleSqlDatabaseInstance_basic = fmt.Sprintf(`
|
|
||||||
resource "google_sql_database_instance" "instance" {
|
resource "google_sql_database_instance" "instance" {
|
||||||
name = "tf-lw-%d"
|
name = "tf-lw-%d"
|
||||||
region = "us-central"
|
region = "us-central"
|
||||||
|
@ -330,9 +338,9 @@ resource "google_sql_database_instance" "instance" {
|
||||||
crash_safe_replication = false
|
crash_safe_replication = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`, databaseId)
|
`
|
||||||
|
|
||||||
var testGoogleSqlDatabaseInstance_settings = fmt.Sprintf(`
|
var testGoogleSqlDatabaseInstance_settings = `
|
||||||
resource "google_sql_database_instance" "instance" {
|
resource "google_sql_database_instance" "instance" {
|
||||||
name = "tf-lw-%d"
|
name = "tf-lw-%d"
|
||||||
region = "us-central"
|
region = "us-central"
|
||||||
|
@ -361,11 +369,11 @@ resource "google_sql_database_instance" "instance" {
|
||||||
activation_policy = "ON_DEMAND"
|
activation_policy = "ON_DEMAND"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`, databaseId)
|
`
|
||||||
|
|
||||||
// Note - this test is not feasible to run unless we generate
|
// Note - this test is not feasible to run unless we generate
|
||||||
// backups first.
|
// backups first.
|
||||||
var testGoogleSqlDatabaseInstance_replica = fmt.Sprintf(`
|
var testGoogleSqlDatabaseInstance_replica = `
|
||||||
resource "google_sql_database_instance" "instance_master" {
|
resource "google_sql_database_instance" "instance_master" {
|
||||||
name = "tf-lw-%d"
|
name = "tf-lw-%d"
|
||||||
database_version = "MYSQL_5_6"
|
database_version = "MYSQL_5_6"
|
||||||
|
@ -406,4 +414,4 @@ resource "google_sql_database_instance" "instance" {
|
||||||
verify_server_certificate = false
|
verify_server_certificate = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`, genRandInt(), genRandInt())
|
`
|
||||||
|
|
Loading…
Reference in New Issue