@@ -386,10 +386,6 @@ function Test-MigrateSqlSqlDBMi
386
386
$fileShareCred = Get-Creds $fileShareUsername $fileSharePassword
387
387
388
388
$backupFileShare = New-AzDmsFileShare - Path $fileSharePath - Credential $fileShareCred
389
- Assert-AreEqual $fileSharePath $backupFileShare.Path
390
- Assert-AreEqual $fileShareUserName $backupFileShare.Username
391
- Assert-AreEqual $fileSharePassword $backupFileShare.Password
392
-
393
389
$sourceDbName = " TestMI"
394
390
$targetDbName = " TestMI6"
395
391
$backupMode = " CreateBackup"
@@ -398,7 +394,6 @@ function Test-MigrateSqlSqlDBMi
398
394
399
395
Assert-AreEqual $sourceDbName $selectedDbs [0 ].Name
400
396
Assert-AreEqual $targetDbName $selectedDbs [0 ].RestoreDatabaseName
401
- Assert-AreEqual $backupFileShare.Path $selectedDbs [0 ].BackupFileShare.Path
402
397
403
398
# Migrating Logins and AgentJobs
404
399
# $selectedLogins = [Microsoft.Azure.Commands.DataMigrationConfig]::GetConfigString("MI_LOGINS")
@@ -424,7 +419,6 @@ function Test-MigrateSqlSqlDBMi
424
419
$task = Get-AzDataMigrationTask - ResourceGroupName $rg.ResourceGroupName - ServiceName $service.Name - ProjectName $project.Name - TaskName $taskName - Expand
425
420
426
421
Assert-AreEqual $taskName $task [0 ].Name
427
- Assert-AreEqual $backupFileShare.Path $task.ProjectTask.Properties.Input.BackupFileShare.Path
428
422
# Assert-AreEqual $selectedJobs[0] $task.ProjectTask.Properties.Input.SelectedAgentJobs[0]
429
423
# Assert-AreEqual $selectedLogins[0] $task.ProjectTask.Properties.Input.SelectedLogins[0]
430
424
Assert-AreEqual $sourceDbName $task.ProjectTask.Properties.Input.SelectedDatabases [0 ].Name
@@ -788,7 +782,7 @@ function Test-MigrateSqlSqlDBSync
788
782
789
783
if ($output.MigrationState -eq " READY_TO_COMPLETE" )
790
784
{
791
- $command = Invoke-AzDmsCommand - CommandType Complete `
785
+ $command = Invoke-AzDmsCommand - CommandType CompleteSqlDBSync `
792
786
- ResourceGroupName $rg.ResourceGroupName `
793
787
- ServiceName $service.Name `
794
788
- ProjectName $project.Name `
@@ -903,7 +897,7 @@ function Test-MigrateMongoDb
903
897
$task = Get-AzDataMigrationTask - ResourceGroupName $rg.ResourceGroupName - ServiceName $service.Name - ProjectName $project.Name - TaskName $taskName - Expand
904
898
905
899
if ($task.ProjectTask.Properties.State -eq " Running" ) {
906
- $res = Invoke-AzDataMigrationCommand - CommandType cancel - ResourceGroupName $rg.ResourceGroupName - ServiceName $service.Name - ProjectName $project.Name - TaskName $taskName - ObjectName " test.many"
900
+ $res = Invoke-AzDataMigrationCommand - CommandType CancelMongoDB - ResourceGroupName $rg.ResourceGroupName - ServiceName $service.Name - ProjectName $project.Name - TaskName $taskName - ObjectName " test.many"
907
901
Assert-AreEqual " Accepted" $res.State
908
902
}
909
903
}
@@ -915,3 +909,216 @@ function Test-MigrateMongoDb
915
909
Remove-ResourceGroupForTest $rg
916
910
}
917
911
}
912
+
913
+ function Test-ConnectToTargetSqlDbMiSync
914
+ {
915
+ $rg = Create- ResourceGroupForTest
916
+
917
+ try
918
+ {
919
+ $service = Create- DataMigrationService($rg )
920
+ $project = Create- ProjectSqlSqlDbMi $rg $service
921
+ $taskName = Get-TaskName
922
+ $connectionInfo = New-TargetSqlMiSyncConnectionInfo
923
+ $userName = [Microsoft.Azure.Commands.DataMigrationConfig ]::GetConfigString(" SQLDBMI_USERNAME" )
924
+ $password = [Microsoft.Azure.Commands.DataMigrationConfig ]::GetConfigString(" SQLDBMI_PASSWORD" )
925
+ $cred = Get-Creds $userName $password
926
+ $app = New-AzureActiveDirectoryApp
927
+
928
+ $task = New-AzDataMigrationTask - TaskType ConnectToTargetSqlDbMiSync - ResourceGroupName $rg.ResourceGroupName - ServiceName $service.Name - ProjectName $project.Name - TaskName $taskName - TargetConnection $connectioninfo - TargetCred $cred - AzureActiveDirectoryApp $app
929
+
930
+ $task = Get-AzDataMigrationTask - ResourceGroupName $rg.ResourceGroupName - ServiceName $service.Name - ProjectName $project.Name - TaskName $taskName - Expand
931
+
932
+ Assert-AreEqual $taskName $task [0 ].Name
933
+ Assert-AreEqual 1 $task.Count
934
+
935
+ while (($task.ProjectTask.Properties.State -eq " Running" ) -or ($task.ProjectTask.Properties.State -eq " Queued" ))
936
+ {
937
+ SleepTask 15
938
+ $task = Get-AzDataMigrationTask - ResourceGroupName $rg.ResourceGroupName - ServiceName $service.Name - ProjectName $project.Name - TaskName $taskName - Expand
939
+ }
940
+
941
+ Assert-AreEqual " Succeeded" $task.ProjectTask.Properties.State
942
+
943
+ Remove-AzDataMigrationTask - ResourceGroupName $rg.ResourceGroupName - ServiceName $service.Name - ProjectName $project.Name - TaskName $taskName - Force
944
+
945
+ Assert-ThrowsContains { $all = Get-AzDmsTask - ResourceGroupName $rg.ResourceGroupName - ServiceName $service.Name - ProjectName $project.Name - TaskName $taskName - Expand ;} " NotFound"
946
+ }
947
+ finally
948
+ {
949
+ Remove-ResourceGroupForTest $rg
950
+ }
951
+ }
952
+
953
+ function Test-ValidateMigrationInputSqlSqlDbMiSync
954
+ {
955
+ $rg = Create- ResourceGroupForTest
956
+
957
+ try
958
+ {
959
+ $service = Create- DataMigrationService($rg )
960
+ $project = Create- ProjectSqlSqlDbMi $rg $service
961
+ $taskName = Get-TaskName
962
+
963
+ # Source Connection Details
964
+ $sourceConnectionInfo = New-SourceSqlConnectionInfo
965
+ $sourceUserName = [Microsoft.Azure.Commands.DataMigrationConfig ]::GetConfigString(" SQL_USERNAME" )
966
+ $sourcePassword = [Microsoft.Azure.Commands.DataMigrationConfig ]::GetConfigString(" SQL_PASSWORD" )
967
+ $sourceCred = Get-Creds $sourceUserName $sourcePassword
968
+
969
+ # Target Connection Details
970
+ $targetConnectionInfo = New-TargetSqlMiSyncConnectionInfo
971
+ $targetUserName = [Microsoft.Azure.Commands.DataMigrationConfig ]::GetConfigString(" SQLDBMI_USERNAME" )
972
+ $targetPassword = [Microsoft.Azure.Commands.DataMigrationConfig ]::GetConfigString(" SQLDBMI_PASSWORD" )
973
+ $targetCred = Get-Creds $targetUserName $targetPassword
974
+
975
+ $app = New-AzureActiveDirectoryApp
976
+
977
+ $fileSharePath = [Microsoft.Azure.Commands.DataMigrationConfig ]::GetConfigString(" FILESHARE_PATH" )
978
+ $fileShareUsername = [Microsoft.Azure.Commands.DataMigrationConfig ]::GetConfigString(" FILESHARE_USERNAME" )
979
+ $fileSharePassword = [Microsoft.Azure.Commands.DataMigrationConfig ]::GetConfigString(" FILESHARE_PASSWORD" )
980
+ $fileShareCred = Get-Creds $fileShareUsername $fileSharePassword
981
+ $backupFileShare = New-AzDmsFileShare - Path $fileSharePath - Credential $fileShareCred
982
+
983
+ $storageResourceId = [Microsoft.Azure.Commands.DataMigrationConfig ]::GetConfigString(" STORAGE_RESOURCE_ID" )
984
+
985
+ $sourceDbName = " AdventureWorks"
986
+ $targetDbName = getDmsAssetName AdventureWorks
987
+
988
+ $selectedDbs = New-AzDataMigrationSelectedDB - MigrateSqlServerSqlDbMi - Name $sourceDbName - TargetDatabaseName $targetDbName - BackupFileShare $backupFileShare
989
+
990
+ $migTask = New-AzDataMigrationTask - TaskType ValidateSqlServerSqlDbMiSync `
991
+ - ResourceGroupName $rg.ResourceGroupName `
992
+ - ServiceName $service.Name `
993
+ - ProjectName $project.Name `
994
+ - TaskName $taskName `
995
+ - SourceConnection $sourceConnectionInfo `
996
+ - SourceCred $sourceCred `
997
+ - TargetConnection $targetConnectionInfo `
998
+ - TargetCred $targetCred `
999
+ - BackupFileShare $backupFileShare `
1000
+ - SelectedDatabase $selectedDbs `
1001
+ - AzureActiveDirectoryApp $app `
1002
+ - StorageResourceId $storageResourceId
1003
+
1004
+
1005
+ $task = Get-AzDataMigrationTask - ResourceGroupName $rg.ResourceGroupName - ServiceName $service.Name - ProjectName $project.Name - TaskName $taskName - Expand
1006
+
1007
+ Assert-AreEqual $taskName $task [0 ].Name
1008
+ Assert-AreEqual 1 $task.Count
1009
+
1010
+ while (($task.ProjectTask.Properties.State -eq " Running" ) -or ($task.ProjectTask.Properties.State -eq " Queued" ))
1011
+ {
1012
+ SleepTask 15
1013
+ $task = Get-AzDataMigrationTask - ResourceGroupName $rg.ResourceGroupName - ServiceName $service.Name - ProjectName $project.Name - TaskName $taskName - Expand
1014
+ }
1015
+
1016
+ Assert-AreEqual " Succeeded" $task.ProjectTask.Properties.State
1017
+
1018
+ Remove-AzDataMigrationTask - ResourceGroupName $rg.ResourceGroupName - ServiceName $service.Name - ProjectName $project.Name - TaskName $taskName - Force
1019
+
1020
+ Assert-ThrowsContains { $all = Get-AzDmsTask - ResourceGroupName $rg.ResourceGroupName - ServiceName $service.Name - ProjectName $project.Name - TaskName $taskName - Expand ;} " NotFound"
1021
+ }
1022
+ finally
1023
+ {
1024
+ Remove-ResourceGroupForTest $rg
1025
+ }
1026
+ }
1027
+
1028
+ function Test-MigrateSqlSqlDbMiSync
1029
+ {
1030
+ $rg = Create- ResourceGroupForTest
1031
+
1032
+ try
1033
+ {
1034
+ $service = Create- DataMigrationService($rg )
1035
+ $project = Create- ProjectSqlSqlDbMi $rg $service
1036
+ $taskName = Get-TaskName
1037
+
1038
+ # Source Connection Details
1039
+ $sourceConnectionInfo = New-SourceSqlConnectionInfo
1040
+ $sourceUserName = [Microsoft.Azure.Commands.DataMigrationConfig ]::GetConfigString(" SQL_USERNAME" )
1041
+ $sourcePassword = [Microsoft.Azure.Commands.DataMigrationConfig ]::GetConfigString(" SQL_PASSWORD" )
1042
+ $sourceCred = Get-Creds $sourceUserName $sourcePassword
1043
+
1044
+ # Target Connection Details
1045
+ $targetConnectionInfo = New-TargetSqlMiSyncConnectionInfo
1046
+ $targetUserName = [Microsoft.Azure.Commands.DataMigrationConfig ]::GetConfigString(" SQLDBMI_USERNAME" )
1047
+ $targetPassword = [Microsoft.Azure.Commands.DataMigrationConfig ]::GetConfigString(" SQLDBMI_PASSWORD" )
1048
+ $targetCred = Get-Creds $targetUserName $targetPassword
1049
+
1050
+ $app = New-AzureActiveDirectoryApp
1051
+
1052
+ $fileSharePath = [Microsoft.Azure.Commands.DataMigrationConfig ]::GetConfigString(" FILESHARE_PATH" )
1053
+ $fileShareUsername = [Microsoft.Azure.Commands.DataMigrationConfig ]::GetConfigString(" FILESHARE_USERNAME" )
1054
+ $fileSharePassword = [Microsoft.Azure.Commands.DataMigrationConfig ]::GetConfigString(" FILESHARE_PASSWORD" )
1055
+ $fileShareCred = Get-Creds $fileShareUsername $fileSharePassword
1056
+ $backupFileShare = New-AzDmsFileShare - Path $fileSharePath - Credential $fileShareCred
1057
+
1058
+ $storageResourceId = [Microsoft.Azure.Commands.DataMigrationConfig ]::GetConfigString(" STORAGE_RESOURCE_ID" )
1059
+
1060
+ $sourceDbName = " AdventureWorks"
1061
+ $dbId = " db|" + $sourceDbName
1062
+ $targetDbName = getDmsAssetName AdventureWorks
1063
+
1064
+ $selectedDbs = New-AzDataMigrationSelectedDB - MigrateSqlServerSqlDbMi - Name $sourceDbName - TargetDatabaseName $targetDbName - BackupFileShare $backupFileShare
1065
+
1066
+ $migTask = New-AzDataMigrationTask - TaskType MigrateSqlServerSqlDbMiSync `
1067
+ - ResourceGroupName $rg.ResourceGroupName `
1068
+ - ServiceName $service.Name `
1069
+ - ProjectName $project.Name `
1070
+ - TaskName $taskName `
1071
+ - SourceConnection $sourceConnectionInfo `
1072
+ - SourceCred $sourceCred `
1073
+ - TargetConnection $targetConnectionInfo `
1074
+ - TargetCred $targetCred `
1075
+ - BackupFileShare $backupFileShare `
1076
+ - SelectedDatabase $selectedDbs `
1077
+ - AzureActiveDirectoryApp $app `
1078
+ - StorageResourceId $storageResourceId
1079
+
1080
+
1081
+ $task = Get-AzDataMigrationTask - ResourceGroupName $rg.ResourceGroupName - ServiceName $service.Name - ProjectName $project.Name - TaskName $taskName - Expand
1082
+
1083
+ Assert-AreEqual $taskName $task [0 ].Name
1084
+ Assert-AreEqual 1 $task.Count
1085
+
1086
+ while (($task.ProjectTask.Properties.State -eq " Running" ) -or ($task.ProjectTask.Properties.State -eq " Queued" ))
1087
+ {
1088
+ Foreach ($output in $task.ProjectTask.Properties.Output )
1089
+ {
1090
+ if ($output.Id -eq $dbId )
1091
+ {
1092
+ if ($output.MigrationState -eq " LOG_FILES_UPLOADING" )
1093
+ {
1094
+ if ($output.FullBackupSetInfo.BackupType -eq " Database" )
1095
+ {
1096
+ if ($output.FullBackupSetInfo.IsBackupRestored )
1097
+ {
1098
+ $command = Invoke-AzDmsCommand - CommandType CompleteSqlMiSync `
1099
+ - ResourceGroupName $rg.ResourceGroupName `
1100
+ - ServiceName $service.Name `
1101
+ - ProjectName $project.Name `
1102
+ - TaskName $taskName `
1103
+ - DatabaseName $output.SourceDatabaseName
1104
+ }
1105
+ }
1106
+ }
1107
+ }
1108
+ }
1109
+
1110
+ SleepTask 15
1111
+ $task = Get-AzDataMigrationTask - ResourceGroupName $rg.ResourceGroupName - ServiceName $service.Name - ProjectName $project.Name - TaskName $taskName - Expand
1112
+ }
1113
+
1114
+ Assert-AreEqual " Succeeded" $task.ProjectTask.Properties.State
1115
+
1116
+ Remove-AzDataMigrationTask - ResourceGroupName $rg.ResourceGroupName - ServiceName $service.Name - ProjectName $project.Name - TaskName $taskName - Force
1117
+
1118
+ Assert-ThrowsContains { $all = Get-AzDmsTask - ResourceGroupName $rg.ResourceGroupName - ServiceName $service.Name - ProjectName $project.Name - TaskName $taskName - Expand ;} " NotFound"
1119
+ }
1120
+ finally
1121
+ {
1122
+ Remove-ResourceGroupForTest $rg
1123
+ }
1124
+ }
0 commit comments