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

Fix test bwcSerialization issue in ForceMergeRequestTests #12778

Merged
merged 1 commit into from
Mar 20, 2024
Merged
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 @@ -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)) {
sohami marked this conversation as resolved.
Show resolved Hide resolved
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
Loading