Skip to content

Commit 208351b

Browse files
committed
fixed test failures mainly to do with _all no no longer magically be rewritten
1 parent e90204f commit 208351b

File tree

30 files changed

+118
-70
lines changed

30 files changed

+118
-70
lines changed

src/Nest/Cluster/ClusterSettings/ClusterGetSettings/ElasticClient-ClusterGetSettings.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,12 @@ public IClusterGetSettingsResponse ClusterGetSettings(IClusterGetSettingsRequest
4242
public Task<IClusterGetSettingsResponse> ClusterGetSettingsAsync(
4343
Func<ClusterGetSettingsDescriptor, IClusterGetSettingsRequest> selector = null,
4444
CancellationToken ct = default
45-
) =>
46-
ClusterGetSettingsAsync(selector.InvokeOrDefault(new ClusterGetSettingsDescriptor()), ct);
45+
) => ClusterGetSettingsAsync(selector.InvokeOrDefault(new ClusterGetSettingsDescriptor()), ct);
4746

4847
/// <inheritdoc cref="ClusterGetSettings(System.Func{Nest.ClusterGetSettingsDescriptor,Nest.IClusterGetSettingsRequest})"/>
49-
public Task<IClusterGetSettingsResponse> ClusterGetSettingsAsync(IClusterGetSettingsRequest request,
48+
public Task<IClusterGetSettingsResponse> ClusterGetSettingsAsync(
49+
IClusterGetSettingsRequest request,
5050
CancellationToken ct = default
51-
) =>
52-
DoRequestAsync<IClusterGetSettingsRequest, IClusterGetSettingsResponse, ClusterGetSettingsResponse>(request, request.RequestParameters, ct);
51+
) => DoRequestAsync<IClusterGetSettingsRequest, IClusterGetSettingsResponse, ClusterGetSettingsResponse>(request, request.RequestParameters, ct);
5352
}
5453
}

src/Nest/Cluster/TaskManagement/GetTask/ElasticClient-GetTask.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ public partial interface IElasticClient
1111

1212
IGetTaskResponse GetTask(IGetTaskRequest request);
1313

14-
Task<IGetTaskResponse> GetTaskAsync(TaskId id, Func<GetTaskDescriptor, IGetTaskRequest> selector = null,
14+
Task<IGetTaskResponse> GetTaskAsync(
15+
TaskId id,
16+
Func<GetTaskDescriptor, IGetTaskRequest> selector = null,
1517
CancellationToken ct = default
1618
);
1719

18-
Task<IGetTaskResponse> GetTaskAsync(IGetTaskRequest request, CancellationToken cancellationToken = default);
20+
Task<IGetTaskResponse> GetTaskAsync(IGetTaskRequest request, CancellationToken ct = default);
1921
}
2022

2123
public partial class ElasticClient

