use of com.alibaba.csp.sentinel.node.EntranceNode in project Sentinel by alibaba.
the class ClientFilterTest method testClientGetHello.
@Test
public void testClientGetHello() {
final String url = "/test/hello";
String resourceName = "GET:" + url;
Response response = SentinelJaxRsClientTemplate.execute(resourceName, new Supplier<Response>() {
@Override
public Response get() {
return client.target(host).path(url).request().get();
}
});
assertEquals(200, response.getStatus());
assertEquals(HELLO_STR, response.readEntity(String.class));
ClusterNode cn = ClusterBuilderSlot.getClusterNode(resourceName);
assertNotNull(cn);
assertEquals(1, cn.passQps(), 0.01);
String context = "";
for (Node n : Constants.ROOT.getChildList()) {
if (n instanceof EntranceNode) {
String id = ((EntranceNode) n).getId().getName();
if (url.equals(id)) {
context = ((EntranceNode) n).getId().getName();
}
}
}
assertEquals("", context);
}
use of com.alibaba.csp.sentinel.node.EntranceNode in project Sentinel by alibaba.
the class ProviderFilterTest method testGetHello.
@Test
public void testGetHello() {
String url = "/test/hello";
String resourceName = "GET:" + url;
Response response = given().get(url);
response.then().statusCode(200).body(equalTo(HELLO_STR));
ClusterNode cn = ClusterBuilderSlot.getClusterNode(resourceName);
assertNotNull(cn);
assertEquals(1, cn.passQps(), 0.01);
String context = "";
for (Node n : Constants.ROOT.getChildList()) {
if (n instanceof EntranceNode) {
String id = ((EntranceNode) n).getId().getName();
if (url.equals(id)) {
context = ((EntranceNode) n).getId().getName();
}
}
}
assertEquals("", context);
}
use of com.alibaba.csp.sentinel.node.EntranceNode in project Sentinel by alibaba.
the class ProviderFilterTest method testAsyncGetHello.
@Test
public void testAsyncGetHello() {
String url = "/test/async-hello";
String resourceName = "GET:" + url;
Response response = given().get(url);
response.then().statusCode(200).body(equalTo(HELLO_STR));
ClusterNode cn = ClusterBuilderSlot.getClusterNode(resourceName);
assertNotNull(cn);
assertEquals(1, cn.passQps(), 0.01);
String context = "";
for (Node n : Constants.ROOT.getChildList()) {
if (n instanceof EntranceNode) {
String id = ((EntranceNode) n).getId().getName();
if (url.equals(id)) {
context = ((EntranceNode) n).getId().getName();
}
}
}
assertEquals("", context);
}
use of com.alibaba.csp.sentinel.node.EntranceNode in project Sentinel by alibaba.
the class MonoSentinelOperatorIntegrationTest method testTransformMonoWithSentinelContextEnter.
@Test
public void testTransformMonoWithSentinelContextEnter() {
String resourceName = createResourceName("testTransformMonoWithSentinelContextEnter");
String contextName = "test_reactive_context";
String origin = "originA";
FlowRuleManager.loadRules(Collections.singletonList(new FlowRule(resourceName).setCount(0).setLimitApp(origin).as(FlowRule.class)));
StepVerifier.create(Mono.just(2).transform(new SentinelReactorTransformer<>(// Customized context with origin.
new EntryConfig(resourceName, EntryType.OUT, new ContextConfig(contextName, origin))))).expectError(BlockException.class).verify();
ClusterNode cn = ClusterBuilderSlot.getClusterNode(resourceName);
assertNotNull(cn);
assertEquals(0, cn.passQps(), 0.01);
assertEquals(1, cn.blockRequest());
assertTrue(Constants.ROOT.getChildList().stream().filter(node -> node instanceof EntranceNode).map(e -> (EntranceNode) e).anyMatch(e -> e.getId().getName().equals(contextName)));
FlowRuleManager.loadRules(new ArrayList<>());
}
use of com.alibaba.csp.sentinel.node.EntranceNode in project Sentinel by alibaba.
the class SentinelJaxRsQuarkusAdapterTest method testGetHello.
@Test
public void testGetHello() {
String url = "/test/hello";
String resourceName = "GET:" + url;
Response response = given().get(url);
response.then().statusCode(200).body(equalTo(HELLO_STR));
ClusterNode cn = ClusterBuilderSlot.getClusterNode(resourceName);
assertNotNull(cn);
assertEquals(1, cn.passQps(), 0.01);
String context = "";
for (Node n : Constants.ROOT.getChildList()) {
if (n instanceof EntranceNode) {
String id = ((EntranceNode) n).getId().getName();
if (url.equals(id)) {
context = ((EntranceNode) n).getId().getName();
}
}
}
assertEquals("", context);
}
Aggregations