Search in sources :

Example 11 with DefaultClientConfigImpl

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());
}
Also used : DefaultClientConfigImpl(com.netflix.client.config.DefaultClientConfigImpl) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 12 with DefaultClientConfigImpl

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());
}
Also used : MockHttpServer(com.netflix.client.testutil.MockHttpServer) DefaultClientConfigImpl(com.netflix.client.config.DefaultClientConfigImpl) Test(org.junit.Test)

Aggregations

DefaultClientConfigImpl (com.netflix.client.config.DefaultClientConfigImpl)12 Test (org.junit.Test)9 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 ArrayList (java.util.ArrayList)2 Properties (java.util.Properties)2 MockHttpServer (com.netflix.client.testutil.MockHttpServer)1 DynamicStringProperty (com.netflix.config.DynamicStringProperty)1 Server (com.netflix.loadbalancer.Server)1