Search in sources :

Example 16 with AbstractConfiguration

use of org.apache.commons.configuration.AbstractConfiguration in project incubator-servicecomb-java-chassis by apache.

the class TestRegistry method initSetup.

@BeforeClass
public static void initSetup() throws Exception {
    AbstractConfiguration dynamicConfig = ConfigUtil.createDynamicConfig();
    ConcurrentCompositeConfiguration configuration = new ConcurrentCompositeConfiguration();
    configuration.addConfiguration(dynamicConfig);
    configuration.addConfiguration(inMemoryConfig);
    ConfigurationManager.install(configuration);
}
Also used : AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) ConcurrentCompositeConfiguration(com.netflix.config.ConcurrentCompositeConfiguration) BeforeClass(org.junit.BeforeClass)

Example 17 with AbstractConfiguration

use of org.apache.commons.configuration.AbstractConfiguration in project incubator-servicecomb-java-chassis by apache.

the class TestMicroServiceInstance method testCreateMicroserviceInstanceFromFile.

@Test
public void testCreateMicroserviceInstanceFromFile() {
    AbstractConfiguration config = ConfigUtil.createDynamicConfig();
    ConcurrentCompositeConfiguration configuration = new ConcurrentCompositeConfiguration();
    configuration.addConfiguration(config);
    ConfigurationManager.install(configuration);
    MicroserviceInstance instance = MicroserviceInstance.createFromDefinition(config);
    Assert.assertEquals(instance.getDataCenterInfo().getName(), "myDC");
    Assert.assertEquals(instance.getDataCenterInfo().getRegion(), "my-Region");
    Assert.assertEquals(instance.getDataCenterInfo().getAvailableZone(), "my-Zone");
}
Also used : AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) ConcurrentCompositeConfiguration(com.netflix.config.ConcurrentCompositeConfiguration) Test(org.junit.Test)

Example 18 with AbstractConfiguration

use of org.apache.commons.configuration.AbstractConfiguration in project incubator-servicecomb-java-chassis by apache.

the class TestIsolationServerListFilter method setUp.

@Before
public void setUp() throws Exception {
    IsolationServerListFilter = new IsolationServerListFilter();
    loadBalancerStats = new LoadBalancerStats("loadBalancer");
    AbstractConfiguration configuration = (AbstractConfiguration) DynamicPropertyFactory.getBackingConfigurationSource();
    configuration.clearProperty("cse.loadbalance.isolation.enabled");
    configuration.addProperty("cse.loadbalance.isolation.enabled", "true");
    configuration.clearProperty("cse.loadbalance.isolation.enableRequestThreshold");
    configuration.addProperty("cse.loadbalance.isolation.enableRequestThreshold", "3");
}
Also used : AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) LoadBalancerStats(com.netflix.loadbalancer.LoadBalancerStats) Before(org.junit.Before)

Example 19 with AbstractConfiguration

use of org.apache.commons.configuration.AbstractConfiguration in project incubator-servicecomb-java-chassis by apache.

the class TestIsolationServerListFilter method testGetFilteredListOfServersOnContinuousFailureIsBelowThreshold.

@Test
public void testGetFilteredListOfServersOnContinuousFailureIsBelowThreshold() {
    ((AbstractConfiguration) DynamicPropertyFactory.getBackingConfigurationSource()).addProperty("cse.loadbalance.isolation.continuousFailureThreshold", "3");
    Invocation invocation = Mockito.mock(Invocation.class);
    CseServer testServer = Mockito.mock(CseServer.class);
    Mockito.when(invocation.getMicroserviceName()).thenReturn("microserviceName");
    Mockito.when(testServer.getCountinuousFailureCount()).thenReturn(2);
    Mockito.when(testServer.getLastVisitTime()).thenReturn(System.currentTimeMillis());
    for (int i = 0; i < 3; ++i) {
        loadBalancerStats.incrementNumRequests(testServer);
    }
    List<Server> serverList = new ArrayList<>();
    serverList.add(testServer);
    IsolationServerListFilter.setLoadBalancerStats(loadBalancerStats);
    IsolationServerListFilter.setInvocation(invocation);
    List<Server> returnedServerList = IsolationServerListFilter.getFilteredListOfServers(serverList);
    Assert.assertEquals(1, returnedServerList.size());
}
Also used : AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) Invocation(org.apache.servicecomb.core.Invocation) CseServer(org.apache.servicecomb.loadbalance.CseServer) CseServer(org.apache.servicecomb.loadbalance.CseServer) Server(com.netflix.loadbalancer.Server) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 20 with AbstractConfiguration

use of org.apache.commons.configuration.AbstractConfiguration in project incubator-servicecomb-java-chassis by apache.

the class TestIsolationServerListFilter method tearDown.

@After
public void tearDown() throws Exception {
    IsolationServerListFilter = null;
    loadBalancerStats = null;
    AbstractConfiguration configuration = (AbstractConfiguration) DynamicPropertyFactory.getBackingConfigurationSource();
    configuration.clearProperty("cse.loadbalance.isolation.continuousFailureThreshold");
}
Also used : AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) After(org.junit.After)

Aggregations

AbstractConfiguration (org.apache.commons.configuration.AbstractConfiguration)80 Test (org.junit.Test)29 ConcurrentCompositeConfiguration (com.netflix.config.ConcurrentCompositeConfiguration)18 BeforeClass (org.junit.BeforeClass)10 Configuration (org.apache.commons.configuration.Configuration)9 URI (java.net.URI)6 BaseConfiguration (org.apache.commons.configuration.BaseConfiguration)6 HttpRequest (com.netflix.client.http.HttpRequest)5 ArrayList (java.util.ArrayList)5 DynamicConfiguration (com.netflix.config.DynamicConfiguration)4 EnvironmentConfiguration (org.apache.commons.configuration.EnvironmentConfiguration)4 SystemConfiguration (org.apache.commons.configuration.SystemConfiguration)4 HttpResponse (com.netflix.client.http.HttpResponse)3 ConcurrentMapConfiguration (com.netflix.config.ConcurrentMapConfiguration)3 ExpandedConfigurationListenerAdapter (com.netflix.config.ExpandedConfigurationListenerAdapter)3 LinkedHashMap (java.util.LinkedHashMap)3 Properties (java.util.Properties)3 AggregatedConfiguration (com.netflix.config.AggregatedConfiguration)2 ConfigurationManager (com.netflix.config.ConfigurationManager)2 DynamicURLConfiguration (com.netflix.config.DynamicURLConfiguration)2