Skip to content

Commit

Permalink
Merge pull request #18543 from arekpalinski/v6.0
Browse files Browse the repository at this point in the history
5.4 to 6.0 merge
  • Loading branch information
arekpalinski committed May 17, 2024
2 parents dbfad58 + fd90c59 commit 0183fd6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 31 deletions.
38 changes: 10 additions & 28 deletions test/SlowTests/Issues/RavenDB-19379.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Raven.Client.Documents;
using Raven.Client.Documents.Conventions;
using Raven.Server;
using Raven.Server.Config;
using Raven.Server.Config.Settings;
using Raven.Server.Documents;
Expand All @@ -19,8 +17,6 @@ namespace SlowTests.Issues
{
public class RavenDB_19379 : ClusterTestBase
{
private static readonly TimeSpan defaultTimeout = TimeSpan.Zero;

public RavenDB_19379(ITestOutputHelper output) : base(output)
{
}
Expand Down Expand Up @@ -68,40 +64,26 @@ public async Task Node_Stays_Rehab_After_Connect_Again()
var cs = new Dictionary<string, string>(DefaultClusterSettings);
cs[RavenConfiguration.GetKey(x => x.Core.ServerUrls)] = nodeToDispose_url;

var revivedServer = GetNewServer(new ServerCreationOptions
using var revivedServer = GetNewServer(new ServerCreationOptions
{
DeletePrevious = false,
RunInMemory = false,
DataDirectory = result.DataDirectory,
CustomSettings = cs
});

var doc = await WaitForDocToReplicateAsync<User>(revivedServer, nodeToDispose_url, store.Database, "Users/1-A");
Assert.NotNull(doc);

await WaitAndAssertMembers(store, nodeTags, TimeSpan.FromSeconds(10));
}


private async Task<T> WaitForDocToReplicateAsync<T>(RavenServer server, string url, string database, string id, int timeout = 15_000_000) where T : class
{
using var revivedStore = new DocumentStore()
{
Urls = new[] { url }, Database = database, Conventions = new DocumentConventions() { DisableTopologyUpdates = true }
}.Initialize();

var sw = Stopwatch.StartNew();
while (sw.ElapsedMilliseconds <= timeout)
{
using (var session = revivedStore.OpenAsyncSession(database))
Urls = new[] { nodeToDispose_url },
Database = store.Database,
Conventions = new DocumentConventions()
{
var doc = await session.LoadAsync<T>(id);
if (doc != null)
return doc;
DisableTopologyUpdates = true
}
}
sw.Stop();
return null;
}.Initialize();
var doc = await WaitForDocumentToReplicateAsync<User>(revivedStore, "Users/1-A", TimeSpan.FromSeconds(15));
Assert.NotNull(doc);

await WaitAndAssertMembers(store, nodeTags, TimeSpan.FromSeconds(10));
}

private async Task WaitAndAssertRehabs(DocumentStore store, List<string> expectedRehabs, TimeSpan timeout)
Expand Down
12 changes: 9 additions & 3 deletions test/Tests.Infrastructure/ClusterTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ public async Task EnsureReplicatingAsync(IDocumentStore src, IDocumentStore dst)
}
}

protected static async Task<T> WaitForDocumentToReplicateAsync<T>(IDocumentStore store, string id, int timeout)
protected static async Task<T> WaitForDocumentToReplicateAsync<T>(IDocumentStore store, string id, TimeSpan timeout)
where T : class
{
var sw = Stopwatch.StartNew();
while (sw.ElapsedMilliseconds <= timeout)
while (sw.Elapsed <= timeout)
{
using (var session = store.OpenAsyncSession(store.Database))
{
Expand All @@ -174,7 +174,13 @@ protected static async Task<T> WaitForDocumentToReplicateAsync<T>(IDocumentStore
return null;
}

protected static T WaitForDocumentToReplicate<T>(IDocumentStore store, string id, int timeout)
protected Task<T> WaitForDocumentToReplicateAsync<T>(IDocumentStore store, string id, int timeoutInMs)
where T : class
{
return WaitForDocumentToReplicateAsync<T>(store, id, TimeSpan.FromMilliseconds(timeoutInMs));
}

protected T WaitForDocumentToReplicate<T>(IDocumentStore store, string id, int timeout)
where T : class
{
var sw = Stopwatch.StartNew();
Expand Down

0 comments on commit 0183fd6

Please sign in to comment.