Default to using leveldb as storage engine in tests.
Switching to leveldb caused a few tests to start failing, because
memstore has a different model of conflicts that leveldb. Those tests
were fixed so they pass with both leveldb and memstore.
You can still run the tests with memstore, by running:
export STORAGE_ENGINE=memstore
make test
Change-Id: I6e080f2df6942d3239d8d383c861e263f778f9cc
diff --git a/test/integration/test-batch.js b/test/integration/test-batch.js
index eb2f2cb..2b200d5 100644
--- a/test/integration/test-batch.js
+++ b/test/integration/test-batch.js
@@ -142,8 +142,10 @@
return batch.table(table.name);
});
+ // Put to the same key in each batch.
+ var key = uniqueName('key');
async.mapSeries(batchTables, function(batchTable, cb) {
- var key = uniqueName('key');
+ // Put different value in each batch.
var value = uniqueName('value');
batchTable.put(ctx, key, value, function(err) {
if (err) {
@@ -339,19 +341,33 @@
var db = o.database;
var table = o.table;
- db.beginBatch(ctx, {}, putTable);
+ db.beginBatch(ctx, {}, readBatchTable);
var key = uniqueName('key');
var value = uniqueName('value');
var batch;
+ var batchTable;
- function putTable(err, _batch) {
+ function readBatchTable(err, _batch) {
if (err) {
- return end(err);
+ return t.end(err);
}
batch = _batch;
+ batchTable = batch.table(table.name);
+
+ batchTable.get(ctx, key, function(err) {
+ // Should error because the key does not exist yet.
+ t.ok(err, 'get should error when key does not exist');
+ putTable();
+ });
+ }
+
+ function putTable(err) {
+ if (err) {
+ return end(err);
+ }
// Put on the table directly, not the batch table. This will conflict
// with future batchTable.put() call.
@@ -365,7 +381,6 @@
var newValue = uniqueName('value');
- var batchTable = batch.table(table.name);
batchTable.put(ctx, key, newValue, commit);
}
diff --git a/test/start-syncbased.sh b/test/start-syncbased.sh
index 6cf9f24..bedc838 100755
--- a/test/start-syncbased.sh
+++ b/test/start-syncbased.sh
@@ -9,7 +9,17 @@
# does not allow flags or arguments to the executables it starts. We should
# fix service-runner to allow flags/arguments, and then have it start syncbased
# directly with the appropriate flags. Then we can delete this file.
-# TODO(rdaoud): how to cleanup the tmp test dir; "rm" here doesn't do it.
-testdir="$(mktemp -d "${TMPDIR:-/tmp}"/sbtest.XXXXXXXX)"
-syncbased -v=1 --name test/syncbased --engine memstore --root-dir "${testdir}" --v23.tcp.address 127.0.0.1:0
+TESTDIR="$(mktemp -d "${TMPDIR:-/tmp}"/sbtest.XXXXXXXX)"
+# Delete TESTDIR and stop syncbased on exit.
+function cleanup {
+ rm -rf "${TESTDIR}"
+ kill -TERM "${CHILD}" 2>/dev/null
+ exit 0
+}
+trap cleanup SIGINT SIGTERM EXIT
+
+syncbased -v=3 --name test/syncbased --engine "${STORAGE_ENGINE:-leveldb}" --root-dir "${TESTDIR}" --v23.tcp.address 127.0.0.1:0 &
+
+CHILD=$!
+wait "${CHILD}"