src/Nest/CommonAbstractions/Request/ApiUrls.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ private static LookupTuple FromRoute(string route)
5959
if (t[0] == '@')
6060
{
6161
if (r.TryGetValue(parts[i], out var v))
62-
sb.Append(Uri.EscapeDataString(v.GetString(s)));
62+
{
63+
var sv = v.GetString(s);
64+
if (string.IsNullOrEmpty(sv))
65+
throw new Exception($"{parts[i]} of type ({v.GetType().Name}) did not resolve to a value on url {route}");
66+
sb.Append(Uri.EscapeDataString(sv));
67+
}
6368
else throw new Exception($"No value provided for {parts[i]} on url {route}");
6469

6570
i++;

src/Nest/CommonAbstractions/Request/RouteValues.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ namespace Nest
66
{
77
public class RouteValues : Dictionary<string, IUrlParameter>
88
{
9-
// TODO Remove
10-
public string Id => throw new Exception("need to be refactored out");
11-
129
private RouteValues Route(string name, IUrlParameter routeValue, bool required = true)
1310
{
1411
switch (routeValue) {

src/Nest/Document/Single/Index/IndexRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void IProxyRequest.WriteJson(IElasticsearchSerializer sourceSerializer, Stream s
2222
protected void DefaultRouting() => Self.RequestParameters.SetQueryString("routing", new Routing(() => Document));
2323

2424
internal static HttpMethod GetHttpMethod(IIndexRequest<TDocument> request) =>
25-
request.Id?.StringOrLongValue != null || request.RouteValues.Id != null ? HttpMethod.PUT : HttpMethod.POST;
25+
request.Id?.StringOrLongValue != null || request.RouteValues.ContainsKey("id") ? HttpMethod.PUT : HttpMethod.POST;
2626

2727
partial void DocumentFromPath(TDocument document) => Document = document;
2828
}

src/Tests/Tests/ClientConcepts/Troubleshooting/LoggingWithOnRequestCompleted.doc.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ public async Task UsingOnRequestCompletedForLogging()
136136
list.Count.Should().Be(4);
137137
list.Should().BeEquivalentTo(new[] // <6> Assert the list contains the contents written in the delegate passed to `OnRequestCompleted`
138138
{
139-
@"POST http://localhost:9200/_search?typed_keys=true&scroll=2m {""sort"":[{""_doc"":{""order"":""asc""}}]}",
139+
@"POST http://localhost:9200/_all/_search?typed_keys=true&scroll=2m {""sort"":[{""_doc"":{""order"":""asc""}}]}",
140140
@"Status: 200",
141-
@"POST http://localhost:9200/_search?typed_keys=true&scroll=10m {""sort"":[{""_doc"":{""order"":""asc""}}]}",
141+
@"POST http://localhost:9200/_all/_search?typed_keys=true&scroll=10m {""sort"":[{""_doc"":{""order"":""asc""}}]}",
142142
@"Status: 200"
143143
});
144144
}
@@ -213,9 +213,9 @@ public async Task OnRequestCompletedPerRequest()
213213
list.Count.Should().Be(4);
214214
list.Should().BeEquivalentTo(new[]
215215
{
216-
@"POST http://localhost:9200/_search?typed_keys=true&scroll=2m", // <3> Only the method and url for the first request is captured
216+
@"POST http://localhost:9200/_all/_search?typed_keys=true&scroll=2m", // <3> Only the method and url for the first request is captured
217217
@"Status: 200",
218-
@"POST http://localhost:9200/_search?typed_keys=true&scroll=10m {""sort"":[{""_doc"":{""order"":""asc""}}]}", // <4> the body of the second request is captured
218+
@"POST http://localhost:9200/_all/_search?typed_keys=true&scroll=10m {""sort"":[{""_doc"":{""order"":""asc""}}]}", // <4> the body of the second request is captured
219219
@"Status: 200"
220220
});
221221
}

src/Tests/Tests/Cluster/ClusterSettings/ClusterGetSettings/ClusterGetSettingsApiTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public ClusterGetSettingsApiTests(ReadOnlyCluster cluster, EndpointUsage usage)
1515
protected override HttpMethod HttpMethod => HttpMethod.GET;
1616
protected override string UrlPath => "/_cluster/settings";
1717

18+
protected override ClusterGetSettingsRequest Initializer { get; } = new ClusterGetSettingsRequest();
19+
1820
protected override LazyResponses ClientUsage() => Calls(
1921
(client, f) => client.ClusterGetSettings(),
2022
(client, f) => client.ClusterGetSettingsAsync(),

src/Tests/Tests/Document/Single/Get/GetUrlTests.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ await GET("/project/_doc/1")
2020
.RequestAsync(c => c.GetAsync<Project>(new GetRequest<Project>(1)))
2121
;
2222

23-
//new GetRequest<Project>(null, null, 1) is still an error
24-
await GET("/project/_doc/1")
25-
.Fluent(c => c.Get<Project>(1, g => g.Index(null)))
26-
.FluentAsync(c => c.GetAsync<Project>(1, g => g.Index(null)))
27-
;
28-
2923
await GET("/testindex/_doc/1")
3024
.Fluent(c => c.Get<Project>(1, g => g.Index("testindex")))
3125
.Request(c => c.Get<Project>(new GetRequest<Project>("testindex", 1)))

src/Tests/Tests/Indices/IndexSettings/UpdateIndicesSettings/UpdateIndexSettingsUrlTests.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,17 @@ await PUT($"/index1%2Cindex2/_settings")
1717
.Fluent(c => c.UpdateIndexSettings(indices, s => s))
1818
.Request(c => c.UpdateIndexSettings(new UpdateIndexSettingsRequest(index)))
1919
.FluentAsync(c => c.UpdateIndexSettingsAsync(indices, s => s))
20-
.RequestAsync(c => c.UpdateIndexSettingsAsync(new UpdateIndexSettingsRequest(index)))
20+
.RequestAsync(c => c.UpdateIndexSettingsAsync(new UpdateIndexSettingsRequest(index)));
21+
22+
await PUT($"/_all/_settings")
23+
.Fluent(c => c.UpdateIndexSettings(AllIndices, s => s))
24+
.Request(c => c.UpdateIndexSettings(new UpdateIndexSettingsRequest(All)))
25+
.FluentAsync(c => c.UpdateIndexSettingsAsync(AllIndices, s => s))
26+
.RequestAsync(c => c.UpdateIndexSettingsAsync(new UpdateIndexSettingsRequest(All)))
2127
;
28+
2229
await PUT($"/_settings")
23-
.Fluent(c => c.UpdateIndexSettings(AllIndices, s => s))
2430
.Request(c => c.UpdateIndexSettings(new UpdateIndexSettingsRequest()))
25-
.FluentAsync(c => c.UpdateIndexSettingsAsync(AllIndices, s => s))
2631
.RequestAsync(c => c.UpdateIndexSettingsAsync(new UpdateIndexSettingsRequest()))
2732
;
2833
}

src/Tests/Tests/Indices/Monitoring/IndicesRecovery/RecoveryStatusApiTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public RecoveryStatusApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : ba
1919
protected override HttpMethod HttpMethod => HttpMethod.GET;
2020

2121
protected override RecoveryStatusRequest Initializer => new RecoveryStatusRequest(Infer.AllIndices);
22-
protected override string UrlPath => "/_recovery";
22+
protected override string UrlPath => "/_all/_recovery";
2323

2424
protected override LazyResponses ClientUsage() => Calls(
2525
(client, f) => client.RecoveryStatus(Infer.AllIndices, f),

0 commit comments

Comments
 (0)