Skip to content

Commit

Permalink
Restore RocksDB test specifics
Browse files Browse the repository at this point in the history
  • Loading branch information
vweevers committed May 22, 2019
1 parent 3843dc0 commit 334af2c
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 20 deletions.
3 changes: 2 additions & 1 deletion test/destroy-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
})
Expand Down
18 changes: 9 additions & 9 deletions test/getproperty-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})

Expand Down
2 changes: 1 addition & 1 deletion test/leak-tester-batch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}))
)
}
Expand Down
2 changes: 1 addition & 1 deletion test/leak-tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})))
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/port-libuv-fix-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 3 additions & 7 deletions test/repair-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
})
Expand All @@ -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)
})
Expand Down

0 comments on commit 334af2c

Please sign in to comment.