Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Remove] Legacy 6x BWC Support #1218

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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 @@ -32,7 +32,6 @@

package org.opensearch.index.reindex;

import org.opensearch.LegacyESVersion;
import org.opensearch.Version;
import org.opensearch.common.bytes.BytesArray;
import org.opensearch.common.bytes.BytesReference;
Expand Down Expand Up @@ -82,15 +81,10 @@ public void testReindexRequest() throws IOException {
ReindexRequest tripped = new ReindexRequest(toInputByteStream(reindex));
assertRequestEquals(reindex, tripped);

// Try slices=auto with a version that doesn't support it, which should fail
reindex.setSlices(AbstractBulkByScrollRequest.AUTO_SLICES);
Exception e = expectThrows(IllegalArgumentException.class, () -> toInputByteStream(LegacyESVersion.V_6_0_0_alpha1, reindex));
assertEquals("Slices set as \"auto\" are not supported before version [6.1.0]. Found version [6.0.0-alpha1]", e.getMessage());

// Try regular slices with a version that doesn't support slices=auto, which should succeed
reindex.setSlices(between(1, Integer.MAX_VALUE));
tripped = new ReindexRequest(toInputByteStream(reindex));
assertRequestEquals(LegacyESVersion.V_6_0_0_alpha1, reindex, tripped);
assertRequestEquals(reindex, tripped);
}

public void testUpdateByQueryRequest() throws IOException {
Expand All @@ -103,11 +97,6 @@ public void testUpdateByQueryRequest() throws IOException {
assertRequestEquals(update, tripped);
assertEquals(update.getPipeline(), tripped.getPipeline());

// Try slices=auto with a version that doesn't support it, which should fail
update.setSlices(AbstractBulkByScrollRequest.AUTO_SLICES);
Exception e = expectThrows(IllegalArgumentException.class, () -> toInputByteStream(LegacyESVersion.V_6_0_0_alpha1, update));
assertEquals("Slices set as \"auto\" are not supported before version [6.1.0]. Found version [6.0.0-alpha1]", e.getMessage());

// Try regular slices with a version that doesn't support slices=auto, which should succeed
update.setSlices(between(1, Integer.MAX_VALUE));
tripped = new UpdateByQueryRequest(toInputByteStream(update));
Expand All @@ -121,11 +110,6 @@ public void testDeleteByQueryRequest() throws IOException {
DeleteByQueryRequest tripped = new DeleteByQueryRequest(toInputByteStream(delete));
assertRequestEquals(delete, tripped);

// Try slices=auto with a version that doesn't support it, which should fail
delete.setSlices(AbstractBulkByScrollRequest.AUTO_SLICES);
Exception e = expectThrows(IllegalArgumentException.class, () -> toInputByteStream(LegacyESVersion.V_6_0_0_alpha1, delete));
assertEquals("Slices set as \"auto\" are not supported before version [6.1.0]. Found version [6.0.0-alpha1]", e.getMessage());

// Try regular slices with a version that doesn't support slices=auto, which should succeed
delete.setSlices(between(1, Integer.MAX_VALUE));
tripped = new DeleteByQueryRequest(toInputByteStream(delete));
Expand Down Expand Up @@ -157,25 +141,6 @@ private void randomRequest(AbstractBulkIndexByScrollRequest<?> request) {
request.setScript(random().nextBoolean() ? null : randomScript());
}

private void assertRequestEquals(Version version, ReindexRequest request, ReindexRequest tripped) {
assertRequestEquals((AbstractBulkIndexByScrollRequest<?>) request, (AbstractBulkIndexByScrollRequest<?>) tripped);
assertEquals(request.getDestination().version(), tripped.getDestination().version());
assertEquals(request.getDestination().index(), tripped.getDestination().index());
if (request.getRemoteInfo() == null) {
assertNull(tripped.getRemoteInfo());
} else {
assertNotNull(tripped.getRemoteInfo());
assertEquals(request.getRemoteInfo().getScheme(), tripped.getRemoteInfo().getScheme());
assertEquals(request.getRemoteInfo().getHost(), tripped.getRemoteInfo().getHost());
assertEquals(request.getRemoteInfo().getQuery(), tripped.getRemoteInfo().getQuery());
assertEquals(request.getRemoteInfo().getUsername(), tripped.getRemoteInfo().getUsername());
assertEquals(request.getRemoteInfo().getPassword(), tripped.getRemoteInfo().getPassword());
assertEquals(request.getRemoteInfo().getHeaders(), tripped.getRemoteInfo().getHeaders());
assertEquals(request.getRemoteInfo().getSocketTimeout(), tripped.getRemoteInfo().getSocketTimeout());
assertEquals(request.getRemoteInfo().getConnectTimeout(), tripped.getRemoteInfo().getConnectTimeout());
}
}

private void assertRequestEquals(AbstractBulkIndexByScrollRequest<?> request,
AbstractBulkIndexByScrollRequest<?> tripped) {
assertRequestEquals((AbstractBulkByScrollRequest<?>) request, (AbstractBulkByScrollRequest<?>) tripped);
Expand Down
Loading