forked from ravendb/ravendb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing an issue with raven documents not being exported
- Loading branch information
Showing
4 changed files
with
96 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Threading; | ||
using Raven.Client.Document; | ||
using Raven.Client.Indexes; | ||
using Raven.Database; | ||
using Raven.Server; | ||
using Xunit; | ||
|
||
namespace Raven.Tests.Bugs | ||
{ | ||
public class HiLoServerKeysNotExported : IDisposable | ||
{ | ||
private DocumentStore documentStore; | ||
private RavenDbServer server; | ||
|
||
public HiLoServerKeysNotExported() | ||
{ | ||
CreateServer(true); | ||
|
||
|
||
} | ||
|
||
private void CreateServer(bool initDocStore = false) | ||
{ | ||
if (Directory.Exists("HiLoData")) Directory.Delete("HiLoData", true); | ||
server = new RavenDbServer(new RavenConfiguration { Port = 8080, DataDirectory = "HiLoData", RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true }); | ||
|
||
if (initDocStore) { | ||
documentStore = new DocumentStore() { Url = "http://localhost:8080/" }; | ||
documentStore.Initialize(); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void Export_And_Import_Retains_HiLoState() | ||
{ | ||
using (var session = documentStore.OpenSession()) { | ||
var foo = new Foo() { Something = "something2" }; | ||
Assert.Null(foo.Id); | ||
session.Store(foo); | ||
Assert.NotNull(foo.Id); | ||
session.SaveChanges(); | ||
} | ||
|
||
if (File.Exists("hilo-export.dump")) | ||
File.Delete("hilo-export.dump"); | ||
Smuggler.Smuggler.ExportData("http://localhost:8080/", "hilo-export.dump", false); | ||
Assert.True(File.Exists("hilo-export.dump")); | ||
|
||
using (var session = documentStore.OpenSession()) { | ||
var hilo = session.Load<HiLoKey>("Raven/Hilo/foos"); | ||
Assert.NotNull(hilo); | ||
Assert.Equal(2, hilo.ServerHi); | ||
} | ||
|
||
server.Dispose(); | ||
CreateServer(); | ||
|
||
Smuggler.Smuggler.ImportData("http://localhost:8080/", "hilo-export.dump"); | ||
|
||
using (var session = documentStore.OpenSession()) { | ||
var hilo = session.Load<HiLoKey>("Raven/Hilo/foos"); | ||
Assert.NotNull(hilo); | ||
Assert.Equal(2, hilo.ServerHi); | ||
} | ||
} | ||
|
||
public class Foo | ||
{ | ||
public string Id { get; set; } | ||
public string Something { get; set; } | ||
} | ||
|
||
private class HiLoKey | ||
{ | ||
public long ServerHi { get; set; } | ||
|
||
} | ||
|
||
public void Dispose() | ||
{ | ||
documentStore.Dispose(); | ||
server.Dispose(); | ||
if (Directory.Exists("HiLoData")) Directory.Delete("HiLoData", true); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters