Search in sources :

Example 1 with InflightActivateJobsRequest

use of io.camunda.zeebe.gateway.impl.job.InflightActivateJobsRequest in project zeebe by camunda.

the class LongPollingActivateJobsTest method shouldProbeIfNoNotificationReceived.

@Test
public void shouldProbeIfNoNotificationReceived() throws Exception {
    // given
    final long probeTimeout = 2000;
    handler = LongPollingActivateJobsHandler.newBuilder().setBrokerClient(brokerClient).setLongPollingTimeout(20000).setProbeTimeoutMillis(probeTimeout).build();
    submitActorToActivateJobs(handler);
    final InflightActivateJobsRequest request = getLongPollingActivateJobsRequest();
    handler.activateJobs(request);
    waitUntil(request::hasScheduledTimer);
    // when
    actorClock.addTime(Duration.ofMillis(probeTimeout));
    // then
    verify(activateJobsStub, timeout(2000).times(2 * partitionsCount)).handle(any());
}
Also used : InflightActivateJobsRequest(io.camunda.zeebe.gateway.impl.job.InflightActivateJobsRequest) Test(org.junit.Test)

Example 2 with InflightActivateJobsRequest

use of io.camunda.zeebe.gateway.impl.job.InflightActivateJobsRequest in project zeebe by camunda.

the class LongPollingActivateJobsTest method shouldNotBlockWhenNegativeTimeout.

@Test
public void shouldNotBlockWhenNegativeTimeout() {
    // given
    final InflightActivateJobsRequest request = new InflightActivateJobsRequest(getNextRequestId(), ActivateJobsRequest.newBuilder().setType(TYPE).setMaxJobsToActivate(1).setRequestTimeout(-1).build(), spy(ServerStreamObserver.class));
    // when
    handler.activateJobs(request);
    verify(request.getResponseObserver(), timeout(1000).times(1)).onCompleted();
    // then
    assertThat(request.hasScheduledTimer()).isFalse();
    assertThat(request.isTimedOut()).isFalse();
}
Also used : InflightActivateJobsRequest(io.camunda.zeebe.gateway.impl.job.InflightActivateJobsRequest) ServerStreamObserver(io.camunda.zeebe.gateway.grpc.ServerStreamObserver) Test(org.junit.Test)

Example 3 with InflightActivateJobsRequest

use of io.camunda.zeebe.gateway.impl.job.InflightActivateJobsRequest in project zeebe by camunda.

the class LongPollingActivateJobsTest method shouldBlockImmediatelyAfterThreshold.

@Test
public void shouldBlockImmediatelyAfterThreshold() throws Exception {
    // given
    final int amount = FAILED_RESPONSE_THRESHOLD;
    activateJobsAndWaitUntilBlocked(amount);
    // when
    final InflightActivateJobsRequest request = getLongPollingActivateJobsRequest();
    handler.activateJobs(request);
    waitUntil(request::hasScheduledTimer);
    // then
    verify(activateJobsStub, times(amount * partitionsCount)).handle(any());
}
Also used : InflightActivateJobsRequest(io.camunda.zeebe.gateway.impl.job.InflightActivateJobsRequest) Test(org.junit.Test)

Example 4 with InflightActivateJobsRequest

use of io.camunda.zeebe.gateway.impl.job.InflightActivateJobsRequest in project zeebe by camunda.

the class LongPollingActivateJobsTest method shouldBlockRequestsWhenResponseHasNoJobs.

@Test
public void shouldBlockRequestsWhenResponseHasNoJobs() {
    // given
    final InflightActivateJobsRequest request = getLongPollingActivateJobsRequest();
    // when
    handler.activateJobs(request);
    // then
    waitUntil(request::hasScheduledTimer);
    verify(request.getResponseObserver(), times(0)).onCompleted();
}
Also used : InflightActivateJobsRequest(io.camunda.zeebe.gateway.impl.job.InflightActivateJobsRequest) Test(org.junit.Test)

Example 5 with InflightActivateJobsRequest

use of io.camunda.zeebe.gateway.impl.job.InflightActivateJobsRequest in project zeebe by camunda.

the class LongPollingActivateJobsTest method shouldCompleteAfterRequestTimeout.

@Test
public void shouldCompleteAfterRequestTimeout() {
    // given
    final InflightActivateJobsRequest longPollingRequest = getLongPollingActivateJobsRequest();
    // when
    handler.activateJobs(longPollingRequest);
    waitUntil(longPollingRequest::hasScheduledTimer);
    actorClock.addTime(Duration.ofMillis(LONG_POLLING_TIMEOUT));
    waitUntil(longPollingRequest::isTimedOut);
    // then
    verify(longPollingRequest.getResponseObserver(), times(1)).onCompleted();
}
Also used : InflightActivateJobsRequest(io.camunda.zeebe.gateway.impl.job.InflightActivateJobsRequest) Test(org.junit.Test)

Aggregations

InflightActivateJobsRequest (io.camunda.zeebe.gateway.impl.job.InflightActivateJobsRequest)54 Test (org.junit.Test)54 ServerStreamObserver (io.camunda.zeebe.gateway.grpc.ServerStreamObserver)18 BrokerActivateJobsRequest (io.camunda.zeebe.gateway.impl.broker.request.BrokerActivateJobsRequest)18 BrokerRejectionException (io.camunda.zeebe.gateway.cmd.BrokerRejectionException)15 BrokerResponse (io.camunda.zeebe.gateway.impl.broker.response.BrokerResponse)15 StatusException (io.grpc.StatusException)15 BrokerError (io.camunda.zeebe.gateway.impl.broker.response.BrokerError)12 ActivateJobsResponse (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsResponse)12 BrokerRejection (io.camunda.zeebe.gateway.impl.broker.response.BrokerRejection)6 ActivateJobsRequest (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsRequest)6 StubbedBrokerClient (io.camunda.zeebe.gateway.api.util.StubbedBrokerClient)3 RequestHandler (io.camunda.zeebe.gateway.api.util.StubbedBrokerClient.RequestHandler)3 BrokerFailJobRequest (io.camunda.zeebe.gateway.impl.broker.request.BrokerFailJobRequest)3 BrokerErrorResponse (io.camunda.zeebe.gateway.impl.broker.response.BrokerErrorResponse)3 BrokerRejectionResponse (io.camunda.zeebe.gateway.impl.broker.response.BrokerRejectionResponse)3 LongPollingActivateJobsHandler (io.camunda.zeebe.gateway.impl.job.LongPollingActivateJobsHandler)3 ActivatedJob (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivatedJob)3 JobBatchRecord (io.camunda.zeebe.protocol.impl.record.value.job.JobBatchRecord)3 ErrorCode (io.camunda.zeebe.protocol.record.ErrorCode)3