Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[controller] Ensure empty string from config doesn't result in an array of an empty string for instance tag list #1202

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,10 @@ public List<String> getList(String key, List<String> defaultValue) {
}

String value = get(key);
if (value.isEmpty()) {
return defaultValue;
}

kvargha marked this conversation as resolved.
Show resolved Hide resolved
String[] pieces = value.split("\\s*,\\s*");
return Arrays.asList(pieces);
}
Expand All @@ -404,6 +408,10 @@ public List<String> getListWithAlternative(String preferredKey, String altKey, L
value = get(altKey);
}

if (value.isEmpty()) {
return defaultValue;
}

String[] pieces = value.split("\\s*,\\s*");
return Arrays.asList(pieces);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,27 @@ public void testClusterResourceInstanceTag() {
}
}

@Test(timeOut = 60 * Time.MS_PER_SECOND)
public void testClusterResourceEmptyInstanceTag() {
try (VeniceClusterWrapper venice = ServiceFactory.getVeniceCluster(0, 0, 0, 1);
HelixAsAServiceWrapper helixAsAServiceWrapper = startAndWaitForHAASToBeAvailable(venice.getZk().getAddress())) {
String instanceTag = "";
String controllerClusterName = "venice-controllers";

Properties clusterProperties = (Properties) enableControllerAndStorageClusterHAASProperties.clone();
clusterProperties.put(ConfigKeys.CONTROLLER_RESOURCE_INSTANCE_GROUP_TAG, instanceTag);
clusterProperties.put(ConfigKeys.CONTROLLER_INSTANCE_TAG_LIST, instanceTag);

VeniceControllerWrapper controllerWrapper = venice.addVeniceController(clusterProperties);

HelixAdmin helixAdmin = controllerWrapper.getVeniceHelixAdmin().getHelixAdmin();
List<String> resources = helixAdmin.getResourcesInClusterWithTag(controllerClusterName, instanceTag);
assertEquals(resources.size(), 0);
List<String> instances = helixAdmin.getInstancesInClusterWithTag(controllerClusterName, instanceTag);
assertEquals(instances.size(), 0);
}
}

@Test(timeOut = 60 * Time.MS_PER_SECOND)
public void testStartHAASHelixControllerAsControllerClusterLeader() {
try (VeniceClusterWrapper venice = ServiceFactory.getVeniceCluster(0, 0, 0, 1);
Expand Down
Loading