From e481bbd8b6e7982f6d2499c2f854513ae55c551f Mon Sep 17 00:00:00 2001 From: Yury Fridlyand Date: Thu, 9 Jun 2022 11:32:34 -0700 Subject: [PATCH] Remove validation for indices segments stats. `OpenSearch` 2.0 uses newer version of `Lucene` (9.0) which doesn't provide segments stats info. Ref: https://github.com/opensearch-project/OpenSearch/pull/2029 https://github.com/opensearch-project/OpenSearch/pull/1109 See also history for `server/src/main/java/org/opensearch/index/engine/SegmentsStats.java` in `OpenSearch` repo. Signed-off-by: Yury Fridlyand --- .../CommonOptions/Stats/SegmentsStats.cs | 4 ++++ .../Cluster/ClusterStats/ClusterStatsApiTests.cs | 14 ++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/OpenSearch.Client/CommonOptions/Stats/SegmentsStats.cs b/src/OpenSearch.Client/CommonOptions/Stats/SegmentsStats.cs index a3cf237aa7..6ff6ccc3e5 100644 --- a/src/OpenSearch.Client/CommonOptions/Stats/SegmentsStats.cs +++ b/src/OpenSearch.Client/CommonOptions/Stats/SegmentsStats.cs @@ -30,6 +30,10 @@ namespace OpenSearch.Client { + /// + /// OpenSearch 2.0 has Lucene upgraded up to version 9.0 which doesn't provide memory info for segments. + /// All fields except `count` might be zeroed. + /// [DataContract] public class SegmentsStats { diff --git a/tests/Tests/Cluster/ClusterStats/ClusterStatsApiTests.cs b/tests/Tests/Cluster/ClusterStats/ClusterStatsApiTests.cs index 1bf6d56c03..5ba842eba6 100644 --- a/tests/Tests/Cluster/ClusterStats/ClusterStatsApiTests.cs +++ b/tests/Tests/Cluster/ClusterStats/ClusterStatsApiTests.cs @@ -132,12 +132,14 @@ protected void Assert(ClusterIndicesStats indices) indices.Segments.Should().NotBeNull(); indices.Segments.Count.Should().BeGreaterThan(0); - - indices.Segments.DocValuesMemoryInBytes.Should().BeGreaterThan(0); - indices.Segments.MemoryInBytes.Should().BeGreaterThan(0); - indices.Segments.NormsMemoryInBytes.Should().BeGreaterThan(0); - indices.Segments.StoredFieldsMemoryInBytes.Should().BeGreaterThan(0); - indices.Segments.TermsMemoryInBytes.Should().BeGreaterThan(0); + if (Cluster.ClusterConfiguration.Version < "2.0.0") + { + indices.Segments.DocValuesMemoryInBytes.Should().BeGreaterThan(0); + indices.Segments.MemoryInBytes.Should().BeGreaterThan(0); + indices.Segments.NormsMemoryInBytes.Should().BeGreaterThan(0); + indices.Segments.StoredFieldsMemoryInBytes.Should().BeGreaterThan(0); + indices.Segments.TermsMemoryInBytes.Should().BeGreaterThan(0); + } indices.Shards.Should().NotBeNull(); indices.Shards.Primaries.Should().BeGreaterThan(0);