Search in sources :

Example 1 with GovernanceConfigurationChangedEvent

use of org.apache.servicecomb.governance.event.GovernanceConfigurationChangedEvent in project java-chassis by ServiceComb.

the class GovernancePropertiesTest method test_match_properties_delete.

@Test
public void test_match_properties_delete() {
    Map<String, TrafficMarker> markers = matchProperties.getParsedEntity();
    Assert.assertEquals(4, markers.size());
    dynamicValues.put("servicecomb.matchGroup.test", "matches:\n" + "  - apiPath:\n" + "      exact: \"/hello2\"\n" + "    name: match0");
    GovernanceEventManager.post(new GovernanceConfigurationChangedEvent(new HashSet<>(dynamicValues.keySet())));
    markers = matchProperties.getParsedEntity();
    Assert.assertEquals(5, markers.size());
    tearDown();
    markers = matchProperties.getParsedEntity();
    Assert.assertEquals(4, markers.size());
}
Also used : TrafficMarker(org.apache.servicecomb.governance.marker.TrafficMarker) GovernanceConfigurationChangedEvent(org.apache.servicecomb.governance.event.GovernanceConfigurationChangedEvent) Test(org.junit.Test)

Example 2 with GovernanceConfigurationChangedEvent

use of org.apache.servicecomb.governance.event.GovernanceConfigurationChangedEvent in project java-chassis by ServiceComb.

the class GovernancePropertiesTest method test_bulkhead_properties_bound.

@Test
public void test_bulkhead_properties_bound() {
    dynamicValues.put("servicecomb.bulkhead.test-bulkhead1", "rules:\n" + "maxConcurrentCalls: 0\n" + "maxWaitDuration: 2000");
    dynamicValues.put("servicecomb.bulkhead.test-bulkhead2", "rules:\n" + "maxConcurrentCalls: 1000\n" + "maxWaitDuration: 0");
    dynamicValues.put("servicecomb.bulkhead.test-bulkhead3", "rules:\n" + "maxConcurrentCalls: 0\n" + "maxWaitDuration: 2S");
    GovernanceEventManager.post(new GovernanceConfigurationChangedEvent(new HashSet<>(dynamicValues.keySet())));
    Map<String, BulkheadPolicy> policies = bulkheadProperties.getParsedEntity();
    Assert.assertEquals(4, policies.size());
    BulkheadPolicy policy = policies.get("test-bulkhead1");
    Assert.assertEquals(0, policy.getMaxConcurrentCalls());
    Assert.assertEquals(2000, Duration.parse(policy.getMaxWaitDuration()).toMillis());
    policy = policies.get("test-bulkhead2");
    Assert.assertEquals(1000, policy.getMaxConcurrentCalls());
    Assert.assertEquals(0, Duration.parse(policy.getMaxWaitDuration()).toMillis());
    Assert.assertEquals("test-bulkhead2", policy.getName());
    policy = policies.get("test-bulkhead3");
    Assert.assertEquals(0, policy.getMaxConcurrentCalls());
    Assert.assertEquals(2000, Duration.parse(policy.getMaxWaitDuration()).toMillis());
    Assert.assertEquals("test-bulkhead3", policy.getName());
}
Also used : GovernanceConfigurationChangedEvent(org.apache.servicecomb.governance.event.GovernanceConfigurationChangedEvent) Test(org.junit.Test)

Example 3 with GovernanceConfigurationChangedEvent

use of org.apache.servicecomb.governance.event.GovernanceConfigurationChangedEvent in project java-chassis by ServiceComb.

the class GovernancePropertiesTest method test_circuit_breaker_properties_Of_windows_size.

