public async Task CanOfflineMigrateEsentBackup() { string dataDir = UnzipTheZips("SampleDataEsent.zip", out PathSetting storageExplorer); var db = new DatabaseRecord($"restoredSampleDataEsent_{Guid.NewGuid()}"); var config = new OfflineMigrationConfiguration(dataDir, storageExplorer.FullPath, db); using (var store = GetDocumentStore(new Options() { CreateDatabase = false })) { var o = await store.Maintenance.Server.SendAsync(new OfflineMigrationOperation(config)); await o.WaitForCompletionAsync(TimeSpan.FromSeconds(60)); using (var store2 = GetDocumentStore(new Options() { CreateDatabase = false, ModifyDatabaseName = s => db.DatabaseName })) { var stats = await store2.Maintenance.SendAsync(new GetStatisticsOperation()); Assert.Equal(1059, stats.CountOfDocuments); Assert.Equal(3, stats.CountOfIndexes); } } }
public async Task CanOfflineMigrateEsentFileSystemBackup() { string dataDir = UnzipTheZips("FSEsent.zip", out PathSetting storageExplorer); var db = new DatabaseRecord($"restoredFSEsentBackup_{Guid.NewGuid()}"); var config = new OfflineMigrationConfiguration(dataDir, storageExplorer.FullPath, db); config.IsRavenFs = true; using (var store = GetDocumentStore(new Options() { CreateDatabase = false })) { var o = await store.Maintenance.Server.SendAsync(new OfflineMigrationOperation(config)); await o.WaitForCompletionAsync(TimeSpan.FromSeconds(15)); using (var store2 = GetDocumentStore(new Options() { CreateDatabase = false, ModifyDatabaseName = s => db.DatabaseName })) { WaitForUserToContinueTheTest(store2); var stats = await store2.Maintenance.SendAsync(new GetStatisticsOperation()); Assert.Equal(4, stats.CountOfDocuments); Assert.Equal(4, stats.CountOfAttachments); } } }
public Task OfflineMigrationTest() { var mode = GetStringQueryString("mode"); var path = GetStringQueryString("path"); using (ServerStore.ContextPool.AllocateOperationContext(out JsonOperationContext context)) { bool isValid = true; string errorMessage = null; try { switch (mode) { case "dataDir": OfflineMigrationConfiguration.ValidateDataDirectory(path); break; case "migratorPath": OfflineMigrationConfiguration.ValidateExporterPath(path); break; default: throw new BadRequestException("Unknown mode: " + mode); } } catch (Exception e) { isValid = false; errorMessage = e.Message; } using (var writer = new BlittableJsonTextWriter(context, ResponseBodyStream())) { context.Write(writer, new DynamicJsonValue { [nameof(OfflineMigrationValidation.IsValid)] = isValid, [nameof(OfflineMigrationValidation.ErrorMessage)] = errorMessage }); } } return(Task.CompletedTask); }
public async Task DatabaseNameValidation() { string dataDir = UnzipTheZips("SampleDataEsent.zip", out PathSetting storageExplorer); var invalidDbName = "abc(123)@.*.456"; var db = new DatabaseRecord(invalidDbName); var config = new OfflineMigrationConfiguration(dataDir, storageExplorer.FullPath, db); using (var store = GetDocumentStore(new Options() { CreateDatabase = false })) { var e = await Assert.ThrowsAsync <BadRequestException>(() => store.Maintenance.Server.SendAsync(new OfflineMigrationOperation(config))); Assert.Contains($"The name '{invalidDbName}' is not permitted. Only letters, digits and characters ('_', '-', '.') are allowed.", e.Message); } }