Skip to content
Merged
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
6 changes: 6 additions & 0 deletions docs/changelog/137275.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 137275
summary: "Reindex-from-remote: Fail on manual slicing param"
area: Indices APIs
type: bug
issues:
- 136269
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ public ActionRequestValidationException validate() {
if (getSlices() == AbstractBulkByScrollRequest.AUTO_SLICES || getSlices() > 1) {
e = addValidationError("reindex from remote sources doesn't support slices > 1 but was [" + getSlices() + "]", e);
}
if (getSearchRequest().source().slice() != null) {
e = addValidationError(
"reindex from remote sources doesn't support source.slice but was [" + getSearchRequest().source().slice() + "]",
e
);
}
if (getRemoteInfo().getUsername() != null && getRemoteInfo().getPassword() == null) {
e = addValidationError("reindex from remote source included username but not password", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public void testReindexFromRemoteDoesNotSupportSearchQuery() {
);
}

public void testReindexFromRemoteDoesNotSupportSlices() {
public void testReindexFromRemoteDoesNotSupportSlicesParameterGreaterThan1() {
ReindexRequest reindex = newRequest();
reindex.setRemoteInfo(
new RemoteInfo(
Expand All @@ -178,6 +178,7 @@ public void testReindexFromRemoteDoesNotSupportSlices() {
RemoteInfo.DEFAULT_CONNECT_TIMEOUT
)
);
// Enable automatic slicing with a random number of slices greater than 1 (like setting the slices URL parameter):
reindex.setSlices(between(2, Integer.MAX_VALUE));
ActionRequestValidationException e = reindex.validate();
assertEquals(
Expand All @@ -186,6 +187,60 @@ public void testReindexFromRemoteDoesNotSupportSlices() {
);
}

public void testReindexFromRemoteDoesNotSupportSlicesParameterSetToAuto() {
ReindexRequest reindex = newRequest();
reindex.setRemoteInfo(
new RemoteInfo(
randomAlphaOfLength(5),
randomAlphaOfLength(5),
between(1, Integer.MAX_VALUE),
null,
matchAll,
null,
null,
emptyMap(),
RemoteInfo.DEFAULT_SOCKET_TIMEOUT,
RemoteInfo.DEFAULT_CONNECT_TIMEOUT
)
);
// Enable automatic slicing with an automatically chosen number of slices (like setting the slices URL parameter to "auto"):
reindex.setSlices(AbstractBulkByScrollRequest.AUTO_SLICES);
ActionRequestValidationException e = reindex.validate();
assertEquals(
"Validation Failed: 1: reindex from remote sources doesn't support slices > 1 but was [" + reindex.getSlices() + "];",
e.getMessage()
);
}

public void testReindexFromRemoteDoesNotSupportSlicesSourceField() {
ReindexRequest reindex = newRequest();
reindex.setRemoteInfo(
new RemoteInfo(
randomAlphaOfLength(5),
randomAlphaOfLength(5),
between(1, Integer.MAX_VALUE),
null,
matchAll,
null,
null,
emptyMap(),
RemoteInfo.DEFAULT_SOCKET_TIMEOUT,
RemoteInfo.DEFAULT_CONNECT_TIMEOUT
)
);
// Enable manual slicing (like setting source.slice.max and source.slice.id in the request body):
int numSlices = randomIntBetween(2, Integer.MAX_VALUE);
int sliceId = randomIntBetween(0, numSlices - 1);
reindex.getSearchRequest().source().slice(new SliceBuilder(sliceId, numSlices));
ActionRequestValidationException e = reindex.validate();
assertEquals(
"Validation Failed: 1: reindex from remote sources doesn't support source.slice but was ["
+ reindex.getSearchRequest().source().slice()
+ "];",
e.getMessage()
);
}

public void testReindexFromRemoteRejectsUsernameWithNoPassword() {
ReindexRequest reindex = newRequest();
reindex.setRemoteInfo(
Expand Down