@Test
public void test_circuit_breaker_properties_Of_windows_size() {
    dynamicValues.put("servicecomb.circuitBreaker.name1", "rules:\n" + "slidingWindowType: count\n" + "slidingWindowSize: 2");
    dynamicValues.put("servicecomb.circuitBreaker.name2", "rules:\n" + "slidingWindowType: time\n" + "slidingWindowSize: 2");
    dynamicValues.put("servicecomb.circuitBreaker.name3", "rules:\n" + "slidingWindowType: test\n" + "slidingWindowSize: 1M");
    GovernanceEventManager.post(new GovernanceConfigurationChangedEvent(new HashSet<>(dynamicValues.keySet())));
    Map<String, CircuitBreakerPolicy> policies = circuitBreakerProperties.getParsedEntity();
    Assert.assertEquals(4, policies.size());
    CircuitBreakerPolicy policy = policies.get("name1");
    Assert.assertEquals("count", policy.getSlidingWindowType());
    Assert.assertEquals("2", policy.getSlidingWindowSize());
    policy = policies.get("name2");
    Assert.assertEquals("time", policy.getSlidingWindowType());
    Assert.assertEquals("2", policy.getSlidingWindowSize());
    policy = policies.get("name3");
    Assert.assertEquals("60", policy.getSlidingWindowSize());
}
Also used : GovernanceConfigurationChangedEvent(org.apache.servicecomb.governance.event.GovernanceConfigurationChangedEvent) Test(org.junit.Test)

Example 4 with GovernanceConfigurationChangedEvent

use of org.apache.servicecomb.governance.event.GovernanceConfigurationChangedEvent in project incubator-servicecomb-java-chassis by apache.

the class GovernancePropertiesTest method test_match_properties_delete.

@Test
public void test_match_properties_delete() {
    Map<String, TrafficMarker> markers = matchProperties.getParsedEntity();
    Assert.assertEquals(4, markers.size());
    dynamicValues.put("servicecomb.matchGroup.test", "matches:\n" + "  - apiPath:\n" + "      exact: \"/hello2\"\n" + "    name: match0");
    GovernanceEventManager.post(new GovernanceConfigurationChangedEvent(new HashSet<>(dynamicValues.keySet())));
    markers = matchProperties.getParsedEntity();
    Assert.assertEquals(5, markers.size());
    tearDown();
    markers = matchProperties.getParsedEntity();
    Assert.assertEquals(4, markers.size());
}
Also used : TrafficMarker(org.apache.servicecomb.governance.marker.TrafficMarker) GovernanceConfigurationChangedEvent(org.apache.servicecomb.governance.event.GovernanceConfigurationChangedEvent) Test(org.junit.Test)

Example 5 with GovernanceConfigurationChangedEvent

use of org.apache.servicecomb.governance.event.GovernanceConfigurationChangedEvent in project incubator-servicecomb-java-chassis by apache.

the class GovernancePropertiesTest method test_bulkhead_properties_changed.

@Test
public void test_bulkhead_properties_changed() {
    dynamicValues.put("servicecomb.bulkhead.demo-bulkhead", "rules:\n" + "maxConcurrentCalls: 2\n" + "maxWaitDuration: 2000");
    dynamicValues.put("servicecomb.bulkhead.bulkhead1", "rules:\n" + "maxConcurrentCalls: 3\n" + "maxWaitDuration: 3000");
    GovernanceEventManager.post(new GovernanceConfigurationChangedEvent(new HashSet<>(dynamicValues.keySet())));
    Map<String, BulkheadPolicy> policies = bulkheadProperties.getParsedEntity();
    Assert.assertEquals(2, policies.size());
    BulkheadPolicy policy = policies.get("demo-bulkhead");
    Assert.assertEquals(2, policy.getMaxConcurrentCalls());
    Assert.assertEquals(2000, Duration.parse(policy.getMaxWaitDuration()).toMillis());
    policies = bulkheadProperties.getParsedEntity();
    Assert.assertEquals(2, policies.size());
    policy = policies.get("bulkhead1");
    Assert.assertEquals(3, policy.getMaxConcurrentCalls());
    Assert.assertEquals(3000, Duration.parse(policy.getMaxWaitDuration()).toMillis());
    Assert.assertEquals("bulkhead1", policy.getName());
}
Also used : GovernanceConfigurationChangedEvent(org.apache.servicecomb.governance.event.GovernanceConfigurationChangedEvent) Test(org.junit.Test)

Aggregations

GovernanceConfigurationChangedEvent (org.apache.servicecomb.governance.event.GovernanceConfigurationChangedEvent)18 Test (org.junit.Test)14 TrafficMarker (org.apache.servicecomb.governance.marker.TrafficMarker)4 Subscribe (com.google.common.eventbus.Subscribe)2 HashSet (java.util.HashSet)2 Matcher (org.apache.servicecomb.governance.marker.Matcher)2 After (org.junit.After)2