narendly commented on a change in pull request #775: Add HttpRoutingDataReader URL: https://github.com/apache/helix/pull/775#discussion_r383713979
########## File path: zookeeper-api/src/test/java/org/apache/helix/zookeeper/util/TestHttpRoutingDataReader.java ########## @@ -0,0 +1,128 @@ +package org.apache.helix.zookeeper.util; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +import java.io.IOException; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import com.google.common.collect.ImmutableSet; +import org.apache.helix.msdcommon.constant.MetadataStoreRoutingConstants; +import org.apache.helix.msdcommon.datamodel.MetadataStoreRoutingData; +import org.apache.helix.msdcommon.exception.InvalidRoutingDataException; +import org.apache.helix.msdcommon.mock.MockMetadataStoreDirectoryServer; +import org.apache.helix.zookeeper.impl.ZkTestBase; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + + +public class TestHttpRoutingDataReader extends ZkTestBase { + private MockMetadataStoreDirectoryServer _msdsServer; + private Map<String, Collection<String>> _testRawRoutingData; + private final String _host = "localhost"; + private final int _port = 1991; + private final String _namespace = "TestHttpRoutingDataReader"; + + @BeforeClass + public void beforeClass() + throws IOException { + // Create fake routing data + _testRawRoutingData = new HashMap<>(); + _testRawRoutingData + .put("zk-0", ImmutableSet.of("/sharding-key-0", "/sharding-key-1", "/sharding-key-2")); + _testRawRoutingData + .put("zk-1", ImmutableSet.of("/sharding-key-3", "/sharding-key-4", "/sharding-key-5")); + _testRawRoutingData + .put("zk-2", ImmutableSet.of("/sharding-key-6", "/sharding-key-7", "/sharding-key-8")); + + // Start MockMSDS + _msdsServer = + new MockMetadataStoreDirectoryServer(_host, _port, _namespace, _testRawRoutingData); + _msdsServer.startServer(); + + // Register the endpoint as a System property + String msdsEndpoint = "http://" + _host + ":" + _port + "/admin/v2/namespaces/" + _namespace; + System.setProperty(MetadataStoreRoutingConstants.MSDS_SERVER_ENDPOINT_KEY, msdsEndpoint); + } + + @AfterClass + public void afterClass() { + _msdsServer.stopServer(); + } + + @Test + public void testGetRawRoutingData() + throws IOException { Review comment: Updated ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to 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]
