Exemplo n.º 1
0
        private ProjectTask CreateDMSSyncTask(MockContext context,
                                              DataMigrationServiceClient client,
                                              ResourceGroup resourceGroup,
                                              DataMigrationService service,
                                              string dmsProjectName,
                                              string dmsTaskName)
        {
            var taskProps = new MigrateSqlServerSqlDbSyncTaskProperties
            {
                Input = new MigrateSqlServerSqlDbSyncTaskInput(
                    new SqlConnectionInfo
                {
                    DataSource             = @"steven-work.redmond.corp.microsoft.com\stevenf16,12345",
                    EncryptConnection      = true,
                    TrustServerCertificate = true,
                    UserName       = "******",
                    Password       = "******",
                    Authentication = AuthenticationType.SqlAuthentication,
                },
                    new SqlConnectionInfo
                {
                    DataSource             = "shuhuandmsdbs.database.windows.net",
                    EncryptConnection      = true,
                    TrustServerCertificate = true,
                    UserName       = "******",
                    Password       = "******",
                    Authentication = AuthenticationType.SqlAuthentication,
                },
                    new List <MigrateSqlServerSqlDbSyncDatabaseInput>
                {
                    new MigrateSqlServerSqlDbSyncDatabaseInput
                    {
                        Name = "JasmineTest",
                        TargetDatabaseName = "JasmineTest",
                        TableMap           = new Dictionary <string, string> {
                            { "dbo.TestTable1", "dbo.TestTable1" }, { "dbo.TestTable2", "dbo.TestTable2" }
                        }
                    }
                })
            };

            return(client.Tasks.CreateOrUpdate(
                       new ProjectTask(
                           properties: taskProps),
                       resourceGroup.Name,
                       service.Name,
                       dmsProjectName,
                       dmsTaskName));
        }
Exemplo n.º 2
0
        public void RunCommandSucceeds()
        {
            var dmsClientHandler = new RecordedDelegatingHandler()
            {
                StatusCodeToReturn = HttpStatusCode.OK
            };
            var resourcesHandler = new RecordedDelegatingHandler()
            {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                var  resourceGroup = CreateResourceGroup(context, resourcesHandler, ResourceGroupName, TestConfiguration.Location);
                var  dmsClient     = Utilities.GetDataMigrationManagementClient(context, dmsClientHandler);
                var  service       = CreateDMSInstance(context, dmsClient, resourceGroup, DmsDeploymentName);
                var  project       = CreateDMSProject(context, dmsClient, resourceGroup, service.Name, DmsProjectName);
                var  task          = CreateDMSSyncTask(context, dmsClient, resourceGroup, service, project.Name, DmsTaskName);
                bool wait          = true;
                do
                {
                    var getResult = dmsClient.Tasks.Get(resourceGroup.Name, service.Name, project.Name, task.Name, "output");

                    Assert.True(getResult.Properties.State.Equals(TaskState.Queued) || getResult.Properties.State.Equals(TaskState.Running));

                    MigrateSqlServerSqlDbSyncTaskProperties properties = (MigrateSqlServerSqlDbSyncTaskProperties)getResult.Properties;
                    var databaseLevelResult = (MigrateSqlServerSqlDbSyncTaskOutputDatabaseLevel)properties.Output.Where(o => o.GetType() == typeof(MigrateSqlServerSqlDbSyncTaskOutputDatabaseLevel)).FirstOrDefault();
                    if (databaseLevelResult != null && databaseLevelResult.MigrationState == SyncDatabaseMigrationReportingState.READYTOCOMPLETE)
                    {
                        wait = false;
                    }
                }while (wait);

                var commandProperties = new MigrateSyncCompleteCommandProperties
                {
                    Input = new MigrateSyncCompleteCommandInput
                    {
                        DatabaseName = "DatabaseName"
                    },
                };

                var command = dmsClient.Tasks.Command(resourceGroup.Name, service.Name, project.Name, task.Name, commandProperties);
                Assert.Equal(command.State, CommandState.Accepted);
            }
            // Wait for resource group deletion to complete.
            Utilities.WaitIfNotInPlaybackMode();
        }
