Fixes
This commit is contained in:
parent
511fbcc876
commit
4bf2c7ba0c
17 changed files with 144 additions and 121 deletions
|
@ -1,13 +1,41 @@
|
||||||
version=2.0.0-RC5
|
version=2.0.0-RC5
|
||||||
project.git = true
|
project.git = true
|
||||||
project.excludeFilters = [
|
|
||||||
scalafmt-benchmarks/src/resources,
|
|
||||||
sbt-test
|
|
||||||
bin/issue
|
|
||||||
]
|
|
||||||
align = none
|
align = none
|
||||||
# Disabled in default since this operation is potentially
|
|
||||||
# dangerous if you define your own stripMargin with different
|
|
||||||
# semantics from the stdlib stripMargin.
|
|
||||||
assumeStandardLibraryStripMargin = true
|
assumeStandardLibraryStripMargin = true
|
||||||
onTestFailure = "To fix this, run ./scalafmt from the project root directory"
|
onTestFailure = "To fix this, run ./scalafmt from the project root directory"
|
||||||
|
style = default
|
||||||
|
align.openParenCallSite=false
|
||||||
|
align.openParenDefnSite=false
|
||||||
|
align.tokens = []
|
||||||
|
assumeStandardLibraryStripMargin = true
|
||||||
|
binPack.parentConstructors = false
|
||||||
|
danglingParentheses = false
|
||||||
|
docstrings = ScalaDoc
|
||||||
|
maxColumn = 100
|
||||||
|
optIn.annotationNewlines = true
|
||||||
|
optIn.breakChainOnFirstMethodDot = true
|
||||||
|
optIn.selfAnnotationNewline = true
|
||||||
|
project.git = true
|
||||||
|
project.includeFilters = [
|
||||||
|
build.sbt
|
||||||
|
ExpectSuite.scala
|
||||||
|
scalameta/contrib
|
||||||
|
scalameta/semanticdb
|
||||||
|
]
|
||||||
|
project.excludeFilters = [
|
||||||
|
scalafmt-benchmarks/src/resources
|
||||||
|
sbt-test
|
||||||
|
bin/issue
|
||||||
|
semanticdb/semanticdb/src/main/generated
|
||||||
|
sbt-test
|
||||||
|
contrib/package.scala
|
||||||
|
scalac-plugin.xml
|
||||||
|
SemanticdbAnalyzer.scala
|
||||||
|
Scalalib.scala
|
||||||
|
com.sun.source.util.Plugin
|
||||||
|
/java/
|
||||||
|
.proto
|
||||||
|
.md
|
||||||
|
]
|
||||||
|
runner.dialect = Scala212
|
||||||
|
runner.optimizer.forceConfigStyleOnOffset = -1
|
||||||
|
|
43
build.sbt
43
build.sbt
|
@ -154,6 +154,11 @@ lazy val rep = project
|
||||||
)
|
)
|
||||||
.dependsOn(core)
|
.dependsOn(core)
|
||||||
|
|
||||||
|
val testLibraryDependencies = Seq (
|
||||||
|
"junit" % "junit" % "4.12" % Test,
|
||||||
|
"com.novocode" % "junit-interface" % "0.11" % Test
|
||||||
|
)
|
||||||
|
|
||||||
lazy val test = project
|
lazy val test = project
|
||||||
.in(file("stasis-test"))
|
.in(file("stasis-test"))
|
||||||
.settings(
|
.settings(
|
||||||
|
@ -204,27 +209,43 @@ lazy val test = project
|
||||||
s"-Ddoclet.jar=${docdir}/HidingDoclet.jar",
|
s"-Ddoclet.jar=${docdir}/HidingDoclet.jar",
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
libraryDependencies ++= Seq(
|
libraryDependencies ++= testLibraryDependencies
|
||||||
"junit" % "junit" % "4.12" % Test,
|
|
||||||
"com.novocode" % "junit-interface" % "0.11" % Test
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
.disablePlugins(plugins.JUnitXmlReportPlugin)
|
.disablePlugins(plugins.JUnitXmlReportPlugin)
|
||||||
.dependsOn(core, persist, rep)
|
.dependsOn(core, persist, rep)
|
||||||
|
|
||||||
|
val testJavacOptions =Seq(
|
||||||
|
"-Xlint:deprecation",
|
||||||
|
"-Xlint:unchecked"
|
||||||
|
)
|
||||||
|
|
||||||
lazy val test_examples = project
|
lazy val test_examples = project
|
||||||
.in(file("stasis-test-examples"))
|
.in(file("stasis-test-examples"))
|
||||||
.settings(
|
.settings(
|
||||||
moduleName := "stasis-test-examples",
|
moduleName := "stasis-test-examples",
|
||||||
assemblyJarName.in(assembly) := "stasis-test-examples.jar",
|
assemblyJarName.in(assembly) := "stasis-test-examples.jar",
|
||||||
Test / javacOptions := Seq(
|
Test / javacOptions := testJavacOptions,
|
||||||
"-Xlint:deprecation",
|
libraryDependencies ++= testLibraryDependencies
|
||||||
"-Xlint:unchecked"
|
|
||||||
),
|
|
||||||
libraryDependencies ++= Seq(
|
|
||||||
"junit" % "junit" % "4.12" % Test,
|
|
||||||
"com.novocode" % "junit-interface" % "0.11" % Test
|
|
||||||
)
|
)
|
||||||
|
.dependsOn(core, persist, rep, test)
|
||||||
|
|
||||||
|
lazy val test_dpl_v0 = project
|
||||||
|
.in(file("stasis-test-dpl-v0"))
|
||||||
|
.settings(
|
||||||
|
moduleName := "stasis-test-dpl-v0",
|
||||||
|
assemblyJarName.in(assembly) := "stasis-test-dpl-v0.jar",
|
||||||
|
Test / javacOptions := testJavacOptions,
|
||||||
|
libraryDependencies ++= testLibraryDependencies
|
||||||
|
)
|
||||||
|
.dependsOn(core, persist, rep, test)
|
||||||
|
|
||||||
|
lazy val test_dpl_v1 = project
|
||||||
|
.in(file("stasis-test-dpl-v1"))
|
||||||
|
.settings(
|
||||||
|
moduleName := "stasis-test-dpl-v1",
|
||||||
|
assemblyJarName.in(assembly) := "stasis-test-dpl-v1.jar",
|
||||||
|
Test / javacOptions := testJavacOptions,
|
||||||
|
libraryDependencies ++= testLibraryDependencies
|
||||||
)
|
)
|
||||||
.dependsOn(core, persist, rep, test)
|
.dependsOn(core, persist, rep, test)
|
||||||
|
|
||||||
|
|
|
@ -614,8 +614,7 @@ public class EnvironmentMutableConfig implements Cloneable, Serializable {
|
||||||
void checkImmutablePropsForEquality(Properties handleConfigProps)
|
void checkImmutablePropsForEquality(Properties handleConfigProps)
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
|
|
||||||
Iterator<String> iter =
|
Iterator<String> iter = EnvironmentParams.SUPPORTED_PARAMS.keySet().iterator();
|
||||||
EnvironmentParams.SUPPORTED_PARAMS.keySet().iterator();
|
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
String paramName = iter.next();
|
String paramName = iter.next();
|
||||||
ConfigParam param =
|
ConfigParam param =
|
||||||
|
|
|
@ -505,7 +505,7 @@ public class DbConfigManager {
|
||||||
|
|
||||||
if (param == null) {
|
if (param == null) {
|
||||||
|
|
||||||
/* See if the parameter is an multi-value parameter. */
|
/* See if the parameter is a multi-value parameter. */
|
||||||
String mvParamName = ConfigParam.multiValueParamName(paramName);
|
String mvParamName = ConfigParam.multiValueParamName(paramName);
|
||||||
param = EnvironmentParams.SUPPORTED_PARAMS.get(mvParamName);
|
param = EnvironmentParams.SUPPORTED_PARAMS.get(mvParamName);
|
||||||
if (param == null) {
|
if (param == null) {
|
||||||
|
|
|
@ -41,6 +41,7 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -1031,7 +1032,8 @@ public class EnvironmentImpl implements EnvConfigObserver {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class<?> newClass = Class.forName(className);
|
Class<?> newClass = Class.forName(className);
|
||||||
MBeanRegistrar mBeanReg = (MBeanRegistrar) newClass.newInstance();
|
Constructor constructor = newClass.getConstructor(String.class);
|
||||||
|
MBeanRegistrar mBeanReg = (MBeanRegistrar)constructor.newInstance();
|
||||||
mBeanReg.doRegister(env);
|
mBeanReg.doRegister(env);
|
||||||
mBeanRegList.add(mBeanReg);
|
mBeanRegList.add(mBeanReg);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -13,6 +13,10 @@
|
||||||
|
|
||||||
package com.sleepycat.je.utilint;
|
package com.sleepycat.je.utilint;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Duplicate of java.sql.Timestamp
|
* Duplicate of java.sql.Timestamp
|
||||||
* This duplicate keeps our implementation constant in case the java.sql.Timestamp implementation
|
* This duplicate keeps our implementation constant in case the java.sql.Timestamp implementation
|
||||||
|
@ -62,12 +66,13 @@ public class Timestamp extends java.util.Date {
|
||||||
* {@code yyyy-mm-dd hh:mm:ss.fffffffff} format
|
* {@code yyyy-mm-dd hh:mm:ss.fffffffff} format
|
||||||
*/
|
*/
|
||||||
public String toString() {
|
public String toString() {
|
||||||
int year = super.getYear() + 1900;
|
Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
|
||||||
int month = super.getMonth() + 1;
|
int year = cal.get(Calendar.YEAR) - 1900;
|
||||||
int day = super.getDate();
|
int month = cal.get(Calendar.MONTH) + 1;
|
||||||
int hour = super.getHours();
|
int day = cal.get(Calendar.DAY_OF_MONTH) + 1;
|
||||||
int minute = super.getMinutes();
|
int hour = cal.get(Calendar.HOUR_OF_DAY) + 1;
|
||||||
int second = super.getSeconds();
|
int minute = cal.get(Calendar.MINUTE) + 1;
|
||||||
|
int second = cal.get(Calendar.SECOND) + 1;
|
||||||
String yearString;
|
String yearString;
|
||||||
String monthString;
|
String monthString;
|
||||||
String dayString;
|
String dayString;
|
||||||
|
|
|
@ -96,9 +96,15 @@ public class StoredClassCatalogTest extends TestBase
|
||||||
* Copy the environment generated by StoredClassCatalogTestInit in
|
* Copy the environment generated by StoredClassCatalogTestInit in
|
||||||
* test dest dir, which is required to perform this test.
|
* test dest dir, which is required to perform this test.
|
||||||
*/
|
*/
|
||||||
SharedTestUtils.copyDir(
|
File dirA = new File(SharedTestUtils.getDestDir().getAbsolutePath(), customName);
|
||||||
new File(SharedTestUtils.getDestDir(), customName),
|
File dirB = new File(SharedTestUtils.getTestDir().getAbsolutePath(), customName);
|
||||||
new File(SharedTestUtils.getTestDir(), customName));
|
if (!dirA.exists()) {
|
||||||
|
dirA.mkdirs();
|
||||||
|
}
|
||||||
|
if (!dirB.exists()) {
|
||||||
|
dirB.mkdirs();
|
||||||
|
}
|
||||||
|
SharedTestUtils.copyDir(dirA, dirB);
|
||||||
|
|
||||||
env = testEnv.open(customName, false);
|
env = testEnv.open(customName, false);
|
||||||
runner = new TransactionRunner(env);
|
runner = new TransactionRunner(env);
|
||||||
|
@ -106,10 +112,8 @@ public class StoredClassCatalogTest extends TestBase
|
||||||
catalog = new StoredClassCatalog(openDb(CATALOG_FILE, false));
|
catalog = new StoredClassCatalog(openDb(CATALOG_FILE, false));
|
||||||
catalog2 = new StoredClassCatalog(openDb("catalog2.db", true));
|
catalog2 = new StoredClassCatalog(openDb("catalog2.db", true));
|
||||||
|
|
||||||
SerialBinding keyBinding = new SerialBinding(catalog,
|
SerialBinding keyBinding = new SerialBinding(catalog, String.class);
|
||||||
String.class);
|
SerialBinding valueBinding = new SerialBinding(catalog, TestSerial.class);
|
||||||
SerialBinding valueBinding = new SerialBinding(catalog,
|
|
||||||
TestSerial.class);
|
|
||||||
store = openDb(STORE_FILE, false);
|
store = openDb(STORE_FILE, false);
|
||||||
|
|
||||||
map = new StoredMap(store, keyBinding, valueBinding, true);
|
map = new StoredMap(store, keyBinding, valueBinding, true);
|
||||||
|
@ -158,7 +162,6 @@ public class StoredClassCatalogTest extends TestBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
public void runTest()
|
public void runTest()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
|
@ -90,8 +90,7 @@ public class StoredClassCatalogTestInit extends TestBase
|
||||||
catalog = new StoredClassCatalog(openDb(CATALOG_FILE));
|
catalog = new StoredClassCatalog(openDb(CATALOG_FILE));
|
||||||
|
|
||||||
SerialBinding keyBinding = new SerialBinding(catalog, String.class);
|
SerialBinding keyBinding = new SerialBinding(catalog, String.class);
|
||||||
SerialBinding valueBinding =
|
SerialBinding valueBinding = new SerialBinding(catalog, TestSerial.class);
|
||||||
new SerialBinding(catalog, TestSerial.class);
|
|
||||||
store = openDb(STORE_FILE);
|
store = openDb(STORE_FILE);
|
||||||
|
|
||||||
map = new StoredMap(store, keyBinding, valueBinding, true);
|
map = new StoredMap(store, keyBinding, valueBinding, true);
|
||||||
|
@ -128,8 +127,11 @@ public class StoredClassCatalogTestInit extends TestBase
|
||||||
* Copy environment generated by this test to test dest dir.
|
* Copy environment generated by this test to test dest dir.
|
||||||
* Since the environment is necessary for StoreClassCatalogTest.
|
* Since the environment is necessary for StoreClassCatalogTest.
|
||||||
*/
|
*/
|
||||||
SharedTestUtils.copyDir(testEnv.getDirectory(customName, false),
|
File destDir = new File(SharedTestUtils.getDestDir().getAbsolutePath(), customName);
|
||||||
new File(SharedTestUtils.getDestDir(), customName));
|
if (!destDir.isDirectory()) {
|
||||||
|
destDir.mkdirs();
|
||||||
|
}
|
||||||
|
SharedTestUtils.copyDir(testEnv.getDirectory(customName, false), destDir);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("Ignored exception during tearDown: ");
|
System.err.println("Ignored exception during tearDown: ");
|
||||||
|
@ -145,11 +147,9 @@ public class StoredClassCatalogTestInit extends TestBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
public void runTest()
|
public void runTest()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
runner.run(this);
|
runner.run(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,8 +128,7 @@ public class EnvironmentConfigTest extends TestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the je.properties. */
|
/* Read the je.properties. */
|
||||||
ArrayList<String> formerLines = TestUtils.readWriteJEProperties
|
ArrayList<String> formerLines = TestUtils.readWriteJEProperties(envHome, propName + "=" + propValue + "\n");
|
||||||
(envHome, propName + "=" + propValue + "\n");
|
|
||||||
|
|
||||||
/* Check this behavior is valid. */
|
/* Check this behavior is valid. */
|
||||||
Environment env = null;
|
Environment env = null;
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class StatCaptureTest extends TestBase {
|
||||||
private static final String DB_NAME = "foo";
|
private static final String DB_NAME = "foo";
|
||||||
|
|
||||||
public StatCaptureTest() {
|
public StatCaptureTest() {
|
||||||
envHome = SharedTestUtils.getTestDir();
|
envHome = new File(SharedTestUtils.getTestDir().getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -573,14 +573,14 @@ public class StatCaptureTest extends TestBase {
|
||||||
envConfig.setConfigParam(
|
envConfig.setConfigParam(
|
||||||
EnvironmentParams.STATS_COLLECT_INTERVAL.getName(), "1 s");
|
EnvironmentParams.STATS_COLLECT_INTERVAL.getName(), "1 s");
|
||||||
envConfig.setConfigParam(EnvironmentConfig.VERIFY_BTREE, "false");
|
envConfig.setConfigParam(EnvironmentConfig.VERIFY_BTREE, "false");
|
||||||
repEnvInfo = RepTestUtils.setupEnvInfos(
|
repEnvInfo = RepTestUtils.setupEnvInfos(envHome, 2, envConfig, new ReplicationConfig());
|
||||||
envHome, 2, envConfig, new ReplicationConfig());
|
|
||||||
repEnvHome = new File[repEnvInfo.length];
|
repEnvHome = new File[repEnvInfo.length];
|
||||||
for (int i = 0; i < repEnvInfo.length; i++) {
|
for (int i = 0; i < repEnvInfo.length; i++) {
|
||||||
repEnvHome[i] = repEnvInfo[i].getEnvHome();
|
repEnvHome[i] = repEnvInfo[i].getEnvHome();
|
||||||
|
SharedTestUtils.cleanUpTestDir(repEnvHome[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove any existing stats files. */
|
/* Remove any existing stats files. */
|
||||||
for (RepEnvInfo ri : repEnvInfo) {
|
for (RepEnvInfo ri : repEnvInfo) {
|
||||||
File[] files = ri.getEnvHome().listFiles(ff);
|
File[] files = ri.getEnvHome().listFiles(ff);
|
||||||
for (File f : files) {
|
for (File f : files) {
|
||||||
|
@ -602,8 +602,7 @@ public class StatCaptureTest extends TestBase {
|
||||||
fastconfig.setClear(true);
|
fastconfig.setClear(true);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* sleep to allow at least one row to be captured in stat file
|
* Sleep to allow at least one row to be captured in stat file before doing work.
|
||||||
* before doing work.
|
|
||||||
*/
|
*/
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
ReplicatedEnvironmentStats rs = replica.getRepStats(fastconfig);
|
ReplicatedEnvironmentStats rs = replica.getRepStats(fastconfig);
|
||||||
|
@ -628,10 +627,9 @@ public class StatCaptureTest extends TestBase {
|
||||||
Thread.sleep(2000);
|
Thread.sleep(2000);
|
||||||
RepTestUtils.shutdownRepEnvs(repEnvInfo);
|
RepTestUtils.shutdownRepEnvs(repEnvInfo);
|
||||||
}
|
}
|
||||||
/* Check master statistics */
|
|
||||||
File statcsv =
|
/* Check master statistics. */
|
||||||
new File(repEnvHome[0].getAbsolutePath() + File.separator +
|
File statcsv = new File(repEnvHome[0].getAbsolutePath() + File.separator + "je.stat.csv");
|
||||||
"je.stat.csv");
|
|
||||||
Map<String, Long> values = StatFile.sumItUp(statcsv);
|
Map<String, Long> values = StatFile.sumItUp(statcsv);
|
||||||
Long putCount = values.get("Op:priInsert");
|
Long putCount = values.get("Op:priInsert");
|
||||||
assertEquals(putCount.longValue(), DATACOUNT);
|
assertEquals(putCount.longValue(), DATACOUNT);
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class ReadOnlyLockingTest extends CleanerTestBase {
|
||||||
private Process readerProcess;
|
private Process readerProcess;
|
||||||
|
|
||||||
private static File getProcessFile() {
|
private static File getProcessFile() {
|
||||||
return SharedTestUtils.getDestDirChlid("ReadOnlyProcessFile");
|
return SharedTestUtils.getDestDirChild("ReadOnlyProcessFile");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void deleteProcessFile() {
|
private static void deleteProcessFile() {
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class DbEnvPoolTest extends TestBase {
|
||||||
Environment envA = new Environment(envHomeA, envConfig);
|
Environment envA = new Environment(envHomeA, envConfig);
|
||||||
|
|
||||||
/* Look in the environment pool with the relative path name. */
|
/* Look in the environment pool with the relative path name. */
|
||||||
File file2 = new File(SharedTestUtils.DEFAULT_DEST_DIR);
|
File file2 = new File(SharedTestUtils.defaultDestDir());
|
||||||
assertTrue(DbEnvPool.getInstance().isOpen(file2));
|
assertTrue(DbEnvPool.getInstance().isOpen(file2));
|
||||||
|
|
||||||
envA.close();
|
envA.close();
|
||||||
|
|
|
@ -147,11 +147,10 @@ public class UpgradeTest extends TestBase {
|
||||||
}
|
}
|
||||||
final ClassLoader parentClassLoader = Thread.currentThread().getContextClassLoader();
|
final ClassLoader parentClassLoader = Thread.currentThread().getContextClassLoader();
|
||||||
for (int i = 0; i < N_APP_VERSIONS; i += 1) {
|
for (int i = 0; i < N_APP_VERSIONS; i += 1) {
|
||||||
final ClassLoader myLoader = new SimpleClassLoader
|
File dir = new File(new File(SharedTestUtils.getCwd()).getParentFile().getParentFile().getAbsolutePath(),
|
||||||
(parentClassLoader,
|
"stasis-test-dpl-v" + String.valueOf(i) + File.separator + SharedTestUtils.defaultDestDir());
|
||||||
new File(evolveParentDir, "dplUpgrade." + i));
|
final ClassLoader myLoader = new SimpleClassLoader(parentClassLoader, dir);
|
||||||
appClasses[i] =
|
appClasses[i] = Class.forName(APP_IMPL, true /*initialize*/, myLoader);
|
||||||
Class.forName(APP_IMPL, true /*initialize*/, myLoader);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open v0 app objects. */
|
/* Open v0 app objects. */
|
||||||
|
|
|
@ -214,49 +214,17 @@ public class RepTestUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a directory within the envRoot directory nodes for housing a
|
* Create a directory within the envRoot directory nodes for housing a
|
||||||
* single replicated environment. The directory will be named
|
* single replicated environment. Name the directory `<envRoot>/rep<i>`.
|
||||||
* <envRoot>/rep<i>
|
|
||||||
*/
|
*/
|
||||||
public static File makeRepEnvDir(File envRoot, int i)
|
public static File makeRepEnvDir(File envRoot, int i)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
File jeProperties = new File(envRoot, "je.properties");
|
/* Make a sub-directory for the replica. */
|
||||||
File envHome = new File(envRoot, REPDIR + i);
|
File envHome = new File(envRoot, REPDIR + i);
|
||||||
envHome.mkdir();
|
envHome.mkdir();
|
||||||
|
|
||||||
/* Copy the test je.properties into the new directories. */
|
/* Copy the test je.properties into the directory. */
|
||||||
File repProperties = new File(envHome, "je.properties");
|
SharedTestUtils.copyFile(new File(envRoot, "je.properties"), envHome);
|
||||||
FileInputStream from = null;
|
|
||||||
FileOutputStream to = null;
|
|
||||||
try {
|
|
||||||
try {
|
|
||||||
from = new FileInputStream(jeProperties);
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
jeProperties.createNewFile();
|
|
||||||
|
|
||||||
from = new FileInputStream(jeProperties);
|
|
||||||
}
|
|
||||||
to = new FileOutputStream(repProperties);
|
|
||||||
byte[] buffer = new byte[4096];
|
|
||||||
int bytesRead;
|
|
||||||
|
|
||||||
while ((bytesRead = from.read(buffer)) != -1) {
|
|
||||||
to.write(buffer, 0, bytesRead);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (from != null) {
|
|
||||||
try {
|
|
||||||
from.close();
|
|
||||||
} catch (IOException ignore) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (to != null) {
|
|
||||||
try {
|
|
||||||
to.close();
|
|
||||||
} catch (IOException ignore) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return envHome;
|
return envHome;
|
||||||
}
|
}
|
||||||
|
@ -439,17 +407,16 @@ public class RepTestUtils {
|
||||||
/*
|
/*
|
||||||
* Give all the environments the same environment configuration.
|
* Give all the environments the same environment configuration.
|
||||||
*
|
*
|
||||||
* If the file size is not set by the calling test, stagger their log
|
* Stagger the log file length when not set to give them slightly
|
||||||
* file length to give them slightly different logs and VLSNs. Disable
|
* different logs and VLSNs. Disable parameter validation because
|
||||||
* parameter validation because we want to make the log file length
|
* we want to make the log file length smaller than the minimums,
|
||||||
* smaller than the minimums, for testing.
|
* for testing.
|
||||||
*/
|
*/
|
||||||
if (!envConfig.isConfigParamSet(EnvironmentConfig.LOG_FILE_MAX)) {
|
if (!envConfig.isConfigParamSet(EnvironmentConfig.LOG_FILE_MAX)) {
|
||||||
DbInternal.disableParameterValidation(envConfig);
|
DbInternal.disableParameterValidation(envConfig);
|
||||||
/* Vary the file size */
|
/* Vary the file size. */
|
||||||
long fileLen = ((envCount++ % 100) + 1) * 10000;
|
long fileLen = ((envCount++ % 100) + 1) * 10000;
|
||||||
envConfig.setConfigParam(EnvironmentConfig.LOG_FILE_MAX,
|
envConfig.setConfigParam(EnvironmentConfig.LOG_FILE_MAX, Long.toString(fileLen));
|
||||||
Long.toString(fileLen));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
repConfig.setHelperHosts((helper == null) ?
|
repConfig.setHelperHosts((helper == null) ?
|
||||||
|
@ -457,7 +424,7 @@ public class RepTestUtils {
|
||||||
helper.getRepConfig().getNodeHostPort());
|
helper.getRepConfig().getNodeHostPort());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If -DlongTimeout is true, then this test will run with very long
|
* NOTE: When `-DlongTimeout` is `true`, then this test will run with very long
|
||||||
* timeouts, to make interactive debugging easier.
|
* timeouts, to make interactive debugging easier.
|
||||||
*/
|
*/
|
||||||
if (longTimeout) {
|
if (longTimeout) {
|
||||||
|
@ -465,8 +432,7 @@ public class RepTestUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If -DlongAckTimeout is true, then the test will set the
|
* When `-DlongAckTimeout` is `true`, then the test will set the `REPLICA_TIMEOUT` to `50secs`.
|
||||||
* REPLICA_TIMEOUT to 50secs.
|
|
||||||
*/
|
*/
|
||||||
if (Boolean.getBoolean("longAckTimeout")) {
|
if (Boolean.getBoolean("longAckTimeout")) {
|
||||||
repConfig.setReplicaAckTimeout(50, TimeUnit.SECONDS);
|
repConfig.setReplicaAckTimeout(50, TimeUnit.SECONDS);
|
||||||
|
|
|
@ -34,11 +34,13 @@ import com.sleepycat.je.DatabaseConfig;
|
||||||
*/
|
*/
|
||||||
public class SharedTestUtils {
|
public class SharedTestUtils {
|
||||||
|
|
||||||
|
/* @see defaultDestDir() */
|
||||||
|
private static String DEFAULT_DEST_DIR = "target/scala-%s/test-classes"; // util.Properties.versionNumberString
|
||||||
|
|
||||||
/* Common system properties for running tests */
|
/* Common system properties for running tests */
|
||||||
public static String DEST_DIR = "testdestdir";
|
public static String DEST_DIR = "testdestdir";
|
||||||
public static String TEST_ENV_DIR = "testenvdirroot";
|
public static String TEST_ENV_DIR = "testenvdirroot";
|
||||||
public static String FAILURE_DIR = "failurecopydir";
|
public static String FAILURE_DIR = "failurecopydir";
|
||||||
public static String DEFAULT_DEST_DIR = "target/scala-%s/test-classes"; // util.Properties.versionNumberString
|
|
||||||
public static String DEFAULT_TEST_DIR_ROOT = "target/envdata";
|
public static String DEFAULT_TEST_DIR_ROOT = "target/envdata";
|
||||||
public static String DEFAULT_FAIL_DIR = "target/failures";
|
public static String DEFAULT_FAIL_DIR = "target/failures";
|
||||||
public static String NO_SYNC = "txnnosync";
|
public static String NO_SYNC = "txnnosync";
|
||||||
|
@ -50,6 +52,10 @@ public class SharedTestUtils {
|
||||||
DBCONFIG_CREATE.setAllowCreate(true);
|
DBCONFIG_CREATE.setAllowCreate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getCwd() {
|
||||||
|
return System.getProperty("user.dir");
|
||||||
|
}
|
||||||
|
|
||||||
public static String defaultDestDir() {
|
public static String defaultDestDir() {
|
||||||
String version = System.getProperty("scala.version");
|
String version = System.getProperty("scala.version");
|
||||||
return String.format(DEFAULT_DEST_DIR, version == null ? "2.13" : version);
|
return String.format(DEFAULT_DEST_DIR, version == null ? "2.13" : version);
|
||||||
|
@ -72,7 +78,7 @@ public class SharedTestUtils {
|
||||||
* The environment store compiled class files and generated environment by
|
* The environment store compiled class files and generated environment by
|
||||||
* test that is distinctive with test environment.
|
* test that is distinctive with test environment.
|
||||||
*/
|
*/
|
||||||
public static File getDestDirChlid(String child) {
|
public static File getDestDirChild(String child) {
|
||||||
String dir = System.getProperty(DEST_DIR, defaultDestDir());
|
String dir = System.getProperty(DEST_DIR, defaultDestDir());
|
||||||
File file = new File(dir, child);
|
File file = new File(dir, child);
|
||||||
|
|
||||||
|
@ -280,8 +286,8 @@ public class SharedTestUtils {
|
||||||
/**
|
/**
|
||||||
* Copy file to specified location.
|
* Copy file to specified location.
|
||||||
*/
|
*/
|
||||||
private static void copyFile(File from, File to)
|
public static void copyFile(File from, File to)
|
||||||
throws Exception {
|
throws IOException {
|
||||||
|
|
||||||
if (to.isDirectory())
|
if (to.isDirectory())
|
||||||
to = new File(to, from.getName());
|
to = new File(to, from.getName());
|
||||||
|
@ -313,8 +319,7 @@ public class SharedTestUtils {
|
||||||
*/
|
*/
|
||||||
public static void cleanUpTestDir(File dir) {
|
public static void cleanUpTestDir(File dir) {
|
||||||
if (!dir.isDirectory() || !dir.exists())
|
if (!dir.isDirectory() || !dir.exists())
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException("Not an existing directory: " + dir);
|
||||||
"Not an existing directory: " + dir);
|
|
||||||
File[] files = dir.listFiles();
|
File[] files = dir.listFiles();
|
||||||
if (files == null)
|
if (files == null)
|
||||||
return;
|
return;
|
||||||
|
@ -327,12 +332,10 @@ public class SharedTestUtils {
|
||||||
cleanUpTestDir(file);
|
cleanUpTestDir(file);
|
||||||
|
|
||||||
if (file.list().length == 0 && !file.delete())
|
if (file.list().length == 0 && !file.delete())
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException("Unable to delete" + file);
|
||||||
"Unable to delete" + file);
|
|
||||||
} else {
|
} else {
|
||||||
if(!file.delete())
|
if(!file.delete())
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException("Unable to delete " + file);
|
||||||
"Unable to delete " + file);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue