forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transform Health API YAML test to Java REST test
This test failed occasionally due to the health node not having received the health info from all nodes yet, resulting in an "unknown" status. In a Java test, we do have the option to retry.
- Loading branch information
1 parent
e6d38bb
commit 04e3112
Showing
2 changed files
with
33 additions
and
13 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/HealthReportIT.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,33 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.http; | ||
|
||
import org.elasticsearch.client.Request; | ||
import org.elasticsearch.client.Response; | ||
import org.elasticsearch.test.XContentTestUtils; | ||
import org.elasticsearch.test.rest.ESRestTestCase; | ||
|
||
public class HealthReportIT extends ESRestTestCase { | ||
|
||
/** | ||
* This test is a Java REST test instead of a YAML one, as the health node might need some time before it has received the health info | ||
* from all the nodes. Until it has received all health info, the status will be "unknown", so we'll wait until the status turns green. | ||
*/ | ||
public void testGetHealth() throws Exception { | ||
Request request = new Request("GET", "_health_report"); | ||
Response response = client().performRequest(request); | ||
assertBusy(() -> { | ||
assertEquals(200, response.getStatusLine().getStatusCode()); | ||
var mapView = XContentTestUtils.createJsonMapView(response.getEntity().getContent()); | ||
assertEquals("green", mapView.get("status")); | ||
assertEquals("green", mapView.get("indicators.master_is_stable.status")); | ||
assertEquals("The cluster has a stable master node", mapView.get("indicators.master_is_stable.symptom")); | ||
}); | ||
} | ||
} |
13 changes: 0 additions & 13 deletions
13
rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/health/10_basic.yml
This file was deleted.
Oops, something went wrong.