Address some CCR REST test case flakiness (#38975)
The CCR REST tests that rely on these assertions are flaky. They are flaky since the introduction of recovery from the remote. The underlying problem is this: these tests are making assertions about the number of operations read by the shard following task. However, with recovery from remote, we no longer have guarantees that the assumptions these tests were relying on hold. Namely, these tests were assuming that the only way that a document could land in the follower index is via the shard following task. With recovery from remote, there is another way, which is via the files that are copied over during the recovery phase. Most of the time this will not be a problem because with the small number of documents that we are indexing in these tests, it is usally not the case that a flush would occur and so there would not be any documents in the files copied over. However, a flush can occur any time at which point all of the indexed documents could end up in a safe commit and copied over during recovery from remote. This commit modifies these assertions to ones that are not prone to this issue, yet still validate the health of the follower shard.
This commit is contained in:
parent
dc0e657091
commit
58551198d5
|
@ -28,6 +28,7 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
|||
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 {
|
||||
|
@ -139,8 +140,9 @@ public class ESCCRRestTestCase extends ESRestTestCase {
|
|||
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));
|
||||
|
@ -153,16 +155,20 @@ public class ESCCRRestTestCase extends ESRestTestCase {
|
|||
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 {
|
||||
|
|
Loading…
Reference in New Issue