use of io.scalecube.services.api.ServiceMessage in project scalecube by scalecube.
the class StreamingServiceTest method test_snapshot_completes.
@Test
public void test_snapshot_completes() {
int batchSize = 1000;
ServiceCall serviceCall = gateway.call();
ServiceMessage message = ServiceMessage.builder().qualifier(QuoteService.NAME, "snapshot").data(batchSize).build();
List<ServiceMessage> serviceMessages = serviceCall.requestMany(message).timeout(Duration.ofSeconds(5)).collectList().block();
assertEquals(batchSize, serviceMessages.size());
}
use of io.scalecube.services.api.ServiceMessage in project scalecube by scalecube.
the class StreamingServiceTest method test_unknown_method.
@Test
public void test_unknown_method() {
ServiceCall service = gateway.call();
ServiceMessage scheduled = ServiceMessage.builder().qualifier(QuoteService.NAME, "unknonwn").build();
try {
service.requestMany(scheduled).blockFirst(Duration.ofSeconds(3));
fail("Expected no-reachable-service-exception");
} catch (Exception ex) {
assertTrue(ex.getMessage().contains("No reachable member with such service"));
}
}
use of io.scalecube.services.api.ServiceMessage in project scalecube by scalecube.
the class StreamingServiceTest method test_call_quotes_snapshot.
@Test
public void test_call_quotes_snapshot() {
int batchSize = 1000;
ServiceCall serviceCall = gateway.call();
ServiceMessage message = ServiceMessage.builder().qualifier(QuoteService.NAME, "snapshot").data(batchSize).build();
List<ServiceMessage> serviceMessages = serviceCall.requestMany(message).take(Duration.ofSeconds(5)).collectList().block();
assertEquals(batchSize, serviceMessages.size());
}
use of io.scalecube.services.api.ServiceMessage in project scalecube by scalecube.
the class RoutersTest method test_service_tags.
@Test
public void test_service_tags() throws Exception {
TimeUnit.SECONDS.sleep(3);
ServiceCall service = gateway.call().router(WeightedRandomRouter.class);
ServiceMessage req = ServiceMessage.builder().qualifier(Reflect.serviceName(CanaryService.class), "greeting").data(new GreetingRequest("joe")).build();
AtomicInteger serviceBCount = new AtomicInteger(0);
int n = (int) 1e3;
for (int i = 0; i < n; i++) {
ServiceMessage message = service.requestOne(req, GreetingResponse.class).block(TIMEOUT);
if (message.data().toString().contains("SERVICE_B_TALKING")) {
serviceBCount.incrementAndGet();
}
}
System.out.println("Service B was called: " + serviceBCount.get() + " times out of " + n);
assertTrue((serviceBCount.doubleValue() / n) > 0.5, "Service B's Weight=0.9; at least more than half " + "of invocations have to be routed to Service B");
}
use of io.scalecube.services.api.ServiceMessage in project scalecube by scalecube.
the class ServiceCallLocalTest method test_local_async_no_params.
@Test
public void test_local_async_no_params() {
ServiceCall serviceCall = provider.call().router(RoundRobinServiceRouter.class);
// call the service.
Publisher<ServiceMessage> future = serviceCall.requestOne(GREETING_NO_PARAMS_REQUEST);
ServiceMessage message = Mono.from(future).block(Duration.ofSeconds(TIMEOUT));
assertEquals(GREETING_NO_PARAMS_REQUEST.qualifier(), message.qualifier(), "Didn't get desired response");
}
Aggregations