Skip to content

Commit fc3454b

Browse files
authored
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).
1 parent 7f1e1c5 commit fc3454b

File tree

5 files changed

+26
-7
lines changed

5 files changed

+26
-7
lines changed

server/src/main/java/org/elasticsearch/index/engine/LuceneChangesSnapshot.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ private Translog.Operation readDocAsOp(int docIndex) throws IOException {
255255
// TODO: Callers should ask for the range that source should be retained. Thus we should always
256256
// check for the existence source once we make peer-recovery to send ops after the local checkpoint.
257257
if (requiredFullRange) {
258-
throw new IllegalStateException("source not found for seqno=" + seqNo +
258+
throw new MissingHistoryOperationsException("source not found for seqno=" + seqNo +
259259
" from_seqno=" + fromSeqNo + " to_seqno=" + toSeqNo);
260260
} else {
261261
skippedOperations++;

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,14 @@ protected void ensureNoCcrTasks() throws Exception {
405405
}, 30, TimeUnit.SECONDS);
406406
}
407407

408+
409+
@Before
410+
public void setupSourceEnabledOrDisabled() {
411+
sourceEnabled = randomBoolean();
412+
}
413+
414+
protected boolean sourceEnabled;
415+
408416
protected String getIndexSettings(final int numberOfShards, final int numberOfReplicas,
409417
final Map<String, String> additionalIndexSettings) throws IOException {
410418
final String settings;
@@ -435,6 +443,11 @@ protected String getIndexSettings(final int numberOfShards, final int numberOfRe
435443
builder.endObject();
436444
}
437445
builder.endObject();
446+
if (sourceEnabled == false) {
447+
builder.startObject("_source");
448+
builder.field("enabled", false);
449+
builder.endObject();
450+
}
438451
}
439452
builder.endObject();
440453
}

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrRepositoryIT.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,10 @@ public void testFollowerMappingIsUpdated() throws IOException {
446446
private void assertExpectedDocument(String followerIndex, final int value) {
447447
final GetResponse getResponse = followerClient().prepareGet(followerIndex, Integer.toString(value)).get();
448448
assertTrue("Doc with id [" + value + "] is missing", getResponse.isExists());
449-
assertTrue((getResponse.getSource().containsKey("f")));
450-
assertThat(getResponse.getSource().get("f"), equalTo(value));
449+
if (sourceEnabled) {
450+
assertTrue((getResponse.getSource().containsKey("f")));
451+
assertThat(getResponse.getSource().get("f"), equalTo(value));
452+
}
451453
}
452454

453455
}

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrRetentionLeaseIT.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,8 +1075,10 @@ private String getRetentionLeaseId(String followerIndex, String followerUUID, St
10751075
private void assertExpectedDocument(final String followerIndex, final int value) {
10761076
final GetResponse getResponse = followerClient().prepareGet(followerIndex, Integer.toString(value)).get();
10771077
assertTrue("doc with id [" + value + "] is missing", getResponse.isExists());
1078-
assertTrue((getResponse.getSource().containsKey("f")));
1079-
assertThat(getResponse.getSource().get("f"), equalTo(value));
1078+
if (sourceEnabled) {
1079+
assertTrue((getResponse.getSource().containsKey("f")));
1080+
assertThat(getResponse.getSource().get("f"), equalTo(value));
1081+
}
10801082
}
10811083

10821084
}

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,8 +1519,10 @@ private CheckedRunnable<Exception> assertExpectedDocumentRunnable(final int key,
15191519
return () -> {
15201520
final GetResponse getResponse = followerClient().prepareGet("index2", Integer.toString(key)).get();
15211521
assertTrue("Doc with id [" + key + "] is missing", getResponse.isExists());
1522-
assertTrue((getResponse.getSource().containsKey("f")));
1523-
assertThat(getResponse.getSource().get("f"), equalTo(value));
1522+
if (sourceEnabled) {
1523+
assertTrue((getResponse.getSource().containsKey("f")));
1524+
assertThat(getResponse.getSource().get("f"), equalTo(value));
1525+
}
15241526
};
15251527
}
15261528

0 commit comments

Comments
 (0)