Tests: Fix upgrade tests by not running stats against arbitrary hosts
Original commit: elastic/x-pack-elasticsearch@1b858aad52
This commit is contained in:
parent
8f6874abf9
commit
2d08477093
|
@ -137,19 +137,17 @@ public class WatchBackwardsCompatibilityIT extends ESRestTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWatcherRestart() throws Exception {
|
public void testWatcherRestart() throws Exception {
|
||||||
executeAgainstRandomNode(client -> {
|
executeAgainstRandomNode(client -> assertOK(client.performRequest("POST", "/_xpack/watcher/_stop")));
|
||||||
assertOK(client.performRequest("POST", "/_xpack/watcher/_stop"));
|
executeAgainstMasterNode(client -> assertBusy(() -> {
|
||||||
assertBusy(() -> {
|
try (InputStream is = client.performRequest("GET", "_xpack/watcher/stats").getEntity().getContent()) {
|
||||||
try (InputStream is = client.performRequest("GET", "_xpack/watcher/stats").getEntity().getContent()) {
|
// TODO once the serialization fix is in here, we can check for concrete fields if the run against a 5.x or a 6.x node
|
||||||
// TODO once the serialization fix is in here, we can check for concrete fields if the run against a 5.x or a 6.x node
|
// using a checkedbiconsumer, that provides info against which node the request runs
|
||||||
// using a checkedbiconsumer, that provides info against which node the request runs
|
String responseBody = Streams.copyToString(new InputStreamReader(is, Charsets.UTF_8));
|
||||||
String responseBody = Streams.copyToString(new InputStreamReader(is, Charsets.UTF_8));
|
assertThat(responseBody, not(containsString("\"watcher_state\":\"starting\"")));
|
||||||
assertThat(responseBody, not(containsString("\"watcher_state\":\"starting\"")));
|
assertThat(responseBody, not(containsString("\"watcher_state\":\"started\"")));
|
||||||
assertThat(responseBody, not(containsString("\"watcher_state\":\"started\"")));
|
assertThat(responseBody, not(containsString("\"watcher_state\":\"stopping\"")));
|
||||||
assertThat(responseBody, not(containsString("\"watcher_state\":\"stopping\"")));
|
}
|
||||||
}
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// currently the triggered watches index is not checked by the upgrade API, resulting in an existing index
|
// currently the triggered watches index is not checked by the upgrade API, resulting in an existing index
|
||||||
// that has not configured the `index.format: 6`, resulting in watcher not starting
|
// that has not configured the `index.format: 6`, resulting in watcher not starting
|
||||||
|
@ -160,19 +158,17 @@ public class WatchBackwardsCompatibilityIT extends ESRestTestCase {
|
||||||
|
|
||||||
executeUpgradeIfNeeded();
|
executeUpgradeIfNeeded();
|
||||||
|
|
||||||
executeAgainstRandomNode(client -> {
|
executeAgainstRandomNode(client -> assertOK(client.performRequest("POST", "/_xpack/watcher/_start")));
|
||||||
assertOK(client.performRequest("POST", "/_xpack/watcher/_start"));
|
executeAgainstMasterNode(client -> assertBusy(() -> {
|
||||||
assertBusy(() -> {
|
try (InputStream is = client.performRequest("GET", "_xpack/watcher/stats").getEntity().getContent()) {
|
||||||
try (InputStream is = client.performRequest("GET", "_xpack/watcher/stats").getEntity().getContent()) {
|
// TODO once the serialization fix is in here, we can check for concrete fields if the run against a 5.x or a 6.x node
|
||||||
// TODO once the serialization fix is in here, we can check for concrete fields if the run against a 5.x or a 6.x node
|
// using a checkedbiconsumer, that provides info against which node the request runs
|
||||||
// using a checkedbiconsumer, that provides info against which node the request runs
|
String responseBody = Streams.copyToString(new InputStreamReader(is, Charsets.UTF_8));
|
||||||
String responseBody = Streams.copyToString(new InputStreamReader(is, Charsets.UTF_8));
|
assertThat(responseBody, not(containsString("\"watcher_state\":\"starting\"")));
|
||||||
assertThat(responseBody, not(containsString("\"watcher_state\":\"starting\"")));
|
assertThat(responseBody, not(containsString("\"watcher_state\":\"stopping\"")));
|
||||||
assertThat(responseBody, not(containsString("\"watcher_state\":\"stopping\"")));
|
assertThat(responseBody, not(containsString("\"watcher_state\":\"stopped\"")));
|
||||||
assertThat(responseBody, not(containsString("\"watcher_state\":\"stopped\"")));
|
}
|
||||||
}
|
}));
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWatchCrudApis() throws IOException {
|
public void testWatchCrudApis() throws IOException {
|
||||||
|
@ -232,6 +228,12 @@ public class WatchBackwardsCompatibilityIT extends ESRestTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void executeAgainstMasterNode(CheckedConsumer<RestClient, Exception> consumer) throws Exception {
|
||||||
|
try (RestClient client = buildClient(restClientSettings(), new HttpHost[]{this.nodes.getMaster().publishAddress})) {
|
||||||
|
consumer.accept(client);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void executeAgainstAllNodes(CheckedConsumer<RestClient, IOException> consumer)
|
private void executeAgainstAllNodes(CheckedConsumer<RestClient, IOException> consumer)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
HttpHost[] newHosts = nodes.getNewNodes().stream().map(Node::getPublishAddress).toArray(HttpHost[]::new);
|
HttpHost[] newHosts = nodes.getNewNodes().stream().map(Node::getPublishAddress).toArray(HttpHost[]::new);
|
||||||
|
|
Loading…
Reference in New Issue