Skip to content

Commit 678ee78

Browse files
authored
Move intrusive xpack tests to own cluster (#4446)
* Moves tests further into their own clusters Enrich is now a CoordinatedUsageTest Slm is in its own cluster Security is in its own cluster to not have role/users API potentially cluttering the rest of the tests * GetRepository does not need to be an integration test as RepositoryCrud covers this already * Move watcher tests to own cluster * fix failing unit test after moving enrich stats api over to unit test only * update docs
1 parent 458f37a commit 678ee78

File tree

33 files changed

+342
-245
lines changed

33 files changed

+342
-245
lines changed

build/scripts/scripts.fsproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<PackageReference Include="FSharp.Core" Version="4.7.0" />
3939

4040
<PackageReference Include="Bullseye" Version="3.1.0" />
41-
<PackageReference Include="Elastic.Managed" Version="0.1.0-ci20191209T135928" />
41+
<PackageReference Include="Elastic.Managed" Version="0.1.0-ci20200224T155731" />
4242

4343
<PackageReference Include="Fake.Core.Environment" Version="5.15.0" />
4444
<PackageReference Include="Fake.Core.SemVer" Version="5.15.0" />

docs/aggregations/bucket/geo-hash-grid/geo-hash-grid-aggregation-usage.asciidoc

+60
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,63 @@ var myGeoHashGrid = response.Aggregations.GeoHash("my_geohash_grid");
6565
myGeoHashGrid.Should().NotBeNull();
6666
----
6767

68+
==== Fluent DSL example
69+
70+
[source,csharp]
71+
----
72+
a => a
73+
.GeoHash("my_geohash_grid", g => g
74+
.Field(p => p.LocationPoint)
75+
.Bounds(b => b
76+
.TopLeft(90,-180)
77+
.BottomRight(-90, 180)
78+
)
79+
)
80+
----
81+
82+
==== Object Initializer syntax example
83+
84+
[source,csharp]
85+
----
86+
new GeoHashGridAggregation("my_geohash_grid")
87+
{
88+
Field = Field<Project>(p => p.LocationPoint),
89+
Bounds = new BoundingBox
90+
{
91+
TopLeft = new GeoLocation(90, -180),
92+
BottomRight = new GeoLocation(-90, 180)
93+
}
94+
}
95+
----
96+
97+
[source,javascript]
98+
.Example json output
99+
----
100+
{
101+
"my_geohash_grid": {
102+
"geohash_grid": {
103+
"field": "locationPoint",
104+
"bounds": {
105+
"top_left": {
106+
"lat": 90.0,
107+
"lon": -180.0
108+
},
109+
"bottom_right": {
110+
"lat": -90.0,
111+
"lon": 180.0
112+
}
113+
}
114+
}
115+
}
116+
}
117+
----
118+
119+
==== Handling Responses
120+
121+
[source,csharp]
122+
----
123+
response.ShouldBeValid();
124+
var myGeoHashGrid = response.Aggregations.GeoHash("my_geohash_grid");
125+
myGeoHashGrid.Should().NotBeNull();
126+
----
127+

docs/query-dsl/specialized/rank-feature/rank-feature-query-usage.asciidoc

+37-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ q
4444
new RankFeatureQuery()
4545
{
4646
Name = "named_query",
47-
Boost = 1.1,
47+
Boost = 1.1,
4848
Field = Infer.Field<Project>(f => f.Rank),
4949
Function = new RankFeatureSaturationFunction()
5050
}
@@ -63,3 +63,39 @@ new RankFeatureQuery()
6363
}
6464
----
6565

66+
==== Fluent DSL example
67+
68+
[source,csharp]
69+
----
70+
q
71+
.RankFeature(rf => rf
72+
.Name("named_query")
73+
.Boost(1.1)
74+
.Field(f => f.Rank)
75+
)
76+
----
77+
78+
==== Object Initializer syntax example
79+
80+
[source,csharp]
81+
----
82+
new RankFeatureQuery
83+
{
84+
Name = "named_query",
85+
Boost = 1.1,
86+
Field = Infer.Field<Project>(f => f.Rank),
87+
}
88+
----
89+
90+
[source,javascript]
91+
.Example json output
92+
----
93+
{
94+
"rank_feature": {
95+
"_name": "named_query",
96+
"boost": 1.1,
97+
"field": "rank"
98+
}
99+
}
100+
----
101+

tests/Tests.Configuration/Tests.Configuration.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
<TargetFramework>netstandard2.0</TargetFramework>
44
</PropertyGroup>
55
<ItemGroup>
6-
<PackageReference Include="Elastic.Managed" Version="0.1.0-ci20191209T135928" />
6+
<PackageReference Include="Elastic.Managed" Version="0.1.0-ci20200224T155731" />
77
</ItemGroup>
88
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using Elasticsearch.Net;
2+
using Nest;
3+
4+
namespace Tests.Core.Extensions
5+
{
6+
public static class ClientExtensions
7+
{
8+
public static ClusterHealthResponse WaitForSecurityIndices(this IElasticClient client) =>
9+
client.Cluster.Health(new ClusterHealthRequest(".security-*") { WaitForStatus = WaitForStatus.Green });
10+
}
11+
}

