use of com.hazelcast.jet.core.TestProcessors.MockP in project hazelcast by hazelcast.
the class ExecutionLifecycleTest method when_processorCooperativeCompleteThrows_then_failJob.
@Test
public void when_processorCooperativeCompleteThrows_then_failJob() {
// Given
DAG dag = new DAG();
dag.newVertex("faulty", new MockPMS(() -> new MockPS(() -> new MockP().setCompleteError(MOCK_ERROR), MEMBER_COUNT)));
// When
Job job = runJobExpectFailure(dag, false);
// Then
assertPClosedWithError();
assertPsClosedWithError();
assertPmsClosedWithError();
assertJobFailed(job, MOCK_ERROR);
}
use of com.hazelcast.jet.core.TestProcessors.MockP in project hazelcast by hazelcast.
the class JobTest method when_lightJob_then_unsupportedMethodsThrow.
// ### Tests for light jobs
@Test
public void when_lightJob_then_unsupportedMethodsThrow() {
DAG streamingDag = new DAG();
streamingDag.newVertex("v", () -> new MockP().streaming());
// When
Job job = instance().getJet().newLightJob(streamingDag);
// Then
assertThatThrownBy(job::getSuspensionCause).isInstanceOf(UnsupportedOperationException.class);
assertThatThrownBy(job::getMetrics).isInstanceOf(UnsupportedOperationException.class);
assertThatThrownBy(job::restart).isInstanceOf(UnsupportedOperationException.class);
assertThatThrownBy(job::suspend).isInstanceOf(UnsupportedOperationException.class);
assertThatThrownBy(job::resume).isInstanceOf(UnsupportedOperationException.class);
assertThatThrownBy(() -> job.cancelAndExportSnapshot("foo")).isInstanceOf(UnsupportedOperationException.class);
assertThatThrownBy(() -> job.exportSnapshot("foo")).isInstanceOf(UnsupportedOperationException.class);
}
use of com.hazelcast.jet.core.TestProcessors.MockP in project hazelcast by hazelcast.
the class MemberReconnectionTest method when_connectionDropped_then_detectedInReceiverTaskletAndFails.
@Test
public void when_connectionDropped_then_detectedInReceiverTaskletAndFails() {
// we use real-network instances, closing the mock connection doesn't cause them to reconnect
Config config = smallInstanceConfig();
config.setClusterName(randomName());
HazelcastInstance inst1 = createHazelcastInstance(config);
HazelcastInstance inst2 = createHazelcastInstance(config);
DAG dag = new DAG();
Vertex v1 = dag.newVertex("v1", () -> new MockP().streaming());
Vertex v2 = dag.newVertex("v2", () -> new MockP());
dag.edge(between(v1, v2).distributed());
Job job = inst1.getJet().newJob(dag);
long executionId = assertJobRunningEventually(inst1, job, null);
// Close the connection. Nothing is sent through the SenderTasklet, therefore we won't detect
// it there. We rely on detecting it in ReceiverTasklet, we assert that it was detected there.
logger.info("closing the connection...");
ImdgUtil.getMemberConnection(getNodeEngineImpl(inst1), getNodeEngineImpl(inst2).getThisAddress()).close("mock close", new Exception("mock close"));
// assert that the job was restarted
assertJobRunningEventually(inst1, job, executionId);
}
use of com.hazelcast.jet.core.TestProcessors.MockP in project hazelcast by hazelcast.
the class ExecutionLifecycleTest method when_pmsCloseThrows_then_jobSucceeds.
@Test
public void when_pmsCloseThrows_then_jobSucceeds() {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPMS(() -> new MockPS(MockP::new, MEMBER_COUNT)).setCloseError(MOCK_ERROR)));
// When
Job job = newJob(dag);
job.join();
// Then
assertPClosedWithoutError();
assertPsClosedWithoutError();
assertPmsClosedWithoutError();
assertJobSucceeded(job);
}
use of com.hazelcast.jet.core.TestProcessors.MockP in project hazelcast by hazelcast.
the class JobTest method when_jobFailed_then_jobStatusIsCompletedEventually.
@Test
public void when_jobFailed_then_jobStatusIsCompletedEventually() throws InterruptedException {
// Given
DAG dag = new DAG().vertex(new Vertex("test", new MockPS((SupplierEx<Processor>) () -> new MockP().setCompleteError(new ExpectedRuntimeException()), NODE_COUNT)));
// When
Job job = instance().getJet().newJob(dag);
// Then
try {
job.getFuture().get();
fail();
} catch (ExecutionException expected) {
assertEquals(FAILED, job.getStatus());
}
}
Aggregations