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);
}
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");
}
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");
}
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());
}
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");
}
Aggregations