Skip to content
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 @@ -28,6 +28,7 @@
import static org.elasticsearch.rest.action.search.RestSearchAction.TOTAL_HITS_AS_INT_PARAM;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;

public class ESCCRRestTestCase extends ESRestTestCase {
Expand Down Expand Up @@ -139,8 +140,9 @@ protected static void verifyCcrMonitoring(final String expectedLeaderIndex, fina
throw new AssertionError("error while searching", e);
}

int numberOfOperationsReceived = 0;
int numberOfOperationsIndexed = 0;
int followerMaxSeqNo = 0;
int followerMappingVersion = 0;
int followerSettingsVersion = 0;

List<?> hits = (List<?>) XContentMapValues.extractValue("hits.hits", response);
assertThat(hits.size(), greaterThanOrEqualTo(1));
Expand All @@ -153,16 +155,20 @@ protected static void verifyCcrMonitoring(final String expectedLeaderIndex, fina
final String followerIndex = (String) XContentMapValues.extractValue("_source.ccr_stats.follower_index", hit);
assertThat(followerIndex, equalTo(expectedFollowerIndex));

int foundNumberOfOperationsReceived =
(int) XContentMapValues.extractValue("_source.ccr_stats.operations_read", hit);
numberOfOperationsReceived = Math.max(numberOfOperationsReceived, foundNumberOfOperationsReceived);
int foundNumberOfOperationsIndexed =
(int) XContentMapValues.extractValue("_source.ccr_stats.operations_written", hit);
numberOfOperationsIndexed = Math.max(numberOfOperationsIndexed, foundNumberOfOperationsIndexed);
int foundFollowerMaxSeqNo =
(int) XContentMapValues.extractValue("_source.ccr_stats.follower_max_seq_no", hit);
followerMaxSeqNo = Math.max(followerMaxSeqNo, foundFollowerMaxSeqNo);
int foundFollowerMappingVersion =
(int) XContentMapValues.extractValue("_source.ccr_stats.follower_mapping_version", hit);
followerMappingVersion = Math.max(followerMappingVersion, foundFollowerMappingVersion);
int foundFollowerSettingsVersion =
(int) XContentMapValues.extractValue("_source.ccr_stats.follower_settings_version", hit);
followerSettingsVersion = Math.max(followerSettingsVersion, foundFollowerSettingsVersion);
}

assertThat(numberOfOperationsReceived, greaterThanOrEqualTo(1));
assertThat(numberOfOperationsIndexed, greaterThanOrEqualTo(1));
assertThat(followerMaxSeqNo, greaterThan(0));
assertThat(followerMappingVersion, greaterThan(0));
assertThat(followerSettingsVersion, greaterThan(0));
}

protected static void verifyAutoFollowMonitoring() throws IOException {
Expand Down