use of io.zeebe.broker.topic.StreamProcessorControl in project zeebe by zeebe-io.
the class CreateDeploymentStreamProcessorTest method shouldTimeOutDeploymentAfterStreamProcessorRestart.
@Test
public void shouldTimeOutDeploymentAfterStreamProcessorRestart() {
// given
rule.getClock().pinCurrentTime();
final StreamProcessorControl control = rule.runStreamProcessor(this::buildStreamProcessor);
control.blockAfterDeploymentEvent(e -> e.getValue().getState() == DeploymentState.VALIDATED);
rule.writeEvent(partitionCreated(STREAM_NAME, 1));
rule.writeEvent(topicCreated(STREAM_NAME, 1));
rule.writeEvent(createDeployment(ONE_TASK_PROCESS));
waitUntil(() -> control.isBlocked());
control.restart();
// when
rule.getClock().addTime(DEPLOYMENT_TIMEOUT.plus(Duration.ofSeconds(1)));
// then
waitUntil(() -> rule.events().onlyDeploymentEvents().inState(DeploymentState.TIMED_OUT).count() > 0);
}
use of io.zeebe.broker.topic.StreamProcessorControl in project zeebe by zeebe-io.
the class TaskInstanceStreamProcessorTest method shouldLockOnlyOnce.
@Test
public void shouldLockOnlyOnce() {
// given
rule.getClock().pinCurrentTime();
final long key = 1;
final StreamProcessorControl control = rule.runStreamProcessor(this::buildStreamProcessor);
control.blockAfterTaskEvent(e -> e.getValue().getState() == TaskState.CREATED);
rule.writeEvent(key, create());
waitForEventInState(TaskState.CREATED);
// when
rule.writeEvent(key, lock(nowPlus(Duration.ofSeconds(30))));
rule.writeEvent(key, lock(nowPlus(Duration.ofSeconds(30))));
control.unblock();
// then
waitForEventInState(TaskState.LOCK_REJECTED);
final List<TypedEvent<TaskEvent>> taskEvents = rule.events().onlyTaskEvents().collect(Collectors.toList());
assertThat(taskEvents).extracting("value.state").containsExactly(TaskState.CREATE, TaskState.CREATED, TaskState.LOCK, TaskState.LOCK, TaskState.LOCKED, TaskState.LOCK_REJECTED);
}
use of io.zeebe.broker.topic.StreamProcessorControl in project zeebe by zeebe-io.
the class TaskInstanceStreamProcessorTest method shouldExpireLockOnlyOnce.
@Test
public void shouldExpireLockOnlyOnce() {
// given
final long key = 1;
final StreamProcessorControl control = rule.runStreamProcessor(this::buildStreamProcessor);
rule.writeEvent(key, create());
waitForEventInState(TaskState.CREATED);
control.blockAfterTaskEvent(e -> e.getValue().getState() == TaskState.LOCKED);
rule.writeEvent(key, lock(nowPlus(Duration.ofSeconds(30))));
waitForEventInState(TaskState.LOCKED);
// when
rule.writeEvent(key, expireLock());
rule.writeEvent(key, expireLock());
control.unblock();
// then
waitForEventInState(TaskState.LOCK_EXPIRATION_REJECTED);
final List<TypedEvent<TaskEvent>> taskEvents = rule.events().onlyTaskEvents().collect(Collectors.toList());
assertThat(taskEvents).extracting("value.state").containsExactly(TaskState.CREATE, TaskState.CREATED, TaskState.LOCK, TaskState.LOCKED, TaskState.EXPIRE_LOCK, TaskState.EXPIRE_LOCK, TaskState.LOCK_EXPIRED, TaskState.LOCK_EXPIRATION_REJECTED);
}
Aggregations