提交 2630f92b authored 作者: Andrei Tokar's avatar Andrei Tokar

Yet another attempt to tighten that testing loop

上级 ff4993e4
...@@ -402,7 +402,7 @@ java org.h2.test.TestAll timer ...@@ -402,7 +402,7 @@ java org.h2.test.TestAll timer
/** /**
* The THROTTLE value to use. * The THROTTLE value to use.
*/ */
int throttle; public int throttle;
/** /**
* The THROTTLE value to use by default. * The THROTTLE value to use by default.
......
...@@ -327,6 +327,9 @@ public class TestTempTables extends TestBase { ...@@ -327,6 +327,9 @@ public class TestTempTables extends TestBase {
* transaction table in the MVStore * transaction table in the MVStore
*/ */
private void testLotsOfTables() throws SQLException { private void testLotsOfTables() throws SQLException {
if (config.networked || config.throttle > 0) {
return; // just to save some testing time
}
deleteDb("tempTables"); deleteDb("tempTables");
Connection conn = getConnection("tempTables"); Connection conn = getConnection("tempTables");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
......
...@@ -11,7 +11,6 @@ import java.sql.ResultSet; ...@@ -11,7 +11,6 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.util.ArrayList; import java.util.ArrayList;
import org.h2.jdbc.JdbcSQLException;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.util.IOUtils; import org.h2.util.IOUtils;
...@@ -41,6 +40,11 @@ public class TestMvccMultiThreaded2 extends TestBase { ...@@ -41,6 +40,11 @@ public class TestMvccMultiThreaded2 extends TestBase {
test.test(); test.test();
} }
private int getTestDuration() {
// to save some testing time
return config.big ? TEST_TIME_SECONDS : TEST_TIME_SECONDS / 10;
}
@Override @Override
public void test() throws SQLException, InterruptedException { public void test() throws SQLException, InterruptedException {
if (!config.mvcc) { if (!config.mvcc) {
...@@ -106,7 +110,7 @@ public class TestMvccMultiThreaded2 extends TestBase { ...@@ -106,7 +110,7 @@ public class TestMvccMultiThreaded2 extends TestBase {
"+ INFO: TestMvccMultiThreaded2 RUN STATS threads=%d, minProcessed=%d, maxProcessed=%d, " "+ INFO: TestMvccMultiThreaded2 RUN STATS threads=%d, minProcessed=%d, maxProcessed=%d, "
+ "totalProcessed=%d, averagePerThread=%d, averagePerThreadPerSecond=%d\n", + "totalProcessed=%d, averagePerThread=%d, averagePerThreadPerSecond=%d\n",
TEST_THREAD_COUNT, minProcessed, maxProcessed, totalProcessed, totalProcessed / TEST_THREAD_COUNT, TEST_THREAD_COUNT, minProcessed, maxProcessed, totalProcessed, totalProcessed / TEST_THREAD_COUNT,
totalProcessed / (TEST_THREAD_COUNT * TEST_TIME_SECONDS))); totalProcessed / (TEST_THREAD_COUNT * getTestDuration())));
} }
IOUtils.closeSilently(conn); IOUtils.closeSilently(conn);
...@@ -142,31 +146,27 @@ public class TestMvccMultiThreaded2 extends TestBase { ...@@ -142,31 +146,27 @@ public class TestMvccMultiThreaded2 extends TestBase {
PreparedStatement ps = conn.prepareStatement( PreparedStatement ps = conn.prepareStatement(
"SELECT * FROM test WHERE entity_id = ? FOR UPDATE"); "SELECT * FROM test WHERE entity_id = ? FOR UPDATE");
while (!done) { while (!done) {
try { String id;
String id; int value;
int value; if ((iterationsProcessed & 1) == 0) {
if ((iterationsProcessed & 1) == 0) { id = "1";
id = "1"; value = 100;
value = 100; } else {
} else { id = "2";
id = "2"; value = 200;
value = 200; }
} ps.setString(1, id);
ps.setString(1, id); ResultSet rs = ps.executeQuery();
ResultSet rs = ps.executeQuery();
assertTrue(rs.next());
assertTrue(rs.next()); assertTrue(rs.getInt(2) == value);
assertTrue(rs.getInt(2) == value);
conn.commit();
conn.commit(); iterationsProcessed++;
iterationsProcessed++;
long now = System.currentTimeMillis();
long now = System.currentTimeMillis(); if (now - start > 1000 * getTestDuration()) {
if (now - start > 1000 * TEST_TIME_SECONDS) { done = true;
done = true;
}
} catch (JdbcSQLException e1) {
throw e1;
} }
} }
} catch (SQLException e) { } catch (SQLException e) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论