public void CompactUpdateMessagesShouldNotAppearInMessages(string requestedStorage)
{
using (var documentStore = NewRemoteDocumentStore(requestedStorage: requestedStorage, databaseName:"Test",runInMemory:false))
{
using (var session = documentStore.OpenSession())
{
session.Store(new RavenJObject());
session.SaveChanges();
}
var ravenHtttpFactory = new HttpRavenRequestFactory();
var request = ravenHtttpFactory.Create("http://localhost:8079/admin/compact?database=Test","POST",new RavenConnectionStringOptions());
var response = request.ExecuteRequest<RavenJObject>();
using (var systemDocumentStore = new DocumentStore() { Url = "http://localhost:8079" }.Initialize())
{
using (var session = systemDocumentStore.OpenSession())
{
var stopeWatch = new Stopwatch();
stopeWatch.Start();
do
{
if (stopeWatch.Elapsed >= timeout) throw new TimeoutException("Waited to long for test to complete compaction.");
var statusRequest = ravenHtttpFactory.Create("http://localhost:8079/operation/status?id=" + response.Value<string>("OperationId"), "GET", new RavenConnectionStringOptions());
var status = statusRequest.ExecuteRequest<RavenJObject>();
if (status.Value<bool>("Completed"))
{
var compactStatus = session.Load<CompactStatus>(CompactStatus.RavenDatabaseCompactStatusDocumentKey("Test"));
Assert.Equal(compactStatus.Messages.Count, storageToExpectedLength[requestedStorage]);
return;
} else if (status.Value<bool>("Faulted"))
{
throw new Exception("Something went wrong, compaction was not successful");
}
Thread.Sleep(1000);
} while (true);
}
}
}
}