{"_id":"@avital/meteor-down","_rev":"3-7dbe56e0df413d4453832710932d37e0","name":"@avital/meteor-down","description":"Load testing for Meteor","dist-tags":{"latest":"2.6.1"},"versions":{"2.6.1":{"name":"@avital/meteor-down","version":"2.6.1","description":"Load testing for Meteor","repository":{"type":"git","url":"git+https://github.com/avital/meteor-down.git"},"main":"./lib/index.js","scripts":{"test":"./node_modules/mocha/bin/mocha"},"author":{"name":"Meteorhacks and Avital Oliver"},"license":"MIT","devDependencies":{"mocha":"1.21.x"},"dependencies":{"ddp":"0.10.x","underscore":"1.7.x","coffee-script":"1.9.x"},"gitHead":"75e50be09c390e7ce3c65fc38b1b4612c40d7bfe","bugs":{"url":"https://github.com/avital/meteor-down/issues"},"homepage":"https://github.com/avital/meteor-down#readme","_id":"@avital/meteor-down@2.6.1","_shasum":"b326b9e013964b82b816845e542cbf6573ebc7c1","_from":".","_npmVersion":"3.6.0","_nodeVersion":"5.7.0","_npmUser":{"name":"avital","email":"avital@thewe.net"},"dist":{"shasum":"b326b9e013964b82b816845e542cbf6573ebc7c1","tarball":"https://registry.npmjs.org/@avital/meteor-down/-/meteor-down-2.6.1.tgz","integrity":"sha512-jk7uG5FSZDLDeZi0ZdBz7gxgTRV+iqno0lsR3sWKUJFqCrqN9/psft+lv1sSeok/yV7QCkJeKTJ3ohOQfsmhng==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDroSPINo15JyAxHMk+V0xn8DfDRe4JyWitj9/I92Nc3QIgE6JU2LzOuRe2DfkPhWOX7wSajArbJXnFnrn4A+aK4ao="}]},"maintainers":[{"name":"avital","email":"avital@thewe.net"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/meteor-down-2.6.1.tgz_1461355283973_0.2944190234411508"}}},"readme":"MeteorDown [![Build Status](https://travis-ci.org/meteorhacks/meteor-down.svg?branch=master)](https://travis-ci.org/meteorhacks/meteor-down)\n==========\n\nMeteorDown is a load testing tool for Meteor server side components. It uses the DDP protocol to communicate with the Meteor application. You can write your load test in JavaScript and let MeteorDown to invoke it.\n\nInstallation\n------------\n\nCreate a file called `my_load_test.js` with the following content:\n\n~~~js\nvar meteorDown = require('@avital/meteor-down');\n\nmeteorDown.init(function (Meteor) {\n  Meteor.call('example-method', function (error, result) {\n    Meteor.kill();\n  });\n});\n\nmeteorDown.run({\n  concurrency: 10,\n  url: \"http://localhost:3000\"\n});\n~~~\n\nThen run your script:\n\n~~~shell\nnode my_load_test.js\n~~~\n\n\nClient API\n----------\n\nWith the MeteorDown script, you can call methods and invoke subscriptions. The function given to `meteorDown.init` will receive the ddp client as the first argument.\n\nThis ddp client is based on [node-ddp-client](https://github.com/oortcloud/node-ddp-client) but with some changes to make it more Meteor like. Let's look at APIs:\n\n###Meteor.call\n\n~~~js\nMeteor.call('name'[, args*], callback)\n~~~\n\nCall a Meteor method. Just like the browser client, the callback will receive 2 arguments Error and the Result.\n\n###Meteor.subscribe\n\n~~~js\nMeteor.subscribe('name'[, args*], callback)\n~~~\n\nThe callback function will be called when the subscription is ready and all initial data is loaded to the client.\n\n###Meteor.kill\n\n~~~js\nMeteor.kill()\n~~~\n\nDisconnect the current client from the server. As soon as this is called, another client will connect to the server and run load test code.\n\n###Meteor.collections\n\n~~~js\nvar Collection = Meteor.collections['name']\n~~~\n\nA dictionary of all client side collections. Data received from subscriptions will be available here.\n\nAuthentication\n--------------\n\nNormally, most of the Meteor methods and subscriptions are only available for  loggedIn users. So, we can't directly invoke those methods and subscriptions. MeteorDown has a solution for that.\n\nFirst you need to install the following package:\n\n~~~js\nmeteor add meteorhacks:meteor-down\n~~~\n\nThen you need to start your Meteor app with a key. That could be anything you like. But it's better to have a hard to guess key.\n\n~~~js\nexport METEOR_DOWN_KEY='YOUR_SUPER_SECRET_KEY'\nmeteor\n~~~\n\nNow, add that key to your MeteorDown script and tell which users you need to authenticated against the load test. This is how you can do it.\n\n~~~js\nmeteorDown.run({\n  concurrency: 10,\n  url: \"http://localhost:3000\",\n  key: 'YOUR_SUPER_SECRET_KEY',\n  auth: {userIds: ['JydhwL4cCRWvt3TiY', 'bg9MZZwFSf8EsFJM4']}\n})\n~~~\n\nThen all your method calls and subscriptions will be authenticated for one of the user mentioned above.\n\nYou can also get the loggedIn user's userId by invoking `Meteor.userId()` as shown below:\n\n~~~js\nmeteorDown.init(function (Meteor) {\n  console.log(\"userId is:\", Meteor.userId());\n})\n~~~\n\nOptions\n-------\n\nAll test options are optional therefor it's perfectly okay to call `mdown.run` without any arguments. All available arguments and their default values are given below.\n\n~~~js\nmeteorDown.run({\n  concurrency: 10,\n  url: 'http://localhost:3000',\n  key: undefined,\n  auth: undefined\n});\n~~~\n\n#### concurrency\n\nThe maximum number of clients connects to the application at any given time. The real number of concurrent connections can be lower than this number.\n\n#### url\n\nMeteor application url.\n**NOTE: This should only have the domain and the port (example: localhost:3000). Meteor-down does not support routes at the moment.**\n\n#### key\n\nThe secret key to use for MeteorDown authentication.\n\n#### auth\n\nAuthentication information. Currently MeteorDown only supports login by userId.\n\nExamples\n--------\n\n### Calling a Method\n\n~~~js\n// Meteor Application\nMeteor.methods({\n  add: function (x, y) {return x + y }\n})\n~~~\n\n~~~js\n// MeteorDown Script\nmeteorDown.init(function (Meteor) {\n  Meteor.call('add', 5, 6, function (err, res) {\n    console.log('5 + 6 is ' + res);\n    Meteor.kill();\n  });\n})\n~~~\n\n### Subscribing\n\n~~~js\n// Meteor Application\nItems = new Meteor.Collection('items');\nMeteor.publish({\n  allitems: function () { return Items.find() }\n})\n~~~\n\n~~~js\n// MeteorDown Script\nmeteorDown.init(function (Meteor) {\n  Meteor.subscribe('allitems', function () {\n    console.log('Subscription is ready');\n    console.log(Meteor.collections.items);\n    Meteor.kill();\n  });\n})\n~~~\n","maintainers":[{"name":"avital","email":"avital@thewe.net"}],"time":{"modified":"2022-06-12T14:53:44.951Z","created":"2016-04-22T20:01:26.072Z","2.6.1":"2016-04-22T20:01:26.072Z"},"homepage":"https://github.com/avital/meteor-down#readme","repository":{"type":"git","url":"git+https://github.com/avital/meteor-down.git"},"author":{"name":"Meteorhacks and Avital Oliver"},"bugs":{"url":"https://github.com/avital/meteor-down/issues"},"license":"MIT","readmeFilename":"README.md"}