Skip to content

Commit

Permalink
Fix test issue in ForceMergeRequestTests (#12778)
Browse files Browse the repository at this point in the history
Signed-off-by: Gao Binlong <[email protected]>
(cherry picked from commit 90b2e4d)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Mar 25, 2024
1 parent 1157e67 commit a90c0c6
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,30 @@ public void testSerialization() throws Exception {
public void testBwcSerialization() throws Exception {
{
final ForceMergeRequest sample = randomRequest();
final Version compatibleVersion = VersionUtils.randomCompatibleVersion(random(), Version.CURRENT);
final Version version = VersionUtils.randomCompatibleVersion(random(), Version.CURRENT);
try (BytesStreamOutput out = new BytesStreamOutput()) {
out.setVersion(compatibleVersion);
out.setVersion(version);
sample.writeTo(out);

try (StreamInput in = out.bytes().streamInput()) {
in.setVersion(Version.CURRENT);
in.setVersion(version);
TaskId.readFromStream(in);
in.readStringArray();
IndicesOptions.readIndicesOptions(in);
int maxNumSegments = in.readInt();
boolean onlyExpungeDeletes = in.readBoolean();
boolean flush = in.readBoolean();
boolean primaryOnly = false;
if (version.onOrAfter(Version.V_2_13_0)) {
primaryOnly = in.readBoolean();
}
String forceMergeUUID = in.readOptionalString();
assertEquals(sample.maxNumSegments(), maxNumSegments);
assertEquals(sample.onlyExpungeDeletes(), onlyExpungeDeletes);
assertEquals(sample.flush(), flush);
if (version.onOrAfter(Version.V_2_13_0)) {
assertEquals(sample.primaryOnly(), primaryOnly);
}
assertEquals(sample.forceMergeUUID(), forceMergeUUID);
}

Expand All @@ -122,30 +129,30 @@ public void testBwcSerialization() throws Exception {

{
final ForceMergeRequest sample = randomRequest();
final Version compatibleVersion = VersionUtils.randomCompatibleVersion(random(), Version.CURRENT);
final Version version = VersionUtils.randomCompatibleVersion(random(), Version.CURRENT);
try (BytesStreamOutput out = new BytesStreamOutput()) {
out.setVersion(Version.CURRENT);
out.setVersion(version);
sample.getParentTask().writeTo(out);
out.writeStringArray(sample.indices());
sample.indicesOptions().writeIndicesOptions(out);
out.writeInt(sample.maxNumSegments());
out.writeBoolean(sample.onlyExpungeDeletes());
out.writeBoolean(sample.flush());
if (compatibleVersion.onOrAfter(Version.V_2_13_0)) {
if (version.onOrAfter(Version.V_2_13_0)) {
out.writeBoolean(sample.primaryOnly());
}
out.writeOptionalString(sample.forceMergeUUID());

final ForceMergeRequest deserializedRequest;
try (StreamInput in = out.bytes().streamInput()) {
in.setVersion(compatibleVersion);
in.setVersion(version);
deserializedRequest = new ForceMergeRequest(in);
}

assertEquals(sample.maxNumSegments(), deserializedRequest.maxNumSegments());
assertEquals(sample.onlyExpungeDeletes(), deserializedRequest.onlyExpungeDeletes());
assertEquals(sample.flush(), deserializedRequest.flush());
if (compatibleVersion.onOrAfter(Version.V_2_13_0)) {
if (version.onOrAfter(Version.V_2_13_0)) {
assertEquals(sample.primaryOnly(), deserializedRequest.primaryOnly());
}
assertEquals(sample.forceMergeUUID(), deserializedRequest.forceMergeUUID());
Expand Down

0 comments on commit a90c0c6

Please sign in to comment.