Unverified 提交 5bc2dcbb authored 作者: Andrei Tokar's avatar Andrei Tokar 提交者: GitHub

Merge pull request #1172 from h2database/reduce-test-time

Yet another attempt to tighten that testing loop
...@@ -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,7 +146,6 @@ public class TestMvccMultiThreaded2 extends TestBase { ...@@ -142,7 +146,6 @@ 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) {
...@@ -162,12 +165,9 @@ public class TestMvccMultiThreaded2 extends TestBase { ...@@ -162,12 +165,9 @@ public class TestMvccMultiThreaded2 extends TestBase {
iterationsProcessed++; iterationsProcessed++;
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
if (now - start > 1000 * TEST_TIME_SECONDS) { if (now - start > 1000 * getTestDuration()) {
done = true; done = true;
} }
} catch (JdbcSQLException e1) {
throw e1;
}
} }
} catch (SQLException e) { } catch (SQLException e) {
TestBase.logError("SQL error from thread "+getName(), e); TestBase.logError("SQL error from thread "+getName(), e);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论