From 334af2c8f30ff18121e65475671f9882aae3fd15 Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Sun, 19 May 2019 14:13:12 +0200 Subject: [PATCH] Restore RocksDB test specifics --- test/destroy-test.js | 3 ++- test/getproperty-test.js | 18 +++++++++--------- test/leak-tester-batch.js | 2 +- test/leak-tester.js | 2 +- test/port-libuv-fix-test.js | 2 +- test/repair-test.js | 10 +++------- 6 files changed, 17 insertions(+), 20 deletions(-) diff --git a/test/destroy-test.js b/test/destroy-test.js index 32dfa976..385f6d04 100644 --- a/test/destroy-test.js +++ b/test/destroy-test.js @@ -56,7 +56,8 @@ test('test destroy non-existent parent directory', function (t) { t.notOk(fs.existsSync(parent), 'parent does not exist before') leveldown.destroy(location, function (err) { - t.error(err, 'no error') + // This behavior differs from LevelDB, which is silent. + t.ok(/.*IO error.*\/1\/2\/3\/4\/LOCK.*/.test(err), 'got IO error') t.notOk(fs.existsSync(location), 'directory does not exist after') }) }) diff --git a/test/getproperty-test.js b/test/getproperty-test.js index fa072c63..f756de6c 100644 --- a/test/getproperty-test.js +++ b/test/getproperty-test.js @@ -28,28 +28,28 @@ test('test non-string getProperty() throws', function (t) { test('test invalid getProperty() returns empty string', function (t) { t.equal(db.getProperty('foo'), '', 'invalid property') - t.equal(db.getProperty('leveldb.foo'), '', 'invalid leveldb.* property') + t.equal(db.getProperty('rocksdb.foo'), '', 'invalid rocksdb.* property') t.end() }) -test('test invalid getProperty("leveldb.num-files-at-levelN") returns numbers', function (t) { +test('test invalid getProperty("rocksdb.num-files-at-levelN") returns numbers', function (t) { for (var i = 0; i < 7; i++) { - t.equal(db.getProperty('leveldb.num-files-at-level' + i), - '0', '"leveldb.num-files-at-levelN" === "0"') + t.equal(db.getProperty('rocksdb.num-files-at-level' + i), + '0', '"rocksdb.num-files-at-levelN" === "0"') } t.end() }) -test('test invalid getProperty("leveldb.stats")', function (t) { - t.ok(db.getProperty('leveldb.stats').split('\n').length > 3, 'leveldb.stats has > 3 newlines') +test('test invalid getProperty("rocksdb.stats")', function (t) { + t.ok(db.getProperty('rocksdb.stats').split('\n').length > 3, 'rocksdb.stats has > 3 newlines') t.end() }) -test('test invalid getProperty("leveldb.sstables")', function (t) { +test('test invalid getProperty("rocksdb.sstables")', function (t) { var expected = [0, 1, 2, 3, 4, 5, 6].map(function (l) { - return '--- level ' + l + ' ---' + return '--- level ' + l + ' --- version# 1 ---' }).join('\n') + '\n' - t.equal(db.getProperty('leveldb.sstables'), expected, 'leveldb.sstables') + t.equal(db.getProperty('rocksdb.sstables'), expected, 'rocksdb.sstables') t.end() }) diff --git a/test/leak-tester-batch.js b/test/leak-tester-batch.js index 5130ffe7..8b6ca9d3 100644 --- a/test/leak-tester-batch.js +++ b/test/leak-tester-batch.js @@ -18,7 +18,7 @@ function print () { Math.round(process.memoryUsage().rss / rssBase * 100) + '%', Math.round(process.memoryUsage().rss / 1024 / 1024) + 'M', JSON.stringify([0, 1, 2, 3, 4, 5, 6].map(function (l) { - return db.getProperty('leveldb.num-files-at-level' + l) + return db.getProperty('rocksdb.num-files-at-level' + l) })) ) } diff --git a/test/leak-tester.js b/test/leak-tester.js index 6419bf6b..118440ee 100644 --- a/test/leak-tester.js +++ b/test/leak-tester.js @@ -35,7 +35,7 @@ function run () { Math.round(process.memoryUsage().rss / rssBase * 100) + '%', Math.round(process.memoryUsage().rss / 1024 / 1024) + 'M', JSON.stringify([0, 1, 2, 3, 4, 5, 6].map(function (l) { - return db.getProperty('leveldb.num-files-at-level' + l) + return db.getProperty('rocksdb.num-files-at-level' + l) }))) } } diff --git a/test/port-libuv-fix-test.js b/test/port-libuv-fix-test.js index 496d76a7..b039dff4 100644 --- a/test/port-libuv-fix-test.js +++ b/test/port-libuv-fix-test.js @@ -2,7 +2,7 @@ const test = require('tape') const path = require('path') const fs = require('fs') -test('test port-libuv is being used', function (t) { +test.skip('test port-libuv is being used', function (t) { var version = fs.readFileSync(path.join(__dirname, '../deps/leveldb/leveldb.gyp'), 'utf8') .match(/"ldbversion": "([^"]+)"/)[1] var porth diff --git a/test/repair-test.js b/test/repair-test.js index 9dc03d48..adbc256f 100644 --- a/test/repair-test.js +++ b/test/repair-test.js @@ -21,11 +21,7 @@ test('test callback-less, 1-arg, repair() throws', function (t) { test('test repair non-existent directory returns error', function (t) { leveldown.repair('/1/2/3/4', function (err) { - if (process.platform !== 'win32') { - t.ok(/no such file or directory/i.test(err), 'error on callback') - } else { - t.ok(/IO error/i.test(err), 'error on callback') - } + t.ok(/^Error: NotFound:/i.test(err), 'error on callback') t.end() }) }) @@ -39,14 +35,14 @@ makeTest('test repair() compacts', function (db, t, done) { var files = fs.readdirSync(location) t.ok(files.some(function (f) { return (/\.log$/).test(f) }), 'directory contains log file(s)') - t.notOk(files.some(function (f) { return (/\.ldb$/).test(f) }), 'directory does not contain ldb file(s)') + t.notOk(files.some(function (f) { return (/\.sst$/).test(f) }), 'directory does not contain sst file(s)') leveldown.repair(location, function (err) { t.ifError(err, 'no error from repair()') files = fs.readdirSync(location) t.notOk(files.some(function (f) { return (/\.log$/).test(f) }), 'directory does not contain log file(s)') - t.ok(files.some(function (f) { return (/\.ldb$/).test(f) }), 'directory contains ldb file(s)') + t.ok(files.some(function (f) { return (/\.sst$/).test(f) }), 'directory contains sst file(s)') done(null, false) })