use of com.netflix.client.config.DefaultClientConfigImpl in project ribbon by Netflix.
the class DiscoveryEnabledLoadBalancerSupportsPortOverrideTest method testSecureVipPortCanBeOverriden.
@Test
public void testSecureVipPortCanBeOverriden() throws Exception {
ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testSecureVipPortCanBeOverriden.ribbon.DeploymentContextBasedVipAddresses", "secureDummy");
ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testSecureVipPortCanBeOverriden.ribbon.IsSecure", "true");
ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testSecureVipPortCanBeOverriden.ribbon.SecurePort", "6002");
ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testSecureVipPortCanBeOverriden.ribbon.TargetRegion", "region");
ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testSecureVipPortCanBeOverriden.ribbon.NIWSServerListClassName", DiscoveryEnabledNIWSServerList.class.getName());
ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testSecureVipPortCanBeOverriden.ribbon.ForceClientPortConfiguration", "true");
DiscoveryEnabledNIWSServerList deList = new DiscoveryEnabledNIWSServerList();
DefaultClientConfigImpl clientConfig = DefaultClientConfigImpl.class.newInstance();
clientConfig.loadProperties("DiscoveryEnabled.testSecureVipPortCanBeOverriden");
deList.initWithNiwsConfig(clientConfig);
List<DiscoveryEnabledServer> serverList = deList.getInitialListOfServers();
Assert.assertEquals(1, serverList.size());
// vip indicated
Assert.assertEquals(8002, serverList.get(0).getPort());
// vip indicated
Assert.assertEquals(8002, serverList.get(0).getInstanceInfo().getPort());
// client property indicated
Assert.assertEquals(6002, serverList.get(0).getInstanceInfo().getSecurePort());
}
use of com.netflix.client.config.DefaultClientConfigImpl in project ribbon by Netflix.
the class DynamicServerListLoadBalancerTest method testDynamicServerListLoadBalancer.
@Test
public void testDynamicServerListLoadBalancer() throws Exception {
DefaultClientConfigImpl config = DefaultClientConfigImpl.getClientConfigWithDefaultValues();
config.setProperty(CommonClientConfigKey.NIWSServerListClassName, MyServerList.class.getName());
config.setProperty(CommonClientConfigKey.NFLoadBalancerClassName, DynamicServerListLoadBalancer.class.getName());
config.setProperty(CommonClientConfigKey.ServerListRefreshInterval, "50");
DynamicServerListLoadBalancer<Server> lb = new DynamicServerListLoadBalancer<Server>(config);
try {
assertTrue(MyServerList.latch.await(2, TimeUnit.SECONDS));
} catch (InterruptedException e) {
// NOPMD
}
assertEquals(lb.getAllServers(), MyServerList.list);
lb.stopServerListRefreshing();
Thread.sleep(1000);
int count = MyServerList.counter.get();
assertTrue(count >= 5);
Thread.sleep(1000);
assertEquals(count, MyServerList.counter.get());
}
Aggregations