Run tests with go-ipfs and js-ipfs-api again
Use go-ipfs 0.4.13 to run tests Add write benchmark for go-ipfs Clean up benchmarks Fix a test not catching errors
This commit is contained in:
parent
99c69b6b74
commit
a2524688d2
54
benchmarks/benchmark-add-go-ipfs.js
Normal file
54
benchmarks/benchmark-add-go-ipfs.js
Normal file
@ -0,0 +1,54 @@
|
||||
'use strict'
|
||||
|
||||
const IPFS = require('ipfs-api')
|
||||
const OrbitDB = require('../src/OrbitDB')
|
||||
|
||||
// Metrics
|
||||
let totalQueries = 0
|
||||
let seconds = 0
|
||||
let queriesPerSecond = 0
|
||||
let lastTenSeconds = 0
|
||||
|
||||
// Main loop
|
||||
const queryLoop = async (db) => {
|
||||
await db.add(totalQueries)
|
||||
totalQueries ++
|
||||
lastTenSeconds ++
|
||||
queriesPerSecond ++
|
||||
setImmediate(() => queryLoop(db))
|
||||
}
|
||||
|
||||
// Start
|
||||
console.log("Starting...")
|
||||
|
||||
// Make sure you have a local IPFS daemon running!
|
||||
const ipfs = IPFS('127.0.0.1')
|
||||
|
||||
const run = async () => {
|
||||
try {
|
||||
const orbit = new OrbitDB(ipfs, './orbitdb/benchmarks')
|
||||
const db = await orbit.eventlog('orbit-db.benchmark', {
|
||||
replicate: false,
|
||||
})
|
||||
|
||||
// Metrics output
|
||||
setInterval(() => {
|
||||
seconds ++
|
||||
if(seconds % 10 === 0) {
|
||||
console.log(`--> Average of ${lastTenSeconds/10} q/s in the last 10 seconds`)
|
||||
if(lastTenSeconds === 0)
|
||||
throw new Error("Problems!")
|
||||
lastTenSeconds = 0
|
||||
}
|
||||
console.log(`${queriesPerSecond} queries per second, ${totalQueries} queries in ${seconds} seconds (Oplog: ${db._oplog.length})`)
|
||||
queriesPerSecond = 0
|
||||
}, 1000)
|
||||
// Start the main loop
|
||||
queryLoop(db)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
run()
|
@ -42,28 +42,32 @@ const ipfs = new IPFS({
|
||||
ipfs.on('error', (err) => console.error(err))
|
||||
|
||||
ipfs.on('ready', async () => {
|
||||
try {
|
||||
const orbit = new OrbitDB(ipfs, './orbitdb/benchmarks')
|
||||
const db = await orbit.eventlog('orbit-db.benchmark', {
|
||||
replicate: false,
|
||||
})
|
||||
const run = async () => {
|
||||
try {
|
||||
const orbit = new OrbitDB(ipfs, './orbitdb/benchmarks')
|
||||
const db = await orbit.eventlog('orbit-db.benchmark', {
|
||||
replicate: false,
|
||||
})
|
||||
|
||||
// Metrics output
|
||||
setInterval(() => {
|
||||
seconds ++
|
||||
if(seconds % 10 === 0) {
|
||||
console.log(`--> Average of ${lastTenSeconds/10} q/s in the last 10 seconds`)
|
||||
if(lastTenSeconds === 0)
|
||||
throw new Error("Problems!")
|
||||
lastTenSeconds = 0
|
||||
}
|
||||
console.log(`${queriesPerSecond} queries per second, ${totalQueries} queries in ${seconds} seconds (Oplog: ${db._oplog.length})`)
|
||||
queriesPerSecond = 0
|
||||
}, 1000)
|
||||
// Start the main loop
|
||||
queryLoop(db)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
process.exit(1)
|
||||
// Metrics output
|
||||
setInterval(() => {
|
||||
seconds ++
|
||||
if(seconds % 10 === 0) {
|
||||
console.log(`--> Average of ${lastTenSeconds/10} q/s in the last 10 seconds`)
|
||||
if(lastTenSeconds === 0)
|
||||
throw new Error("Problems!")
|
||||
lastTenSeconds = 0
|
||||
}
|
||||
console.log(`${queriesPerSecond} queries per second, ${totalQueries} queries in ${seconds} seconds (Oplog: ${db._oplog.length})`)
|
||||
queriesPerSecond = 0
|
||||
}, 1000)
|
||||
// Start the main loop
|
||||
queryLoop(db)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
run()
|
||||
})
|
||||
|
864
package-lock.json
generated
864
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -32,6 +32,7 @@
|
||||
"babel-polyfill": "^6.26.0",
|
||||
"babel-preset-es2015": "^6.24.1",
|
||||
"datastore-level": "~0.7.0",
|
||||
"go-ipfs-dep": "^0.4.13",
|
||||
"ipfs": "~0.28.2",
|
||||
"ipfs-repo": "~0.18.7",
|
||||
"ipfsd-ctl": "~0.30.3",
|
||||
@ -46,7 +47,7 @@
|
||||
"examples": "npm run examples:node",
|
||||
"examples:node": "node examples/eventlog.js",
|
||||
"examples:browser": "open examples/browser/browser.html",
|
||||
"test": "mocha",
|
||||
"test": "TEST=all mocha",
|
||||
"build": "npm run build:es5 && npm run build:debug && npm run build:dist && npm run build:examples",
|
||||
"build:examples": "webpack --config conf/webpack.example.config.js --sort-modules-by size && mkdir -p examples/browser/lib && cp node_modules/ipfs/dist/index.js examples/browser/lib/ipfs.js",
|
||||
"build:dist": "webpack --config conf/webpack.config.js --sort-modules-by size && mkdir -p examples/browser/lib && cp dist/orbitdb.min.js examples/browser/lib/orbitdb.min.js",
|
||||
|
@ -237,6 +237,7 @@ Object.keys(testAPIs).forEach(API => {
|
||||
setTimeout(resolve, 900)
|
||||
orbitdb.open(address)
|
||||
.then(() => reject(new Error('Shouldn\'t open the database')))
|
||||
.catch(reject)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -1,5 +1,9 @@
|
||||
const IPFS = require('ipfs')
|
||||
|
||||
/**
|
||||
* IPFS daemons to run the tests with.
|
||||
*/
|
||||
|
||||
// Available daemon types are defined in:
|
||||
// https://github.com/ipfs/js-ipfsd-ctl#ipfsfactory---const-f--ipfsfactorycreateoptions
|
||||
let jsIpfs = {
|
||||
@ -15,12 +19,15 @@ const goIpfs = {
|
||||
}
|
||||
}
|
||||
|
||||
// IPFS daemons to run the tests with
|
||||
// By default, we run tests against js-ipfs.
|
||||
let testAPIs = Object.assign({}, jsIpfs)
|
||||
|
||||
// By default, we only run tests against js-ipfs.
|
||||
// Setting env variable 'TEST=all' will make tests run with go-ipfs also.
|
||||
// Setting env variable 'TEST=all' will make tests run with js-ipfs and go-ipfs.
|
||||
// Setting env variable 'TEST=go' will make tests run with go-ipfs.
|
||||
// Eg. 'TEST=go mocha' runs tests with go-ipfs
|
||||
if (process.env.TEST === 'all')
|
||||
testAPIs = Object.assign({}, testAPIs, goIpfs)
|
||||
else if (process.env.TEST === 'go')
|
||||
testAPIs = Object.assign({}, goIpfs)
|
||||
|
||||
module.exports = testAPIs
|
||||
|
Loading…
x
Reference in New Issue
Block a user