Search in sources :

Example 1 with BlobConsistencyChecker

use of com.zimbra.cs.store.file.BlobConsistencyChecker in project zm-mailbox by Zimbra.

the class AbstractBlobConsistencyCheckTest method allBlobs.

@Test
public void allBlobs() throws Exception {
    Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
    DeliveryOptions dopt = new DeliveryOptions().setFolderId(Mailbox.ID_FOLDER_INBOX);
    int msgs = 10;
    for (int i = 0; i < msgs; i++) {
        mbox.addMessage(null, new ParsedMessage("From: test1-1@sub1.zimbra.com".getBytes(), false), dopt, null);
    }
    BlobConsistencyChecker checker = getChecker();
    Results results = checker.check(getVolumeIds(), mbox.getId(), true, true);
    Assert.assertEquals(0, results.missingBlobs.size());
    Assert.assertEquals(0, results.unexpectedBlobs.size());
    Assert.assertEquals(msgs, results.usedBlobs.size());
    Assert.assertEquals(0, results.incorrectSize.size());
    Assert.assertEquals(0, results.incorrectModContent.size());
}
Also used : Mailbox(com.zimbra.cs.mailbox.Mailbox) Results(com.zimbra.cs.store.file.BlobConsistencyChecker.Results) ParsedMessage(com.zimbra.cs.mime.ParsedMessage) BlobConsistencyChecker(com.zimbra.cs.store.file.BlobConsistencyChecker) DeliveryOptions(com.zimbra.cs.mailbox.DeliveryOptions) Test(org.junit.Test)

Example 2 with BlobConsistencyChecker

use of com.zimbra.cs.store.file.BlobConsistencyChecker in project zm-mailbox by Zimbra.

the class AbstractBlobConsistencyCheckTest method wrongSize.

@Test
public void wrongSize() throws Exception {
    Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
    DeliveryOptions dopt = new DeliveryOptions().setFolderId(Mailbox.ID_FOLDER_INBOX);
    Message msg = mbox.addMessage(null, new ParsedMessage("From: test1-1@sub1.zimbra.com".getBytes(), false), dopt, null);
    MailboxBlob blob = msg.getBlob();
    String text = "some garbage";
    appendText(blob, text);
    BlobConsistencyChecker checker = getChecker();
    Results results = checker.check(getVolumeIds(), mbox.getId(), true, false);
    Assert.assertEquals(0, results.missingBlobs.size());
    Assert.assertEquals(0, results.unexpectedBlobs.size());
    Assert.assertEquals(0, results.usedBlobs.size());
    Assert.assertEquals(1, results.incorrectSize.size());
    BlobInfo info = results.incorrectSize.values().iterator().next();
    Assert.assertEquals(blob.size + text.length(), (long) info.fileDataSize);
    Assert.assertEquals(0, results.incorrectModContent.size());
}
Also used : Mailbox(com.zimbra.cs.mailbox.Mailbox) Message(com.zimbra.cs.mailbox.Message) ParsedMessage(com.zimbra.cs.mime.ParsedMessage) Results(com.zimbra.cs.store.file.BlobConsistencyChecker.Results) ParsedMessage(com.zimbra.cs.mime.ParsedMessage) BlobConsistencyChecker(com.zimbra.cs.store.file.BlobConsistencyChecker) BlobInfo(com.zimbra.cs.store.file.BlobConsistencyChecker.BlobInfo) DeliveryOptions(com.zimbra.cs.mailbox.DeliveryOptions) Test(org.junit.Test)

Example 3 with BlobConsistencyChecker

use of com.zimbra.cs.store.file.BlobConsistencyChecker in project zm-mailbox by Zimbra.

the class AbstractBlobConsistencyCheckTest method unexpectedBlobs.

@Test
public void unexpectedBlobs() throws Exception {
    Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
    String path = createUnexpectedBlob(0);
    BlobConsistencyChecker checker = getChecker();
    Results results = checker.check(getVolumeIds(), mbox.getId(), true, false);
    Assert.assertEquals(0, results.missingBlobs.size());
    Assert.assertEquals(1, results.unexpectedBlobs.size());
    BlobInfo info = results.unexpectedBlobs.values().iterator().next();
    Assert.assertEquals(path, info.path);
    Assert.assertEquals(0, results.usedBlobs.size());
    Assert.assertEquals(0, results.incorrectSize.size());
    Assert.assertEquals(0, results.incorrectModContent.size());
    deleteAllBlobs();
    DeliveryOptions dopt = new DeliveryOptions().setFolderId(Mailbox.ID_FOLDER_INBOX);
    mbox.addMessage(null, new ParsedMessage("From: test1-1@sub1.zimbra.com".getBytes(), false), dopt, null);
    int msgs = 10;
    for (int i = 0; i < msgs; i++) {
        createUnexpectedBlob(i);
    }
    results = checker.check(getVolumeIds(), mbox.getId(), true, false);
    Assert.assertEquals(0, results.missingBlobs.size());
    Assert.assertEquals(msgs, results.unexpectedBlobs.size());
    Assert.assertEquals(0, results.usedBlobs.size());
    Assert.assertEquals(0, results.incorrectSize.size());
    Assert.assertEquals(0, results.incorrectModContent.size());
}
Also used : Mailbox(com.zimbra.cs.mailbox.Mailbox) Results(com.zimbra.cs.store.file.BlobConsistencyChecker.Results) ParsedMessage(com.zimbra.cs.mime.ParsedMessage) BlobConsistencyChecker(com.zimbra.cs.store.file.BlobConsistencyChecker) BlobInfo(com.zimbra.cs.store.file.BlobConsistencyChecker.BlobInfo) DeliveryOptions(com.zimbra.cs.mailbox.DeliveryOptions) Test(org.junit.Test)

