jackjlli commented on a change in pull request #3633: Use
ZkCacheBaseDataAccessor to cache instance configs in PinotHelixResourceManager
URL: https://github.com/apache/incubator-pinot/pull/3633#discussion_r245431432
##########
File path:
pinot-controller/src/test/java/com/linkedin/pinot/controller/helix/core/PinotHelixResourceManagerTest.java
##########
@@ -76,6 +86,60 @@ public void testGetInstanceEndpoints() throws
InvalidConfigException {
for (int i = 0; i < NUM_INSTANCES; i++) {
Assert.assertTrue(endpoints.inverse().containsKey("localhost:" +
String.valueOf(BASE_SERVER_ADMIN_PORT + i)));
}
+ ZkCacheBaseDataAccessor<ZNRecord> zkCacheBaseDataAccessor =
_helixResourceManager.getCacheInstanceConfigsDataAccessor();
+ Assert.assertNotNull(zkCacheBaseDataAccessor);
+ List<ZNRecord> znRecords = zkCacheBaseDataAccessor.getChildren("/", null,
AccessOption.PERSISTENT);
+ for (ZNRecord znRecord : znRecords) {
+ if (znRecord.getId().startsWith("Server")) {
+
Assert.assertNotNull(znRecord.getSimpleField(CommonConstants.Helix.Instance.ADMIN_PORT_KEY));
+ String adminPort =
znRecord.getSimpleField(CommonConstants.Helix.Instance.ADMIN_PORT_KEY);
+ InstanceConfig instanceConfig = new InstanceConfig(znRecord);
+ String[] hostnameSplit = instanceConfig.getHostName().split("_");
+ String adminEndpoint = hostnameSplit[1] + ":" + adminPort;
+ Assert.assertTrue(endpoints.inverse().containsKey(adminEndpoint));
+ }
+ }
+ }
+
+ @Test
+ public void testGetInstanceConfigsFromZkCacheBaseDataAccessor() throws
InterruptedException {
+ Set<String> servers =
_helixResourceManager.getAllInstancesForServerTenant(SERVER_TENANT_NAME);
+ for (String server : servers) {
+ InstanceConfig cachedInstanceConfig =
_helixResourceManager.getHelixInstanceConfig(server);
+ InstanceConfig realInstanceConfig =
_helixAdmin.getInstanceConfig(_helixClusterName, server);
+ Assert.assertEquals(cachedInstanceConfig, realInstanceConfig);
+ }
+
+ String helixZkUrl = _helixResourceManager.getHelixZkURL();
+ ZkClient zkClient = new ZkClient(helixZkUrl, 10_000, 10_000, new
ZNRecordSerializer());
+ String instanceName = "Server_localhost_" + new
Random().nextInt(NUM_INSTANCES);
+ String instanceConfigPath =
PropertyPathBuilder.instanceConfig(_helixClusterName, instanceName);
+ Assert.assertTrue(zkClient.exists(instanceConfigPath));
+ ZNRecord znRecord = zkClient.readData(instanceConfigPath, null);
+
+ InstanceConfig cachedInstanceConfig =
_helixResourceManager.getHelixInstanceConfig(instanceName);
+ String originalPort = cachedInstanceConfig.getPort();
+ Assert.assertNotNull(originalPort);
+ String newPort = Long.toString(System.currentTimeMillis());
+ Assert.assertTrue(!newPort.equals(originalPort));
+
Review comment:
Another tests added.
----------------------------------------------------------------
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]