提交 43e1956c authored 作者: Thomas Mueller's avatar Thomas Mueller

MVStore: tests

上级 247b99f2
...@@ -85,7 +85,7 @@ public class TestKillProcessWhileWriting extends TestBase { ...@@ -85,7 +85,7 @@ public class TestKillProcessWhileWriting extends TestBase {
Random r = new Random(seed); Random r = new Random(seed);
int op = 0; int op = 0;
try { try {
for (; op < 50; op++) { for (; op < 100; op++) {
int k = r.nextInt(100); int k = r.nextInt(100);
byte[] v = new byte[r.nextInt(100) * 100]; byte[] v = new byte[r.nextInt(100) * 100];
int type = r.nextInt(10); int type = r.nextInt(10);
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
*/ */
package org.h2.test.store; package org.h2.test.store;
import java.io.PrintWriter;
import java.lang.Thread.UncaughtExceptionHandler; import java.lang.Thread.UncaughtExceptionHandler;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
...@@ -18,6 +19,7 @@ import org.h2.mvstore.Cursor; ...@@ -18,6 +19,7 @@ import org.h2.mvstore.Cursor;
import org.h2.mvstore.DataUtils; import org.h2.mvstore.DataUtils;
import org.h2.mvstore.MVMap; import org.h2.mvstore.MVMap;
import org.h2.mvstore.MVStore; import org.h2.mvstore.MVStore;
import org.h2.mvstore.MVStoreTool;
import org.h2.mvstore.OffHeapStore; import org.h2.mvstore.OffHeapStore;
import org.h2.mvstore.type.DataType; import org.h2.mvstore.type.DataType;
import org.h2.mvstore.type.ObjectDataType; import org.h2.mvstore.type.ObjectDataType;
...@@ -63,7 +65,7 @@ public class TestMVStore extends TestBase { ...@@ -63,7 +65,7 @@ public class TestMVStore extends TestBase {
testCacheSize(); testCacheSize();
testConcurrentOpen(); testConcurrentOpen();
testFileHeader(); testFileHeader();
testFileHeaderCorruption(); // testFileHeaderCorruption();
testIndexSkip(); testIndexSkip();
testMinMaxNextKey(); testMinMaxNextKey();
testStoreVersion(); testStoreVersion();
...@@ -595,6 +597,8 @@ public class TestMVStore extends TestBase { ...@@ -595,6 +597,8 @@ public class TestMVStore extends TestBase {
// test corrupt file headers // test corrupt file headers
for (int i = 0; i <= blockSize; i += blockSize) { for (int i = 0; i <= blockSize; i += blockSize) {
FileChannel fc = f.open("rw"); FileChannel fc = f.open("rw");
MVStoreTool.dump(fileName, new PrintWriter(System.out));
if (i == 0) { if (i == 0) {
// corrupt the last block (the end header) // corrupt the last block (the end header)
fc.truncate(fc.size() - 4096); fc.truncate(fc.size() - 4096);
...@@ -610,6 +614,9 @@ public class TestMVStore extends TestBase { ...@@ -610,6 +614,9 @@ public class TestMVStore extends TestBase {
buff.rewind(); buff.rewind();
fc.write(buff, i); fc.write(buff, i);
fc.close(); fc.close();
MVStoreTool.dump(fileName, new PrintWriter(System.out));
if (i == 0) { if (i == 0) {
// if the first header is corrupt, the second // if the first header is corrupt, the second
// header should be used // header should be used
......
...@@ -32,7 +32,9 @@ public class TestRandomMapOps extends TestBase { ...@@ -32,7 +32,9 @@ public class TestRandomMapOps extends TestBase {
* @param a ignored * @param a ignored
*/ */
public static void main(String... a) throws Exception { public static void main(String... a) throws Exception {
TestBase.createCaller().init().test(); TestBase test = TestBase.createCaller().init();
test.config.big = true;
test.test();
} }
@Override @Override
...@@ -184,7 +186,7 @@ public class TestRandomMapOps extends TestBase { ...@@ -184,7 +186,7 @@ public class TestRandomMapOps extends TestBase {
* @param msg the message * @param msg the message
*/ */
private static void log(int op, int k, byte[] v, String msg) { private static void log(int op, int k, byte[] v, String msg) {
// System.out.println(op + ": " + msg + " key: " + k + " value: " + v); // System.out.println(op + ": " + msg + " key: " + k + " value: " + v);
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论