Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix org.opensearch.rest.action.admin.cluster.RestNodesStatsActionTests.testIndexMetricsRequestWithoutIndicesMetric is flaky #13658

Merged
merged 5 commits into from
May 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,12 @@ public void testUnrecognizedIndexMetricDidYouMean() {
);
}

public void testIndexMetricsRequestWithoutIndicesMetric() throws IOException {
public void testIndexMetricsRequestWithoutIndicesAndCachesMetrics() throws IOException {
final HashMap<String, String> params = new HashMap<>();
final Set<String> metrics = new HashSet<>(RestNodesStatsAction.METRICS.keySet());
metrics.remove("indices");
// caches stats is handled separately
metrics.remove("caches");
reta marked this conversation as resolved.
Show resolved Hide resolved
params.put("metric", randomSubsetOf(1, metrics).get(0));
final String indexMetric = randomSubsetOf(1, RestNodesStatsAction.FLAGS.keySet()).get(0);
params.put("index_metric", indexMetric);
Expand All @@ -150,6 +152,19 @@ public void testIndexMetricsRequestWithoutIndicesMetric() throws IOException {
);
}

public void testCacheStatsRequestWithInvalidCacheType() throws IOException {
final HashMap<String, String> params = new HashMap<>();
params.put("metric", "caches");
final String cacheType = randomAlphaOfLength(64);
params.put("index_metric", cacheType);
final RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withPath("/_nodes/stats").withParams(params).build();
final IllegalArgumentException e = expectThrows(
IllegalArgumentException.class,
() -> action.prepareRequest(request, mock(NodeClient.class))
);
assertThat(e, hasToString(containsString("request [/_nodes/stats] contains unrecognized cache type: [" + cacheType + "]")));
}

public void testIndexMetricsRequestOnAllRequest() throws IOException {
final HashMap<String, String> params = new HashMap<>();
params.put("metric", "_all");
Expand Down
Loading