Skip to content

Commit 003abb7

Browse files
committed
CCR url and api tests
1 parent b2fccc3 commit 003abb7

File tree

15 files changed

+426
-0
lines changed

15 files changed

+426
-0
lines changed

src/Nest/XPack/CrossClusterReplication/Follow/ResumeFollowIndex/ResumeFollowIndexRequest.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,43 @@ namespace Nest
1313
public partial interface IResumeFollowIndexRequest
1414
{
1515
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxReadRequestOperationCount"/>
16+
[JsonProperty("max_read_request_operation_count")]
1617
long? MaxReadRequestOperationCount { get; set; }
1718

1819
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxOutstandingReadRequests"/>
20+
[JsonProperty("max_outstanding_read_requests")]
1921
long? MaxOutstandingReadRequests { get; set; }
2022

2123
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxRequestSize"/>
24+
[JsonProperty("max_read_request_size")]
2225
string MaxRequestSize { get; set; }
2326

2427
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxWriteRequestOperationCount"/>
28+
[JsonProperty("max_write_request_operation_count")]
2529
long? MaxWriteRequestOperationCount { get; set; }
2630

2731
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxWriteRequestSize"/>
32+
[JsonProperty("max_write_request_size")]
2833
string MaxWriteRequestSize { get; set; }
2934

3035
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxOutstandingWriteRequests"/>
36+
[JsonProperty("max_outstanding_write_requests")]
3137
long? MaxOutstandingWriteRequests { get; set; }
3238

3339
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxWriteBufferCount"/>
40+
[JsonProperty("max_write_buffer_count")]
3441
long? MaxWriteBufferCount { get; set; }
3542

3643
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxWriteBufferSize"/>
44+
[JsonProperty("max_write_buffer_size")]
3745
string MaxWriteBufferSize { get; set; }
3846

3947
/// <inheritdoc cref="ICreateFollowIndexRequest.MaxRetryDelay"/>
48+
[JsonProperty("max_retry_delay")]
4049
Time MaxRetryDelay { get; set; }
4150

4251
/// <inheritdoc cref="ICreateFollowIndexRequest.ReadPollTimeout"/>
52+
[JsonProperty("read_poll_timeout")]
4353
Time ReadPollTimeout { get; set; }
4454
}
4555

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
using System;
2+
using Elasticsearch.Net;
3+
using Nest;
4+
using Tests.Core.ManagedElasticsearch.Clusters;
5+
using Tests.Framework;
6+
using Tests.Framework.Integration;
7+
8+
namespace Tests.XPack.CrossClusterReplication.AutoFollow.CreateAutoFollowPattern
9+
{
10+
public class CreateAutoFollowPatternApiTests : ApiTestBase<XPackCluster, ICreateAutoFollowPatternResponse, ICreateAutoFollowPatternRequest, CreateAutoFollowPatternDescriptor, CreateAutoFollowPatternRequest>
11+
{
12+
public CreateAutoFollowPatternApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { }
13+
14+
protected override object ExpectJson { get; } = new
15+
{
16+
follow_index_pattern = "y",
17+
leader_index_patterns = new [] { "z" },
18+
max_outstanding_read_requests = 100,
19+
max_outstanding_write_requests = 101,
20+
max_read_request_operation_count = 102,
21+
max_read_request_size = "2mb",
22+
max_retry_delay = "1m",
23+
max_write_buffer_count = 104,
24+
max_write_buffer_size = "1mb",
25+
max_write_request_operation_count = 103,
26+
max_write_request_size = "3mb",
27+
read_poll_timeout = "2m",
28+
remote_cluster = "x"
29+
};
30+
31+
protected override CreateAutoFollowPatternDescriptor NewDescriptor() => new CreateAutoFollowPatternDescriptor("x");
32+
33+
protected override Func<CreateAutoFollowPatternDescriptor, ICreateAutoFollowPatternRequest> Fluent => d => d
34+
.RemoteCluster("x")
35+
.FollowIndexPattern("y")
36+
.LeaderIndexPatterns("z")
37+
.MaxWriteBufferSize("1mb")
38+
.MaxOutstandingReadRequests(100)
39+
.MaxOutstandingWriteRequests( 101)
40+
.MaxReadRequestOperationCount(102)
41+
.MaxWriteRequestOperationCount(103)
42+
.MaxRetryDelay("1m")
43+
.MaxPollTimeout("2m")
44+
.MaxReadRequestSize("2mb")
45+
.MaxWriteBufferCount(104)
46+
.MaxWriteRequestSize("3mb")
47+
;
48+
49+
protected override HttpMethod HttpMethod => HttpMethod.PUT;
50+
51+
protected override CreateAutoFollowPatternRequest Initializer => new CreateAutoFollowPatternRequest("x")
52+
{
53+
RemoteCluster = "x",
54+
FollowIndexPattern = "y",
55+
LeaderIndexPatterns = new []{"z"},
56+
MaxWriteBufferSize = "1mb",
57+
MaxOutstandingReadRequests = 100,
58+
MaxOutstandingWriteRequests = 101,
59+
MaxReadRequestOperationCount = 102,
60+
MaxWriteRequestOperationCount = 103,
61+
MaxRetryDelay = "1m",
62+
MaxPollTimeout = "2m",
63+
MaxReadRequestSize = "2mb",
64+
MaxWriteBufferCount = 104,
65+
MaxWriteRequestSize = "3mb"
66+
67+
};
68+
69+
protected override bool SupportsDeserialization => false;
70+
protected override string UrlPath => $"/_ccr/auto_follow/x";
71+
72+
protected override LazyResponses ClientUsage() => Calls(
73+
(client, f) => client.CreateAutoFollowPattern("x", f),
74+
(client, f) => client.CreateAutoFollowPatternAsync("x", f),
75+
(client, r) => client.CreateAutoFollowPattern(r),
76+
(client, r) => client.CreateAutoFollowPatternAsync(r)
77+
);
78+
}
79+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Threading.Tasks;
2+
using Elastic.Xunit.XunitPlumbing;
3+
using Nest;
4+
using Tests.Framework;
5+
6+
namespace Tests.XPack.CrossClusterReplication.AutoFollow.CreateAutoFollowPattern
7+
{
8+
public class CreateAutoFollowPatternUrlTests : UrlTestsBase
9+
{
10+
[U] public override async Task Urls()
11+
{
12+
var name = "x";
13+
await UrlTester.PUT($"/_ccr/auto_follow/{name}")
14+
.Fluent(c => c.CreateAutoFollowPattern(name, d => d))
15+
.Request(c => c.CreateAutoFollowPattern(new CreateAutoFollowPatternRequest(name)))
16+
.FluentAsync(c => c.CreateAutoFollowPatternAsync(name, d => d))
17+
.RequestAsync(c => c.CreateAutoFollowPatternAsync(new CreateAutoFollowPatternRequest(name)));
18+
19+
}
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Threading.Tasks;
2+
using Elastic.Xunit.XunitPlumbing;
3+
using Nest;
4+
using Tests.Framework;
5+
6+
namespace Tests.XPack.CrossClusterReplication.AutoFollow.DeleteAutoFollowPattern
7+
{
8+
public class DeleteAutoFollowPatternUrlTests : UrlTestsBase
9+
{
10+
[U] public override async Task Urls()
11+
{
12+
var name = "x";
13+
await UrlTester.DELETE($"/_ccr/auto_follow/{name}")
14+
.Fluent(c => c.DeleteAutoFollowPattern(name, d => d))
15+
.Request(c => c.DeleteAutoFollowPattern(new DeleteAutoFollowPatternRequest(name)))
16+
.FluentAsync(c => c.DeleteAutoFollowPatternAsync(name, d => d))
17+
.RequestAsync(c => c.DeleteAutoFollowPatternAsync(new DeleteAutoFollowPatternRequest(name)));
18+
19+
}
20+
}
21+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Threading.Tasks;
2+
using Elastic.Xunit.XunitPlumbing;
3+
using Nest;
4+
using Tests.Framework;
5+
6+
namespace Tests.XPack.CrossClusterReplication.AutoFollow.GetAutoFollowPattern
7+
{
8+
public class GetAutoFollowPatternUrlTests : UrlTestsBase
9+
{
10+
[U] public override async Task Urls()
11+
{
12+
var name = "x";
13+
await UrlTester.GET($"/_ccr/auto_follow/{name}")
14+
.Fluent(c => c.GetAutoFollowPattern(d => d.Name(name)))
15+
.Request(c => c.GetAutoFollowPattern(new GetAutoFollowPatternRequest(name)))
16+
.FluentAsync(c => c.GetAutoFollowPatternAsync(d => d.Name(name)))
17+
.RequestAsync(c => c.GetAutoFollowPatternAsync(new GetAutoFollowPatternRequest(name)));
18+
19+
await UrlTester.GET($"/_ccr/auto_follow")
20+
.Fluent(c => c.GetAutoFollowPattern(d => d))
21+
.Request(c => c.GetAutoFollowPattern(new GetAutoFollowPatternRequest()))
22+
.FluentAsync(c => c.GetAutoFollowPatternAsync(d => d))
23+
.RequestAsync(c => c.GetAutoFollowPatternAsync(new GetAutoFollowPatternRequest()));
24+
25+
}
26+
}
27+
}

src/Tests/Tests/XPack/CrossClusterReplication/CrossClusterReplicationAutoFollowTests .cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
namespace Tests.XPack.CrossClusterReplication
1616
{
17+
[SkipVersion("<6.5.0", "")]
1718
public class CrossClusterReplicationAutoFollowTests : CoordinatedIntegrationTestBase<WritableCluster>
1819
{
1920
private const string CreateAutoFollowStep = nameof(CreateAutoFollowStep);

src/Tests/Tests/XPack/CrossClusterReplication/CrossClusterReplicationFollowTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
namespace Tests.XPack.CrossClusterReplication
1616
{
17+
[SkipVersion("<6.5.0", "")]
1718
public class CrossClusterReplicationFollowTests : CoordinatedIntegrationTestBase<WritableCluster>
1819
{
1920
private const string CloseIndexStep = nameof(CloseIndexStep);
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
using System;
2+
using Elasticsearch.Net;
3+
using Nest;
4+
using Tests.Core.ManagedElasticsearch.Clusters;
5+
using Tests.Framework;
6+
using Tests.Framework.Integration;
7+
8+
namespace Tests.XPack.CrossClusterReplication.Follow.CreateFollowIndex
9+
{
10+
public class CreateFollowIndexApiTests : ApiTestBase<XPackCluster, ICreateFollowIndexResponse, ICreateFollowIndexRequest, CreateFollowIndexDescriptor, CreateFollowIndexRequest>
11+
{
12+
public CreateFollowIndexApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { }
13+
14+
protected override object ExpectJson { get; } = new
15+
{
16+
leader_index = "leader",
17+
max_outstanding_read_requests = 100,
18+
max_outstanding_write_requests = 101,
19+
max_read_request_operation_count = 102,
20+
max_read_request_size = "4mb",
21+
max_retry_delay = "1m",
22+
max_write_buffer_count = 104,
23+
max_write_buffer_size = "1mb",
24+
max_write_request_operation_count = 103,
25+
max_write_request_size = "3mb",
26+
read_poll_timeout = "2m",
27+
remote_cluster = "x"
28+
};
29+
30+
protected override CreateFollowIndexDescriptor NewDescriptor() => new CreateFollowIndexDescriptor("x");
31+
32+
protected override Func<CreateFollowIndexDescriptor, ICreateFollowIndexRequest> Fluent => d => d
33+
.RemoteCluster("x")
34+
.MaxWriteBufferSize("1mb")
35+
.MaxOutstandingReadRequests(100)
36+
.MaxOutstandingWriteRequests( 101)
37+
.MaxReadRequestOperationCount(102)
38+
.MaxWriteRequestOperationCount(103)
39+
.MaxRetryDelay("1m")
40+
.MaxWriteBufferCount(104)
41+
.MaxWriteRequestSize("3mb")
42+
.MaxRequestSize("4mb")
43+
.ReadPollTimeout("2m")
44+
.LeaderIndex("leader")
45+
;
46+
47+
protected override HttpMethod HttpMethod => HttpMethod.PUT;
48+
49+
protected override CreateFollowIndexRequest Initializer => new CreateFollowIndexRequest("x")
50+
{
51+
RemoteCluster = "x",
52+
MaxWriteBufferSize = "1mb",
53+
MaxOutstandingReadRequests = 100,
54+
MaxOutstandingWriteRequests = 101,
55+
MaxReadRequestOperationCount = 102,
56+
MaxWriteRequestOperationCount = 103,
57+
MaxRetryDelay = "1m",
58+
MaxWriteBufferCount = 104,
59+
MaxWriteRequestSize = "3mb",
60+
MaxRequestSize = "4mb",
61+
ReadPollTimeout = "2m",
62+
LeaderIndex = "leader",
63+
};
64+
65+
protected override bool SupportsDeserialization => false;
66+
protected override string UrlPath => $"/x/_ccr/follow";
67+
68+
protected override LazyResponses ClientUsage() => Calls(
69+
(client, f) => client.CreateFollowIndex("x", f),
70+
(client, f) => client.CreateFollowIndexAsync("x", f),
71+
(client, r) => client.CreateFollowIndex(r),
72+
(client, r) => client.CreateFollowIndexAsync(r)
73+
);
74+
}
75+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Threading.Tasks;
2+
using Elastic.Xunit.XunitPlumbing;
3+
using Nest;
4+
using Tests.Framework;
5+
6+
namespace Tests.XPack.CrossClusterReplication.Follow.CreateFollowIndex
7+
{
8+
public class CreateFollowIndexUrlTests : UrlTestsBase
9+
{
10+
[U] public override async Task Urls()
11+
{
12+
var name = "x";
13+
await UrlTester.PUT($"/{name}/_ccr/follow")
14+
.Fluent(c => c.CreateFollowIndex(name, d => d))
15+
.Request(c => c.CreateFollowIndex(new CreateFollowIndexRequest(name)))
16+
.FluentAsync(c => c.CreateFollowIndexAsync(name, d => d))
17+
.RequestAsync(c => c.CreateFollowIndexAsync(new CreateFollowIndexRequest(name)));
18+
19+
}
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Threading.Tasks;
2+
using Elastic.Xunit.XunitPlumbing;
3+
using Nest;
4+
using Tests.Framework;
5+
6+
namespace Tests.XPack.CrossClusterReplication.Follow.FollowIndexStats
7+
{
8+
public class FollowIndexStatsUrlTests : UrlTestsBase
9+
{
10+
[U] public override async Task Urls()
11+
{
12+
var name = "x";
13+
await UrlTester.GET($"/{name}/_ccr/stats")
14+
.Fluent(c => c.FollowIndexStats(name, d => d))
15+
.Request(c => c.FollowIndexStats(new FollowIndexStatsRequest(name)))
16+
.FluentAsync(c => c.FollowIndexStatsAsync(name, d => d))
17+
.RequestAsync(c => c.FollowIndexStatsAsync(new FollowIndexStatsRequest(name)));
18+
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)