Example 4 with BlobConsistencyChecker

use of com.zimbra.cs.store.file.BlobConsistencyChecker in project zm-mailbox by Zimbra.

the class AbstractBlobConsistencyCheckTest method missingBlobs.

@Test
public void missingBlobs() throws Exception {
    Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
    DeliveryOptions dopt = new DeliveryOptions().setFolderId(Mailbox.ID_FOLDER_INBOX);
    int msgs = 10;
    for (int i = 0; i < msgs; i++) {
        mbox.addMessage(null, new ParsedMessage("From: test1-1@sub1.zimbra.com".getBytes(), false), dopt, null);
    }
    deleteAllBlobs();
    BlobConsistencyChecker checker = getChecker();
    Results results = checker.check(getVolumeIds(), mbox.getId(), true, false);
    Assert.assertEquals(msgs, results.missingBlobs.size());
    Assert.assertEquals(0, results.unexpectedBlobs.size());
    Assert.assertEquals(0, results.usedBlobs.size());
    Assert.assertEquals(0, results.incorrectSize.size());
    Assert.assertEquals(0, results.incorrectModContent.size());
}
Also used : Mailbox(com.zimbra.cs.mailbox.Mailbox) Results(com.zimbra.cs.store.file.BlobConsistencyChecker.Results) ParsedMessage(com.zimbra.cs.mime.ParsedMessage) BlobConsistencyChecker(com.zimbra.cs.store.file.BlobConsistencyChecker) DeliveryOptions(com.zimbra.cs.mailbox.DeliveryOptions) Test(org.junit.Test)

Example 5 with BlobConsistencyChecker

use of com.zimbra.cs.store.file.BlobConsistencyChecker in project zm-mailbox by Zimbra.

the class AbstractBlobConsistencyCheckTest method singleBlob.

@Test
public void singleBlob() throws Exception {
    Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
    DeliveryOptions dopt = new DeliveryOptions().setFolderId(Mailbox.ID_FOLDER_INBOX);
    mbox.addMessage(null, new ParsedMessage("From: test1-1@sub1.zimbra.com".getBytes(), false), dopt, null);
    BlobConsistencyChecker checker = getChecker();
    Results results = checker.check(getVolumeIds(), mbox.getId(), true, false);
    Assert.assertEquals(0, results.unexpectedBlobs.size());
    Assert.assertEquals(0, results.missingBlobs.size());
    Assert.assertEquals(0, results.usedBlobs.size());
    Assert.assertEquals(0, results.incorrectSize.size());
    Assert.assertEquals(0, results.incorrectModContent.size());
}
Also used : Mailbox(com.zimbra.cs.mailbox.Mailbox) Results(com.zimbra.cs.store.file.BlobConsistencyChecker.Results) ParsedMessage(com.zimbra.cs.mime.ParsedMessage) BlobConsistencyChecker(com.zimbra.cs.store.file.BlobConsistencyChecker) DeliveryOptions(com.zimbra.cs.mailbox.DeliveryOptions) Test(org.junit.Test)

Aggregations

Mailbox (com.zimbra.cs.mailbox.Mailbox)6 BlobConsistencyChecker (com.zimbra.cs.store.file.BlobConsistencyChecker)6 DeliveryOptions (com.zimbra.cs.mailbox.DeliveryOptions)5 ParsedMessage (com.zimbra.cs.mime.ParsedMessage)5 Results (com.zimbra.cs.store.file.BlobConsistencyChecker.Results)5 Test (org.junit.Test)5 BlobInfo (com.zimbra.cs.store.file.BlobConsistencyChecker.BlobInfo)2 Element (com.zimbra.common.soap.Element)1 Message (com.zimbra.cs.mailbox.Message)1 StoreManager (com.zimbra.cs.store.StoreManager)1 ExternalBlobConsistencyChecker (com.zimbra.cs.store.external.ExternalBlobConsistencyChecker)1 ExternalStoreManager (com.zimbra.cs.store.external.ExternalStoreManager)1 FileBlobStore (com.zimbra.cs.store.file.FileBlobStore)1 Volume (com.zimbra.cs.volume.Volume)1 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1