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 bt...@apache.org on 2019/05/30 07:22:23 UTC
[james-project] 12/19: MAILBOX-351 Test ReIndexing tasks
information upon failures
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit a5214fd6534ca45807498d4cab0597487dd35d3c
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Fri May 24 13:59:40 2019 +0700
MAILBOX-351 Test ReIndexing tasks information upon failures
---
.../indexer/ReprocessingContextInformation.java | 2 +-
.../webadmin/routes/ReindexingRoutesTest.java | 153 ++++++++++++++++++++-
2 files changed, 152 insertions(+), 3 deletions(-)
diff --git a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReprocessingContextInformation.java b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReprocessingContextInformation.java
index 6590e43..c3bc0ae 100644
--- a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReprocessingContextInformation.java
+++ b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReprocessingContextInformation.java
@@ -49,7 +49,7 @@ public class ReprocessingContextInformation implements TaskExecutionDetails.Addi
return reprocessingContext.failures();
}
- @JsonProperty
+ @JsonProperty("failures")
public SerializableReIndexingExecutionFailures failuresAsJson() {
return SerializableReIndexingExecutionFailures.from(failures());
}
diff --git a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ReindexingRoutesTest.java b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ReindexingRoutesTest.java
index 091ddb9..fc3c701 100644
--- a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ReindexingRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/ReindexingRoutesTest.java
@@ -197,6 +197,40 @@ class ReindexingRoutesTest {
.body("submitDate", is(notNullValue()))
.body("completedDate", is(notNullValue()));
}
+
+ @Test
+ void fullReprocessingShouldReturnTaskDetailsWhenFailing() throws Exception {
+ MailboxSession systemSession = mailboxManager.createSystemSession(USERNAME);
+ MailboxId mailboxId = mailboxManager.createMailbox(INBOX, systemSession).get();
+ ComposedMessageId composedMessageId = mailboxManager.getMailbox(INBOX, systemSession)
+ .appendMessage(
+ MessageManager.AppendCommand.builder().build("header: value\r\n\r\nbody"),
+ systemSession);
+
+ doThrow(new RuntimeException())
+ .when(searchIndex)
+ .add(any(MailboxSession.class), any(Mailbox.class), any(MailboxMessage.class));
+
+ String taskId = with()
+ .post("/mailboxes?task=reIndex")
+ .jsonPath()
+ .get("taskId");
+
+ long uidAsLong = composedMessageId.getUid().asLong();
+ given()
+ .basePath(TasksRoutes.BASE)
+ .when()
+ .get(taskId + "/await")
+ .then()
+ .body("status", is("failed"))
+ .body("taskId", is(notNullValue()))
+ .body("type", is(FullReindexingTask.FULL_RE_INDEXING))
+ .body("additionalInformation.successfullyReprocessMailCount", is(0))
+ .body("additionalInformation.failedReprocessedMailCount", is(1))
+ .body("additionalInformation.failures.\"" + mailboxId.serialize() + "\"[0].uid", is(Long.valueOf(uidAsLong).intValue()))
+ .body("startedDate", is(notNullValue()))
+ .body("submitDate", is(notNullValue()));
+ }
}
@Nested
@@ -344,6 +378,42 @@ class ReindexingRoutesTest {
.body("submitDate", is(notNullValue()))
.body("completedDate", is(notNullValue()));
}
+
+ @Test
+ void userReprocessingShouldReturnTaskDetailsWhenFailing() throws Exception {
+ MailboxSession systemSession = mailboxManager.createSystemSession(USERNAME);
+ MailboxId mailboxId = mailboxManager.createMailbox(INBOX, systemSession).get();
+ ComposedMessageId composedMessageId = mailboxManager.getMailbox(INBOX, systemSession)
+ .appendMessage(
+ MessageManager.AppendCommand.builder().build("header: value\r\n\r\nbody"),
+ systemSession);
+
+ doThrow(new RuntimeException())
+ .when(searchIndex)
+ .add(any(MailboxSession.class), any(Mailbox.class), any(MailboxMessage.class));
+
+ String taskId = with()
+ .queryParam("user", USERNAME)
+ .queryParam("task", "reIndex")
+ .post("/mailboxes")
+ .jsonPath()
+ .get("taskId");
+
+ long uidAsLong = composedMessageId.getUid().asLong();
+ given()
+ .basePath(TasksRoutes.BASE)
+ .when()
+ .get(taskId + "/await")
+ .then()
+ .body("status", is("failed"))
+ .body("taskId", is(notNullValue()))
+ .body("type", is(UserReindexingTask.USER_RE_INDEXING))
+ .body("additionalInformation.successfullyReprocessMailCount", is(0))
+ .body("additionalInformation.failedReprocessedMailCount", is(1))
+ .body("additionalInformation.failures.\"" + mailboxId.serialize() + "\"[0].uid", is(Long.valueOf(uidAsLong).intValue()))
+ .body("startedDate", is(notNullValue()))
+ .body("submitDate", is(notNullValue()));
+ }
}
@Nested
@@ -498,8 +568,42 @@ class ReindexingRoutesTest {
.body("additionalInformation.successfullyReprocessMailCount", is(1))
.body("additionalInformation.failedReprocessedMailCount", is(0))
.body("startedDate", is(notNullValue()))
- .body("submitDate", is(notNullValue()))
- .body("completedDate", is(notNullValue()));
+ .body("submitDate", is(notNullValue()));
+ }
+
+ @Test
+ void mailboxReprocessingShouldReturnTaskDetailsWhenFailing() throws Exception {
+ MailboxSession systemSession = mailboxManager.createSystemSession(USERNAME);
+ MailboxId mailboxId = mailboxManager.createMailbox(INBOX, systemSession).get();
+ ComposedMessageId composedMessageId = mailboxManager.getMailbox(INBOX, systemSession)
+ .appendMessage(
+ MessageManager.AppendCommand.builder().build("header: value\r\n\r\nbody"),
+ systemSession);
+
+ doThrow(new RuntimeException())
+ .when(searchIndex)
+ .add(any(MailboxSession.class), any(Mailbox.class), any(MailboxMessage.class));
+
+ String taskId = with()
+ .queryParam("task", "reIndex")
+ .post("/mailboxes/" + mailboxId.serialize())
+ .jsonPath()
+ .get("taskId");
+
+ long uidAsLong = composedMessageId.getUid().asLong();
+ given()
+ .basePath(TasksRoutes.BASE)
+ .when()
+ .get(taskId + "/await")
+ .then()
+ .body("status", is("failed"))
+ .body("taskId", is(notNullValue()))
+ .body("type", is(SingleMailboxReindexingTask.MAILBOX_RE_INDEXING))
+ .body("additionalInformation.successfullyReprocessMailCount", is(0))
+ .body("additionalInformation.failedReprocessedMailCount", is(1))
+ .body("additionalInformation.failures.\"" + mailboxId.serialize() + "\"[0].uid", is(Long.valueOf(uidAsLong).intValue()))
+ .body("startedDate", is(notNullValue()))
+ .body("submitDate", is(notNullValue()));
}
}
@@ -1000,6 +1104,51 @@ class ReindexingRoutesTest {
.body("submitDate", is(notNullValue()))
.body("completedDate", is(notNullValue()));
}
+
+ @Test
+ void mailboxReprocessingShouldReturnTaskDetailsWhenFailing() throws Exception {
+ MailboxSession systemSession = mailboxManager.createSystemSession(USERNAME);
+ MailboxId mailboxId = mailboxManager.createMailbox(INBOX, systemSession).get();
+ ComposedMessageId composedMessageId = mailboxManager.getMailbox(INBOX, systemSession)
+ .appendMessage(
+ MessageManager.AppendCommand.builder().build("header: value\r\n\r\nbody"),
+ systemSession);
+
+ doThrow(new RuntimeException())
+ .when(searchIndex)
+ .add(any(MailboxSession.class), any(Mailbox.class), any(MailboxMessage.class));
+
+ String taskId = with()
+ .post("/mailboxes?task=reIndex")
+ .jsonPath()
+ .get("taskId");
+
+ with()
+ .basePath(TasksRoutes.BASE)
+ .get(taskId + "/await");
+
+ String fixingTaskId = with()
+ .queryParam("reIndexFailedMessagesOf", taskId)
+ .queryParam("task", "reIndex")
+ .post("/mailboxes")
+ .jsonPath()
+ .get("taskId");
+
+ long uidAsLong = composedMessageId.getUid().asLong();
+ given()
+ .basePath(TasksRoutes.BASE)
+ .when()
+ .get(fixingTaskId + "/await")
+ .then()
+ .body("status", is("failed"))
+ .body("taskId", is(notNullValue()))
+ .body("type", is("ReIndexPreviousFailures"))
+ .body("additionalInformation.successfullyReprocessMailCount", is(0))
+ .body("additionalInformation.failedReprocessedMailCount", is(1))
+ .body("additionalInformation.failures.\"" + mailboxId.serialize() + "\"[0].uid", is(Long.valueOf(uidAsLong).intValue()))
+ .body("startedDate", is(notNullValue()))
+ .body("submitDate", is(notNullValue()));
+ }
}
@Nested
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org