You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2019/05/07 19:48:23 UTC
[activemq-artemis] branch master updated: NO-JIRA Fixing random
failure on Journal Test
This is an automated email from the ASF dual-hosted git repository.
clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
The following commit(s) were added to refs/heads/master by this push:
new 6f572de NO-JIRA Fixing random failure on Journal Test
6f572de is described below
commit 6f572de59ec4942b0805eafaef17fc35349afde3
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Tue May 7 15:45:48 2019 -0400
NO-JIRA Fixing random failure on Journal Test
---
.../integration/journal/NIOJournalCompactTest.java | 27 +---
.../core/journal/impl/JournalImplTestBase.java | 140 +++++++++++++++++++--
2 files changed, 129 insertions(+), 38 deletions(-)
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java
index b97a861..17ca88e 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java
@@ -64,7 +64,7 @@ public class NIOJournalCompactTest extends JournalImplTestBase {
private static final Logger logger = Logger.getLogger(NIOJournalCompactTest.class);
- private static final int NUMBER_OF_RECORDS = 1000;
+ private static final int NUMBER_OF_RECORDS = 100;
IDGenerator idGenerator = new SimpleIDGenerator(100000);
@@ -127,19 +127,6 @@ public class NIOJournalCompactTest extends JournalImplTestBase {
}
- // public void testRepeat() throws Exception
- // {
- // int i = 0 ;
- //
- // while (true)
- // {
- // System.out.println("#test (" + (i++) + ")");
- // testCrashRenamingFiles();
- // tearDown();
- // setUp();
- // }
- // }
-
@Test
public void testCrashRenamingFiles() throws Exception {
internalCompactTest(false, false, true, false, false, false, false, false, false, false, true, false, false);
@@ -484,7 +471,7 @@ public class NIOJournalCompactTest extends JournalImplTestBase {
performNonTransactionalDelete = false;
}
- setup(2, 60 * 4096, false);
+ setup(2, 60 * 4096, true);
ArrayList<Long> liveIDs = new ArrayList<>();
@@ -788,16 +775,6 @@ public class NIOJournalCompactTest extends JournalImplTestBase {
}
@Test
- public void testLoopStressAppends() throws Exception {
- for (int i = 0; i < 10; i++) {
- logger.info("repetition " + i);
- testStressAppends();
- tearDown();
- setUp();
- }
- }
-
- @Test
public void testStressAppends() throws Exception {
setup(2, 60 * 1024, true);
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestBase.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestBase.java
index b22881d..07a3800 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestBase.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestBase.java
@@ -18,6 +18,7 @@ package org.apache.activemq.artemis.tests.unit.core.journal.impl;
import java.io.File;
import java.io.FilenameFilter;
+import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
@@ -34,7 +35,9 @@ import org.apache.activemq.artemis.core.journal.EncodingSupport;
import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo;
import org.apache.activemq.artemis.core.journal.RecordInfo;
import org.apache.activemq.artemis.core.journal.TestableJournal;
+import org.apache.activemq.artemis.core.journal.impl.JournalFile;
import org.apache.activemq.artemis.core.journal.impl.JournalImpl;
+import org.apache.activemq.artemis.core.journal.impl.JournalReaderCallback;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.artemis.utils.ReusableLatch;
import org.jboss.logging.Logger;
@@ -248,6 +251,82 @@ public abstract class JournalImplTestBase extends ActiveMQTestBase {
loadAndCheck(false);
}
+ /**
+ * @param fileFactory
+ * @param journal
+ * @throws Exception
+ */
+ private static void describeJournal(SequentialFileFactory fileFactory,
+ JournalImpl journal,
+ final File path,
+ PrintStream out) throws Exception {
+ List<JournalFile> files = journal.orderFiles();
+
+ out.println("Journal path: " + path);
+
+ for (JournalFile file : files) {
+ out.println("#" + file + " (size=" + file.getFile().size() + ")");
+
+ JournalImpl.readJournalFile(fileFactory, file, new JournalReaderCallback() {
+
+ @Override
+ public void onReadUpdateRecordTX(final long transactionID, final RecordInfo recordInfo) throws Exception {
+ out.println("operation@UpdateTX;txID=" + transactionID + "," + recordInfo);
+ }
+
+ @Override
+ public void onReadUpdateRecord(final RecordInfo recordInfo) throws Exception {
+ out.println("operation@Update;" + recordInfo);
+ }
+
+ @Override
+ public void onReadRollbackRecord(final long transactionID) throws Exception {
+ out.println("operation@Rollback;txID=" + transactionID);
+ }
+
+ @Override
+ public void onReadPrepareRecord(final long transactionID,
+ final byte[] extraData,
+ final int numberOfRecords) throws Exception {
+ out.println("operation@Prepare,txID=" + transactionID + ",numberOfRecords=" + numberOfRecords);
+ }
+
+ @Override
+ public void onReadDeleteRecordTX(final long transactionID, final RecordInfo recordInfo) throws Exception {
+ out.println("operation@DeleteRecordTX;txID=" + transactionID + "," + recordInfo);
+ }
+
+ @Override
+ public void onReadDeleteRecord(final long recordID) throws Exception {
+ out.println("operation@DeleteRecord;recordID=" + recordID);
+ }
+
+ @Override
+ public void onReadCommitRecord(final long transactionID, final int numberOfRecords) throws Exception {
+ out.println("operation@Commit;txID=" + transactionID + ",numberOfRecords=" + numberOfRecords);
+ }
+
+ @Override
+ public void onReadAddRecordTX(final long transactionID, final RecordInfo recordInfo) throws Exception {
+ out.println("operation@AddRecordTX;txID=" + transactionID + "," + recordInfo);
+ }
+
+ @Override
+ public void onReadAddRecord(final RecordInfo recordInfo) throws Exception {
+ out.println("operation@AddRecord;" + recordInfo);
+ }
+
+ @Override
+ public void markAsDataFile(final JournalFile file1) {
+ }
+
+ });
+ }
+
+ out.println();
+
+ }
+
protected void loadAndCheck(final boolean printDebugJournal) throws Exception {
List<RecordInfo> committedRecords = new ArrayList<>();
@@ -522,31 +601,66 @@ public abstract class JournalImplTestBase extends ActiveMQTestBase {
* @param actual
*/
protected void printJournalLists(final List<RecordInfo> expected, final List<RecordInfo> actual) {
+ try {
- HashSet<RecordInfo> expectedSet = new HashSet<>();
- expectedSet.addAll(expected);
+ HashSet<RecordInfo> expectedSet = new HashSet<>();
+ expectedSet.addAll(expected);
+ Assert.assertEquals("There are duplicated on the expected list", expectedSet.size(), expected.size());
- Assert.assertEquals("There are duplicated on the expected list", expectedSet.size(), expected.size());
+ HashSet<RecordInfo> actualSet = new HashSet<>();
+ actualSet.addAll(actual);
- HashSet<RecordInfo> actualSet = new HashSet<>();
- actualSet.addAll(actual);
+ expectedSet.removeAll(actualSet);
- expectedSet.removeAll(actualSet);
+ for (RecordInfo info : expectedSet) {
+ logger.warn("The following record is missing:: " + info);
+ }
- for (RecordInfo info: expectedSet) {
- logger.warn("The following record is missing:: " + info);
- }
+ Assert.assertEquals("There are duplicates on the actual list", actualSet.size(), actualSet.size());
+ RecordInfo[] expectedArray = expected.toArray(new RecordInfo[expected.size()]);
+ RecordInfo[] actualArray = actual.toArray(new RecordInfo[actual.size()]);
+ Assert.assertArrayEquals(expectedArray, actualArray);
+ } catch (AssertionError e) {
- Assert.assertEquals("There are duplicates on the actual list", actualSet.size(), actualSet.size());
+ HashSet<RecordInfo> hashActual = new HashSet<>();
+ hashActual.addAll(actual);
+ HashSet<RecordInfo> hashExpected = new HashSet<>();
+ hashExpected.addAll(expected);
+ System.out.println("#Summary **********************************************************************************************************************");
+ for (RecordInfo r : hashActual) {
+ if (!hashExpected.contains(r)) {
+ System.out.println("Record " + r + " was supposed to be removed and it exists");
+ }
+ }
- RecordInfo[] expectedArray = expected.toArray(new RecordInfo[expected.size()]);
- RecordInfo[] actualArray = actual.toArray(new RecordInfo[actual.size()]);
- Assert.assertArrayEquals(expectedArray, actualArray);
+ for (RecordInfo r : hashExpected) {
+ if (!hashActual.contains(r)) {
+ System.out.println("Record " + r + " was not found on actual list");
+ }
+ }
+ System.out.println("#expected **********************************************************************************************************************");
+ for (RecordInfo recordInfo : expected) {
+ System.out.println("Record::" + recordInfo);
+ }
+ System.out.println("#actual ************************************************************************************************************************");
+ for (RecordInfo recordInfo : actual) {
+ System.out.println("Record::" + recordInfo);
+ }
+
+ System.out.println("#records ***********************************************************************************************************************");
+
+ try {
+ describeJournal(journal.getFileFactory(), (JournalImpl) journal, journal.getFileFactory().getDirectory(), System.out);
+ } catch (Exception e2) {
+ e2.printStackTrace();
+ }
+
+ }
}
protected byte[] generateRecord(final int length) {