|
| 1 | +using System; |
| 2 | +using System.Linq; |
| 3 | +using Elasticsearch.Net; |
| 4 | +using FluentAssertions; |
| 5 | +using Nest; |
| 6 | +using Tests.Framework; |
| 7 | +using Tests.Framework.Integration; |
| 8 | +using Tests.Framework.ManagedElasticsearch.Clusters; |
| 9 | + |
| 10 | +namespace Tests.Indices.Monitoring.IndicesStats |
| 11 | +{ |
| 12 | + public class IndicesStatsWithShardsInformationApiTests : ApiIntegrationTestBase<WritableCluster, IIndicesStatsResponse, |
| 13 | + IIndicesStatsRequest, IndicesStatsDescriptor, IndicesStatsRequest> |
| 14 | + { |
| 15 | + public IndicesStatsWithShardsInformationApiTests(WritableCluster cluster, EndpointUsage usage) : base(cluster, usage) |
| 16 | + { |
| 17 | + } |
| 18 | + |
| 19 | + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) |
| 20 | + { |
| 21 | + var createShardedIndex = this.Client.CreateIndex(RandomString(), c => c |
| 22 | + .Settings(settings => settings |
| 23 | + .NumberOfShards(3) |
| 24 | + ) |
| 25 | + ); |
| 26 | + createShardedIndex.ShouldBeValid(); |
| 27 | + } |
| 28 | + |
| 29 | + protected override LazyResponses ClientUsage() => Calls( |
| 30 | + fluent: (client, f) => client.IndicesStats(Infer.AllIndices, f), |
| 31 | + fluentAsync: (client, f) => client.IndicesStatsAsync(Infer.AllIndices, f), |
| 32 | + request: (client, r) => client.IndicesStats(r), |
| 33 | + requestAsync: (client, r) => client.IndicesStatsAsync(r) |
| 34 | + ); |
| 35 | + |
| 36 | + protected override bool ExpectIsValid => true; |
| 37 | + protected override int ExpectStatusCode => 200; |
| 38 | + protected override HttpMethod HttpMethod => HttpMethod.GET; |
| 39 | + protected override string UrlPath => "/_stats?level=shards"; |
| 40 | + |
| 41 | + protected override Func<IndicesStatsDescriptor, IIndicesStatsRequest> Fluent => d => d.Level(Level.Shards); |
| 42 | + |
| 43 | + protected override IndicesStatsRequest Initializer => new IndicesStatsRequest(Infer.AllIndices) |
| 44 | + { |
| 45 | + Level = Level.Shards |
| 46 | + }; |
| 47 | + |
| 48 | + protected override void ExpectResponse(IIndicesStatsResponse response) |
| 49 | + { |
| 50 | + var firstIndex = response.Indices.First().Value; |
| 51 | + firstIndex.Shards.Should().NotBeNull(); |
| 52 | + |
| 53 | + var firstShard = firstIndex.Shards.Values.First(); |
| 54 | + firstShard.Length.Should().Be(1); |
| 55 | + |
| 56 | + var first = firstShard.First(); |
| 57 | + first.Routing.Should().NotBeNull(); |
| 58 | + first.Commit.Should().NotBeNull(); |
| 59 | + first.Path.Should().NotBeNull(); |
| 60 | + first.Store.Should().NotBeNull(); |
| 61 | + } |
| 62 | + } |
| 63 | +} |
0 commit comments