You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ja...@apache.org on 2019/01/25 03:29:08 UTC
[incubator-pinot] branch master updated: Fix
SegmentZKMetadataTest.segmentPartitionMetadataTest() (#3745)
This is an automated email from the ASF dual-hosted git repository.
jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 1724bc7 Fix SegmentZKMetadataTest.segmentPartitionMetadataTest() (#3745)
1724bc7 is described below
commit 1724bc7f193ab53a22b63bfec7d8f20b1f8f408a
Author: Xiaotian (Jackie) Jiang <17...@users.noreply.github.com>
AuthorDate: Thu Jan 24 19:29:03 2019 -0800
Fix SegmentZKMetadataTest.segmentPartitionMetadataTest() (#3745)
There is no guarantee on the order of fields for a serialized json string
Check the metadata itself instead of the json string
---
.../common/metadata/SegmentZKMetadataTest.java | 24 +++++++++++++---------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/pinot-common/src/test/java/org/apache/pinot/common/metadata/SegmentZKMetadataTest.java b/pinot-common/src/test/java/org/apache/pinot/common/metadata/SegmentZKMetadataTest.java
index 923b3b3..da7f03a 100644
--- a/pinot-common/src/test/java/org/apache/pinot/common/metadata/SegmentZKMetadataTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/common/metadata/SegmentZKMetadataTest.java
@@ -19,8 +19,9 @@
package org.apache.pinot.common.metadata;
import java.io.IOException;
-import java.util.Collections;
+import java.util.Arrays;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.apache.helix.ZNRecord;
@@ -79,19 +80,22 @@ public class SegmentZKMetadataTest {
throws IOException {
// Test for partition metadata serialization/de-serialization.
String legacyMetadataString = "{\"columnPartitionMap\":{"
- + "\"column1\":{\"functionName\":\"func1\",\"numPartitions\":7,\"partitionRanges\":\"[5 5],[7 7]\"},"
- + "\"column2\":{\"functionName\":\"func2\",\"numPartitions\":11,\"partitionRanges\":\"[11 11],[13 13]\"}}}";
- String expectedMetadataString = "{\"columnPartitionMap\":{"
- + "\"column1\":{\"functionName\":\"func1\",\"numPartitions\":7,\"partitions\":[5,7]},"
- + "\"column2\":{\"functionName\":\"func2\",\"numPartitions\":11,\"partitions\":[11,13]}}}";
- assertEquals(SegmentPartitionMetadata.fromJsonString(legacyMetadataString).toJsonString(), expectedMetadataString);
- assertEquals(SegmentPartitionMetadata.fromJsonString(expectedMetadataString).toJsonString(),
- expectedMetadataString);
+ + "\"column1\":{\"functionName\":\"func1\",\"numPartitions\":8,\"partitionRanges\":\"[5 5],[7 7]\"},"
+ + "\"column2\":{\"functionName\":\"func2\",\"numPartitions\":12,\"partitionRanges\":\"[9 11]\"}}}";
+ String metadataString = "{\"columnPartitionMap\":{"
+ + "\"column1\":{\"functionName\":\"func1\",\"numPartitions\":8,\"partitions\":[5,7]},"
+ + "\"column2\":{\"functionName\":\"func2\",\"numPartitions\":12,\"partitions\":[9,10,11]}}}";
Map<String, ColumnPartitionMetadata> columnPartitionMetadataMap = new HashMap<>();
- columnPartitionMetadataMap.put("column", new ColumnPartitionMetadata("foo", 7, Collections.singleton(11)));
+ columnPartitionMetadataMap
+ .put("column1", new ColumnPartitionMetadata("func1", 8, new HashSet<>(Arrays.asList(5, 7))));
+ columnPartitionMetadataMap
+ .put("column2", new ColumnPartitionMetadata("func2", 12, new HashSet<>(Arrays.asList(9, 10, 11))));
SegmentPartitionMetadata expectedPartitionMetadata = new SegmentPartitionMetadata(columnPartitionMetadataMap);
+ assertEquals(SegmentPartitionMetadata.fromJsonString(legacyMetadataString), expectedPartitionMetadata);
+ assertEquals(SegmentPartitionMetadata.fromJsonString(metadataString), expectedPartitionMetadata);
+
// Test partition metadata in OfflineSegmentZkMetadata
ZNRecord znRecord = getTestOfflineSegmentZNRecord();
znRecord.setSimpleField(CommonConstants.Segment.PARTITION_METADATA, expectedPartitionMetadata.toJsonString());
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org