Randomly run CCR tests with _source disabled (#49922)
Makes sure that CCR also properly works with _source disabled. Changes one exception in LuceneChangesSnapshot as the case of missing _recovery_source because of a missing lease was not properly properly bubbled up to CCR (testIndexFallBehind was failing).
This commit is contained in:
parent
f768f8ddab
commit
01d36afa4b
|
@ -256,7 +256,7 @@ final class LuceneChangesSnapshot implements Translog.Snapshot {
|
|||
// TODO: Callers should ask for the range that source should be retained. Thus we should always
|
||||
// check for the existence source once we make peer-recovery to send ops after the local checkpoint.
|
||||
if (requiredFullRange) {
|
||||
throw new IllegalStateException("source not found for seqno=" + seqNo +
|
||||
throw new MissingHistoryOperationsException("source not found for seqno=" + seqNo +
|
||||
" from_seqno=" + fromSeqNo + " to_seqno=" + toSeqNo);
|
||||
} else {
|
||||
skippedOperations++;
|
||||
|
|
|
@ -415,6 +415,14 @@ public abstract class CcrIntegTestCase extends ESTestCase {
|
|||
}, 30, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void setupSourceEnabledOrDisabled() {
|
||||
sourceEnabled = randomBoolean();
|
||||
}
|
||||
|
||||
protected boolean sourceEnabled;
|
||||
|
||||
protected String getIndexSettings(final int numberOfShards, final int numberOfReplicas,
|
||||
final Map<String, String> additionalIndexSettings) throws IOException {
|
||||
final String settings;
|
||||
|
@ -445,6 +453,11 @@ public abstract class CcrIntegTestCase extends ESTestCase {
|
|||
builder.endObject();
|
||||
}
|
||||
builder.endObject();
|
||||
if (sourceEnabled == false) {
|
||||
builder.startObject("_source");
|
||||
builder.field("enabled", false);
|
||||
builder.endObject();
|
||||
}
|
||||
}
|
||||
builder.endObject();
|
||||
}
|
||||
|
|
|
@ -447,8 +447,10 @@ public class CcrRepositoryIT extends CcrIntegTestCase {
|
|||
private void assertExpectedDocument(String followerIndex, final int value) {
|
||||
final GetResponse getResponse = followerClient().prepareGet(followerIndex, "doc", Integer.toString(value)).get();
|
||||
assertTrue("Doc with id [" + value + "] is missing", getResponse.isExists());
|
||||
assertTrue((getResponse.getSource().containsKey("f")));
|
||||
assertThat(getResponse.getSource().get("f"), equalTo(value));
|
||||
if (sourceEnabled) {
|
||||
assertTrue((getResponse.getSource().containsKey("f")));
|
||||
assertThat(getResponse.getSource().get("f"), equalTo(value));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1075,8 +1075,10 @@ public class CcrRetentionLeaseIT extends CcrIntegTestCase {
|
|||
private void assertExpectedDocument(final String followerIndex, final int value) {
|
||||
final GetResponse getResponse = followerClient().prepareGet(followerIndex, "doc", Integer.toString(value)).get();
|
||||
assertTrue("doc with id [" + value + "] is missing", getResponse.isExists());
|
||||
assertTrue((getResponse.getSource().containsKey("f")));
|
||||
assertThat(getResponse.getSource().get("f"), equalTo(value));
|
||||
if (sourceEnabled) {
|
||||
assertTrue((getResponse.getSource().containsKey("f")));
|
||||
assertThat(getResponse.getSource().get("f"), equalTo(value));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1523,8 +1523,10 @@ public class IndexFollowingIT extends CcrIntegTestCase {
|
|||
return () -> {
|
||||
final GetResponse getResponse = followerClient().prepareGet("index2", "doc", Integer.toString(key)).get();
|
||||
assertTrue("Doc with id [" + key + "] is missing", getResponse.isExists());
|
||||
assertTrue((getResponse.getSource().containsKey("f")));
|
||||
assertThat(getResponse.getSource().get("f"), equalTo(value));
|
||||
if (sourceEnabled) {
|
||||
assertTrue((getResponse.getSource().containsKey("f")));
|
||||
assertThat(getResponse.getSource().get("f"), equalTo(value));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue