• Stars
    star
    175
  • Rank 218,059 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 10 years ago
  • Updated about 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Load testing for Meteor

MeteorDown Build Status

MeteorDown 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.

Installation

npm i -g meteor-down

Then create a file called my_load_test.js with the following content:

meteorDown.init(function (Meteor) {
  Meteor.call('example-method', function (error, result) {
    Meteor.kill();
  });
});

meteorDown.run({
  concurrency: 10,
  url: "http://localhost:3000"
});

Then invoke the load test with:

meteor-down my_load_test.js

Client API

With 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.

This ddp client is based on node-ddp-client but with some changes to make it more Meteor like. Let's look at APIs:

###Meteor.call

Meteor.call('name'[, args*], callback)

Call a Meteor method. Just like the browser client, the callback will receive 2 arguments Error and the Result.

###Meteor.subscribe

Meteor.subscribe('name'[, args*], callback)

The callback function will be called when the subscription is ready and all initial data is loaded to the client.

###Meteor.kill

Meteor.kill()

Disconnect the current client from the server. As soon as this is called, another client will connect to the server and run load test code.

###Meteor.collections

var Collection = Meteor.collections['name']

A dictionary of all client side collections. Data received from subscriptions will be available here.

Authentication

Normally, 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.

First you need to install the following package:

meteor add meteorhacks:meteor-down

Then 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.

export METEOR_DOWN_KEY='YOUR_SUPER_SECRET_KEY'
meteor

Now, 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.

meteorDown.run({
  concurrency: 10,
  url: "http://localhost:3000",
  key: 'YOUR_SUPER_SECRET_KEY',
  auth: {userIds: ['JydhwL4cCRWvt3TiY', 'bg9MZZwFSf8EsFJM4']}
})

Then all your method calls and subscriptions will be authenticated for one of the user mentioned above.

You can also get the loggedIn user's userId by invoking Meteor.userId() as shown below:

meteorDown.init(function (Meteor) {
  console.log("userId is:", Meteor.userId());
})

Options

All 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.

meteorDown.run({
  concurrency: 10,
  url: 'http://localhost:3000',
  key: undefined,
  auth: undefined
});

concurrency

The maximum number of clients connects to the application at any given time. The real number of concurrent connections can be lower than this number.

url

Meteor application url. NOTE: This should only have the domain and the port (example: localhost:3000). Meteor-down does not support routes at the moment.

key

The secret key to use for MeteorDown authentication.

auth

Authentication information. Currently MeteorDown only supports login by userId.

Using Custom Node Modules

Currently, there is no direct support for that. But you could do it very easily. Let's say you've installed couple npm modules on the current directory. Then, you'll have a node_modules directory in the current directory.

Invoke MeteorDown like this and you'll access those npm modules by requiring them inside the MeteorDown script.

NODE_PATH=./node_modules meteor-down myMeteorDownScript.js

Examples

Calling a Method

// Meteor Application
Meteor.methods({
  add: function (x, y) {return x + y }
})
// MeteorDown Script
meteorDown.init(function (Meteor) {
  Meteor.call('add', 5, 6, function (err, res) {
    console.log('5 + 6 is ' + res);
    Meteor.kill();
  });
})

Subscribing

// Meteor Application
Items = new Meteor.Collection('items');
Meteor.publish({
  allitems: function () { return Items.find() }
})
// MeteorDown Script
meteorDown.init(function (Meteor) {
  Meteor.subscribe('allitems', function () {
    console.log('Subscription is ready');
    console.log(Meteor.collections.items);
    Meteor.kill();
  });
})

More Repositories

1

cluster

Clustering solution for Meteor with load balancing and service discovery
JavaScript
631
star
2

npm

Complete NPM integration for Meteor
JavaScript
508
star
3

meteord

MeteorD - Docker Runtime for Meteor Apps for Production Deployments
Shell
439
star
4

meteor-ssr

Server Side Rendering for Meteor
JavaScript
264
star
5

sikka

Sikka - A Firewall for Meteor Apps
JavaScript
258
star
6

kadira

Performance Monitoring for Meteor
JavaScript
217
star
7

meteor-aggregate

Proper MongoDB aggregations support for Meteor
JavaScript
189
star
8

picker

Server Side Router for Meteor
JavaScript
182
star
9

search-source

Reactive Data Source for Search
JavaScript
146
star
10

flow-components

Build your Meteor app with Components.
JavaScript
132
star
11

unblock

this.unblock inside publications :D
JavaScript
87
star
12

meteor-inject-initial

Allow injection of arbitrary data to initial Meteor HTML page
JavaScript
80
star
13

meteor-async

Set of async utilities to work with NPM modules inside Meteor
JavaScript
63
star
14

goddp

DDP Server implemented with golang
Go
47
star
15

meteorx

Exposing some of the internal Meteor API prototypes
JavaScript
41
star
16

mup-frontend-server

Frontend Server for Meteor Up
Nginx
37
star
17

kube-init

Easiest way to deploy a Kubernetes Cluster to learn Kubernetes
Shell
34
star
18

zones

Zone.js integration for meteor
JavaScript
30
star
19

meteorhacks.github.io

MeteorHacks Website
HTML
29
star
20

hyperkube

Hyperkube
Shell
20
star
21

inject-data

A way to inject data to the client with initial HTML
JavaScript
18
star
22

kadira-profiler

CPU Profiling support for Kadira
JavaScript
14
star
23

bddp

DDP like binary protocol implemented using cap'n proto
Go
12
star
24

repeeet

making repeeet tweeting super simple
JavaScript
11
star
25

code-standards

Code Standards for MeteorHacks projects
9
star
26

js-pipes

MongoDB aggregation pipeline implementation in JavaScript
JavaScript
9
star
27

meteor-customer-io

Customer.io Integration for Meteor
JavaScript
9
star
28

cluster-performance

Performance Test for Cluster
JavaScript
8
star
29

docker-librato

Forward all stats from all running docker containers to Librato
JavaScript
8
star
30

kdb

ACID High Performance Time Series DB for any kind of storage - No it isn't
Go
7
star
31

meteor-todo-app

Simple Todo App with Meteor
JavaScript
5
star
32

gocluster

Meteor Cluster protocol implemented for Go
Go
4
star
33

meteor-collection-utils

Expose some underline collection apis
JavaScript
4
star
34

find-faster-chat-demo

Simple Chat To Demo Meteor Fast Finder Use
JavaScript
3
star
35

ddptest

Test DDP servers
JavaScript
3
star
36

zones-simple-example

Simple Example Meteor App with Zones
JavaScript
2
star
37

mongo-search

Simple API to use MongoDB Full Text search with Meteor
2
star
38

kmdb

metric database powered by kdb
Go
2
star
39

meteor-down-backdoor

Backdoor Meteor package for MeteorDown
JavaScript
2
star
40

kadira-binary-deps

Binary Dependencies for Kadira
JavaScript
2
star
41

simple-rpc-go

A really simple and fast binary RPC middleware
Go
2
star
42

kmdb-node

NodeJS client for kmdb
JavaScript
2
star
43

nsqd-to-librato

Send NSQ stats to librato
JavaScript
2
star
44

lean-components-example

lean-components-example
JavaScript
2
star
45

meteor-zone-example

Example meteor app for meteor-zone package
JavaScript
1
star
46

node-histo-utils

A set of utilities to create, merge and manage histograms
JavaScript
1
star
47

blaze-ext

Create blaze templates with .blaze extension
1
star