Strengthen testUpdate in rolling upgrade
We hit a bug where we can't partially update documents created in a mixed cluster between 5.x and 6.x. Although this bug does not affect 7.0 or later, we should have a good test that catches this issue. Relates #46198
This commit is contained in:
parent
57f322f85e
commit
f91dd903cb
|
@ -34,6 +34,7 @@ import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
|||
import org.elasticsearch.index.IndexSettings;
|
||||
import org.elasticsearch.index.seqno.RetentionLeaseUtils;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
import org.elasticsearch.rest.action.document.RestGetAction;
|
||||
import org.elasticsearch.rest.action.document.RestIndexAction;
|
||||
import org.elasticsearch.rest.action.document.RestUpdateAction;
|
||||
import org.elasticsearch.test.rest.yaml.ObjectPath;
|
||||
|
@ -43,6 +44,7 @@ import org.hamcrest.Matchers;
|
|||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
@ -694,14 +696,32 @@ public class RecoveryIT extends AbstractRollingTestCase {
|
|||
.put(IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1)
|
||||
.put(IndexMetaData.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 2);
|
||||
createIndex(index, settings.build());
|
||||
indexDocs(index, 0, 100);
|
||||
}
|
||||
if (randomBoolean()) {
|
||||
ensureGreen(index);
|
||||
indexDocs(index, 0, 10);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Request update = new Request("POST", index + "/test/" + i + "/_update/");
|
||||
}
|
||||
Map<Integer, Long> updates = new HashMap<>();
|
||||
for (int docId = 0; docId < 100; docId++) {
|
||||
final int times = randomIntBetween(0, 2);
|
||||
for (int i = 0; i < times; i++) {
|
||||
long value = randomNonNegativeLong();
|
||||
Request update = new Request("POST", index + "/test/" + docId + "/_update");
|
||||
update.setOptions(expectWarnings(RestUpdateAction.TYPES_DEPRECATION_MESSAGE));
|
||||
update.setJsonEntity("{\"doc\": {\"f\": " + randomNonNegativeLong() + "}}");
|
||||
update.setJsonEntity("{\"doc\": {\"updated_field\": " + value + "}}");
|
||||
client().performRequest(update);
|
||||
updates.put(docId, value);
|
||||
}
|
||||
}
|
||||
client().performRequest(new Request("POST", index + "/_refresh"));
|
||||
for (int docId : updates.keySet()) {
|
||||
Request get = new Request("GET", index + "/test/" + docId);
|
||||
get.setOptions(expectWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE));
|
||||
Map<String, Object> doc = entityAsMap(client().performRequest(get));
|
||||
assertThat(XContentMapValues.extractValue("_source.updated_field", doc), equalTo(updates.get(docId)));
|
||||
}
|
||||
if (randomBoolean()) {
|
||||
syncedFlush(index);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue