Further research showed that it might be a licensing issue. I wrote a little helper class which activates a developer license for the unit tests. With this fix in place, I get the following numbers for Raven 5.1.5:
- 4 tests in parallel: 18 s
- 8 tests in parallel: 27 s
- 16 tests in parallel: 52 s
public static class SlowRavenDB5TestHelper
{
private static readonly SemaphoreSlim Semaphore = new SemaphoreSlim(1, 1);
private static bool _isFixed = false;
public static async Task FixLicenseAsync(IDocumentStore store)
{
if (!_isFixed)
{
await Semaphore.WaitAsync();
try
{
if (!_isFixed)
{
var license = GetLicense();
var url = store.Identifier.Split(' ')[0];
var request = WebRequest.Create(url + "/admin/license/activate");
request.Method = "POST";
request.ContentType = "application/json";
request.ContentLength = license.Length;
using (var stream = await request.GetRequestStreamAsync())
{
await stream.WriteAsync(license, 0, license.Length);
await request.GetResponseAsync();
}
_isFixed = true;
}
}
finally
{
Semaphore.Release();
}
}
}
private static byte[] GetLicense() =>
Encoding.UTF8.GetBytes(/* insert developer license string*/);
}
The usage is as simple as follows:
protected async Task TestTemplate(int items)
{
var database = Guid.NewGuid().ToString();
using (var store = GetDocumentStore(database: database))
{
await SlowRavenDB5TestHelper.FixLicenseAsync(store);
[..]
}
}
It's just a dirty workaround but it might help you in finding the root cause of this issue.