1010
1111namespace Tests . Cluster . TaskManagement . TasksCancel
1212{
13- // TODO Unit tests will fail in mixed mode because SetupTaskIds isn't setup
1413 [ Collection ( IntegrationContext . OwnIndex ) ]
1514 public class TasksCancelApiTests : ApiIntegrationTestBase < ITasksCancelResponse , ITasksCancelRequest , TasksCancelDescriptor , TasksCancelRequest >
1615 {
17- public class Test
16+ private TaskId TaskId => this . RanIntegrationSetup ? this . ExtendedValue < TaskId > ( "taskId" ) : "foo:1" ;
17+
18+ private class Test
1819 {
1920 public long Id { get ; set ; }
2021 public string Flag { get ; set ; }
2122 }
2223
2324 public TasksCancelApiTests ( OwnIndexCluster cluster , EndpointUsage usage ) : base ( cluster , usage ) { }
2425
25- protected IDictionary < string , TaskId > SetupTaskIds { get ; } = new Dictionary < string , TaskId > ( ) ;
26-
27- protected override void BeforeAllCalls ( IElasticClient client , IDictionary < ClientMethod , string > values )
26+ protected override void IntegrationSetup ( IElasticClient client , CallUniqueValues values )
2827 {
2928 foreach ( var index in values . Values )
3029 {
3130 client . IndexMany ( Enumerable . Range ( 0 , 10000 ) . Select ( i => new Test { Id = i + 1 , Flag = "bar" } ) , index ) ;
3231 client . Refresh ( index ) ;
3332 }
34- foreach ( var index in values . Values )
33+ foreach ( var view in values . Views )
3534 {
35+ values . CurrentView = view ;
36+ var index = values . Value ;
37+
3638 var reindex = client . ReindexOnServer ( r => r
3739 . Source ( s => s . Index ( index ) )
3840 . Destination ( s => s . Index ( $ "{ index } -clone") )
@@ -42,7 +44,7 @@ protected override void BeforeAllCalls(IElasticClient client, IDictionary<Client
4244 var taskId = reindex . Task ;
4345 var taskInfo = client . TasksList ( new TasksListRequest ( taskId ) ) ;
4446 taskInfo . IsValid . Should ( ) . BeTrue ( ) ;
45- this . SetupTaskIds [ index ] = taskId ;
47+ values . ExtendedValue ( "taskId" , taskId ) ;
4648 }
4749 }
4850 protected override LazyResponses ClientUsage ( ) => Calls (
@@ -58,20 +60,18 @@ protected override LazyResponses ClientUsage() => Calls(
5860 protected override string UrlPath => $ "/_tasks/{ Uri . EscapeDataString ( this . TaskId . ToString ( ) ) } /_cancel";
5961 protected override bool SupportsDeserialization => false ;
6062
61- private TaskId TaskId => TestClient . Configuration . RunIntegrationTests ? this . SetupTaskIds [ CallIsolatedValue ] : "foo:1" ;
6263
6364 protected override Func < TasksCancelDescriptor , ITasksCancelRequest > Fluent => d => d
6465 . TaskId ( this . TaskId ) ;
6566
6667 protected override TasksCancelRequest Initializer => new TasksCancelRequest ( this . TaskId ) ;
6768
68- // TODO this test is flaky, sometimes SetupTaskIds is empty
6969 protected override void ExpectResponse ( ITasksCancelResponse response )
7070 {
7171 response . NodeFailures . Should ( ) . BeNullOrEmpty ( ) ;
7272 response . Nodes . Should ( ) . NotBeEmpty ( ) ;
7373 var tasks = response . Nodes . First ( ) . Value . Tasks ;
74- tasks . Should ( ) . NotBeEmpty ( ) . And . ContainKey ( this . SetupTaskIds [ CallIsolatedValue ] ) ;
74+ tasks . Should ( ) . NotBeEmpty ( ) . And . ContainKey ( this . TaskId ) ;
7575 }
7676 }
7777}
0 commit comments