Skip to content

Commit

Permalink
Fix test failure
Browse files Browse the repository at this point in the history
Signed-off-by: Gao Binlong <gbinlong@amazon.com>
  • Loading branch information
gaobinlong committed Mar 12, 2024
1 parent a3465d6 commit 1340aa8
Showing 1 changed file with 14 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
package org.opensearch.action.admin.indices.forcemerge;

import org.opensearch.Version;
import org.opensearch.action.support.IndicesOptions;
import org.opensearch.common.io.stream.BytesStreamOutput;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.tasks.TaskId;
import org.opensearch.test.OpenSearchTestCase;
import org.opensearch.test.VersionUtils;

Expand Down Expand Up @@ -100,21 +102,21 @@ public void testBwcSerialization() throws Exception {
out.setVersion(compatibleVersion);
sample.writeTo(out);

final ForceMergeRequest deserializedRequest;
try (StreamInput in = out.bytes().streamInput()) {
in.setVersion(Version.CURRENT);
deserializedRequest = new ForceMergeRequest(in);
TaskId.readFromStream(in);
in.readStringArray();
IndicesOptions.readIndicesOptions(in);
int maxNumSegments = in.readInt();
boolean onlyExpungeDeletes = in.readBoolean();
boolean flush = in.readBoolean();
String forceMergeUUID = in.readOptionalString();
assertEquals(sample.maxNumSegments(), maxNumSegments);
assertEquals(sample.onlyExpungeDeletes(), onlyExpungeDeletes);
assertEquals(sample.flush(), flush);
assertEquals(sample.forceMergeUUID(), forceMergeUUID);
}

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

Expand All @@ -132,11 +134,7 @@ public void testBwcSerialization() throws Exception {
if (compatibleVersion.onOrAfter(Version.V_2_13_0)) {
out.writeBoolean(sample.primaryOnly());
}
if (compatibleVersion.onOrAfter(Version.V_3_0_0)) {
out.writeString(sample.forceMergeUUID());
} else {
out.writeOptionalString(sample.forceMergeUUID());
}
out.writeOptionalString(sample.forceMergeUUID());

final ForceMergeRequest deserializedRequest;
try (StreamInput in = out.bytes().streamInput()) {
Expand All @@ -151,7 +149,6 @@ public void testBwcSerialization() throws Exception {
assertEquals(sample.primaryOnly(), deserializedRequest.primaryOnly());
}
assertEquals(sample.forceMergeUUID(), deserializedRequest.forceMergeUUID());

}
}
}
Expand Down

0 comments on commit 1340aa8

Please sign in to comment.