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

[Backport to 2.x] [Segment Replication] Unmute testIndexingWithSegRep rolling upgrade test #9278

Merged
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 @@ -110,14 +110,25 @@ private void waitForSearchableDocs(String index, int shardCount, int replicaCoun
Request segrepStatsRequest = new Request("GET", "/_cat/segments/" + index + "?s=shard,segment,primaryOrReplica");
segrepStatsRequest.addParameter("h", "index,shard,primaryOrReplica,segment,docs.count");
Response segrepStatsResponse = client().performRequest(segrepStatsRequest);
logger.info("--> _cat/segments response\n {}", EntityUtils.toString(client().performRequest(segrepStatsRequest).getEntity()));
List<String> responseList = Streams.readAllLines(segrepStatsResponse.getEntity().getContent());
for (int segmentsIndex=0; segmentsIndex < responseList.size();) {
String[] primaryRow = responseList.get(segmentsIndex++).split(" +");
logger.info("--> _cat/segments response\n {}", responseList.toString().replace(',', '\n'));
// Filter response for rows with zero doc count
List<String> filteredList = new ArrayList<>();
for(String row: responseList) {
String count = row.split(" +")[4];
if (count.equals("0") == false) {
filteredList.add(row);
}
}
// Ensure there is result for replica copies before processing the result. This results in retry when there
// are not enough number of rows vs failing with IndexOutOfBoundsException
assertEquals(0, filteredList.size() % (replicaCount + 1));
for (int segmentsIndex=0; segmentsIndex < filteredList.size();) {
String[] primaryRow = filteredList.get(segmentsIndex++).split(" +");
String shardId = primaryRow[0] + primaryRow[1];
assertTrue(primaryRow[2].equals("p"));
for(int replicaIndex = 1; replicaIndex <= replicaCount; replicaIndex++) {
String[] replicaRow = responseList.get(segmentsIndex).split(" +");
String[] replicaRow = filteredList.get(segmentsIndex).split(" +");
String replicaShardId = replicaRow[0] + replicaRow[1];
// When segment has 0 doc count, not all replica copies posses that segment. Skip to next segment
if (replicaRow[2].equals("p")) {
Expand Down Expand Up @@ -161,7 +172,7 @@ private void verifySegmentStats(String indexName) throws Exception {
}, 1, TimeUnit.MINUTES);
}

public void testIndexing() throws IOException, ParseException {
public void testIndexing() throws Exception {
switch (CLUSTER_TYPE) {
case OLD:
break;
Expand Down Expand Up @@ -403,12 +414,14 @@ private void bulk(String index, String valueSuffix, int count) throws IOExceptio
client().performRequest(bulk);
}

private void assertCount(String index, int count) throws IOException {
Request searchTestIndexRequest = new Request("POST", "/" + index + "/_search");
searchTestIndexRequest.addParameter(TOTAL_HITS_AS_INT_PARAM, "true");
searchTestIndexRequest.addParameter("filter_path", "hits.total");
Response searchTestIndexResponse = client().performRequest(searchTestIndexRequest);
assertEquals("{\"hits\":{\"total\":" + count + "}}",
private void assertCount(String index, int count) throws Exception {
assertBusy(() -> {
Request searchTestIndexRequest = new Request("POST", "/" + index + "/_search");
searchTestIndexRequest.addParameter(TOTAL_HITS_AS_INT_PARAM, "true");
searchTestIndexRequest.addParameter("filter_path", "hits.total");
Response searchTestIndexResponse = client().performRequest(searchTestIndexRequest);
assertEquals("{\"hits\":{\"total\":" + count + "}}",
EntityUtils.toString(searchTestIndexResponse.getEntity(), StandardCharsets.UTF_8));
}, 30, TimeUnit.SECONDS);
}
}