|
| 1 | +/* |
| 2 | + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one |
| 3 | + * or more contributor license agreements. Licensed under the Elastic License |
| 4 | + * 2.0 and the Server Side Public License, v 1; you may not use this file except |
| 5 | + * in compliance with, at your election, the Elastic License 2.0 or the Server |
| 6 | + * Side Public License, v 1. |
| 7 | + */ |
| 8 | +package org.elasticsearch.backwards; |
| 9 | + |
| 10 | +import org.apache.http.util.EntityUtils; |
| 11 | +import org.elasticsearch.client.Request; |
| 12 | +import org.elasticsearch.client.Response; |
| 13 | +import org.elasticsearch.test.rest.ESRestTestCase; |
| 14 | + |
| 15 | +import static org.hamcrest.Matchers.equalTo; |
| 16 | + |
| 17 | +public class HotThreadsIT extends ESRestTestCase { |
| 18 | + |
| 19 | + public void testHotThreads() throws Exception { |
| 20 | + final IndexingIT.Nodes nodes = IndexingIT.buildNodeAndVersions(client()); |
| 21 | + final Request request = new Request("GET", "/_nodes/hot_threads"); |
| 22 | + final Response response = client().performRequest(request); |
| 23 | + final String responseString = EntityUtils.toString(response.getEntity()); |
| 24 | + final String[] nodeResponses = responseString.split("::: "); |
| 25 | + int respondedNodes = 0; |
| 26 | + for (String nodeResponse : nodeResponses) { |
| 27 | + final String[] lines = nodeResponse.split("\n"); |
| 28 | + final String nodeId = lines[0].trim(); |
| 29 | + if (nodeId.isEmpty() == false) { |
| 30 | + respondedNodes++; |
| 31 | + } |
| 32 | + } |
| 33 | + assertThat(respondedNodes, equalTo(nodes.getNewNodes().size() + nodes.getBWCNodes().size())); |
| 34 | + } |
| 35 | +} |
0 commit comments