Skip to content

Commit

Permalink
RavenDB-19900: changed test to use Action
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGoldenPlatypus committed Jul 26, 2023
1 parent 440d2af commit 2ec4c29
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/Raven.Client/Http/RequestExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,7 @@ public virtual async Task<bool> UpdateTopologyAsync(UpdateTopologyParameters par
using (ContextPool.AllocateOperationContext(out JsonOperationContext context))
{
var command = new GetDatabaseTopologyCommand(parameters.DebugTag, Conventions.SendApplicationIdentifier ? parameters.ApplicationIdentifier : null);
if (ForTestingPurposes != null && ForTestingPurposes.timeout != TimeSpan.Zero)
command.Timeout = ForTestingPurposes.timeout;
ForTestingPurposes?.SetCommandTimeout?.Invoke(command);

if (DefaultTimeout.HasValue && DefaultTimeout.Value > command.Timeout)
command.Timeout = DefaultTimeout.Value;
Expand Down Expand Up @@ -2373,7 +2372,7 @@ internal TestingStuff(RequestExecutor requestExecutor)
internal ConcurrentDictionary<ServerNode, Lazy<NodeStatus>> FailedNodesTimers => _requestExecutor._failedNodesTimers;
internal (int Index, ServerNode Node) PreferredNode => _requestExecutor._nodeSelector.GetPreferredNode();
internal Action DelayRequest;
internal TimeSpan timeout;
internal Action<GetDatabaseTopologyCommand> SetCommandTimeout;
}
}
}
9 changes: 6 additions & 3 deletions test/SlowTests/Issues/RavenDB_19900.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
using Xunit.Abstractions;
using System;
using System.Threading;
using FastTests;
using Raven.Client.Http;
using Tests.Infrastructure;


namespace SlowTests.Issues
{
public class RavenDB_19900 : ClusterTestBase
public class RavenDB_19900 : RavenTestBase
{
public RavenDB_19900(ITestOutputHelper output) : base(output)
{
Expand All @@ -30,7 +30,10 @@ public async Task UpdateTopologyTimeoutBehaviourShouldBeAccordingToConfiguration
{
// delaying response should result in UpdateTopology timeout
executor.ForTestingPurposesOnly().DelayRequest = () => { Thread.Sleep(delay); };
executor.ForTestingPurposesOnly().timeout = customCommandTimeout;
executor.ForTestingPurposesOnly().SetCommandTimeout = (command) =>
{
command.Timeout = customCommandTimeout;
};
var e = await Assert.ThrowsAsync<TimeoutException>(async () => await UpdateTopology());
Assert.Contains("failed with timeout after 00:00:01", e.ToString());

Expand Down

0 comments on commit 2ec4c29

Please sign in to comment.