提交 db4ebf32 authored 作者: Thomas Mueller's avatar Thomas Mueller

Remove unused code; automated test case.

上级 b095405a
......@@ -291,7 +291,9 @@ java org.h2.test.TestAll timer
/*
power failure test
power failure test: larger binaries and additional index.
power failure test with randomly generating / dropping indexes and tables.
drop table test;
create table test(id identity, name varchar(100) default space(100));
......
......@@ -1134,15 +1134,6 @@ public abstract class TestBase {
return "bin" + File.pathSeparator + "temp" + File.pathSeparator + ".";
}
/**
* Get the page store property to use when starting new processes.
*
* @return the property
*/
public String getPageStoreProperty() {
return "-Dh2.pageStore=" + System.getProperty("h2.pageStore");
}
/**
* Use up almost all memory.
*
......
/*
* Copyright 2004-2010 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.poweroff;
import java.io.InputStream;
import java.util.Random;
import org.h2.store.fs.FileSystemDisk;
import org.h2.test.TestBase;
import org.h2.test.synth.OutputCatcher;
/**
* Run the TestRecover test case in a loop. The process is killed after 10 seconds.
*/
public class TestRecoverKillLoop extends TestBase {
/**
* This method is called when executing this application from the command
* line.
*
* @param args the command line parameters
*/
public static void main(String... args) throws Exception {
new TestRecoverKillLoop().runTest(Integer.MAX_VALUE);
}
public void test() throws Exception {
runTest(3);
}
private void runTest(int count) throws Exception {
FileSystemDisk.getInstance().deleteRecursive("data/db", false);
Random random = new Random(1);
for (int i = 0; i < count; i++) {
String[] procDef = new String[] {
"java", "-cp", getClassPath(),
"-Dtest.dir=data/db",
TestRecover.class.getName()
};
Process p = Runtime.getRuntime().exec(procDef);
InputStream in = p.getInputStream();
OutputCatcher catcher = new OutputCatcher(in);
catcher.start();
while (true) {
String s = catcher.readLine(60 * 1000);
// System.out.println("> " + s);
if (s == null) {
fail("No reply from process");
} else if (s.startsWith("testing...")) {
int sleep = random.nextInt(10000);
Thread.sleep(sleep);
printTime("killing");
p.destroy();
p.waitFor();
break;
} else if (s.startsWith("error!")) {
fail("Failed: " + s);
}
}
}
}
}
......@@ -15,11 +15,11 @@ import org.h2.util.IOUtils;
/**
* Catches the output of another process.
*/
class OutputCatcher extends Thread {
public class OutputCatcher extends Thread {
private InputStream in;
private LinkedList<String> list = new LinkedList<String>();
OutputCatcher(InputStream in) {
public OutputCatcher(InputStream in) {
this.in = in;
}
......@@ -29,7 +29,7 @@ class OutputCatcher extends Thread {
* @param wait the maximum number of milliseconds to wait
* @return the line
*/
String readLine(long wait) {
public String readLine(long wait) {
long start = System.currentTimeMillis();
while (true) {
synchronized (list) {
......
......@@ -234,7 +234,7 @@ public abstract class TestHalt extends TestBase {
// String classPath = "-cp
// .;D:/data/java/hsqldb.jar;D:/data/java/derby.jar";
String selfDestruct = SelfDestructor.getPropertyString(60);
String[] procDef = new String[] { "java", selfDestruct, getPageStoreProperty(),
String[] procDef = new String[] { "java", selfDestruct,
"-cp", getClassPath(),
getClass().getName(), "" + operations, "" + flags, "" + testValue};
traceOperation("start: " + StringUtils.arrayCombine(procDef, ' '));
......
......@@ -48,7 +48,7 @@ public class TestKill extends TestBase {
String password = getPassword();
String selfDestruct = SelfDestructor.getPropertyString(60);
String[] procDef = new String[] {
"java", selfDestruct, getPageStoreProperty(),
"java", selfDestruct,
"-cp", getClassPath(),
"org.h2.test.synth.TestKillProcess", url, user,
password, baseDir, "" + accounts };
......
......@@ -32,7 +32,7 @@ public class TestKillRestart extends TestBase {
// "killRestart;CACHE_SIZE=2048;WRITE_DELAY=0", true);
String user = getUser(), password = getPassword();
String selfDestruct = SelfDestructor.getPropertyString(60);
String[] procDef = new String[] { "java", selfDestruct, getPageStoreProperty(),
String[] procDef = new String[] { "java", selfDestruct,
"-cp", getClassPath(),
getClass().getName(), "-url", url, "-user", user,
"-password", password };
......
......@@ -45,7 +45,7 @@ public class TestKillRestartMulti extends TestBase {
user = getUser();
password = getPassword();
String selfDestruct = SelfDestructor.getPropertyString(60);
String[] procDef = new String[] { "java", selfDestruct, getPageStoreProperty(),
String[] procDef = new String[] { "java", selfDestruct,
"-cp", getClassPath(),
getClass().getName(), "-url", url, "-user", user,
"-password", password };
......
......@@ -32,7 +32,7 @@ public class TestExit extends TestBase implements DatabaseEventListener {
}
deleteDb("exit");
String selfDestruct = SelfDestructor.getPropertyString(60);
String[] procDef = new String[] { "java", selfDestruct, getPageStoreProperty(),
String[] procDef = new String[] { "java", selfDestruct,
"-cp", getClassPath(),
getClass().getName(), "" + OPEN_WITH_CLOSE_ON_EXIT };
Process proc = Runtime.getRuntime().exec(procDef);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论