Esempio n. 1
0
        public async Task disableVersioningDuringImportFs()
        {
            var export = Path.Combine(NewDataPath("src"), "Export");

            using (var store = NewStore(activeBundles: "Versioning"))
            {
                await store.AsyncFilesCommands.Configuration.SetKeyAsync(VersioningUtil.DefaultConfigurationName, new VersioningConfiguration
                {
                    Id = VersioningUtil.DefaultConfigurationName
                });

                for (int i = 0; i < 10; i++)
                {
                    await store.AsyncFilesCommands.UploadAsync("test-" + i, StringToStream("hello"));
                }

                var options = new FilesConnectionStringOptions
                {
                    Url = store.Url,
                    DefaultFileSystem = store.DefaultFileSystem
                };

                var smuggler = new SmugglerFilesApi();
                await smuggler.ExportData(new SmugglerExportOptions <FilesConnectionStringOptions>
                {
                    From   = options,
                    ToFile = export
                });
            }
            using (var store = NewStore(activeBundles: "Versioning", fileSystemName: "Import", index: 1))
            {
                await store.AsyncFilesCommands.Configuration.SetKeyAsync(VersioningUtil.DefaultConfigurationName, new VersioningConfiguration
                {
                    Id = VersioningUtil.DefaultConfigurationName
                });

                var smuggler = new SmugglerFilesApi(new SmugglerFilesOptions()
                {
                    ShouldDisableVersioningBundle = true
                });

                var options = new FilesConnectionStringOptions {
                    Url = store.Url, DefaultFileSystem = store.DefaultFileSystem
                };

                var e = await AssertAsync.DoesNotThrow(async() => await smuggler.ImportData(new SmugglerImportOptions <FilesConnectionStringOptions> {
                    FromFile = export, To = options
                }));

                Assert.True(e);
            }
        }
Esempio n. 2
0
        public async Task allows_to_create_historical_file_if_changes_to_revisions_are_allowed()
        {
            using (var store = NewStore(activeBundles: "Versioning", customConfig: configuration => configuration.Settings[Constants.FileSystem.Versioning.ChangesToRevisionsAllowed] = "true"))
            {
                await store.AsyncFilesCommands.Configuration.SetKeyAsync(VersioningUtil.DefaultConfigurationName, new FileVersioningConfiguration { Id = VersioningUtil.DefaultConfigurationName, MaxRevisions = 10 });


                Assert.True(await AssertAsync.DoesNotThrow(() => store.AsyncFilesCommands.UploadAsync("files/1/revision", new MemoryStream(), new RavenJObject()
                {
                    { VersioningUtil.RavenFileRevisionStatus, "Historical" }
                })));
            }
        }
Esempio n. 3
0
        public async Task SmugglingResivionDocsIntoDatabaseWithVersioningDisabled()
        {
            using (var server = GetNewServer())
            {
                var path = Path.GetTempFileName();
                using (var store = NewRemoteDocumentStore(ravenDbServer: server))
                {
                    store
                    .DatabaseCommands
                    .GlobalAdmin
                    .CreateDatabase(new DatabaseDocument
                    {
                        Id       = "Source",
                        Settings =
                        {
                            { Constants.ActiveBundles, "Versioning"  },
                            { "Raven/DataDir",         NewDataPath() }
                        }
                    });
                    store.DatabaseCommands.EnsureDatabaseExists("Source");

                    store
                    .DatabaseCommands
                    .GlobalAdmin
                    .CreateDatabase(new DatabaseDocument
                    {
                        Id       = "Dest",
                        Settings =
                        {
                            { Constants.ActiveBundles, "Versioning"  },
                            { "Raven/DataDir",         NewDataPath() }
                        }
                    });
                    store.DatabaseCommands.EnsureDatabaseExists("Dest");


                    store.DatabaseCommands.ForDatabase("Source")
                    .Put("Raven/Versioning/DefaultConfiguration", null, RavenJObject.FromObject(new Raven.Bundles.Versioning.Data.VersioningConfiguration
                    {
                        Exclude      = false,
                        Id           = "DefaultConfiguration",
                        MaxRevisions = 5
                    }), new RavenJObject());
                    store.DatabaseCommands.ForDatabase("Dest")
                    .Put("Raven/Versioning/DefaultConfiguration", null, RavenJObject.FromObject(new Raven.Bundles.Versioning.Data.VersioningConfiguration
                    {
                        Exclude      = false,
                        Id           = "DefaultConfiguration",
                        MaxRevisions = 5
                    }), new RavenJObject());
                    using (var session = store.OpenSession("Source"))
                    {
                        var doc = new User {
                            Id = "worker/1", Age = 20
                        };
                        session.Store(doc);
                        session.SaveChanges();
                    }
                    using (var session = store.OpenSession("Source"))
                    {
                        var doc = session.Load <User>("worker/1");
                        doc.Age++;
                        session.Store(doc);
                        session.SaveChanges();
                    }
                    var smuggler = new SmugglerDatabaseApi(new SmugglerDatabaseOptions()
                    {
                        ShouldDisableVersioningBundle = false
                    });

                    await smuggler.ExportData(new SmugglerExportOptions <RavenConnectionStringOptions>
                    {
                        ToFile = path,
                        From   = new RavenConnectionStringOptions()
                        {
                            Url             = store.Url,
                            DefaultDatabase = "Source"
                        }
                    });

                    var smuggler2 = new SmugglerDatabaseApi(new SmugglerDatabaseOptions()
                    {
                        ShouldDisableVersioningBundle = true
                    });
                    var isImporting = await AssertAsync.DoesNotThrow(async() => await smuggler2.ImportData(new SmugglerImportOptions <RavenConnectionStringOptions>
                    {
                        FromFile = path,
                        To       = new RavenConnectionStringOptions()
                        {
                            Url             = store.Url,
                            DefaultDatabase = "Dest"
                        }
                    }));

                    Assert.True(isImporting);
                }
            }
        }