Search in sources :

Example 51 with NoOutputSourceP

use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.

the class ExecutionLifecycleTest method when_processorCompletesSuccessfully_then_closeCalledImmediately.

@Test
public void when_processorCompletesSuccessfully_then_closeCalledImmediately() {
    DAG dag = new DAG();
    Vertex v1 = dag.newVertex("v1", MockP::new);
    Vertex v2 = dag.newVertex("v2", () -> new NoOutputSourceP());
    dag.edge(between(v1, v2));
    Job job = newJob(dag);
    assertTrueEventually(this::assertPClosedWithoutError);
    NoOutputSourceP.proceedLatch.countDown();
    job.join();
    assertJobSucceeded(job);
}
Also used : MockP(com.hazelcast.jet.core.TestProcessors.MockP) NoOutputSourceP(com.hazelcast.jet.core.TestProcessors.NoOutputSourceP) Job(com.hazelcast.jet.Job) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 52 with NoOutputSourceP

use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.

the class Job_SeparateClusterTest method when_joinFromClientSentToNonMaster_then_futureShouldNotBeCompletedEarly.

@Test
public void when_joinFromClientSentToNonMaster_then_futureShouldNotBeCompletedEarly() throws InterruptedException {
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT)));
    int timeoutSecs = 1;
    Address address = getAddress(instance2);
    ClientConfig config = new ClientConfig().setProperty(ClientProperty.INVOCATION_TIMEOUT_SECONDS.getName(), Integer.toString(timeoutSecs)).setNetworkConfig(new ClientNetworkConfig().setSmartRouting(false).addAddress(address.getHost() + ":" + address.getPort()));
    HazelcastInstance client = createHazelcastClient(config);
    // join request is sent along with job submission
    Job job = client.getJet().newJob(dag);
    NoOutputSourceP.executionStarted.await();
    // wait for join invocation to timeout
    Thread.sleep(TimeUnit.SECONDS.toMillis(timeoutSecs));
    // When
    NoOutputSourceP.initCount.set(0);
    instance1.getLifecycleService().terminate();
    // wait for job to be restarted on remaining node
    assertTrueEventually(() -> assertEquals(LOCAL_PARALLELISM, NoOutputSourceP.initCount.get()));
    RuntimeException ex = new RuntimeException("Faulty job");
    NoOutputSourceP.failure.set(ex);
    // Then
    expectedException.expectMessage(Matchers.containsString(ex.getMessage()));
    job.join();
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Address(com.hazelcast.cluster.Address) NoOutputSourceP(com.hazelcast.jet.core.TestProcessors.NoOutputSourceP) ClientConfig(com.hazelcast.client.config.ClientConfig) Job(com.hazelcast.jet.Job) ClientNetworkConfig(com.hazelcast.client.config.ClientNetworkConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 53 with NoOutputSourceP

use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.

the class Job_SeparateClusterTest method when_suspendedJobScannedOnNewMaster_then_newJobWithEqualNameFails.

@Test
public void when_suspendedJobScannedOnNewMaster_then_newJobWithEqualNameFails() {
    // Given
    DAG dag = new DAG().vertex(new Vertex("test", new MockPS(NoOutputSourceP::new, NODE_COUNT * 2)));
    JobConfig config = new JobConfig().setName("job1");
    // When
    Job job1 = instance1.getJet().newJob(dag, config);
    assertJobStatusEventually(job1, RUNNING);
    job1.suspend();
    assertJobStatusEventually(job1, SUSPENDED);
    // gracefully shutdown the master
    instance1.shutdown();
    // Then
    expectedException.expect(JobAlreadyExistsException.class);
    instance2.getJet().newJob(dag, config);
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) NoOutputSourceP(com.hazelcast.jet.core.TestProcessors.NoOutputSourceP) Job(com.hazelcast.jet.Job) JobConfig(com.hazelcast.jet.config.JobConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 54 with NoOutputSourceP

use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.

the class ClusterStateChangeTest method before.

@Before
public void before() {
    TestProcessors.reset(TOTAL_PARALLELISM);
    Config config = smallInstanceConfig();
    config.getJetConfig().setCooperativeThreadCount(LOCAL_PARALLELISM);
    members = createHazelcastInstances(config, NODE_COUNT);
    assertTrueEventually(() -> {
        for (HazelcastInstance instance : members) {
            assertClusterSizeEventually(NODE_COUNT, instance);
        }
    });
    for (HazelcastInstance member : members) {
        if (!getNodeEngineImpl(member).getClusterService().isMaster()) {
            hz = member;
            break;
        }
    }
    cluster = hz.getCluster();
    dag = new DAG().vertex(new Vertex("test", new MockPMS(() -> new MockPS(NoOutputSourceP::new, NODE_COUNT))));
}
Also used : MockPMS(com.hazelcast.jet.core.TestProcessors.MockPMS) MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) NoOutputSourceP(com.hazelcast.jet.core.TestProcessors.NoOutputSourceP) Before(org.junit.Before)

Example 55 with NoOutputSourceP

use of com.hazelcast.jet.core.TestProcessors.NoOutputSourceP in project hazelcast by hazelcast.

the class JobTest method stressTest_parallelNamedJobSubmission.

private void stressTest_parallelNamedJobSubmission(HazelcastInstance instance) throws Exception {
    final int nThreads = 5;
    ExecutorService executor = Executors.newFixedThreadPool(nThreads);
    String randomPrefix = randomName();
    try {
        for (int round = 0; round < 10; round++) {
            DAG dag = new DAG().vertex(new Vertex("test" + round, new MockPS(NoOutputSourceP::new, NODE_COUNT * 2)));
            System.out.println("Starting round " + round);
            JobConfig config = new JobConfig().setName(randomPrefix + round);
            List<Future<Job>> futures = new ArrayList<>();
            for (int i = 0; i < nThreads; i++) {
                futures.add(executor.submit(() -> instance.getJet().newJobIfAbsent(dag, config)));
            }
            for (int i = 1; i < nThreads; i++) {
                assertEquals(futures.get(0).get().getId(), futures.get(i).get().getId());
            }
        }
    } finally {
        executor.shutdownNow();
        assertTrue(executor.awaitTermination(1, MINUTES));
    }
}
Also used : MockPS(com.hazelcast.jet.core.TestProcessors.MockPS) ExecutorService(java.util.concurrent.ExecutorService) NoOutputSourceP(com.hazelcast.jet.core.TestProcessors.NoOutputSourceP) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) JobConfig(com.hazelcast.jet.config.JobConfig)

