Skip to content

Commit

Permalink
[Tests] Fix GetResultTests and DocumentFieldTests failures (#29083)
Browse files Browse the repository at this point in the history
Changes made in #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 #29080
  • Loading branch information
Christoph Büscher authored Mar 15, 2018
1 parent 18d848f commit 312ccc0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public void testEqualsAndHashcode() {
DocumentFieldTests::mutateDocumentField);
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/29080")
public void testToAndFromXContent() throws Exception {
XContentType xContentType = randomFrom(XContentType.values());
Tuple<DocumentField, DocumentField> tuple = randomDocumentField(xContentType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@

public class GetResultTests extends ESTestCase {

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

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/29080")
public void testToAndFromXContentEmbedded() throws Exception {
XContentType xContentType = randomFrom(XContentType.values());
Tuple<GetResult, GetResult> tuple = randomGetResult(xContentType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@

import com.carrotsearch.randomizedtesting.generators.RandomPicks;
import com.carrotsearch.randomizedtesting.generators.RandomStrings;

import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.support.replication.ReplicationResponse.ShardInfo;
import org.elasticsearch.action.support.replication.ReplicationResponse.ShardInfo.Failure;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.common.xcontent.ToXContent;
Expand Down Expand Up @@ -127,14 +129,14 @@ public static Tuple<List<Object>, List<Object>> randomStoredFieldValues(Random r
break;
case 8:
byte[] randomBytes = RandomStrings.randomUnicodeOfLengthBetween(random, 10, 50).getBytes(StandardCharsets.UTF_8);
BytesArray randomBytesArray = new BytesArray(randomBytes);
originalValues.add(randomBytesArray);
if (xContentType == XContentType.JSON || xContentType == XContentType.YAML) {
//JSON and YAML write the base64 format
expectedParsedValues.add(Base64.getEncoder().encodeToString(randomBytes));
originalValues.add(Base64.getEncoder().encodeToString(randomBytes));
} else {
//SMILE and CBOR write the original bytes as they support binary format
expectedParsedValues.add(randomBytes);
originalValues.add(randomBytes);
expectedParsedValues.add(randomBytesArray);
}
break;
default:
Expand Down

0 comments on commit 312ccc0

Please sign in to comment.