0.3.0 • Published 9 years ago

chain-smoker v0.3.0

Weekly downloads
1
License
MIT
Repository
-
Last release
9 years ago

Chain Smoker

It runs your tests. It checks the callbacks. Chain Smoker is an old curmudgeon that will yell at you when your stuff falls over.

It's totally not ready for use yet. Come back later.

Setup

Chain Smoker requires Redis.

  1. Install Chain Smoker

    $ npm install chain-smoker --save
  2. Create your test suite.

    var ChainSmoker = require('chain-smoker');
    
    var Suite = {};
    
    Suite.tests = [
      {
        name: 'example-get',
        address: 'http://example.com',
        assertions: {
          statusCode: 200
        }
      },
      {
        name: 'example-callback',
        address: 'http://example.com/call/me/back',
        method: 'POST',
        headers: {
          'X-Awesome-Header': 'this is really cool'
        },
        body: {
          neato: true,
          callback_url: 'http://this-hostname/callback/example-callback'
        },
        assertions: {
          statusCode: 201
        },
        callback_assertions: {
          job_success: function(req) {
            return req.body.status === 'success';
          }
        },
        callback_time_limit: 10000,
        external_id: function(req) {
          return req.body.id;
        }
      }
    ];
    
    var options = {
      apiPort: 8080,
      lateCallback: function(jobs) {
        if (jobs.length === 0) {
          console.log('There are no late jobs!');
        } else {
          console.log('There are '+ jobs.length +' late jobs!');
          console.log(jobs);
        }
      }
    }
    
    ChainSmoker(Suite, options, function(err, runner) {
      if (err) return console.log(err);
      console.log('Locked and loaded.');
    
      // Now that everything's nice and ready, we need to
      // kick off the tests. Sit back and let the man smoke.
      runner.runAll();
    });
  3. Enjoy.

Test options

OptionDetails (default)
nameString (null) - Name of the test (really useful for callback routing)
addressstring (null) - Endpoint to hit for the test
methodstring (GET) - HTTP method to use when hitting the specified address
headersObject ({}) - Headers to deliver when making the request
bodyString or Object ('null') - If an object is given, it will be stringified before making the request.
external_idFunction (msg.body.id) - Function that returns a unique ID from the response. If this is null, msg.body.id is blindly used, so external_id could potentially be null.
assertionsObject ({}) - Object containing the assertions to run against the initial request. The values of each assertion can either be a string (or object) to compare against the key of the same name in the response, or a function that returns true or false.
callback_assertionsObject (null) - Same as above, but for the callback received from the initial request
callback_time_limitInteger (0) - Amount of time (in milliseconds) before a callback is considered late. After this point, the late jobs begin to show up in the lateCallback mentioned below.

Chain Smoker Run Options

OptionValues (default)Details
apiPortInteger (3000)The port to use for the callback server
lateCallbackFn(jobs) (noop())The function to call when the check for late jobs comes back. The callback fires even if the array is empty, which can be useful to clear out any pager alerts or other things fired when the array was not empty.
lateCheckFrequencyInteger (1500)How often in milliseconds to check for late jobs
disableCleanerBoolean (false)If true, old completed jobs will not be removed from the database
cleanFailuresBoolean (false)Whether or not to remove jobs that have completed, but were unsuccessful
maxCompletedAgeInteger (3600000)If cleanup is enabled, this is the age (in milliseconds) threshold before a job is cleaned. Default is 1 hour.
cleanFrequencyInteger (5000)How often in milliseconds to run the cleanup check
0.3.0

9 years ago

0.2.8

9 years ago

0.2.7

9 years ago

0.2.6

9 years ago

0.2.5

9 years ago

0.2.4

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago