1+ using FluentAssertions ;
2+ using NUnit . Framework ;
3+ using System ;
4+ using System . Collections . Generic ;
5+ using System . IO ;
6+ using System . Linq ;
7+ using System . Text ;
8+ using System . Threading . Tasks ;
9+
10+ namespace Nest . Tests . Unit . Cluster
11+ {
12+ [ TestFixture ]
13+ public class PendingTasksTests : BaseJsonTests
14+ {
15+ [ Test ]
16+ public void RequestUrlTest ( )
17+ {
18+ var r = this . _client . ClusterPendingTasks ( ) ;
19+ var status = r . ConnectionStatus ;
20+ var url = new Uri ( status . RequestUrl ) ;
21+ url . AbsolutePath . Should ( ) . StartWith ( "/_cluster/pending_tasks" ) ;
22+ }
23+
24+ [ Test ]
25+ public void ResponseBodyJsonTest ( )
26+ {
27+ var json = @"{
28+ tasks: [
29+ {
30+ insert_order: 101,
31+ priority: ""URGENT"",
32+ source: ""create-index [foo_9], cause [api]"",
33+ time_in_queue_millis: 86,
34+ time_in_queue: ""86ms""
35+ },
36+ {
37+ insert_order: 46,
38+ priority: ""HIGH"",
39+ source: ""shard-started ([foo_2][1], node[tMTocMvQQgGCkj7QDHl3OA], [P], s[INITIALIZING]), reason [after recovery from gateway]"",
40+ time_in_queue_millis: 842,
41+ time_in_queue: ""842ms""
42+ }
43+ ]
44+ }" ;
45+
46+ var bytes = System . Text . Encoding . UTF8 . GetBytes ( json ) ;
47+ var stream = new MemoryStream ( bytes ) ;
48+
49+ var response = _client . Serializer . Deserialize < ClusterPendingTasksResponse > ( stream ) ;
50+ response . Should ( ) . NotBeNull ( ) ;
51+ response . Tasks . Count ( ) . ShouldBeEquivalentTo ( 2 ) ;
52+
53+ var task1 = response . Tasks . ElementAt ( 0 ) ;
54+ task1 . InsertOrder . ShouldBeEquivalentTo ( 101 ) ;
55+ task1 . Priority . ShouldBeEquivalentTo ( "URGENT" ) ;
56+ task1 . Source . ShouldBeEquivalentTo ( "create-index [foo_9], cause [api]" ) ;
57+ task1 . TimeInQueueMilliseconds . ShouldBeEquivalentTo ( 86 ) ;
58+ task1 . TimeInQueue . ShouldBeEquivalentTo ( "86ms" ) ;
59+
60+ var task2 = response . Tasks . ElementAt ( 1 ) ;
61+ task2 . InsertOrder . ShouldBeEquivalentTo ( 46 ) ;
62+ task2 . Priority . ShouldBeEquivalentTo ( "HIGH" ) ;
63+ task2 . Source . ShouldBeEquivalentTo ( "shard-started ([foo_2][1], node[tMTocMvQQgGCkj7QDHl3OA], [P], s[INITIALIZING]), reason [after recovery from gateway]" ) ;
64+ task2 . TimeInQueueMilliseconds . ShouldBeEquivalentTo ( 842 ) ;
65+ task2 . TimeInQueue . ShouldBeEquivalentTo ( "842ms" ) ;
66+ }
67+ }
68+ }
0 commit comments