Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update databasemigration API version from 2018-04-19 to 2021-06-30 #25997

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/services/databasemigration/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ package client
import (
"fmt"

"github.com/hashicorp/go-azure-sdk/resource-manager/datamigration/2018-04-19/projectresource"
"github.com/hashicorp/go-azure-sdk/resource-manager/datamigration/2018-04-19/serviceresource"
"github.com/hashicorp/go-azure-sdk/resource-manager/datamigration/2021-06-30/projectresource"
"github.com/hashicorp/go-azure-sdk/resource-manager/datamigration/2021-06-30/serviceresource"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-helpers/resourcemanager/tags"
"github.com/hashicorp/go-azure-sdk/resource-manager/datamigration/2018-04-19/projectresource"
"github.com/hashicorp/go-azure-sdk/resource-manager/datamigration/2021-06-30/projectresource"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/databasemigration/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ data "azurerm_database_migration_project" "test" {
service_name = azurerm_database_migration_project.test.service_name
resource_group_name = azurerm_database_migration_project.test.resource_group_name
}
`, DatabaseMigrationProjectResource{}.basic(data))
`, DatabaseMigrationProjectResource{}.basic(data, "SQL", "SQLDB"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-helpers/resourcemanager/tags"
"github.com/hashicorp/go-azure-sdk/resource-manager/datamigration/2018-04-19/projectresource"
"github.com/hashicorp/go-azure-sdk/resource-manager/datamigration/2021-06-30/projectresource"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down Expand Up @@ -66,8 +66,11 @@ func resourceDatabaseMigrationProject() *pluginsdk.Resource {
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
// Now that go sdk only export SQL as source platform type, we only allow it here.
string(projectresource.ProjectSourcePlatformMongoDb),
string(projectresource.ProjectSourcePlatformMySQL),
string(projectresource.ProjectSourcePlatformPostgreSql),
string(projectresource.ProjectSourcePlatformSQL),
string(projectresource.ProjectSourcePlatformUnknown),
}, false),
},

Expand All @@ -76,8 +79,12 @@ func resourceDatabaseMigrationProject() *pluginsdk.Resource {
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
// Now that go sdk only export SQL as source platform type, we only allow it here.
string(projectresource.ProjectTargetPlatformAzureDbForMySql),
string(projectresource.ProjectTargetPlatformAzureDbForPostgreSql),
string(projectresource.ProjectTargetPlatformMongoDb),
string(projectresource.ProjectTargetPlatformSQLDB),
string(projectresource.ProjectTargetPlatformSQLMI),
string(projectresource.ProjectTargetPlatformUnknown),
}, false),
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"
"testing"

"github.com/hashicorp/go-azure-sdk/resource-manager/datamigration/2018-04-19/projectresource"
"github.com/hashicorp/go-azure-sdk/resource-manager/datamigration/2021-06-30/projectresource"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand All @@ -18,12 +18,12 @@ import (

type DatabaseMigrationProjectResource struct{}

func TestAccDatabaseMigrationProject_basic(t *testing.T) {
func TestAccDatabaseMigrationProject_basicSQLToSQLDB(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_database_migration_project", "test")
r := DatabaseMigrationProjectResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Config: r.basic(data, "SQL", "SQLDB"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("source_platform").HasValue("SQL"),
Expand All @@ -34,6 +34,54 @@ func TestAccDatabaseMigrationProject_basic(t *testing.T) {
})
}

func TestAccDatabaseMigrationProject_basicPostgreSqlToAzureDbForPostgreSql(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_database_migration_project", "test")
r := DatabaseMigrationProjectResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data, "PostgreSql", "AzureDbForPostgreSql"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("source_platform").HasValue("PostgreSql"),
check.That(data.ResourceName).Key("target_platform").HasValue("AzureDbForPostgreSql"),
),
},
data.ImportStep(),
})
}

func TestAccDatabaseMigrationProject_basicMySQLToAzureDbForMySql(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_database_migration_project", "test")
r := DatabaseMigrationProjectResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data, "MySQL", "AzureDbForMySql"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("source_platform").HasValue("MySQL"),
check.That(data.ResourceName).Key("target_platform").HasValue("AzureDbForMySql"),
),
},
data.ImportStep(),
})
}

func TestAccDatabaseMigrationProject_basicMongoDbToMongoDb(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_database_migration_project", "test")
r := DatabaseMigrationProjectResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data, "MongoDb", "MongoDb"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("source_platform").HasValue("MongoDb"),
check.That(data.ResourceName).Key("target_platform").HasValue("MongoDb"),
),
},
data.ImportStep(),
})
}

func TestAccDatabaseMigrationProject_complete(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_database_migration_project", "test")
r := DatabaseMigrationProjectResource{}
Expand All @@ -58,7 +106,7 @@ func TestAccDatabaseMigrationProject_requiresImport(t *testing.T) {

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Config: r.basic(data, "SQL", "SQLDB"),
},
data.RequiresImportErrorStep(r.requiresImport),
})
Expand All @@ -70,7 +118,7 @@ func TestAccDatabaseMigrationProject_update(t *testing.T) {

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Config: r.basic(data, "SQL", "SQLDB"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
Expand All @@ -85,7 +133,7 @@ func TestAccDatabaseMigrationProject_update(t *testing.T) {
},
data.ImportStep(),
{
Config: r.basic(data),
Config: r.basic(data, "SQL", "SQLDB"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
Expand All @@ -108,7 +156,7 @@ func (t DatabaseMigrationProjectResource) Exists(ctx context.Context, clients *c
return utils.Bool(resp.Model != nil), nil
}

func (DatabaseMigrationProjectResource) basic(data acceptance.TestData) string {
func (DatabaseMigrationProjectResource) basic(data acceptance.TestData, sourcePlatform string, targetPlatform string) string {
return fmt.Sprintf(`
%s

Expand All @@ -117,10 +165,10 @@ resource "azurerm_database_migration_project" "test" {
service_name = azurerm_database_migration_service.test.name
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
source_platform = "SQL"
target_platform = "SQLDB"
source_platform = "%s"
target_platform = "%s"
}
`, DatabaseMigrationServiceResource{}.basic(data), data.RandomInteger)
`, DatabaseMigrationServiceResource{}.basic(data), data.RandomInteger, sourcePlatform, targetPlatform)
}

func (DatabaseMigrationProjectResource) complete(data acceptance.TestData) string {
Expand All @@ -142,7 +190,7 @@ resource "azurerm_database_migration_project" "test" {
}

func (DatabaseMigrationProjectResource) requiresImport(data acceptance.TestData) string {
template := DatabaseMigrationProjectResource{}.basic(data)
template := DatabaseMigrationProjectResource{}.basic(data, "SQL", "SQLDB")
return fmt.Sprintf(`
%s

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-helpers/resourcemanager/tags"
"github.com/hashicorp/go-azure-sdk/resource-manager/datamigration/2018-04-19/serviceresource"
"github.com/hashicorp/go-azure-sdk/resource-manager/datamigration/2021-06-30/serviceresource"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/databasemigration/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-helpers/resourcemanager/tags"
"github.com/hashicorp/go-azure-sdk/resource-manager/datamigration/2018-04-19/serviceresource"
"github.com/hashicorp/go-azure-sdk/resource-manager/datamigration/2021-06-30/serviceresource"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"
"testing"

"github.com/hashicorp/go-azure-sdk/resource-manager/datamigration/2018-04-19/serviceresource"
"github.com/hashicorp/go-azure-sdk/resource-manager/datamigration/2021-06-30/serviceresource"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down

This file was deleted.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading