This repository has been archived by the owner on Feb 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
197 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
node_modules | ||
package-lock.json | ||
yarn.lock | ||
dist | ||
dist | ||
coverage | ||
.nyc_output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const DaemonFactory = require('ipfsd-ctl') | ||
const df = DaemonFactory.create() | ||
const expect = require('chai').expect | ||
const StatsPoller = require('../src/index') | ||
|
||
describe('stats poller', () => { | ||
let ipfsd | ||
let poller | ||
|
||
before(function (done) { | ||
// CI takes longer to instantiate the daemon, | ||
// so we need to increase the timeout for the | ||
// before step | ||
this.timeout(60 * 1000) | ||
|
||
df.spawn({disposable: true}, (err, node) => { | ||
expect(err).to.be.null // eslint-disable-line no-unused-expressions | ||
ipfsd = node | ||
|
||
poller = new StatsPoller(node.api, 500) | ||
done() | ||
}) | ||
}) | ||
|
||
after(function (done) { | ||
this.timeout(15 * 1000) | ||
ipfsd.stop(done) | ||
}) | ||
|
||
it('id stats', function (done) { | ||
this.timeout(5000) | ||
|
||
const assert = () => { | ||
try { | ||
expect(poller.stats).to.have.property('id') | ||
done() | ||
} catch (e) {} | ||
} | ||
|
||
setTimeout(() => { assert() }, 500) | ||
}) | ||
|
||
it('peer stats', function (done) { | ||
this.timeout(5000) | ||
|
||
poller.start('peers') | ||
|
||
const assert = () => { | ||
try { | ||
expect(poller.stats).to.have.property('peers') | ||
expect(poller.stats.peers).to.be.an('array') | ||
poller.stop('peers') | ||
done() | ||
} catch (e) {} | ||
} | ||
|
||
setTimeout(() => { assert() }, 500) | ||
}) | ||
|
||
it('bandwidth stats', function (done) { | ||
this.timeout(5000) | ||
|
||
poller.start('bw') | ||
|
||
const assert = () => { | ||
try { | ||
expect(poller.stats).to.have.property('bw') | ||
poller.stop('bw') | ||
done() | ||
} catch (e) {} | ||
} | ||
|
||
setTimeout(() => { assert() }, 500) | ||
}) | ||
|
||
it('repo stats', function (done) { | ||
this.timeout(5000) | ||
|
||
poller.start('repo') | ||
|
||
const assert = () => { | ||
try { | ||
expect(poller.stats).to.have.property('repo') | ||
poller.stop('repo') | ||
done() | ||
} catch (e) {} | ||
} | ||
|
||
setTimeout(() => { assert() }, 500) | ||
}) | ||
}) |