-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cluster stats rolling version upgrade IT.
Signed-off-by: Swetha Guptha <[email protected]>
- Loading branch information
Swetha Guptha
committed
Oct 22, 2024
1 parent
c5621f1
commit 302e7ec
Showing
2 changed files
with
67 additions
and
102 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/ClusterStatsIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.upgrades; | ||
|
||
import org.opensearch.Version; | ||
import org.opensearch.client.Request; | ||
import org.opensearch.client.Response; | ||
|
||
import java.io.IOException; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class ClusterStatsIT extends AbstractRollingTestCase { | ||
|
||
private final List<String> nodeStatsMetrics = List.of("os", "process", "jvm", "fs", "plugins", "ingest", "network_types", "discovery_types", "packaging_types"); | ||
|
||
private final List<String> indicesStatsMetrics = List.of("shards", "docs", "store", "fielddata", "query_cache", "completion", "segments", "analysis", "mappings"); | ||
|
||
public void testClusterStats() throws IOException { | ||
Response response = client().performRequest(new Request("GET", "/_cluster/stats")); | ||
validateClusterStatsWithFilterResponse(response, nodeStatsMetrics, indicesStatsMetrics); | ||
if (AbstractRollingTestCase.UPGRADE_FROM_VERSION.onOrAfter(Version.V_3_0_0) || ( | ||
CLUSTER_TYPE == ClusterType.UPGRADED && Version.CURRENT.onOrAfter(Version.V_3_0_0))) { | ||
response = client().performRequest(new Request("GET", "/_cluster/stats/os/nodes/_all")); | ||
validateClusterStatsWithFilterResponse(response, List.of("os"), Collections.emptyList()); | ||
response = client().performRequest(new Request("GET", "/_cluster/stats/indices/mappings/nodes/_all")); | ||
validateClusterStatsWithFilterResponse(response, Collections.emptyList(), List.of("mappings")); | ||
response = client().performRequest(new Request("GET", "/_cluster/stats/os,indices/mappings/nodes/_all")); | ||
validateClusterStatsWithFilterResponse(response, List.of("os"), List.of("mappings")); | ||
} | ||
} | ||
|
||
private void validateClusterStatsWithFilterResponse(Response response, List<String> requestedNodesStatsMetrics, List<String> requestedIndicesStatsMetrics) throws IOException { | ||
assertEquals(200, response.getStatusLine().getStatusCode()); | ||
Map<String, Object> entity = entityAsMap(response); | ||
if (requestedNodesStatsMetrics != null && !requestedNodesStatsMetrics.isEmpty()) { | ||
assertTrue(entity.containsKey("nodes")); | ||
Map<?, ?> nodesStats = (Map<?, ?>) entity.get("nodes"); | ||
for (String metric : nodeStatsMetrics) { | ||
if (requestedNodesStatsMetrics.contains(metric)) { | ||
assertTrue(nodesStats.containsKey(metric)); | ||
} else { | ||
assertFalse(nodesStats.containsKey(metric)); | ||
} | ||
} | ||
} | ||
|
||
if (requestedIndicesStatsMetrics != null && !requestedIndicesStatsMetrics.isEmpty()) { | ||
assertTrue(entity.containsKey("indices")); | ||
Map<?, ?> indicesStats = (Map<?, ?>) entity.get("indices"); | ||
for (String metric : indicesStatsMetrics) { | ||
if (requestedIndicesStatsMetrics.contains(metric)) { | ||
assertTrue(indicesStats.containsKey(metric)); | ||
} else { | ||
assertFalse(indicesStats.containsKey(metric)); | ||
} | ||
} | ||
} | ||
} | ||
} |
102 changes: 0 additions & 102 deletions
102
server/src/test/java/org/opensearch/action/admin/cluster/stats/ClusterStatsRequestTests.java
This file was deleted.
Oops, something went wrong.