-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #208 from ipfs/go-js-tests
added go -> js extract tests
- Loading branch information
Showing
6 changed files
with
62 additions
and
3 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
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,45 @@ | ||
'use strict' | ||
|
||
const os = require('os') | ||
const fs = require('fs') | ||
const { build } = require('./schema/results') | ||
const { file } = require('./lib/fixtures') | ||
const run = require('./lib/runner') | ||
const { once } = require('stream-iterators-utils') | ||
const NodeFactory = require('./lib/node-factory') | ||
const util = require('util') | ||
const execute = util.promisify(util.promisify(require('child_process').exec)) | ||
const conf = { tmpPath: os.tmpdir() } | ||
|
||
async function extractGo2Js (ipfs, name, warmup, fileSet, version) { | ||
//Runner rtunrs the NodeJS ipfs but we need to create the Go ipfs | ||
const nodeFactory = new NodeFactory() | ||
await nodeFactory.add('go') | ||
const filePath = await file(fileSet) | ||
const peer = ipfs[0] | ||
|
||
const peerId = await peer.id() | ||
let command = `export IPFS_PATH=${conf.tmpPath}/ipfs0 && ipfs swarm connect ${peerId.addresses[0]} > /dev/null` | ||
await execute(command) | ||
// redirect stderr to dev/null due to the progress of file being processed is sent to stderr causing maxBuffer error | ||
const addCommand = `export IPFS_PATH=${conf.tmpPath}/ipfs0 && ipfs add ${filePath} 2> /dev/null` | ||
const { stdout } = await execute(addCommand) | ||
const start = process.hrtime() | ||
let stream = peer.catReadableStream(stdout.split(' ')[1]) | ||
// endof steam | ||
stream.resume() | ||
await once(stream, 'end') | ||
const end = process.hrtime(start) | ||
await nodeFactory.stop('go') | ||
return build({ | ||
name: name, | ||
warmup: warmup, | ||
file: filePath, | ||
meta: { version: version }, | ||
description: 'Extract files from GO to JS IPFS peers', | ||
file_set: fileSet, | ||
duration: { s: end[0], | ||
ms: end[1] / 1000000 } | ||
}) | ||
} | ||
run(extractGo2Js) |
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