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.
RavenDB-19900: added an option to modify the timeout of GetDatabaseTo…
…pologyCommand
- Loading branch information
1 parent
4b67b2d
commit b7a8afd
Showing
3 changed files
with
72 additions
and
1 deletion.
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,61 @@ | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
using System; | ||
using System.Threading; | ||
using FastTests; | ||
using Raven.Client.Http; | ||
|
||
|
||
namespace SlowTests.Issues | ||
{ | ||
public class RavenDB_19900 : RavenTestBase | ||
{ | ||
public RavenDB_19900(ITestOutputHelper output) : base(output) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public async Task UpdateTopologyTimeoutBehaviourShouldBeAccordingToConfiguration() | ||
{ | ||
var generalTimeout = TimeSpan.FromSeconds(3); | ||
var customCommandTimeout = TimeSpan.FromSeconds(1); | ||
var delay = 2000; | ||
|
||
using (var store = GetDocumentStore()) | ||
{ | ||
var executor = store.GetRequestExecutor(); | ||
|
||
try | ||
{ | ||
// delaying response should result in UpdateTopology timeout | ||
executor.ForTestingPurposesOnly().DelayRequest = () => { Thread.Sleep(delay); }; | ||
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()); | ||
|
||
// increasing the general timeout should let UpdateTopology() to be executed | ||
using (store.SetRequestTimeout(generalTimeout)) | ||
{ | ||
await UpdateTopology(); | ||
} | ||
|
||
async Task UpdateTopology() | ||
{ | ||
var node = executor.GetPreferredNode().Result.Node; | ||
var topologyUpdateCommand = new RequestExecutor.UpdateTopologyParameters(node); | ||
await executor.UpdateTopologyAsync(topologyUpdateCommand); | ||
} | ||
} | ||
finally | ||
{ | ||
executor.ForTestingPurposes = null; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|