You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ro...@apache.org on 2019/10/18 06:40:45 UTC

[james-project] 12/17: JAMES-2813 check that AdditionalInformation instances are shared between nodes

This is an automated email from the ASF dual-hosted git repository.

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

commit 769d64edf8dbc22a5f27d5ce504f0c372f6ec803
Author: Matthieu Baechler <ma...@apache.org>
AuthorDate: Wed Oct 9 15:30:43 2019 +0200

    JAMES-2813 check that AdditionalInformation instances are shared between nodes
---
 .../org/apache/james/task/TaskManagerContract.java | 39 ++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/server/task/task-api/src/test/java/org/apache/james/task/TaskManagerContract.java b/server/task/task-api/src/test/java/org/apache/james/task/TaskManagerContract.java
index 2420a83..d482eed 100644
--- a/server/task/task-api/src/test/java/org/apache/james/task/TaskManagerContract.java
+++ b/server/task/task-api/src/test/java/org/apache/james/task/TaskManagerContract.java
@@ -275,6 +275,45 @@ public interface TaskManagerContract {
     }
 
     @Test
+    default void additionalInformationShouldBeUpdatedDuringExecution(CountDownLatch countDownLatch) {
+        TaskManager taskManager = taskManager();
+        TaskId id = taskManager.submit(new MemoryReferenceWithCounterTask((counter) -> {
+            counter.incrementAndGet();
+            countDownLatch.await();
+            return Task.Result.COMPLETED;
+        }));
+
+        awaitUntilTaskHasStatus(id, TaskManager.Status.IN_PROGRESS, taskManager);
+
+        calmlyAwait.atMost(FIVE_SECONDS).untilAsserted(() ->
+            assertThat(getAdditionalInformation(taskManager, id).getCount()).isEqualTo(1L));
+    }
+
+    @Test
+    default void additionalInformationShouldBeAvailableOnAnyTaskManagerDuringExecution(CountDownLatch countDownLatch) {
+        TaskManager taskManager = taskManager();
+        TaskManager otherTaskManager = taskManager();
+        TaskId id = taskManager.submit(new MemoryReferenceWithCounterTask((counter) -> {
+            counter.incrementAndGet();
+            countDownLatch.await();
+            return Task.Result.COMPLETED;
+        }));
+
+        awaitUntilTaskHasStatus(id, TaskManager.Status.IN_PROGRESS, taskManager);
+
+        calmlyAwait.atMost(FIVE_SECONDS).untilAsserted(() ->
+            assertThat(getAdditionalInformation(taskManager, id).getCount()).isEqualTo(1L));
+        assertThat(getAdditionalInformation(otherTaskManager, id).getCount()).isEqualTo(1L);
+    }
+
+    default MemoryReferenceWithCounterTask.AdditionalInformation getAdditionalInformation(TaskManager taskManager, TaskId id) {
+        return (MemoryReferenceWithCounterTask.AdditionalInformation) taskManager
+            .getExecutionDetails(id)
+            .getAdditionalInformation()
+            .get();
+    }
+
+    @Test
     default void getStatusShouldReturnFailedWhenRunPartially() {
         TaskManager taskManager = taskManager();
         TaskId taskId = taskManager.submit(


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