Search in sources :

Example 1 with QueueManager

use of com.netflix.conductor.contribs.queue.QueueManager in project conductor by Netflix.

the class TestQueueManager method testFailure.

@Test(expected = IllegalArgumentException.class)
public void testFailure() throws Exception {
    Map<Status, ObservableQueue> queues = new HashMap<>();
    queues.put(Status.COMPLETED, queue);
    QueueManager qm = new QueueManager(queues, es, objectMapper);
    qm.updateByTaskRefName("v_1", "t1", new HashMap<>(), Status.CANCELED);
    Uninterruptibles.sleepUninterruptibly(1_000, TimeUnit.MILLISECONDS);
}
Also used : Status(com.netflix.conductor.common.metadata.tasks.Task.Status) HashMap(java.util.HashMap) ObservableQueue(com.netflix.conductor.core.events.queue.ObservableQueue) QueueManager(com.netflix.conductor.contribs.queue.QueueManager) Test(org.junit.Test)

Example 2 with QueueManager

use of com.netflix.conductor.contribs.queue.QueueManager in project conductor by Netflix.

the class TestQueueManager method test.

@Test
public void test() throws Exception {
    Map<Status, ObservableQueue> queues = new HashMap<>();
    queues.put(Status.COMPLETED, queue);
    QueueManager qm = new QueueManager(queues, es, objectMapper);
    qm.updateByTaskRefName("v_0", "t0", new HashMap<>(), Status.COMPLETED);
    Uninterruptibles.sleepUninterruptibly(1_000, TimeUnit.MILLISECONDS);
    assertTrue(updatedTasks.stream().anyMatch(task -> task.getTaskId().equals("t0")));
}
Also used : Status(com.netflix.conductor.common.metadata.tasks.Task.Status) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BeforeClass(org.junit.BeforeClass) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Status(com.netflix.conductor.common.metadata.tasks.Task.Status) HashMap(java.util.HashMap) Wait(com.netflix.conductor.core.execution.tasks.Wait) ArgumentMatchers.anyBoolean(org.mockito.ArgumentMatchers.anyBoolean) Task(com.netflix.conductor.common.metadata.tasks.Task) Answer(org.mockito.stubbing.Answer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Workflow(com.netflix.conductor.common.run.Workflow) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Map(java.util.Map) LinkedList(java.util.LinkedList) Mockito.doReturn(org.mockito.Mockito.doReturn) Message(com.netflix.conductor.core.events.queue.Message) Uninterruptibles(com.google.common.util.concurrent.Uninterruptibles) Assert.assertNotNull(org.junit.Assert.assertNotNull) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) QueueManager(com.netflix.conductor.contribs.queue.QueueManager) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) ExecutionService(com.netflix.conductor.service.ExecutionService) JsonMapperProvider(com.netflix.conductor.common.utils.JsonMapperProvider) ObservableQueue(com.netflix.conductor.core.events.queue.ObservableQueue) Mockito.mock(org.mockito.Mockito.mock) HashMap(java.util.HashMap) ObservableQueue(com.netflix.conductor.core.events.queue.ObservableQueue) QueueManager(com.netflix.conductor.contribs.queue.QueueManager) Test(org.junit.Test)

Example 3 with QueueManager

use of com.netflix.conductor.contribs.queue.QueueManager in project conductor by Netflix.

the class TestQueueManager method testWithTaskId.

@Test
public void testWithTaskId() throws Exception {
    Map<Status, ObservableQueue> queues = new HashMap<>();
    queues.put(Status.COMPLETED, queue);
    QueueManager qm = new QueueManager(queues, es, objectMapper);
    qm.updateByTaskId("v_2", "t2", new HashMap<>(), Status.COMPLETED);
    Uninterruptibles.sleepUninterruptibly(1_000, TimeUnit.MILLISECONDS);
    assertTrue(updatedTasks.stream().anyMatch(task -> task.getTaskId().equals("t2")));
}
Also used : Status(com.netflix.conductor.common.metadata.tasks.Task.Status) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BeforeClass(org.junit.BeforeClass) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Status(com.netflix.conductor.common.metadata.tasks.Task.Status) HashMap(java.util.HashMap) Wait(com.netflix.conductor.core.execution.tasks.Wait) ArgumentMatchers.anyBoolean(org.mockito.ArgumentMatchers.anyBoolean) Task(com.netflix.conductor.common.metadata.tasks.Task) Answer(org.mockito.stubbing.Answer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Workflow(com.netflix.conductor.common.run.Workflow) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Map(java.util.Map) LinkedList(java.util.LinkedList) Mockito.doReturn(org.mockito.Mockito.doReturn) Message(com.netflix.conductor.core.events.queue.Message) Uninterruptibles(com.google.common.util.concurrent.Uninterruptibles) Assert.assertNotNull(org.junit.Assert.assertNotNull) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) QueueManager(com.netflix.conductor.contribs.queue.QueueManager) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) ExecutionService(com.netflix.conductor.service.ExecutionService) JsonMapperProvider(com.netflix.conductor.common.utils.JsonMapperProvider) ObservableQueue(com.netflix.conductor.core.events.queue.ObservableQueue) Mockito.mock(org.mockito.Mockito.mock) HashMap(java.util.HashMap) ObservableQueue(com.netflix.conductor.core.events.queue.ObservableQueue) QueueManager(com.netflix.conductor.contribs.queue.QueueManager) Test(org.junit.Test)

Aggregations

Status (com.netflix.conductor.common.metadata.tasks.Task.Status)3 QueueManager (com.netflix.conductor.contribs.queue.QueueManager)3 ObservableQueue (com.netflix.conductor.core.events.queue.ObservableQueue)3 HashMap (java.util.HashMap)3 Test (org.junit.Test)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Uninterruptibles (com.google.common.util.concurrent.Uninterruptibles)2 Task (com.netflix.conductor.common.metadata.tasks.Task)2 Workflow (com.netflix.conductor.common.run.Workflow)2 JsonMapperProvider (com.netflix.conductor.common.utils.JsonMapperProvider)2 Message (com.netflix.conductor.core.events.queue.Message)2 Wait (com.netflix.conductor.core.execution.tasks.Wait)2 ExecutionService (com.netflix.conductor.service.ExecutionService)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Map (java.util.Map)2 TimeUnit (java.util.concurrent.TimeUnit)2 Assert.assertNotNull (org.junit.Assert.assertNotNull)2 Assert.assertTrue (org.junit.Assert.assertTrue)2 BeforeClass (org.junit.BeforeClass)2