You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by gt...@apache.org on 2017/05/10 10:30:43 UTC
activemq git commit: [AMQ-6670] - harden the test to avoid ci failure
Repository: activemq
Updated Branches:
refs/heads/master 73e70299e -> eb1a3eb77
[AMQ-6670] - harden the test to avoid ci failure
Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/eb1a3eb7
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/eb1a3eb7
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/eb1a3eb7
Branch: refs/heads/master
Commit: eb1a3eb77bf0ce823ba5f4891ef7a546edce5321
Parents: 73e7029
Author: gtully <ga...@gmail.com>
Authored: Wed May 10 11:30:30 2017 +0100
Committer: gtully <ga...@gmail.com>
Committed: Wed May 10 11:30:30 2017 +0100
----------------------------------------------------------------------
.../kahadb/JournalCorruptionExceptionTest.java | 22 +++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq/blob/eb1a3eb7/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/JournalCorruptionExceptionTest.java
----------------------------------------------------------------------
diff --git a/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/JournalCorruptionExceptionTest.java b/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/JournalCorruptionExceptionTest.java
index 3f554b5..30f062e 100644
--- a/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/JournalCorruptionExceptionTest.java
+++ b/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/JournalCorruptionExceptionTest.java
@@ -22,6 +22,8 @@ import org.apache.activemq.broker.region.policy.PolicyEntry;
import org.apache.activemq.broker.region.policy.PolicyMap;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.store.kahadb.disk.journal.DataFile;
+import org.apache.activemq.store.kahadb.disk.journal.Journal;
+import org.apache.activemq.util.ByteSequence;
import org.apache.activemq.util.RecoverableRandomAccessFile;
import org.junit.After;
import org.junit.Test;
@@ -67,10 +69,12 @@ public class JournalCorruptionExceptionTest {
public static Iterable<Object[]> parameters() {
// corruption can be valid record type values
return Arrays.asList(new Object[][]{
+ {Byte.valueOf("0"), 6},
+ {Byte.valueOf("1"), 8},
+ {Byte.valueOf("-1"), 6},
{Byte.valueOf("0"), 10},
{Byte.valueOf("1"), 10},
- {Byte.valueOf("1"), 9},
- {Byte.valueOf("2"), 20},
+ {Byte.valueOf("2"), 10},
{Byte.valueOf("-1"), 10}
});
}
@@ -143,10 +147,18 @@ public class JournalCorruptionExceptionTest {
DataFile dataFile = (DataFile) files.toArray()[id];
RecoverableRandomAccessFile randomAccessFile = dataFile.openRandomAccessFile();
- int offset = 2415;
- if (fillLength < 10) {
- offset += (fillLength * 2);
+ final ByteSequence header = new ByteSequence(Journal.BATCH_CONTROL_RECORD_HEADER);
+ byte data[] = new byte[1024 * 20];
+ ByteSequence bs = new ByteSequence(data, 0, randomAccessFile.read(data, 0, data.length));
+
+ int offset = bs.indexOf(header, 0);
+
+ offset += Journal.BATCH_CONTROL_RECORD_SIZE;
+
+ if (fillLength >= 10) {
+ offset += 4; // location size
+ offset += 1; // location type
}
LOG.info("Whacking batch record in file:" + id + ", at offset: " + offset + " with fill:" + fill);