I've ran H2 (trunk) tests on my old netbook, and some of them failed.
Till now I've checked and fixed the following:
- *TestReadOnly* fails trying to load a DB at *readOnlyDbCreate* instead
of *readonlyDbCreate*: it could happen if the code was written and
tested on a case-insensitive file system (i.e. ntfs)
- *TestFileLockSerialized* fails probably because my netbook is veeery
slow, and the test code uses *Thread.sleep()* in order to coordinate
threads: I've replaced it with *CountDownLatch*.
Cheers
Davide
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.
Index: h2/src/test/org/h2/test/db/TestReadOnly.java
===================================================================
--- h2/src/test/org/h2/test/db/TestReadOnly.java (revision 4965)
+++ h2/src/test/org/h2/test/db/TestReadOnly.java (working copy)
@@ -106,7 +106,7 @@
stat.execute("create table a(id int)");
stat.execute("create index ai on a(id)");
conn.close();
- conn = getConnection("readOnlyDbCreate;ACCESS_MODE_DATA=r");
+ conn = getConnection("readonlyDbCreate;ACCESS_MODE_DATA=r");
stat = conn.createStatement();
stat.execute("create table if not exists a(id int)");
stat.execute("create index if not exists ai on a(id)");
Index: h2/src/test/org/h2/test/unit/TestFileLockSerialized.java
===================================================================
--- h2/src/test/org/h2/test/unit/TestFileLockSerialized.java (revision 4965)
+++ h2/src/test/org/h2/test/unit/TestFileLockSerialized.java (working copy)
@@ -14,6 +14,8 @@
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
+import java.util.concurrent.CountDownLatch;
+
import org.h2.constant.ErrorCode;
import org.h2.jdbc.JdbcConnection;
import org.h2.store.fs.FileUtils;
@@ -541,17 +543,21 @@
deleteDb("fileLockSerialized");
}
- private void testBigDatabase(boolean withCache) {
+ private void testBigDatabase(boolean withCache) throws
InterruptedException {
boolean longRun = false;
final int howMuchRows = longRun ? 2000000 : 500000;
deleteDb("fileLockSerialized");
int cacheSizeKb = withCache ? 5000 : 0;
+ final CountDownLatch importFinished = new CountDownLatch(1);
+ final CountDownLatch check1Finished = new CountDownLatch(1);
+ final CountDownLatch updateFinished = new CountDownLatch(1);
+ final CountDownLatch testFinished = new CountDownLatch(2);
+
final String url = "jdbc:h2:" + getBaseDir() + "/fileLockSerialized" +
";FILE_LOCK=SERIALIZED" +
";OPEN_NEW=TRUE" +
";CACHE_SIZE=" + cacheSizeKb;
- final boolean[] importFinished = { false };
final Task importUpdate = new Task() {
@Override
public void call() throws Exception {
@@ -561,33 +567,31 @@
for (int i = 0; i < howMuchRows; i++) {
stat.execute("insert into test values(" + i + ", " + i +
")");
}
- importFinished[0] = true;
- Thread.sleep(5000);
+ importFinished.countDown();
+ check1Finished.await();
+
stat.execute("update test set id2=999 where id=500");
conn.close();
- importFinished[0] = true;
+ updateFinished.countDown();
+ testFinished.countDown();
}
};
- importUpdate.execute();
Task select = new Task() {
@Override
public void call() throws Exception {
Connection conn = DriverManager.getConnection(url);
Statement stat = conn.createStatement();
- while (!importFinished[0]) {
- Thread.sleep(100);
- }
- Thread.sleep(1000);
+ importFinished.await();
+
ResultSet rs = stat.executeQuery("select id2 from test where
id=500");
assertTrue(rs.next());
assertEquals(500, rs.getInt(1));
rs.close();
- // wait until the task finished
- importUpdate.get();
+ check1Finished.countDown();
- Thread.sleep(1000);
+ updateFinished.await();
// can't use the exact same query, otherwise it would use
// the query cache
rs = stat.executeQuery("select id2 from test where id=500+0");
@@ -595,11 +599,12 @@
assertEquals(999, rs.getInt(1));
rs.close();
conn.close();
+ testFinished.countDown();
}
};
+ importUpdate.execute();
select.execute();
- importUpdate.get();
- select.get();
+ testFinished.await();
deleteDb("fileLockSerialized");
}