Search in sources :

Example 1 with TrafficMarker

use of org.apache.servicecomb.governance.marker.TrafficMarker 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 TrafficMarker

use of org.apache.servicecomb.governance.marker.TrafficMarker in project incubator-servicecomb-java-chassis by apache.

the class GovernancePropertiesTest method test_match_properties_successfully_loaded.

@Test
public void test_match_properties_successfully_loaded() {
    Map<String, TrafficMarker> markers = matchProperties.getParsedEntity();
    Assert.assertEquals(4, markers.size());
    TrafficMarker demoRateLimiting = markers.get("demo-rateLimiting");
    List<Matcher> matchers = demoRateLimiting.getMatches();
    Assert.assertEquals(1, matchers.size());
    Matcher matcher = matchers.get(0);
    Assert.assertEquals("/hello", matcher.getApiPath().get("exact"));
    TrafficMarker demoBulkhead = markers.get("demo-bulkhead");
    matchers = demoBulkhead.getMatches();
    Assert.assertEquals(2, matchers.size());
    matcher = matchers.get(0);
    Assert.assertEquals("/bulkhead", matcher.getApiPath().get("exact"));
    Assert.assertEquals("matchPath", matcher.getName());
}
Also used : Matcher(org.apache.servicecomb.governance.marker.Matcher) TrafficMarker(org.apache.servicecomb.governance.marker.TrafficMarker) Test(org.junit.Test)

Example 3 with TrafficMarker

use of org.apache.servicecomb.governance.marker.TrafficMarker 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 4 with TrafficMarker

use of org.apache.servicecomb.governance.marker.TrafficMarker in project java-chassis by ServiceComb.

the class MatchersServiceImpl method checkMatch.

@Override
public boolean checkMatch(GovernanceRequest governanceRequest, String key) {
    Map<String, TrafficMarker> parsedEntity = matchProperties.getParsedEntity();
    TrafficMarker trafficMarker = parsedEntity.get(key);
    if (trafficMarker == null) {
        return false;
    }
    return trafficMarker.checkMatch(governanceRequest, requestProcessor);
}
Also used : TrafficMarker(org.apache.servicecomb.governance.marker.TrafficMarker)

Example 5 with TrafficMarker

use of org.apache.servicecomb.governance.marker.TrafficMarker in project java-chassis by ServiceComb.

the class GovernancePropertiesTest method test_match_properties_successfully_loaded.

@Test
public void test_match_properties_successfully_loaded() {
    Map<String, TrafficMarker> markers = matchProperties.getParsedEntity();
    Assert.assertEquals(4, markers.size());
    TrafficMarker demoRateLimiting = markers.get("demo-rateLimiting");
    List<Matcher> matchers = demoRateLimiting.getMatches();
    Assert.assertEquals(1, matchers.size());
    Matcher matcher = matchers.get(0);
    Assert.assertEquals("/hello", matcher.getApiPath().get("exact"));
    TrafficMarker demoBulkhead = markers.get("demo-bulkhead");
    matchers = demoBulkhead.getMatches();
    Assert.assertEquals(2, matchers.size());
    matcher = matchers.get(0);
    Assert.assertEquals("/bulkhead", matcher.getApiPath().get("exact"));
    Assert.assertEquals("matchPath", matcher.getName());
}
Also used : Matcher(org.apache.servicecomb.governance.marker.Matcher) TrafficMarker(org.apache.servicecomb.governance.marker.TrafficMarker) Test(org.junit.Test)

Aggregations

TrafficMarker (org.apache.servicecomb.governance.marker.TrafficMarker)8 Test (org.junit.Test)6 GovernanceConfigurationChangedEvent (org.apache.servicecomb.governance.event.GovernanceConfigurationChangedEvent)4 Matcher (org.apache.servicecomb.governance.marker.Matcher)4