tests/Tests.Core/ManagedElasticsearch/Clusters/XPackCluster.cs

-2
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,8 @@ protected virtual ConnectionSettings ConnectionSettings(ConnectionSettings s) =>
5050
protected sealed override void SeedCluster()
5151
{
5252
Client.Cluster.Health(new ClusterHealthRequest { WaitForStatus = WaitForStatus.Green });
53-
Client.Cluster.Health(new ClusterHealthRequest(".security-7") { WaitForStatus = WaitForStatus.Green });
5453
SeedNode();
5554
Client.Cluster.Health(new ClusterHealthRequest { WaitForStatus = WaitForStatus.Green });
56-
Client.Cluster.Health(new ClusterHealthRequest(".security-7") { WaitForStatus = WaitForStatus.Green });
5755
}
5856

5957
protected virtual void SeedNode() => new DefaultSeeder(Client).SeedNode();

tests/Tests.Core/Tests.Core.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<PackageReference Include="xunit" Version="2.3.1" />
1919
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.1" />
2020
<PackageReference Include="coverlet.collector" Version="1.1.0" />
21-
<PackageReference Include="Elastic.Xunit" Version="0.1.0-ci20191209T135928" />
21+
<PackageReference Include="Elastic.Xunit" Version="0.1.0-ci20200224T155731" />
2222
<PackageReference Include="FluentAssertions" Version="5.7.0" />
2323

2424
<PackageReference Include="DiffPlex" Version="1.4.1" />

tests/Tests.Domain/Tests.Domain.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</ItemGroup>
1212
<ItemGroup>
1313
<PackageReference Include="Bogus" Version="22.1.2" />
14-
<PackageReference Include="Elastic.Managed" Version="0.1.0-ci20191209T135928" />
14+
<PackageReference Include="Elastic.Managed" Version="0.1.0-ci20200224T155731" />
1515
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
1616
<ProjectReference Include="$(SolutionRoot)\tests\Tests.Configuration\Tests.Configuration.csproj" />
1717
</ItemGroup>

