Giter VIP home page Giter VIP logo

cottonballs's Introduction

Cottonballs

Cottonballs is your own mock, fluffy version of GCM for testing purposes, based on node.js.

You would need this if you keep asking yourself the question

How can I test sending tons of GCM messages, without really bothering Google?

With Cottonballs, you don't need to trouble yourself about large-scale testing against real GCM, abusing the GCM service for testing, or needlessly expiring quotas when you're developing your Push solutions.

Quick Start

You'll have to do some work here.

$ git clone git://github.com/jondot/cottonballs.git
$ cd cottonballs
$ npm install
$ ./genkeys.sh
$ [sudo] node cottonballs [options]

Aside from getting Cottonballs, you generated SSL keys with genkeys.sh and you also might want to use sudo to run the service to allow the service to bind on SSL.

SSL?

By default, Cottonballs will try to bind on SSL. The fastest possible way to use it is to run Cottonballs, and change your /etc/hosts to point to it, instead of android.googleapis.com.

# /etc/hosts
127.0.0.1 android.googleapis.com

This is a very bad thing to do generally, but depending on the point of view, can be very good (think of pre-configuring a test machine with this, and deploying and testing on it - no configuration or code changes on your side).

In any case, Cottonballs also binds to a non-SSL port just in case you do want to point your code at it directly.

Behaviour

You can configure Cottonballs to behave in very useful ways, through command-line options:

  • -f or --failure-ratio will simulate message send failures.
  • -l or --latency will simulate a processing latency. So that you can simulate cases where GCM isn't behaving that well in terms of performance.
  • -x or --latency-flux is the variance in latency.
  • -c or --crash-ratio is the of all requests that will crash on you (HTTP 500 from GCM).
  • -p or --port is a non-SSL port to bind on

Tinkering

That's it. Some of the options (such as certificate filenames) are hard coded, and this is designed to minimize any friction and get you going as fast as possible.

The code is very hackable and you're welcome to submit pull requests if you think it'd be suitable.

When in doubt just run node cottonballs -h to get a listing of your options.

Contributing

Fork, implement, add tests, pull request, get my everlasting thanks and a respectable place here :).

Copyright

Copyright (c) 2012 Dotan Nahum @jondot. See MIT-LICENSE for further details.

cottonballs's People

Contributors

jondot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cottonballs's Issues

Unable to install cottonballs

I was trying to install “cottonballs” for a similar testing, however I see the following errors.
Do you have any insight as to what might be happening ? from the look of it, it feels like the Code is old and using some old functions which are deprecated ?

Appreciate if you could help


(node) sys is deprecated. Use util instead.
== CottonBalls v0.0.4. Puffy clouds for your GCM. ==
* Listening on port 7333.
2016-05-10T23:50:43.671Z - info: Starting with f:0 l:100 x:100 c:0
2016-05-10T23:50:43.681Z - error: uncaughtException: Most middleware (like bodyParser) is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware. date=Tue May 10 2016 23:50:43 GMT+0000 (UTC), pid=19239, uid=0, gid=0, cwd=/home/centos/cottonballs, execPath=/usr/bin/node, version=v4.4.4, argv=[/usr/bin/node, /home/centos/cottonballs/cottonballs], rss=28921856, heapTotal=18748000, heapUsed=12273864, loadavg=[0.0908203125, 0.22802734375, 0.20263671875], uptime=709, trace=[column=13, file=/home/centos/cottonballs/node_modules/express/lib/express.js, function=Function.Object.defineProperty.get, line=99, method=Object.defineProperty.get, native=false, column=18, file=/home/centos/cottonballs/cottonballs.js, function=, line=47, method=null, native=false, column=4, file=/home/centos/cottonballs/cottonballs.js, function=, line=136, method=null, native=false, column=26, file=module.js, function=Module._compile, line=409, method=_compile, native=false, column=10, file=module.js, function=Object.Module._extensions..js, line=416, method=Module._extensions..js, native=false, column=32, file=module.js, function=Module.load, line=343, method=load, native=false, column=12, file=module.js, function=Function.Module._load, line=300, method=Module._load, native=false, column=10, file=module.js, function=Function.Module.runMain, line=441, method=Module.runMain, native=false, column=18, file=node.js, function=startup, line=139, method=null, native=false, column=3, file=node.js, function=null, line=968, method=null, native=false], stack=[Error: Most middleware (like bodyParser) is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.,     at Function.Object.defineProperty.get (/home/centos/cottonballs/node_modules/express/lib/express.js:99:13),     at Object.<anonymous> (/home/centos/cottonballs/cottonballs.js:47:18),     at Object.<anonymous> (/home/centos/cottonballs/cottonballs.js:136:4),     at Module._compile (module.js:409:26),     at Object.Module._extensions..js (module.js:416:10),     at Module.load (module.js:343:32),     at Function.Module._load (module.js:300:12),     at Function.Module.runMain (module.js:441:10),     at startup (node.js:139:18),     at node.js:968:3]
[root@ip-172-31-41-50 cottonballs]#

It's not working with https

  1. Setup cottonballs
  2. Updated host file ccording to documentation i.e. 127.0.0.1 android.googleapis.com
  3. Using postman POST: https://android.googleapis.com/gcm/send

{
"registration_ids" : ["APA91bHpPg5OHGQswCT3FMv4MkdEbm2J2WEzuf69HlMljPvi_7htN3dlaZXCYReGGwDvtnoxw_TsaX0mY63x_htxdFrPvlWbnxUhIEKtbARAjCrbSXueIk6W66dw6zUBvEaSufZf4hSa_XQu5WpfzzYYmKy8OPFZyA", "ssghgshgsshg"],
"data" : {
"message":"Hello World from Watson!!"
}
}

We get response status 0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.