示例#1
0
        public void LargeMigrationSelf(int numberOfIterations, string requestedStorage)
        {
            var backupLocation = NewDataPath("Self-Backup", forceCreateDir: true);

            DataGenerator generator;

            using (var store = NewRemoteDocumentStore(runInMemory: false, requestedStorage: requestedStorage))
            {
                using (var client = new ThinClient(store.Url, DatabaseName))
                {
                    generator = new DataGenerator(client, numberOfIterations);

                    client.PutDatabase(DatabaseName);

                    generator.Generate();

                    client.StartBackup(DatabaseName, backupLocation, waitForBackupToComplete: true);
                }
            }

            using (var store = NewRemoteDocumentStore(runInMemory: false))
            {
                store.DefaultDatabase = "Northwind";

                var operation = store
                                .DatabaseCommands
                                .GlobalAdmin
                                .StartRestore(new DatabaseRestoreRequest
                {
                    BackupLocation = backupLocation,
                    DatabaseName   = "Northwind"
                });

                operation.WaitForCompletion();

                ValidateBackup(store, generator);
            }
        }
示例#2
0
        public void LargeMigration(int numberOfIterations)
        {
            var exceptions = new List <Exception>();

            foreach (var configuration in serversToTest)
            {
                foreach (var storageType in configuration.StorageTypes)
                {
                    KillPreviousServers();

                    Console.WriteLine("|> Processing: {0}. Storage: {1}.", configuration.Name, storageType);

                    var backupLocation = NewDataPath(configuration.Name + "-Backup", forceCreateDir: true);
                    using (var client = new ThinClient(string.Format("http://localhost:{0}", Port), DatabaseName))
                    {
                        var generator = new DataGenerator(client, numberOfIterations);

                        using (var server = DeployServer(configuration.Name, storageType))
                        {
                            File.AppendAllLines(ServersFileName, new[] { server.ProcessId.ToString(CultureInfo.InvariantCulture) });

                            client.PutDatabase(DatabaseName);

                            generator.Generate();

                            if (configuration.WaitForIndexingBeforeBackup)
                            {
                                client.WaitForIndexing();
                            }

                            client.StartBackup(DatabaseName, backupLocation, waitForBackupToComplete: true);
                        }

                        using (var store = NewRemoteDocumentStore(runInMemory: false))
                        {
                            store.DefaultDatabase = "Northwind";

                            var operation = store
                                            .DatabaseCommands
                                            .GlobalAdmin
                                            .StartRestore(new DatabaseRestoreRequest
                            {
                                BackupLocation = backupLocation,
                                DatabaseName   = "Northwind"
                            });

                            operation.WaitForCompletion();

                            try
                            {
                                ValidateBackup(store, generator);
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e);

                                exceptions.Add(new InvalidOperationException("Migration failed: " + configuration.Name + ". Storage: " + storageType + ". Message: " + e.Message, e));
                            }
                        }
                    }
                }
            }

            if (exceptions.Count > 0)
            {
                throw new AggregateException(exceptions);
            }
        }