浏览代码

[Tests] Fix GetResultTests and DocumentFieldTests failures (#29083)

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
Christoph Büscher 7 年之前
父节点
当前提交
312ccc05d5

+ 0 - 1
server/src/test/java/org/elasticsearch/index/get/DocumentFieldTests.java

@@ -55,7 +55,6 @@ public class DocumentFieldTests extends ESTestCase {
                 DocumentFieldTests::mutateDocumentField);
                 DocumentFieldTests::mutateDocumentField);
     }
     }
 
 
-    @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/29080")
     public void testToAndFromXContent() throws Exception {
     public void testToAndFromXContent() throws Exception {
         XContentType xContentType = randomFrom(XContentType.values());
         XContentType xContentType = randomFrom(XContentType.values());
         Tuple<DocumentField, DocumentField> tuple = randomDocumentField(xContentType);
         Tuple<DocumentField, DocumentField> tuple = randomDocumentField(xContentType);

+ 0 - 2
server/src/test/java/org/elasticsearch/index/get/GetResultTests.java

@@ -49,7 +49,6 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertToXC
 
 
 public class GetResultTests extends ESTestCase {
 public class GetResultTests extends ESTestCase {
 
 
-    @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/29080")
     public void testToAndFromXContent() throws Exception {
     public void testToAndFromXContent() throws Exception {
         XContentType xContentType = randomFrom(XContentType.values());
         XContentType xContentType = randomFrom(XContentType.values());
         Tuple<GetResult, GetResult> tuple = randomGetResult(xContentType);
         Tuple<GetResult, GetResult> tuple = randomGetResult(xContentType);
@@ -87,7 +86,6 @@ public class GetResultTests extends ESTestCase {
         }
         }
     }
     }
 
 
-    @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/29080")
     public void testToAndFromXContentEmbedded() throws Exception {
     public void testToAndFromXContentEmbedded() throws Exception {
         XContentType xContentType = randomFrom(XContentType.values());
         XContentType xContentType = randomFrom(XContentType.values());
         Tuple<GetResult, GetResult> tuple = randomGetResult(xContentType);
         Tuple<GetResult, GetResult> tuple = randomGetResult(xContentType);

+ 5 - 3
test/framework/src/main/java/org/elasticsearch/test/RandomObjects.java

@@ -21,10 +21,12 @@ package org.elasticsearch.test;
 
 
 import com.carrotsearch.randomizedtesting.generators.RandomPicks;
 import com.carrotsearch.randomizedtesting.generators.RandomPicks;
 import com.carrotsearch.randomizedtesting.generators.RandomStrings;
 import com.carrotsearch.randomizedtesting.generators.RandomStrings;
+
 import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.ElasticsearchException;
 import org.elasticsearch.action.support.replication.ReplicationResponse.ShardInfo;
 import org.elasticsearch.action.support.replication.ReplicationResponse.ShardInfo;
 import org.elasticsearch.action.support.replication.ReplicationResponse.ShardInfo.Failure;
 import org.elasticsearch.action.support.replication.ReplicationResponse.ShardInfo.Failure;
 import org.elasticsearch.cluster.block.ClusterBlockException;
 import org.elasticsearch.cluster.block.ClusterBlockException;
+import org.elasticsearch.common.bytes.BytesArray;
 import org.elasticsearch.common.bytes.BytesReference;
 import org.elasticsearch.common.bytes.BytesReference;
 import org.elasticsearch.common.collect.Tuple;
 import org.elasticsearch.common.collect.Tuple;
 import org.elasticsearch.common.xcontent.ToXContent;
 import org.elasticsearch.common.xcontent.ToXContent;
@@ -127,14 +129,14 @@ public final class RandomObjects {
                     break;
                     break;
                 case 8:
                 case 8:
                     byte[] randomBytes = RandomStrings.randomUnicodeOfLengthBetween(random, 10, 50).getBytes(StandardCharsets.UTF_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) {
                     if (xContentType == XContentType.JSON || xContentType == XContentType.YAML) {
                         //JSON and YAML write the base64 format
                         //JSON and YAML write the base64 format
                         expectedParsedValues.add(Base64.getEncoder().encodeToString(randomBytes));
                         expectedParsedValues.add(Base64.getEncoder().encodeToString(randomBytes));
-                        originalValues.add(Base64.getEncoder().encodeToString(randomBytes));
                     } else {
                     } else {
                         //SMILE and CBOR write the original bytes as they support binary format
                         //SMILE and CBOR write the original bytes as they support binary format
-                        expectedParsedValues.add(randomBytes);
-                        originalValues.add(randomBytes);
+                        expectedParsedValues.add(randomBytesArray);
                     }
                     }
                     break;
                     break;
                 default:
                 default: