mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-21 22:04:31 -04:00
more granular Concurrency control.
indexer calls are done fully paralleled. events are dispatched on max of 2 threads.
This commit is contained in:
@@ -9,6 +9,7 @@ using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Indexers.Newznab;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.IndexerTests
|
||||
{
|
||||
@@ -45,26 +46,20 @@ namespace NzbDrone.Core.Test.IndexerTests
|
||||
[Explicit]
|
||||
public void should_call_fetch_on_all_indexers_at_the_same_time()
|
||||
{
|
||||
var callsToFetch = new List<DateTime>();
|
||||
|
||||
var counter = new ConcurrencyCounter(_indexers.Count);
|
||||
|
||||
Mocker.GetMock<IFetchFeedFromIndexers>().Setup(c => c.FetchRss(It.IsAny<IIndexer>()))
|
||||
.Returns(new List<ReportInfo>())
|
||||
.Callback((() =>
|
||||
{
|
||||
Thread.Sleep(2000);
|
||||
Console.WriteLine(DateTime.Now);
|
||||
callsToFetch.Add(DateTime.Now);
|
||||
}));
|
||||
.Callback((() => counter.SimulateWork(500)));
|
||||
|
||||
Mocker.GetMock<IIndexerService>().Setup(c => c.GetAvailableIndexers()).Returns(_indexers);
|
||||
|
||||
Subject.Fetch();
|
||||
|
||||
counter.WaitForAllItems();
|
||||
|
||||
var first = callsToFetch.Min();
|
||||
var last = callsToFetch.Max();
|
||||
|
||||
(last - first).Should().BeLessThan(TimeSpan.FromSeconds(1));
|
||||
counter.MaxThreads.Should().Be(_indexers.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user