mongodb-runner
TypeScript icon, indicating that this package has built-in type declarations

1.1.4 • Public • Published

mongodb-runner

build status

Starts all of the deployment types for testing by piping to mongo shell.

Example

var mongodb = require('mongodb-runner');

// Start a standalone, standalone with auth, replica set, and cluster
// process.env.DEBUG = 'mongodb*'; // uncomment me to get stdout from shell commands
mongodb(function(err){
  if(err) return console.error('Uhoh...', err);
  console.log('MongoDB deployments for testing ready!');
  // do tests and stuff
  // all processes started by runner will be SIGTERM'd when this process exits.
});

// start just a standalone
mongodb({port: 27018, dbpath: '/ebs/data/'+process.env.JOB_ID+'_standalone'}, function(err){
  if(err) return console.error('Uhoh...', err);
  console.log('Standalone ready on localhost:27018!');
});

// just a replicaset
mongodb('replicaset', {name: 'replicom', instances: 3, startPort: 6000}, function(err, res){
  if(err) return console.error('Uhoh...', err);
  console.log('replicaset ready!', res.uri);
});

Shell

npm install -g mongodb-runner
DEBUG=* mongodb-runner

Under the hood

Just uses the kernel's testing helpers:

shell(
  'var opts = {shards: '+opts.shards+', chunkSize: 1, rs: {oplogSize: 10}, name: \''+opts.db+'\'};',
  'var st = new ShardingTest(opts);',
  'st.s.getDB(\''+opts.db+'\').adminCommand({enableSharding: \''+opts.db+'\'});',
  'st.s.getDB(\''+opts.db+'\').adminCommand({shardCollection: \''+opts.ns+'\', key: {_id: 1 }});',
fn);
shell('var opts = {name: \''+opts.name+'\', nodes: '+opts.instances+', useHostName: false, startPort: '+opts.startPort+'};',
  'var rs = new ReplSetTest(opts);',
  'rs.startSet();', 'rs.initiate();',
  fn);

Todo

  • [x] use lone to prebake binaries and upload to releases
  • [x] support auth
  • [ ] HTTP control like mongodb-bridge
  • [ ] Use -version-manager to prepare env, add to travis, add ci gulp task
  • [ ] option for version, integrated with -version-manager
  • [ ] integrate @imlucas/mongodb-bridge fully as a option bridge: true. make mongodb-bridge capable of reconfiguring oplog.rs automatically per kristina's example

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i mongodb-runner@1.1.4

Version

1.1.4

License

MIT

Last publish

Collaborators

  • mongodb-js-user
  • rueckstiess
  • durran
  • alexander_schroll
  • mbroadst
  • hswolff
  • satyasinha
  • matt_d_rat
  • jeff-allen-mongo
  • jonathan.balsano
  • mongodb-build
  • jack.weir
  • mcasimir
  • kristina.stefano
  • jarjee
  • shaketbaby
  • devtoolsbot
  • addaleax
  • gribnoysup
  • mutukrish
  • mongo-j
  • nbbeeken
  • dbx-node
  • nirinchev
  • pearsb1
  • tylerbrock
  • imlucas
  • cilix
  • kangas
  • micheal.parks
  • machyne
  • schwartzrw
  • i80and
  • kay-kim
  • glowe
  • dpercy
  • redondos