|
5 | 5 | using Nest; |
6 | 6 | using Tests.Framework; |
7 | 7 | using Tests.Framework.Integration; |
| 8 | +using Tests.Framework.MockData; |
8 | 9 | using Xunit; |
9 | 10 |
|
10 | 11 | namespace Tests.Cluster.TaskManagement.TasksList |
@@ -56,8 +57,86 @@ protected override void ExpectResponse(ITasksListResponse response) |
56 | 57 | var parentTask = taskExecutingNode.Tasks[task.ParentTaskId]; |
57 | 58 | parentTask.Should().NotBeNull(); |
58 | 59 | parentTask.ParentTaskId.Should().BeNull(); |
| 60 | + } |
| 61 | + } |
| 62 | + |
| 63 | + [SkipVersion("<2.3.0", "")] |
| 64 | + public class TasksListDetailedApiTests : ApiIntegrationTestBase<IntrusiveOperationCluster, ITasksListResponse, ITasksListRequest, TasksListDescriptor, TasksListRequest> |
| 65 | + { |
| 66 | + private static TaskId _taskId = new TaskId("fakeid:1"); |
| 67 | + |
| 68 | + public TasksListDetailedApiTests(IntrusiveOperationCluster cluster, EndpointUsage usage) : base(cluster, usage) { } |
| 69 | + protected override LazyResponses ClientUsage() => Calls( |
| 70 | + fluent: (client, f) => client.TasksList(f), |
| 71 | + fluentAsync: (client, f) => client.TasksListAsync(f), |
| 72 | + request: (client, r) => client.TasksList(r), |
| 73 | + requestAsync: (client, r) => client.TasksListAsync(r) |
| 74 | + ); |
| 75 | + |
| 76 | + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) |
| 77 | + { |
| 78 | + var seeder = new Seeder(this.Cluster.Node); |
| 79 | + seeder.SeedNode(); |
| 80 | + |
| 81 | + // get a suitable load of projects in order to get a decent task status out |
| 82 | + var bulkResponse = client.IndexMany(Project.Generator.Generate(20000)); |
| 83 | + if (!bulkResponse.IsValid) |
| 84 | + throw new Exception("failure in setting up integration"); |
| 85 | + |
| 86 | + var response = client.ReindexOnServer(r => r |
| 87 | + .Source(s => s |
| 88 | + .Index(Infer.Index<Project>()) |
| 89 | + .Type(typeof(Project)) |
| 90 | + ) |
| 91 | + .Destination(d => d |
| 92 | + .Index("tasks-list-projects") |
| 93 | + .OpType(OpType.Create) |
| 94 | + ) |
| 95 | + .Conflicts(Conflicts.Proceed) |
| 96 | + .WaitForCompletion(false) |
| 97 | + .Refresh() |
| 98 | + ); |
| 99 | + |
| 100 | + _taskId = response.Task; |
| 101 | + } |
| 102 | + |
| 103 | + protected override bool ExpectIsValid => true; |
| 104 | + protected override int ExpectStatusCode => 200; |
| 105 | + protected override HttpMethod HttpMethod => HttpMethod.GET; |
| 106 | + protected override string UrlPath => $"/_tasks/{Uri.EscapeDataString(_taskId.ToString())}?detailed=true"; |
59 | 107 |
|
| 108 | + protected override Func<TasksListDescriptor, ITasksListRequest> Fluent => s => s |
| 109 | + .TaskId(_taskId) |
| 110 | + .Detailed(); |
| 111 | + |
| 112 | + protected override TasksListRequest Initializer => new TasksListRequest(_taskId) |
| 113 | + { |
| 114 | + Detailed = true |
| 115 | + }; |
| 116 | + |
| 117 | + protected override void ExpectResponse(ITasksListResponse response) |
| 118 | + { |
| 119 | + response.Nodes.Should().NotBeEmpty(); |
| 120 | + var taskExecutingNode = response.Nodes.First().Value; |
| 121 | + taskExecutingNode.Host.Should().NotBeNullOrWhiteSpace(); |
| 122 | + taskExecutingNode.Ip.Should().NotBeNullOrWhiteSpace(); |
| 123 | + taskExecutingNode.Name.Should().NotBeNullOrWhiteSpace(); |
| 124 | + taskExecutingNode.TransportAddress.Should().NotBeNullOrWhiteSpace(); |
| 125 | + taskExecutingNode.Tasks.Should().NotBeEmpty(); |
| 126 | + taskExecutingNode.Tasks.Count().Should().Be(1); |
| 127 | + |
| 128 | + var task = taskExecutingNode.Tasks[_taskId]; |
| 129 | + task.Action.Should().NotBeNullOrWhiteSpace(); |
| 130 | + task.Type.Should().NotBeNullOrWhiteSpace(); |
| 131 | + task.Id.Should().BePositive(); |
| 132 | + task.Node.Should().NotBeNullOrWhiteSpace(); |
| 133 | + task.RunningTimeInNanoSeconds.Should().BeGreaterThan(0); |
| 134 | + task.StartTimeInMilliseconds.Should().BeGreaterThan(0); |
60 | 135 |
|
| 136 | + var status = task.Status; |
| 137 | + status.Should().NotBeNull(); |
| 138 | + status.Total.Should().BeGreaterOrEqualTo(0); |
| 139 | + status.Batches.Should().BeGreaterOrEqualTo(0); |
61 | 140 | } |
62 | 141 | } |
63 | 142 | } |
0 commit comments