Exemplo n.º 3
0
        private ProjectTask CreateDMSSqlSyncTask(MockContext context,
                                                 DataMigrationServiceClient client,
                                                 ResourceGroup resourceGroup,
                                                 DataMigrationService service,
                                                 string dmsProjectName,
                                                 string dmsTaskName)
        {
            var taskProps = new MigrateSqlServerSqlDbSyncTaskProperties
            {
                Input = new MigrateSqlServerSqlDbSyncTaskInput(
                    new SqlConnectionInfo
                {
                    DataSource = @"someSourceServerName",
                    UserName   = "******",
                    Password   = "******"
                },
                    new SqlConnectionInfo
                {
                    DataSource = @"someTargetServerName",
                    UserName   = "******",
                    Password   = "******"
                },
                    new List <MigrateSqlServerSqlDbSyncDatabaseInput>
                {
                    new MigrateSqlServerSqlDbSyncDatabaseInput
                    {
                        Name = "someSourceDatabaseName",
                        TargetDatabaseName = "someTargetDatabaseName",
                        TableMap           = new Dictionary <string, string> {
                            { "someTableSource", "someTableSource" }
                        }
                    }
                })
            };

            return(client.Tasks.CreateOrUpdate(
                       new ProjectTask(
                           properties: taskProps),
                       resourceGroup.Name,
                       service.Name,
                       dmsProjectName,
                       dmsTaskName));
        }
Exemplo n.º 4
0
        public override ProjectTaskProperties ProcessTaskCmdlet()
        {
            MigrateSqlServerSqlDbSyncTaskProperties properties = new MigrateSqlServerSqlDbSyncTaskProperties();

            SqlConnectionInfo source = new SqlConnectionInfo();
            SqlConnectionInfo target = new SqlConnectionInfo();

            source = (SqlConnectionInfo)MyInvocation.BoundParameters[SourceConnection];
            PSCredential sourceCred = (PSCredential)MyInvocation.BoundParameters[SourceCred];

            source.UserName = sourceCred.UserName;
            source.Password = Decrypt(sourceCred.Password);

            target = (SqlConnectionInfo)MyInvocation.BoundParameters[TargetConnection];
            PSCredential targetCred = (PSCredential)MyInvocation.BoundParameters[TargetCred];

            target.UserName = targetCred.UserName;
            target.Password = Decrypt(targetCred.Password);

            MigrateSqlServerSqlDbSyncTaskInput input = new MigrateSqlServerSqlDbSyncTaskInput
            {
                SourceConnectionInfo = source,
                TargetConnectionInfo = target
            };

            if (MyInvocation.BoundParameters.ContainsKey(SelectedDatabase))
            {
                input.SelectedDatabases = ((MigrateSqlServerSqlDbSyncDatabaseInput[])MyInvocation.BoundParameters[SelectedDatabase]).ToList();
            }

            MigrationValidationOptions options = new MigrationValidationOptions();

            if (MyInvocation.BoundParameters.ContainsKey(SchemaValidation))
            {
                options.EnableSchemaValidation = (SwitchParameter)MyInvocation.BoundParameters[SchemaValidation];
            }
            else
            {
                options.EnableSchemaValidation = false;
            }

            if (MyInvocation.BoundParameters.ContainsKey(DataIntegrityValidation))
            {
                options.EnableDataIntegrityValidation = (SwitchParameter)MyInvocation.BoundParameters[DataIntegrityValidation];
            }
            else
            {
                options.EnableDataIntegrityValidation = false;
            }

            if (MyInvocation.BoundParameters.ContainsKey(QueryAnalysisValidation))
            {
                options.EnableQueryAnalysisValidation = (SwitchParameter)MyInvocation.BoundParameters[QueryAnalysisValidation];
            }
            else
            {
                options.EnableQueryAnalysisValidation = false;
            }

            input.ValidationOptions = options;

            properties.Input = input;

            return(properties);
        }