snleee commented on a change in pull request #3583: Add segment selector for merged segments URL: https://github.com/apache/incubator-pinot/pull/3583#discussion_r238898223
########## File path: pinot-broker/src/test/java/com/linkedin/pinot/broker/routing/selector/MergedSegmentSelectorTest.java ########## @@ -0,0 +1,102 @@ +/** + * Copyright (C) 2014-2018 LinkedIn Corp. ([email protected]) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.linkedin.pinot.broker.routing.selector; + +import com.linkedin.pinot.broker.util.FakePropertyStore; +import com.linkedin.pinot.common.config.TableConfig; +import com.linkedin.pinot.common.lineage.SegmentMergeLineage; +import com.linkedin.pinot.common.lineage.SegmentMergeLineageAccessHelper; +import com.linkedin.pinot.common.utils.CommonConstants; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import org.apache.helix.ZNRecord; +import org.apache.helix.store.zk.ZkHelixPropertyStore; +import org.testng.Assert; +import org.testng.annotations.Test; + + +public class MergedSegmentSelectorTest { + private static final String TEST_TABLE_NAME = "test_OFFLINE"; + + @Test + public void testMergedSegmentSelector() throws Exception { + MergedSegmentSelector segmentSelector = new MergedSegmentSelector(); + + TableConfig tableConfig = + new TableConfig.Builder(CommonConstants.Helix.TableType.OFFLINE).setTableName(TEST_TABLE_NAME).build(); + ZkHelixPropertyStore<ZNRecord> fakePropertyStore = new FakePropertyStore(); + segmentSelector.init(tableConfig, fakePropertyStore); + + // Add G0 (segment0), G1 (segment1), G2 (segment2) that represent 3 base segments Review comment: If we generate the tree programatically, i still won't have the result to test against. I can probably come up with another implementation of the same logic directly from hashmap representation (not using tree). I will add this as a separate pr for improving testability of this segment selection logic. For now, I expanded the testing case to cover more edge cases with a fixed example. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
