james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From matth...@apache.org
Subject [james-project] branch master updated: JAMES-2813 Add unit test to verify behavior of listing tasks on distributed task manager
Date Thu, 05 Sep 2019 07:06:25 GMT
This is an automated email from the ASF dual-hosted git repository.

matthieu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
     new c6db41a  JAMES-2813 Add unit test to verify behavior of listing tasks on distributed
task manager
c6db41a is described below

commit c6db41ada95dc5b5336db096e123138345d3b140
Author: RĂ©mi Kowalski <rkowalski@linagora.com>
AuthorDate: Tue Aug 27 14:51:14 2019 +0200

    JAMES-2813 Add unit test to verify behavior of listing tasks on distributed task manager
---
 .../distributed/DistributedTaskManagerTest.java    | 33 ++++++++++++++++++++--
 1 file changed, 30 insertions(+), 3 deletions(-)

diff --git a/server/task-distributed/src/test/java/org/apache/james/task/eventsourcing/distributed/DistributedTaskManagerTest.java
b/server/task-distributed/src/test/java/org/apache/james/task/eventsourcing/distributed/DistributedTaskManagerTest.java
index e38edd9..b4ad5a6 100644
--- a/server/task-distributed/src/test/java/org/apache/james/task/eventsourcing/distributed/DistributedTaskManagerTest.java
+++ b/server/task-distributed/src/test/java/org/apache/james/task/eventsourcing/distributed/DistributedTaskManagerTest.java
@@ -21,6 +21,7 @@ package org.apache.james.task.eventsourcing.distributed;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
+import java.util.List;
 import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
@@ -55,8 +56,6 @@ import org.apache.james.task.eventsourcing.WorkQueueSupplier;
 import org.apache.james.task.eventsourcing.cassandra.CassandraTaskExecutionDetailsProjection;
 import org.apache.james.task.eventsourcing.cassandra.CassandraTaskExecutionDetailsProjectionDAO;
 import org.apache.james.task.eventsourcing.cassandra.CassandraTaskExecutionDetailsProjectionModule;
-
-import com.github.steveash.guavate.Guavate;
 import org.awaitility.Awaitility;
 import org.awaitility.Duration;
 import org.junit.jupiter.api.BeforeEach;
@@ -64,6 +63,8 @@ import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.junit.jupiter.api.extension.RegisterExtension;
 
+import com.github.steveash.guavate.Guavate;
+
 @ExtendWith(CountDownLatchExtension.class)
 class DistributedTaskManagerTest implements TaskManagerContract {
 
@@ -202,11 +203,37 @@ class DistributedTaskManagerTest implements TaskManagerContract {
             .contains(remoteTaskManager.getKey());
     }
 
-    private Pair<Hostname, TaskManager> getOtherTaskManager(Hostname node, Pair<Hostname,
TaskManager> taskManager1, Pair<Hostname, TaskManager>  taskManager2) {
+    private Pair<Hostname, TaskManager> getOtherTaskManager(Hostname node, Pair<Hostname,
TaskManager> taskManager1, Pair<Hostname, TaskManager> taskManager2) {
         if (node.equals(taskManager1.getKey())) {
             return taskManager2;
         } else {
             return taskManager1;
         }
     }
+
+    @Test
+    void givenTwoTaskManagerAndATaskRanPerTaskManagerListingThemOnEachShouldShowBothTasks()
{
+        try (EventSourcingTaskManager taskManager1 = taskManager();
+             EventSourcingTaskManager taskManager2 = taskManager(HOSTNAME_2)) {
+
+            TaskId taskId1 = taskManager1.submit(new CompletedTask());
+            TaskId taskId2 = taskManager2.submit(new CompletedTask());
+
+            Awaitility.await()
+                .atMost(Duration.ONE_SECOND)
+                .pollInterval(100L, TimeUnit.MILLISECONDS)
+                .untilAsserted(() -> {
+                    List<TaskExecutionDetails> listOnTaskManager1 = taskManager1.list();
+                    List<TaskExecutionDetails> listOnTaskManager2 = taskManager2.list();
+
+                    assertThat(listOnTaskManager1)
+                        .hasSize(2)
+                        .isEqualTo(listOnTaskManager2)
+                        .allSatisfy(taskExecutionDetails -> assertThat(taskExecutionDetails.getStatus()).isEqualTo(TaskManager.Status.COMPLETED))
+                        .extracting(TaskExecutionDetails::getTaskId)
+                        .containsExactlyInAnyOrder(taskId1, taskId2);
+                });
+        }
+    }
+
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message