提交 2e98e3f4 authored 作者: Thomas Mueller's avatar Thomas Mueller

More / fixed test cases.

上级 8e7003d9
...@@ -42,12 +42,14 @@ public class TestMemoryUsage extends TestBase { ...@@ -42,12 +42,14 @@ public class TestMemoryUsage extends TestBase {
testCreateIndex(); testCreateIndex();
testClob(); testClob();
testReconnectOften(); testReconnectOften();
deleteDb("memoryUsage"); deleteDb("memoryUsage");
reconnect(); reconnect();
insertUpdateSelectDelete(); insertUpdateSelectDelete();
reconnect(); reconnect();
insertUpdateSelectDelete(); insertUpdateSelectDelete();
conn.close(); conn.close();
deleteDb("memoryUsage"); deleteDb("memoryUsage");
} }
...@@ -68,21 +70,36 @@ public class TestMemoryUsage extends TestBase { ...@@ -68,21 +70,36 @@ public class TestMemoryUsage extends TestBase {
} }
private void testCreateDropLoop() throws SQLException { private void testCreateDropLoop() throws SQLException {
deleteDb("memoryUsage"); deleteDb("memoryUsageCreateDropLoop");
conn = getConnection("memoryUsage"); conn = getConnection("memoryUsageCreateDropLoop");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
stat.execute("CREATE TABLE TEST(ID INT)"); stat.execute("CREATE TABLE TEST(ID INT)");
stat.execute("DROP TABLE TEST"); stat.execute("DROP TABLE TEST");
} }
stat.execute("checkpoint");
int used = Utils.getMemoryUsed(); int used = Utils.getMemoryUsed();
for (int i = 0; i < 1000; i++) { for (int i = 0; i < 1000; i++) {
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY)"); stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY)");
stat.execute("DROP TABLE TEST"); stat.execute("DROP TABLE TEST");
} }
stat.execute("checkpoint");
int usedNow = Utils.getMemoryUsed(); int usedNow = Utils.getMemoryUsed();
if (usedNow > used * 1.3) { if (usedNow > used * 1.3) {
assertEquals(used, usedNow); // try to lower memory usage (because it might be wrong)
// by forcing OOME
for (int i = 1024;; i *= 2) {
try {
byte[] oome = new byte[1024 * 1024 * 256];
oome[0] = (byte) i;
} catch (OutOfMemoryError e) {
break;
}
}
usedNow = Utils.getMemoryUsed();
if (usedNow > used * 1.3) {
assertEquals(used, usedNow);
}
} }
conn.close(); conn.close();
} }
...@@ -101,8 +118,8 @@ public class TestMemoryUsage extends TestBase { ...@@ -101,8 +118,8 @@ public class TestMemoryUsage extends TestBase {
if (config.memory || !config.big) { if (config.memory || !config.big) {
return; return;
} }
deleteDb("memoryUsage"); deleteDb("memoryUsageClob");
conn = getConnection("memoryUsage"); conn = getConnection("memoryUsageClob");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("SET MAX_LENGTH_INPLACE_LOB 8192"); stat.execute("SET MAX_LENGTH_INPLACE_LOB 8192");
stat.execute("SET CACHE_SIZE 8000"); stat.execute("SET CACHE_SIZE 8000");
......
...@@ -80,7 +80,7 @@ public class TestOptimizations extends TestBase { ...@@ -80,7 +80,7 @@ public class TestOptimizations extends TestBase {
testConvertOrToIn(); testConvertOrToIn();
deleteDb("optimizations"); deleteDb("optimizations");
} }
private void testIdentityIndexUsage() throws Exception { private void testIdentityIndexUsage() throws Exception {
Connection conn = getConnection("optimizations"); Connection conn = getConnection("optimizations");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
......
...@@ -88,6 +88,7 @@ public class TestSpatial extends TestBase { ...@@ -88,6 +88,7 @@ public class TestSpatial extends TestBase {
testInPlaceUpdate(); testInPlaceUpdate();
testScanIndexOnNonSpatialQuery(); testScanIndexOnNonSpatialQuery();
testStoreCorruption(); testStoreCorruption();
testExplainSpatialIndexWithPk();
} }
private void testHashCode() { private void testHashCode() {
...@@ -881,4 +882,32 @@ public class TestSpatial extends TestBase { ...@@ -881,4 +882,32 @@ public class TestSpatial extends TestBase {
} }
deleteDb("spatial"); deleteDb("spatial");
} }
private void testExplainSpatialIndexWithPk() throws SQLException {
deleteDb("spatial");
Connection conn = getConnection(url);
try {
Statement stat = conn.createStatement();
stat.execute("drop table if exists pt_cloud;");
stat.execute("CREATE TABLE PT_CLOUD(id serial, the_geom geometry) AS"
+ " SELECT null, CONCAT('POINT(',A.X,' ',B.X,')')::geometry the_geom "
+ "from system_range(0,120) A,system_range(0,10) B;");
stat.execute("create spatial index on pt_cloud(the_geom);");
ResultSet rs = stat.executeQuery(
"explain select * from PT_CLOUD " +
"where the_geom && 'POINT(1 1)'");
try {
assertTrue(rs.next());
assertFalse("H2 should use spatial index got this explain:\n" +
rs.getString(1), rs.getString(1).contains("tableScan"));
} finally {
rs.close();
}
} finally {
// Close the database
conn.close();
}
deleteDb("spatial");
}
} }
...@@ -431,7 +431,7 @@ public class TestMVStore extends TestBase { ...@@ -431,7 +431,7 @@ public class TestMVStore extends TestBase {
header.put("format", "2"); header.put("format", "2");
MVMap<Integer, String> m = s.openMap("data"); MVMap<Integer, String> m = s.openMap("data");
// this is to ensure the file header is overwritten // this is to ensure the file header is overwritten
for (int i = 0; i < 10; i++) { for (int i = 0; i < 100; i++) {
m.put(0, "Hello World " + i); m.put(0, "Hello World " + i);
s.commit(); s.commit();
if (i > 5) { if (i > 5) {
...@@ -445,7 +445,8 @@ public class TestMVStore extends TestBase { ...@@ -445,7 +445,8 @@ public class TestMVStore extends TestBase {
encryptionKey("007".toCharArray()). encryptionKey("007".toCharArray()).
fileName(fileName). fileName(fileName).
open(); open();
fail(); header = s.getStoreHeader();
fail(header.toString());
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
assertEquals(DataUtils.ERROR_UNSUPPORTED_FORMAT, assertEquals(DataUtils.ERROR_UNSUPPORTED_FORMAT,
DataUtils.getErrorCode(e.getMessage())); DataUtils.getErrorCode(e.getMessage()));
...@@ -480,12 +481,12 @@ public class TestMVStore extends TestBase { ...@@ -480,12 +481,12 @@ public class TestMVStore extends TestBase {
autoCommitDisabled(). autoCommitDisabled().
open(); open();
MVMap<Integer, String> m; MVMap<Integer, String> m;
for (int i = 0; i < 10; i++) { for (int i = 0; i < 100; i++) {
m = s.openMap("data" + i); m = s.openMap("data" + i);
m.put(0, "Hello World"); m.put(0, "Hello World");
s.commit(); s.commit();
} }
for (int i = 0; i < 10; i += 2) { for (int i = 0; i < 100; i += 2) {
m = s.openMap("data" + i); m = s.openMap("data" + i);
s.removeMap(m); s.removeMap(m);
s.commit(); s.commit();
......
...@@ -93,7 +93,8 @@ public class TestDiskFull extends TestBase { ...@@ -93,7 +93,8 @@ public class TestDiskFull extends TestBase {
} catch (SQLException e2) { } catch (SQLException e2) {
if (e2.getErrorCode() != ErrorCode.IO_EXCEPTION_1 if (e2.getErrorCode() != ErrorCode.IO_EXCEPTION_1
&& e2.getErrorCode() != ErrorCode.IO_EXCEPTION_2 && e2.getErrorCode() != ErrorCode.IO_EXCEPTION_2
&& e2.getErrorCode() != ErrorCode.DATABASE_IS_CLOSED) { && e2.getErrorCode() != ErrorCode.DATABASE_IS_CLOSED
&& e2.getErrorCode() != ErrorCode.OBJECT_CLOSED) {
throw e2; throw e2;
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论