integration tests updates

- support Array or String when using execPlus
- pass SSH_AUTH_SOCK to support ssh-agent signing
- use current node binary with process.execPath
- config.insecure defaults to false if undefined
This commit is contained in:
Dave Eddy 2015-09-21 18:48:03 -04:00
parent a6d9bad267
commit 46927aeed7
2 changed files with 16 additions and 8 deletions

View File

@ -28,7 +28,9 @@ try {
assert.string(CONFIG.url, 'test/config.json#url');
assert.string(CONFIG.account, 'test/config.json#account');
assert.string(CONFIG.key_id, 'test/config.json#key_id');
assert.optionalBool(CONFIG.insecure, 'test/config.json#insecure');
if (CONFIG.insecure === undefined)
CONFIG.insecure = false;
assert.bool(CONFIG.insecure, 'test/config.json#insecure');
} catch (e) {
error('* * *');
error('node-triton integration tests require a ./test/config.json');
@ -46,7 +48,7 @@ try {
throw e;
}
var TRITON = 'node ' + path.resolve(__dirname, '../../bin/triton');
var TRITON = [process.execPath, path.resolve(__dirname, '../../bin/triton')];
var UA = 'node-triton-test';
var LOG = require('../lib/log');
@ -59,13 +61,18 @@ var LOG = require('../lib/log');
* Call the `triton` CLI with the given args.
*/
function triton(args, cb) {
var command = [].concat(TRITON).concat(args);
if (typeof (args) === 'string')
command = command.join(' ');
testcommon.execPlus({
command: TRITON + ' ' + args,
command: command,
execOpts: {
maxBuffer: Infinity,
env: {
PATH: process.env.PATH,
HOME: process.env.HOME,
SSH_AUTH_SOCK: process.env.SSH_AUTH_SOCK,
SDC_URL: CONFIG.url,
SDC_ACCOUNT: CONFIG.account,
SDC_KEY_ID: CONFIG.key_id,

View File

@ -9,7 +9,7 @@
*/
var assert = require('assert-plus');
var exec = require('child_process').exec;
var execFile = require('child_process').execFile;
var VError = require('verror').VError;
@ -21,7 +21,7 @@ var VError = require('verror').VError;
* logging and error handling boilerplate.
*
* @param args {Object}
* - command {String} Required.
* - command {String|Array} Required.
* - log {Bunyan Logger} Required. Use to log details at trace level.
* - execOpts {Array} Optional. child_process.exec options.
* - errMsg {String} Optional. Error string to use in error message on
@ -38,10 +38,11 @@ function execPlus(args, cb) {
assert.func(cb);
var command = args.command;
var execOpts = args.execOpts;
if (typeof (command) === 'string')
command = ['/bin/sh', '-c', command];
// args.log.trace({exec: true, command: command, execOpts: execOpts},
// 'exec start');
exec(command, execOpts, function (err, stdout, stderr) {
execFile(command[0], command.slice(1), execOpts,
function (err, stdout, stderr) {
args.log.trace({exec: true, command: command, execOpts: execOpts,
err: err, stdout: stdout, stderr: stderr}, 'exec done');
if (err) {