From a94fda766f7481a427fe4dd9f2e20ea736af35eb Mon Sep 17 00:00:00 2001 From: Greg Burd Date: Fri, 9 Aug 2019 12:03:00 -0400 Subject: [PATCH] WIP --- NOTES | 4 +++ build.sbt | 4 +-- .../test/com/sleepycat/je/jmx/MBeanTest.java | 5 ++-- .../je/utilint/CronScheduleParser.java | 3 +- .../sleepycat/je/EnvironmentConfigTest.java | 3 +- .../com/sleepycat/je/EnvironmentTest.java | 25 +++++++++------- .../je/cleaner/BackgroundIOTest.java | 1 - .../com/sleepycat/je/cleaner/CleanerTest.java | 2 -- .../je/cleaner/FileSelectionTest.java | 1 - .../je/cleaner/ReadOnlyLockingTest.java | 5 +--- .../je/cleaner/TruncateAndRemoveTest.java | 2 -- .../com/sleepycat/je/dbi/DbEnvPoolTest.java | 8 ++--- .../sleepycat/je/dbi/StartupTrackerTest.java | 4 +-- .../com/sleepycat/je/log/LogManagerTest.java | 3 +- .../java/com/sleepycat/je/txn/TxnEndTest.java | 1 - .../je/utilint/FileStoreInfoTest.java | 30 +------------------ .../sleepycat/util/test/SharedTestUtils.java | 15 ++++++++-- 17 files changed, 46 insertions(+), 70 deletions(-) diff --git a/NOTES b/NOTES index ad0b771..4efd51c 100644 --- a/NOTES +++ b/NOTES @@ -24,3 +24,7 @@ * assert * http://dbmsmusings.blogspot.com/2019/06/correctness-anomalies-under.html + + +--- + * -DJE_TEST=true diff --git a/build.sbt b/build.sbt index 579a42c..5a0fdbf 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,7 @@ import Dependencies._ def scala211 = "2.11.12" -def scala212 = "2.12.8" +def scala212 = "2.12.9" def scala213 = "2.13" name := "stasis" @@ -39,7 +39,7 @@ inThisBuild( CrossVersion.partialVersion(scalaVersion.value) match { case Some((2, 11)) => Seq("-target:jvm-1.8") case Some((2, 12)) => Seq("-target:jvm-1.8") - case Some((2, 13)) => Seq("-target:jvm-1.8") + case Some((2, 13)) => Seq("-target:jvm-1.12") case _ => Seq.empty } }, diff --git a/je-7.5.11/test/com/sleepycat/je/jmx/MBeanTest.java b/je-7.5.11/test/com/sleepycat/je/jmx/MBeanTest.java index e5cf0ea..2a23134 100644 --- a/je-7.5.11/test/com/sleepycat/je/jmx/MBeanTest.java +++ b/je-7.5.11/test/com/sleepycat/je/jmx/MBeanTest.java @@ -20,6 +20,7 @@ import javax.management.DynamicMBean; import junit.framework.TestCase; import com.sleepycat.je.Environment; +import com.sleepycat.je.util.SharedTestUtils; import com.sleepycat.je.util.TestUtils; /** @@ -34,8 +35,8 @@ public class MBeanTest extends TestCase { private String environmentDir; public MBeanTest() { - environmentDir = System.getProperty(TestUtils.DEST_DIR); - envHome = new File(environmentDir); + environmentDir = SharedTestUtils.DEFAULT_TEST_DIR_ROOT; + envHome = SharedTestUtils.getDestDir(); } public void setUp() { diff --git a/stasis-core/src/main/java/com/sleepycat/je/utilint/CronScheduleParser.java b/stasis-core/src/main/java/com/sleepycat/je/utilint/CronScheduleParser.java index 8de8312..a5fd931 100644 --- a/stasis-core/src/main/java/com/sleepycat/je/utilint/CronScheduleParser.java +++ b/stasis-core/src/main/java/com/sleepycat/je/utilint/CronScheduleParser.java @@ -136,8 +136,7 @@ public class CronScheduleParser { } private void assertDelay() { - assert delay >= 0 : - "Delay is: " + delay + "; interval is: " + interval; + assert delay >= 0 : "Delay is: " + delay + "; interval is: " + interval; } private void parser(final String cronSchedule) { diff --git a/stasis-test/src/test/java/com/sleepycat/je/EnvironmentConfigTest.java b/stasis-test/src/test/java/com/sleepycat/je/EnvironmentConfigTest.java index c4c99e8..9fa3ed1 100644 --- a/stasis-test/src/test/java/com/sleepycat/je/EnvironmentConfigTest.java +++ b/stasis-test/src/test/java/com/sleepycat/je/EnvironmentConfigTest.java @@ -105,7 +105,6 @@ public class EnvironmentConfigTest extends TestBase { * Test that replicated config param is wrongly set on a standalone * Environment. */ - @Ignore @Test public void testRepParam() throws Exception { @@ -169,7 +168,7 @@ public class EnvironmentConfigTest extends TestBase { final String nodeName = "env1"; EnvironmentConfig envConfig = new EnvironmentConfig(); - /* Test the seriliazed fileds of EnvironmentConfig. */ + /* Test the serialized fields of EnvironmentConfig. */ envConfig.setAllowCreate(true); envConfig.setNodeName(nodeName); /* Test the transient fields of EnvironmentConfig. */ diff --git a/stasis-test/src/test/java/com/sleepycat/je/EnvironmentTest.java b/stasis-test/src/test/java/com/sleepycat/je/EnvironmentTest.java index d046d2d..6bfc0a2 100644 --- a/stasis-test/src/test/java/com/sleepycat/je/EnvironmentTest.java +++ b/stasis-test/src/test/java/com/sleepycat/je/EnvironmentTest.java @@ -21,6 +21,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.File; +import java.nio.file.Files; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -46,7 +47,7 @@ import com.sleepycat.je.util.TestUtils; import com.sleepycat.je.utilint.DaemonRunner; import com.sleepycat.util.test.SharedTestUtils; -import org.junit.Ignore; +import org.apache.commons.io.FileUtils; import org.junit.Test; public class EnvironmentTest extends DualTestCase { @@ -728,7 +729,6 @@ public class EnvironmentTest extends DualTestCase { /** * Make sure that config param loading follows the right precedence. */ - @Ignore @Test public void testParamLoading() throws Throwable { @@ -736,20 +736,23 @@ public class EnvironmentTest extends DualTestCase { File testEnvHome = null; try { - /* - * A je.properties file has been put into - * /propTest/je.properties - */ - StringBuilder testPropsEnv = new StringBuilder(); - testPropsEnv.append(SharedTestUtils.getTestDir().getParent()); - testPropsEnv.append(File.separatorChar); - testPropsEnv.append("propTest"); + StringBuilder testPropsEnv = new StringBuilder() + .append(SharedTestUtils.getTestDir().getParent()) + .append(File.separatorChar) + .append("propTest"); testEnvHome = new File(testPropsEnv.toString()); + if (!testEnvHome.isDirectory()) + testEnvHome.mkdir(); + + // Place the proper `je.properties` file into /propTest/je.properties + String jePropPath = new java.io.File( ".." ).getCanonicalPath() + File.separatorChar + "stasis-test/src/test/resources/com/sleepycat/je/je.properties"; + FileUtils.copyFile(new File(jePropPath), new File(testPropsEnv.toString() + File.separatorChar + "je.properties")); + TestUtils.removeLogFiles("testParamLoading start", testEnvHome, false); /* - * Set some configuration params programatically. Do not use + * Set some configuration params programmatically. Do not use * TestUtils.initEnvConfig since we're counting properties. */ EnvironmentConfig appConfig = new EnvironmentConfig(); diff --git a/stasis-test/src/test/java/com/sleepycat/je/cleaner/BackgroundIOTest.java b/stasis-test/src/test/java/com/sleepycat/je/cleaner/BackgroundIOTest.java index c51e88e..228fede 100644 --- a/stasis-test/src/test/java/com/sleepycat/je/cleaner/BackgroundIOTest.java +++ b/stasis-test/src/test/java/com/sleepycat/je/cleaner/BackgroundIOTest.java @@ -40,7 +40,6 @@ import com.sleepycat.je.latch.LatchSupport; import com.sleepycat.je.util.TestUtils; import com.sleepycat.je.utilint.TestHook; -@Ignore @RunWith(Parameterized.class) public class BackgroundIOTest extends CleanerTestBase { diff --git a/stasis-test/src/test/java/com/sleepycat/je/cleaner/CleanerTest.java b/stasis-test/src/test/java/com/sleepycat/je/cleaner/CleanerTest.java index 90691d1..d4e74bc 100644 --- a/stasis-test/src/test/java/com/sleepycat/je/cleaner/CleanerTest.java +++ b/stasis-test/src/test/java/com/sleepycat/je/cleaner/CleanerTest.java @@ -932,7 +932,6 @@ public class CleanerTest extends CleanerTestBase { * Tests that cleaner mutable configuration parameters can be changed and * that the changes actually take effect. */ - @Ignore @Test public void testMutableConfig() throws DatabaseException { @@ -1311,7 +1310,6 @@ public class CleanerTest extends CleanerTestBase { * flushed. This feature (incremental update) was added so that log * cleaning is not delayed until the end of the checkpoint. [#16037] */ - @Ignore @Test public void testUtilizationDuringCheckpoint() throws DatabaseException { diff --git a/stasis-test/src/test/java/com/sleepycat/je/cleaner/FileSelectionTest.java b/stasis-test/src/test/java/com/sleepycat/je/cleaner/FileSelectionTest.java index f1d7d3e..ed4e1fd 100644 --- a/stasis-test/src/test/java/com/sleepycat/je/cleaner/FileSelectionTest.java +++ b/stasis-test/src/test/java/com/sleepycat/je/cleaner/FileSelectionTest.java @@ -970,7 +970,6 @@ public class FileSelectionTest extends TestBase { * occurring in JE 3.3.74 and earlier, under the same circumstances as * tested here (IN compression). [#16610] */ - @Ignore @Test public void testCompressionBug() throws DatabaseException { diff --git a/stasis-test/src/test/java/com/sleepycat/je/cleaner/ReadOnlyLockingTest.java b/stasis-test/src/test/java/com/sleepycat/je/cleaner/ReadOnlyLockingTest.java index 341b602..d3e475c 100644 --- a/stasis-test/src/test/java/com/sleepycat/je/cleaner/ReadOnlyLockingTest.java +++ b/stasis-test/src/test/java/com/sleepycat/je/cleaner/ReadOnlyLockingTest.java @@ -40,7 +40,6 @@ import com.sleepycat.je.utilint.JVMSystemUtils; import com.sleepycat.util.test.SharedTestUtils; import org.junit.After; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -67,8 +66,7 @@ public class ReadOnlyLockingTest extends CleanerTestBase { private Process readerProcess; private static File getProcessFile() { - return new File(System.getProperty(TestUtils.DEST_DIR), - "ReadOnlyProcessFile"); + return SharedTestUtils.getDestDirChlid("ReadOnlyProcessFile"); } private static void deleteProcessFile() { @@ -184,7 +182,6 @@ public class ReadOnlyLockingTest extends CleanerTestBase { * Tests that cleaned files are not deleted when there is a reader process. */ @Test - @Ignore public void testReadOnlyLocking() throws Exception { diff --git a/stasis-test/src/test/java/com/sleepycat/je/cleaner/TruncateAndRemoveTest.java b/stasis-test/src/test/java/com/sleepycat/je/cleaner/TruncateAndRemoveTest.java index 371a470..51eb407 100644 --- a/stasis-test/src/test/java/com/sleepycat/je/cleaner/TruncateAndRemoveTest.java +++ b/stasis-test/src/test/java/com/sleepycat/je/cleaner/TruncateAndRemoveTest.java @@ -746,7 +746,6 @@ public class TruncateAndRemoveTest extends CleanerTestBase { * Tests that a log file is not deleted by the cleaner when it contains * entries in a database that is pending deletion. */ - @Ignore @Test public void testDBPendingDeletion() throws DatabaseException, InterruptedException { @@ -761,7 +760,6 @@ public class TruncateAndRemoveTest extends CleanerTestBase { * deleted DBs to the cleaner's pending DB set if all entries in the log * file were known obsoleted. [#13333] */ - @Ignore @Test public void testObsoleteLogFile() throws DatabaseException, InterruptedException { diff --git a/stasis-test/src/test/java/com/sleepycat/je/dbi/DbEnvPoolTest.java b/stasis-test/src/test/java/com/sleepycat/je/dbi/DbEnvPoolTest.java index e87e795..fec2e9f 100644 --- a/stasis-test/src/test/java/com/sleepycat/je/dbi/DbEnvPoolTest.java +++ b/stasis-test/src/test/java/com/sleepycat/je/dbi/DbEnvPoolTest.java @@ -18,9 +18,9 @@ import static org.junit.Assert.assertTrue; import java.io.File; import java.util.concurrent.CountDownLatch; +import com.sleepycat.util.test.SharedTestUtils; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import com.sleepycat.bind.tuple.IntegerBinding; @@ -45,7 +45,7 @@ public class DbEnvPoolTest extends TestBase { private final File envHomeB; public DbEnvPoolTest() { - envHomeA = new File(System.getProperty(TestUtils.DEST_DIR)); + envHomeA = SharedTestUtils.getDestDir(); envHomeB = new File(envHomeA, envHomeBName); } @@ -75,7 +75,6 @@ public class DbEnvPoolTest extends TestBase { } } - @Ignore @Test public void testCanonicalEnvironmentName () throws Throwable { @@ -87,7 +86,7 @@ public class DbEnvPoolTest extends TestBase { Environment envA = new Environment(envHomeA, envConfig); /* Look in the environment pool with the relative path name. */ - File file2 = new File("build/test/classes"); + File file2 = new File(SharedTestUtils.DEFAULT_DEST_DIR); assertTrue(DbEnvPool.getInstance().isOpen(file2)); envA.close(); @@ -102,7 +101,6 @@ public class DbEnvPoolTest extends TestBase { /** * Test that SharedCache Environments really shares cache. */ - @Ignore @Test public void testSharedCacheEnv() throws Throwable { diff --git a/stasis-test/src/test/java/com/sleepycat/je/dbi/StartupTrackerTest.java b/stasis-test/src/test/java/com/sleepycat/je/dbi/StartupTrackerTest.java index 8040a0d..9f15a6f 100644 --- a/stasis-test/src/test/java/com/sleepycat/je/dbi/StartupTrackerTest.java +++ b/stasis-test/src/test/java/com/sleepycat/je/dbi/StartupTrackerTest.java @@ -20,6 +20,7 @@ import java.io.File; import java.io.PrintStream; import java.util.logging.Logger; +import com.sleepycat.util.test.SharedTestUtils; import org.junit.After; import org.junit.Before; import org.junit.Ignore; @@ -44,7 +45,7 @@ public class StartupTrackerTest extends TestBase { private final File envHome; public StartupTrackerTest() { - envHome = new File(System.getProperty(TestUtils.DEST_DIR)); + envHome = SharedTestUtils.getDestDir(); } @Before @@ -75,7 +76,6 @@ public class StartupTrackerTest extends TestBase { // TestUtils.removeLogFiles("TearDown", envHome, false); } - @Ignore @Test public void testEnvRecovery() { diff --git a/stasis-test/src/test/java/com/sleepycat/je/log/LogManagerTest.java b/stasis-test/src/test/java/com/sleepycat/je/log/LogManagerTest.java index 9a8725c..115ea82 100644 --- a/stasis-test/src/test/java/com/sleepycat/je/log/LogManagerTest.java +++ b/stasis-test/src/test/java/com/sleepycat/je/log/LogManagerTest.java @@ -979,7 +979,6 @@ public class LogManagerTest extends TestBase { testChecksumExReasonInternal("logbufferPersistent"); } - @Ignore @Test public void testChecksumExReasonFileSource() throws FileNotFoundException{ @@ -1001,7 +1000,7 @@ public class LogManagerTest extends TestBase { Trace smallTrace = new Trace("generate logbuffer"); long lsn = Trace.trace(envImpl, smallTrace); - /* Crash the logbuffer. */ + /* Crash the logBuffer. */ try { LogBuffer logBuffer = (LogBuffer) logManager.getLogSource(lsn); ByteBuffer byteBuf = logBuffer.getBytes(DbLsn.getFileOffset(lsn)); diff --git a/stasis-test/src/test/java/com/sleepycat/je/txn/TxnEndTest.java b/stasis-test/src/test/java/com/sleepycat/je/txn/TxnEndTest.java index b15d46f..f453480 100644 --- a/stasis-test/src/test/java/com/sleepycat/je/txn/TxnEndTest.java +++ b/stasis-test/src/test/java/com/sleepycat/je/txn/TxnEndTest.java @@ -656,7 +656,6 @@ public class TxnEndTest extends TestBase { * perform a cursor operation. While the BIN is held, it attempts to get a * non-blocking lock. */ - @Ignore @Test public void testAbortLatchDeadlock() { diff --git a/stasis-test/src/test/java/com/sleepycat/je/utilint/FileStoreInfoTest.java b/stasis-test/src/test/java/com/sleepycat/je/utilint/FileStoreInfoTest.java index 033456e..f1dac45 100644 --- a/stasis-test/src/test/java/com/sleepycat/je/utilint/FileStoreInfoTest.java +++ b/stasis-test/src/test/java/com/sleepycat/je/utilint/FileStoreInfoTest.java @@ -36,36 +36,8 @@ public class FileStoreInfoTest { private final Logger logger = LoggerUtils.getLoggerFixedPrefix(getClass(), "Test"); - /** Test when running on Java 6. */ - @Ignore @Test - public void testJava6() - throws Exception { - - try { - Class.forName(FileStoreInfo.FILE_STORE_CLASS); - assumeThat("Skip when running Java 7 or later", nullValue()); - } catch (ClassNotFoundException e) { - } - - try { - FileStoreInfo.checkSupported(); - fail("Expected UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { - logger.info("Got expected unsupported exception for Java 6: " + e); - } - - try { - FileStoreInfo.getInfo(System.getProperty("user.dir")); - fail("Expected UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { - logger.info("Got expected exception for Java 6: " + e); - } - } - - /** Test when running on Java 7 or later. */ - @Test - public void testJava7() + public void testJava7andLater() throws Exception { try { diff --git a/stasis-test/src/test/java/com/sleepycat/util/test/SharedTestUtils.java b/stasis-test/src/test/java/com/sleepycat/util/test/SharedTestUtils.java index 1332948..908b987 100644 --- a/stasis-test/src/test/java/com/sleepycat/util/test/SharedTestUtils.java +++ b/stasis-test/src/test/java/com/sleepycat/util/test/SharedTestUtils.java @@ -37,7 +37,7 @@ public class SharedTestUtils { public static String DEST_DIR = "testdestdir"; public static String TEST_ENV_DIR = "testenvdirroot"; public static String FAILURE_DIR = "failurecopydir"; - public static String DEFAULT_DEST_DIR = "target/scala-2.12/test-classes"; + public static String DEFAULT_DEST_DIR = "target/scala-2.12/test-classes"; // util.Properties.versionNumberString public static String DEFAULT_TEST_DIR_ROOT = "target/envdata"; public static String DEFAULT_FAIL_DIR = "target/failures"; public static String NO_SYNC = "txnnosync"; @@ -58,7 +58,18 @@ public class SharedTestUtils { File file = new File(dir); if (!file.isDirectory()) file.mkdir(); - + + return file; + } + + /** + * The environment store compiled class files and generated environment by + * test that is distinctive with test environment. + */ + public static File getDestDirChlid(String child) { + String dir = System.getProperty(DEST_DIR, DEFAULT_DEST_DIR); + File file = new File(dir, child); + return file; }