use of org.apache.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class TestBizkeeperCommand method testResumeWithFallbackProvider.
@Test
public void testResumeWithFallbackProvider() {
Invocation invocation = Mockito.mock(Invocation.class);
Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");
HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter().withRequestCacheEnabled(true).withRequestLogEnabled(false);
BizkeeperCommand bizkeeperCommand = new ProviderBizkeeperCommand("groupname", invocation, HystrixObservableCommand.Setter.withGroupKey(CommandKey.toHystrixCommandGroupKey("groupname", invocation)).andCommandKey(CommandKey.toHystrixCommandKey("groupname", invocation)).andCommandPropertiesDefaults(setter));
Observable<Response> observe = bizkeeperCommand.resumeWithFallback();
Assert.assertNotNull(observe);
}
use of org.apache.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class TestBizkeeperCommand method testResumeWithFallbackConsumer.
@Test
public void testResumeWithFallbackConsumer() {
Invocation invocation = Mockito.mock(Invocation.class);
Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");
HystrixCommandProperties.Setter setter = HystrixCommandProperties.Setter().withRequestCacheEnabled(true).withRequestLogEnabled(false);
BizkeeperCommand bizkeeperCommand = new ConsumerBizkeeperCommand("groupname", invocation, HystrixObservableCommand.Setter.withGroupKey(CommandKey.toHystrixCommandGroupKey("groupname", invocation)).andCommandKey(CommandKey.toHystrixCommandKey("groupname", invocation)).andCommandPropertiesDefaults(setter));
Observable<Response> observe = bizkeeperCommand.resumeWithFallback();
Assert.assertNotNull(observe);
}
use of org.apache.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class TestCommandKey method testToHystrixCommandKey.
@Test
public void testToHystrixCommandKey() {
Invocation invocation = Mockito.mock(Invocation.class);
Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");
Assert.assertNotNull(invocation);
HystrixCommandKey hystrixCommandGroupKey = CommandKey.toHystrixCommandKey("groupname", invocation);
Assert.assertNotNull(hystrixCommandGroupKey);
}
use of org.apache.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class TestConsumerBizkeeperHandler method testCreateBizkeeperCommand.
@Test
public void testCreateBizkeeperCommand() {
HystrixPlugins.reset();
ConsumerBizkeeperHandler consumerBizkeeperHandler = new ConsumerBizkeeperHandler();
Invocation invocation = Mockito.mock(Invocation.class);
Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
Mockito.when(invocation.getOperationMeta().getMicroserviceQualifiedName()).thenReturn("test1");
CommandKey.toHystrixCommandGroupKey("groupname", invocation);
CommandKey.toHystrixCommandKey("groupname", invocation);
BizkeeperCommand command = consumerBizkeeperHandler.createBizkeeperCommand(invocation);
Assert.assertNotNull(command);
}
use of org.apache.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class TestConfiguration method testConfiguration.
@Test
public void testConfiguration() {
assertNotNull(Configuration.INSTANCE);
assertEquals("returnnull", Configuration.FALLBACKPOLICY_POLICY_RETURN);
assertEquals("throwexception", Configuration.FALLBACKPOLICY_POLICY_THROW);
Configuration c = Configuration.INSTANCE;
Invocation invocation = Mockito.mock(Invocation.class);
String test2 = invocation.getMicroserviceName();
Mockito.when(invocation.getOperationMeta()).thenReturn(Mockito.mock(OperationMeta.class));
Mockito.when(invocation.getOperationMeta().getMicroserviceName()).thenReturn("testqualify");
int res = c.getIsolationTimeoutInMilliseconds("groupname", test2, "testqualify");
assertEquals(30000, res);
boolean b1 = c.getIsolationTimeoutEnabled("groupname", test2, "testqualify");
assertFalse(b1);
int res1 = c.getIsolationMaxConcurrentRequests("groupname", test2, "testqualify");
assertEquals(1000, res1);
boolean b2 = c.isCircuitBreakerEnabled("groupname", test2, "testqualify");
assertTrue(b2);
String str = c.getFallbackPolicyPolicy("groupname", test2, "testqualify");
// no need to give default value now
assertEquals(null, str);
assertFalse(c.isCircuitBreakerForceOpen("groupname", test2, "testqualify"));
assertFalse(c.isCircuitBreakerForceClosed("groupname", test2, "testqualify"));
assertEquals(15000, c.getCircuitBreakerSleepWindowInMilliseconds("groupname", test2, "testqualify"));
assertEquals(20, c.getCircuitBreakerRequestVolumeThreshold("groupname", test2, "testqualify"));
assertEquals(50, c.getCircuitBreakerErrorThresholdPercentage("groupname", test2, "testqualify"));
}
Aggregations