tests/Tests/Modules/SnapshotAndRestore/Repositories/CleanupRepository/CleanupRepositoryApiTests.cs

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
namespace Tests.Modules.SnapshotAndRestore.Repositories.CleanupRepository
99
{
10-
// TODO NOT an integration tests, move SnapshotCrud tests over to a coordinatedtestbase so we can inject this in the request pipeline in order
11-
// todo meaningful assertions
1210
public class CleanupRepositoryApiTests
1311
: ApiTestBase<ReadOnlyCluster, CleanupRepositoryResponse, ICleanupRepositoryRequest, CleanupRepositoryDescriptor, CleanupRepositoryRequest>
1412
{

tests/Tests/Modules/SnapshotAndRestore/Repositories/GetRepository/GetRepositoryApiTests.cs

+1-52
Original file line numberDiff line numberDiff line change
@@ -10,51 +10,14 @@
1010
namespace Tests.Modules.SnapshotAndRestore.Repositories.GetRepository
1111
{
1212
public class GetRepositoryApiTests
13-
: ApiIntegrationTestBase<WritableCluster, GetRepositoryResponse, IGetRepositoryRequest, GetRepositoryDescriptor, GetRepositoryRequest>
13+
: ApiTestBase<WritableCluster, GetRepositoryResponse, IGetRepositoryRequest, GetRepositoryDescriptor, GetRepositoryRequest>
1414
{
15-
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values)
16-
{
17-
foreach (var callUniqueValue in values)
18-
{
19-
var createRepositoryResponse = client.Snapshot.CreateRepository(callUniqueValue.Value, d => d
20-
.SourceOnly(so => so
21-
.FileSystem(fs => fs
22-
.Settings("some/location", s => s
23-
.Compress()
24-
.ConcurrentStreams(5)
25-
.ChunkSize("64mb")
26-
.RestoreBytesPerSecondMaximum("100mb")
27-
.SnapshotBytesPerSecondMaximum("200mb")
28-
)
29-
)
30-
)
31-
);
32-
33-
if (!createRepositoryResponse.IsValid)
34-
throw new Exception($"Error in integration setup: {createRepositoryResponse.DebugInformation}");
35-
}
36-
}
37-
38-
protected override void IntegrationTeardown(IElasticClient client, CallUniqueValues values)
39-
{
40-
foreach (var callUniqueValue in values)
41-
{
42-
var deleteRepositoryResponse = client.Snapshot.DeleteRepository(callUniqueValue.Value);
43-
44-
if (!deleteRepositoryResponse.IsValid)
45-
throw new Exception($"Error in integration teardown: {deleteRepositoryResponse.DebugInformation}");
46-
}
47-
}
48-
4915
public GetRepositoryApiTests(WritableCluster cluster, EndpointUsage usage) : base(cluster, usage) { }
5016

5117
protected override Func<GetRepositoryDescriptor, IGetRepositoryRequest> Fluent => d => d.RepositoryName(CallIsolatedValue);
5218

5319
protected override HttpMethod HttpMethod => HttpMethod.GET;
5420

55-
protected override bool ExpectIsValid => true;
56-
57-
protected override int ExpectStatusCode => 200;
5821
protected override GetRepositoryRequest Initializer => new GetRepositoryRequest(CallIsolatedValue);
5922

6023
protected override bool SupportsDeserialization => false;
@@ -67,19 +30,5 @@ protected override LazyResponses ClientUsage() => Calls(
6730
(client, r) => client.Snapshot.GetRepositoryAsync(r)
6831
);
6932

70-
protected override void ExpectResponse(GetRepositoryResponse response)
71-
{
72-
response.ShouldBeValid();
73-
74-
response.Repositories.Should().ContainKey(CallIsolatedValue);
75-
76-
var repository = response.Repositories[CallIsolatedValue];
77-
repository.Type.Should().Be("source");
78-
79-
var sourceOnlyRespository = repository as ISourceOnlyRepository;
80-
sourceOnlyRespository.Should().NotBeNull();
81-
sourceOnlyRespository.DelegateType.Should().Be("fs");
82-
sourceOnlyRespository.DelegateSettings.Should().BeAssignableTo<IFileSystemRepositorySettings>();
83-
}
8433
}
8534
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
using System;
2-
using Elastic.Xunit.XunitPlumbing;
1+
using Elastic.Xunit.XunitPlumbing;
32
using Elasticsearch.Net;
4-
using FluentAssertions;
53
using Nest;
6-
using Tests.Core.ManagedElasticsearch.Clusters;
7-
using Tests.Core.Xunit;
8-
using Tests.Domain;
94
using Tests.Framework.EndpointTests;
105
using Tests.Framework.EndpointTests.TestState;
116
using static Elasticsearch.Net.HttpMethod;
@@ -14,46 +9,20 @@ namespace Tests.XPack.Enrich.DeletePolicy
149
{
1510
[SkipVersion("<7.5.0", "Introduced in 7.5.0")]
1611
public class DeletePolicyApiTests
17-
: ApiIntegrationTestBase<XPackCluster, DeleteEnrichPolicyResponse, IDeleteEnrichPolicyRequest, DeleteEnrichPolicyDescriptor, DeleteEnrichPolicyRequest>
12+
: ApiTestBase<EnrichCluster, DeleteEnrichPolicyResponse, IDeleteEnrichPolicyRequest, DeleteEnrichPolicyDescriptor, DeleteEnrichPolicyRequest>
1813
{
19-
public DeletePolicyApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { }
14+
public DeletePolicyApiTests(EnrichCluster cluster, EndpointUsage usage) : base(cluster, usage) { }
2015

21-
protected override bool ExpectIsValid => true;
22-
protected override int ExpectStatusCode => 200;
2316
protected override HttpMethod HttpMethod => DELETE;
24-
25-
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values)
26-
{
27-
foreach (var callUniqueValue in values)
28-
{
29-
var putPolicyResponse = client.Enrich.PutPolicy<Project>(callUniqueValue.Value, p => p
30-
.Match(m => m
31-
.Indices(typeof(Project))
32-
.MatchField(f => f.Name)
33-
.EnrichFields(f => f
34-
.Field(ff => ff.Description)
35-
.Field(ff => ff.Tags)
36-
)
37-
)
38-
);
39-
40-
if (!putPolicyResponse.IsValid)
41-
throw new Exception($"Failure setting up integration test: {putPolicyResponse.DebugInformation}");
42-
}
43-
}
17+
protected override string UrlPath => $"/_enrich/policy/{CallIsolatedValue}";
4418

4519
protected override DeleteEnrichPolicyRequest Initializer => new DeleteEnrichPolicyRequest(CallIsolatedValue);
4620

47-
protected override string UrlPath => $"/_enrich/policy/{CallIsolatedValue}";
48-
4921
protected override LazyResponses ClientUsage() => Calls(
5022
(client, f) => client.Enrich.DeletePolicy(CallIsolatedValue, f),
5123
(client, f) => client.Enrich.DeletePolicyAsync(CallIsolatedValue, f),
5224
(client, r) => client.Enrich.DeletePolicy(r),
5325
(client, r) => client.Enrich.DeletePolicyAsync(r)
5426
);
55-
56-
protected override void ExpectResponse(DeleteEnrichPolicyResponse response) =>
57-
response.Acknowledged.Should().BeTrue();
5827
}
5928
}

0 commit comments

Comments
 (0)