use of org.apache.pulsar.broker.loadbalance.impl.BrokerVersionFilter in project incubator-pulsar by apache.
the class BrokerVersionFilterTest method testLatestVersion.
@Test
public void testLatestVersion() {
LoadData loadData = initLoadData();
Set<String> brokers = new TreeSet<>();
brokers.add("broker1");
brokers.add("broker2");
brokers.add("broker3");
BrokerVersionFilter filter = new BrokerVersionFilter();
try {
Version latestVersion = filter.getLatestVersionNumber(brokers, loadData);
Assert.assertEquals(latestVersion.getMajorVersion(), 1);
Assert.assertEquals(latestVersion.getMinorVersion(), 2);
Assert.assertEquals(latestVersion.getPatchVersion(), 0);
} catch (BrokerFilterBadVersionException bad) {
Assert.fail(bad.getMessage(), bad);
}
ServiceConfiguration configuration = new ServiceConfiguration();
configuration.setPreferLaterVersions(true);
try {
filter.filter(brokers, null, loadData, configuration);
// Only one broker is running the latest version
Assert.assertEquals(brokers.size(), 1);
} catch (BrokerFilterBadVersionException bad) {
Assert.fail(bad.getMessage(), bad);
}
}
Aggregations