Aggregations

NoOutputSourceP (com.hazelcast.jet.core.TestProcessors.NoOutputSourceP)68 Job (com.hazelcast.jet.Job)64 Test (org.junit.Test)54 MockPS (com.hazelcast.jet.core.TestProcessors.MockPS)52 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)43 QuickTest (com.hazelcast.test.annotation.QuickTest)33 JobConfig (com.hazelcast.jet.config.JobConfig)31 HazelcastInstance (com.hazelcast.core.HazelcastInstance)22 NightlyTest (com.hazelcast.test.annotation.NightlyTest)11 CancellationException (java.util.concurrent.CancellationException)11 CountDownLatch (java.util.concurrent.CountDownLatch)11 SlowTest (com.hazelcast.test.annotation.SlowTest)10 Config (com.hazelcast.config.Config)9 JetServiceBackend (com.hazelcast.jet.impl.JetServiceBackend)9 JobRepository (com.hazelcast.jet.impl.JobRepository)9 Future (java.util.concurrent.Future)8 ExpectedException (org.junit.rules.ExpectedException)8 JobExecutionRecord (com.hazelcast.jet.impl.JobExecutionRecord)7 MasterContext (com.hazelcast.jet.impl.MasterContext)7 ClusterService (com.hazelcast.internal.cluster.ClusterService)6