Skip to content

Commit 4c38808

Browse files
author
Christoph Büscher
committed
[Tests] Fix GetResultTests and DocumentFieldTests failures
Changes made in elastic#28972 seems to have changed some assumptions about how SMILE and CBOR write byte[] values and how this is tested. This changes the generation of the randomized DocumentField values back to BytesArray while expecting the JSON and YAML deserialisation to produce Base64 encoded strings and SMILE and CBOR to parse back BytesArray instances. Closes elastic#29080
1 parent 8593316 commit 4c38808

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

server/src/test/java/org/elasticsearch/index/get/DocumentFieldTests.java

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ public void testEqualsAndHashcode() {
5555
DocumentFieldTests::mutateDocumentField);
5656
}
5757

58-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/29080")
5958
public void testToAndFromXContent() throws Exception {
6059
XContentType xContentType = randomFrom(XContentType.values());
6160
Tuple<DocumentField, DocumentField> tuple = randomDocumentField(xContentType);

server/src/test/java/org/elasticsearch/index/get/GetResultTests.java

-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949

5050
public class GetResultTests extends ESTestCase {
5151

52-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/29080")
5352
public void testToAndFromXContent() throws Exception {
5453
XContentType xContentType = randomFrom(XContentType.values());
5554
Tuple<GetResult, GetResult> tuple = randomGetResult(xContentType);
@@ -87,7 +86,6 @@ public void testToXContent() throws IOException {
8786
}
8887
}
8988

90-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/29080")
9189
public void testToAndFromXContentEmbedded() throws Exception {
9290
XContentType xContentType = randomFrom(XContentType.values());
9391
Tuple<GetResult, GetResult> tuple = randomGetResult(xContentType);

test/framework/src/main/java/org/elasticsearch/test/RandomObjects.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@
2121

2222
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
2323
import com.carrotsearch.randomizedtesting.generators.RandomStrings;
24+
2425
import org.elasticsearch.ElasticsearchException;
2526
import org.elasticsearch.action.support.replication.ReplicationResponse.ShardInfo;
2627
import org.elasticsearch.action.support.replication.ReplicationResponse.ShardInfo.Failure;
2728
import org.elasticsearch.cluster.block.ClusterBlockException;
29+
import org.elasticsearch.common.bytes.BytesArray;
2830
import org.elasticsearch.common.bytes.BytesReference;
2931
import org.elasticsearch.common.collect.Tuple;
3032
import org.elasticsearch.common.xcontent.ToXContent;
@@ -127,14 +129,14 @@ public static Tuple<List<Object>, List<Object>> randomStoredFieldValues(Random r
127129
break;
128130
case 8:
129131
byte[] randomBytes = RandomStrings.randomUnicodeOfLengthBetween(random, 10, 50).getBytes(StandardCharsets.UTF_8);
132+
BytesArray randomBytesArray = new BytesArray(randomBytes);
133+
originalValues.add(randomBytesArray);
130134
if (xContentType == XContentType.JSON || xContentType == XContentType.YAML) {
131135
//JSON and YAML write the base64 format
132136
expectedParsedValues.add(Base64.getEncoder().encodeToString(randomBytes));
133-
originalValues.add(Base64.getEncoder().encodeToString(randomBytes));
134137
} else {
135138
//SMILE and CBOR write the original bytes as they support binary format
136-
expectedParsedValues.add(randomBytes);
137-
originalValues.add(randomBytes);
139+
expectedParsedValues.add(randomBytesArray);
138140
}
139141
break;
140142
default:

0 commit comments

Comments
 (0)