Example #1
0
      redis.smembers('metroplex:servers', function (err, servers) {
        if (err) return next(err);

        assume(!!~servers).to.be.true();
        next();
      });
Example #2
0
File: test.js Project: Hao8816/coco
    it('tags the assigned function', function () {
      assume(ee.listeners('foo').length).equals(0);

      ultron.on('foo', function () {});
      assume(ee.listeners('foo')[0].__ultron).equals(ultron.id);
    });
 i.on('error', err => {
   debug('correctly getting expired watchdog timer');
   i.stop();
   assume(i.keepGoing).is.not.ok();
   done();
 });
Example #4
0
File: test.js Project: Hao8816/coco
 it('can be initialized without the new keyword', function () {
   assume(Ultron(ee)).is.instanceOf(Ultron);
 });
Example #5
0
File: test.js Project: Hao8816/coco
 it('removes the .ee reference', function () {
   assume(ultron.ee).equals(ee);
   ultron.destroy();
   assume(ultron.ee).equals(null);
 });
 it('should return a list of AMI sets', async () => {
   await client.createAmiSet(id, amiSetDefinition);
   assume(await client.listAmiSets()).to.deeply.equal([id]);
 });
Example #7
0
File: test.js Project: Hao8816/coco
    it('removes our private __ultron references', function () {
      function once() {}
      function on() {}

      assume('__ultron' in once).is.false();
      assume('__ultron' in on).is.false();

      ultron.on('foo', on);
      ultron.once('bar', once);

      assume('__ultron' in once).is.true();
      assume('__ultron' in on).is.true();

      ultron.remove('foo, bar');

      assume('__ultron' in once).is.false();
      assume('__ultron' in on).is.false();

      ultron.destroy();

      ee = new EE();
      ultron = new Ultron(ee);

      assume('__ultron' in once).is.false();
      assume('__ultron' in on).is.false();

      ultron.on('foo', on);
      ultron.once('bar', once);

      assume('__ultron' in once).is.true();
      assume('__ultron' in on).is.true();

      ultron.remove('foo, bar');

      assume('__ultron' in once).is.false();
      assume('__ultron' in on).is.false();
    });
Example #8
0
 primus.on('connection', function (spark) {
   assume(spark.mirage).to.equal('new');
   spark.on('end', next);
 });
Example #9
0
 client.on('mirage', function (id) {
   assume(id).equals('new');
   client.end();
 });
Example #10
0
 primus.on('connection', function (spark) {
   assume(spark.mirage).to.equal('lol');
   spark.end();
   next();
 });
Example #11
0
      primus.id.validator(function validator(spark, fn) {
        assume(spark.query).to.be.a('object');
        assume(spark.mirage).to.equal('ohai');

        fn(new Error('I SHOULD BE OK'));
      });
Example #12
0
 it('is exported as function', function () {
   assume(extend).is.a('function');
 });
Example #13
0
  it('returns the newly extended function', function () {
    function foo() {} foo.extend = extend;

    var bar = foo.extend();
    assume(bar).does.not.equal(foo);
  });
Example #14
0
      redis.hget('metroplex:sparks', id, function canihas(err, address) {
        if (err) return next(err);

        assume(address).to.contain(http.port);
        client.end();
      });
  test('taskA, taskB <- taskC && taskA <- taskD', helper.runWithFakeTime(async () => {
    let taskIdA = slugid.v4();
    let taskIdB = slugid.v4();
    let taskIdC = slugid.v4();
    let taskIdD = slugid.v4();

    let taskA = taskDef();
    let taskB = taskDef();
    let taskC = _.defaults({
      dependencies: [taskIdA, taskIdB],
    }, taskDef());
    let taskD = _.defaults({
      dependencies: [taskIdA],
    }, taskDef());

    // Start dependency-resolver
    const dependencyResolver = await helper.startPollingService('dependency-resolver');

    debug('### Create taskA, taskB, taskC');
    let r1 = await helper.queue.createTask(taskIdA, taskA);
    helper.checkNextMessage('task-defined', m => assert.equal(m.payload.status.taskId, taskIdA));
    helper.checkNextMessage('task-pending', m => assert.equal(m.payload.status.taskId, taskIdA));
    let r2 = await helper.queue.createTask(taskIdB, taskB);
    helper.checkNextMessage('task-defined', m => assert.equal(m.payload.status.taskId, taskIdB));
    helper.checkNextMessage('task-pending', m => assert.equal(m.payload.status.taskId, taskIdB));
    let r3 = await helper.queue.createTask(taskIdC, taskC);
    helper.checkNextMessage('task-defined', m => assert.equal(m.payload.status.taskId, taskIdC));
    helper.checkNoNextMessage('task-pending');
    let r4 = await helper.queue.createTask(taskIdD, taskD);
    helper.checkNextMessage('task-defined', m => assert.equal(m.payload.status.taskId, taskIdD));
    helper.checkNoNextMessage('task-pending');
    assume(r1.status.state).equals('pending');
    assume(r2.status.state).equals('pending');
    assume(r3.status.state).equals('unscheduled');
    assume(r4.status.state).equals('unscheduled');

    debug('### Claim taskA and taskB');
    await helper.queue.claimTask(taskIdA, 0, {
      workerGroup:    'my-worker-group',
      workerId:       'my-worker',
    });
    helper.checkNextMessage('task-running', m => assert.equal(m.payload.status.taskId, taskIdA));
    await helper.queue.claimTask(taskIdB, 0, {
      workerGroup:    'my-worker-group',
      workerId:       'my-worker',
    });
    helper.checkNextMessage('task-running', m => assert.equal(m.payload.status.taskId, taskIdB));

    debug('### Resolve taskA');
    await helper.queue.reportCompleted(taskIdA, 0);
    helper.checkNextMessage('task-completed', m => assert.equal(m.payload.status.taskId, taskIdA));

    debug('### Wait for taskD to be pending');
    await testing.poll(
      async () => helper.checkNextMessage('task-pending', m => assert.equal(m.payload.status.taskId, taskIdD)),
      Infinity);

    debug('### Resolve taskB');
    await helper.queue.reportCompleted(taskIdB, 0);
    helper.checkNextMessage('task-completed', m => assert.equal(m.payload.status.taskId, taskIdB));

    debug('### Wait for taskC to be pending');
    await testing.poll(
      async () => helper.checkNextMessage('task-pending', m => assert.equal(m.payload.status.taskId, taskIdC)),
      Infinity);

    await dependencyResolver.terminate();
  }, mock));
Example #16
0
 primus.on('connection', function connection(spark) {
   assume(spark.mirage).to.equal('foo');
 });
  test('taskA <- taskB', helper.runWithFakeTime(async () => {
    let taskIdA = slugid.v4();
    let taskIdB = slugid.v4();

    let taskA = taskDef();
    let taskB = _.defaults({
      dependencies: [taskIdA],
    }, taskDef());

    // Start dependency-resolver
    const dependencyResolver = await helper.startPollingService('dependency-resolver');

    debug('### Create taskA and taskB');
    let r1 = await helper.queue.createTask(taskIdA, taskA);
    helper.checkNextMessage('task-defined', m => assert.equal(m.payload.status.taskId, taskIdA));
    helper.checkNextMessage('task-pending', m => assert.equal(m.payload.status.taskId, taskIdA));
    let r2 = await helper.queue.createTask(taskIdB, taskB);
    helper.checkNextMessage('task-defined', m => assert.equal(m.payload.status.taskId, taskIdB));
    assume(r1.status.state).equals('pending');
    assume(r2.status.state).equals('unscheduled');

    debug('### listTaskDependents');
    {
      let d1 = await helper.queue.listDependentTasks(taskIdA);
      assume(d1.taskId).equals(taskIdA);
      assume(d1.tasks).has.length(1);
      assume(d1.tasks[0].status.taskId).equals(taskIdB);
      let d2 = await helper.queue.listDependentTasks(taskIdB);
      assume(d2.taskId).equals(taskIdB);
      assume(d2.tasks).has.length(0);
    }

    debug('### Claim and resolve taskA');
    await helper.queue.claimTask(taskIdA, 0, {
      workerGroup:    'my-worker-group',
      workerId:       'my-worker',
    });
    helper.checkNextMessage('task-running', m => assert.equal(m.payload.status.taskId, taskIdA));
    await helper.queue.reportCompleted(taskIdA, 0);
    helper.checkNextMessage('task-completed', m => assert.equal(m.payload.status.taskId, taskIdA));

    // task B should become pending on next poll
    await testing.poll(
      async () => helper.checkNextMessage('task-pending', m => assert.equal(m.payload.status.taskId, taskIdB)),
      Infinity);

    debug('### Claim and resolve taskB');
    await helper.queue.claimTask(taskIdB, 0, {
      workerGroup:    'my-worker-group',
      workerId:       'my-worker',
    });
    helper.checkNextMessage('task-running', m => assert.equal(m.payload.status.taskId, taskIdB));
    await helper.queue.reportCompleted(taskIdB, 0);
    helper.checkNextMessage('task-completed', m => assert.equal(m.payload.status.taskId, taskIdB));

    debug('### listTaskDependents');
    {
      let d1 = await helper.queue.listDependentTasks(taskIdA);
      assume(d1.taskId).equals(taskIdA);
      assume(d1.tasks).has.length(1);
      assume(d1.tasks[0].status.taskId).equals(taskIdB);
      let d2 = await helper.queue.listDependentTasks(taskIdB);
      assume(d2.taskId).equals(taskIdB);
      assume(d2.tasks).has.length(0);
    }

    await dependencyResolver.terminate();
  }, mock));
Example #18
0
    it('is a number', function () {
      primus.use('mirage', mirage);

      assume(primus.id.timeout).is.a('number');
    });
Example #19
0
 spawnColorizer(function (err, data) {
   assume(err).equals(null);
   assume(data).includes('\u001b[32mSimply a test\u001b[39m');
   done();
 })
Example #20
0
 spark.on('error', function (err) {
   assume(err.message).to.include('timely manner');
   next();
 });
Example #21
0
File: test.js Project: Hao8816/coco
 it('is exposed as a function', function () {
   assume(Ultron).is.a('function');
 });
Example #22
0
 helpers.load(function (err, data) {
   assume(err).equals(null);
   config = data;
   done();
 });
Example #23
0
File: test.js Project: Hao8816/coco
 it('assigns a unique id to every instance', function () {
   for (var i = 0; i < 100; i++) {
     assume(ultron.id).does.not.equal((new Ultron()).id);
   }
 });
Example #24
0
 it('should create datastar instance without pre-heating connection', function (done) {
   var datastar = new Datastar({ config: config.cassandra });
   datastar.connect();
   assume(datastar.connection).is.not.an('undefined');
   datastar.close(done);
 });
Example #25
0
File: test.js Project: Hao8816/coco
 it('returns booleans for state indication', function () {
   assume(ultron.destroy()).is.true();
   assume(ultron.destroy()).is.false();
   assume(ultron.destroy()).is.false();
   assume(ultron.destroy()).is.false();
 });
Example #26
0
 datastar.connect(function (err) {
   assume(err).is.falsey();
   assume(datastar.connection).is.not.an('undefined');
   datastar.close(done);
 });
 i.on('completed', () => {
   assume(iterations).equals(5);
   assume(i.keepGoing).is.not.ok();
   i.stop();
   done();
 });
  test('taskA <- taskB, taskC, taskD, taskE', helper.runWithFakeTime(async () => {
    let taskIdA = slugid.v4();
    let taskIdB = slugid.v4();
    let taskIdC = slugid.v4();
    let taskIdD = slugid.v4();
    let taskIdE = slugid.v4();

    let taskA = taskDef();
    let taskB = _.defaults({
      dependencies: [taskIdA],
    }, taskDef());
    let taskC = _.cloneDeep(taskB);
    let taskD = _.cloneDeep(taskB);
    let taskE = _.cloneDeep(taskB);

    // Start dependency-resolver
    const dependencyResolver = await helper.startPollingService('dependency-resolver');

    debug('### Create taskA');
    await helper.queue.createTask(taskIdA, taskA);
    helper.checkNextMessage('task-defined', m => assert.equal(m.payload.status.taskId, taskIdA));
    helper.checkNextMessage('task-pending', m => assert.equal(m.payload.status.taskId, taskIdA));

    debug('### listTaskDependents');
    let d1 = await helper.queue.listDependentTasks(taskIdA);
    assume(d1.taskId).equals(taskIdA);
    assume(d1.tasks).has.length(0);

    debug('### Create taskB, taskC, taskD, taskE');
    await helper.queue.createTask(taskIdB, taskB);
    helper.checkNextMessage('task-defined', m => assert.equal(m.payload.status.taskId, taskIdB));
    helper.checkNoNextMessage('task-pending');
    await helper.queue.createTask(taskIdC, taskC);
    helper.checkNextMessage('task-defined', m => assert.equal(m.payload.status.taskId, taskIdC));
    helper.checkNoNextMessage('task-pending');
    await helper.queue.createTask(taskIdD, taskD);
    helper.checkNextMessage('task-defined', m => assert.equal(m.payload.status.taskId, taskIdD));
    helper.checkNoNextMessage('task-pending');
    await helper.queue.createTask(taskIdE, taskE);
    helper.checkNextMessage('task-defined', m => assert.equal(m.payload.status.taskId, taskIdE));
    helper.checkNoNextMessage('task-pending');

    debug('### listTaskDependents');
    let d2 = await helper.queue.listDependentTasks(taskIdA);
    assume(d2.taskId).equals(taskIdA);
    assume(d2.tasks).has.length(4);
    assume(d2.tasks.map(t => t.status.taskId)).contains(taskIdB);
    assume(d2.tasks.map(t => t.status.taskId)).contains(taskIdC);
    assume(d2.tasks.map(t => t.status.taskId)).contains(taskIdD);
    assume(d2.tasks.map(t => t.status.taskId)).contains(taskIdE);

    debug('### Claim and resolve taskA');
    await helper.queue.claimTask(taskIdA, 0, {
      workerGroup:    'my-worker-group',
      workerId:       'my-worker',
    });
    helper.checkNextMessage('task-running', m => assert.equal(m.payload.status.taskId, taskIdA));
    await helper.queue.reportCompleted(taskIdA, 0);
    helper.checkNextMessage('task-completed', m => assert.equal(m.payload.status.taskId, taskIdA));

    debug('### Wait for taskB, taskC, taskD, taskE to be pending');
    await testing.poll(async () => assert(helper.messages.length >= 4), Infinity);
    const nowPending = new Set(helper.messages
      .filter(m => m.exchange.endsWith('task-pending'))
      .map(m => m.payload.status.taskId));
    assume(nowPending).to.deeply.equal(new Set([taskIdB, taskIdC, taskIdD, taskIdE]));

    debug('### listTaskDependents, limit = 2');
    let d3 = await helper.queue.listDependentTasks(taskIdA, {limit: 2});
    assume(d3.tasks).has.length(2);
    assume(d3).ownProperty('continuationToken');
    let d4 = await helper.queue.listDependentTasks(taskIdA, {
      limit: 2,
      continuationToken: d3.continuationToken,
    });
    assume(d4.tasks).has.length(2);
    assume(d4).not.has.ownProperty('continuationToken');
    let tids = _.flatten([d3.tasks, d4.tasks]).map(t => t.status.taskId);
    assume(tids).contains(taskIdB);
    assume(tids).contains(taskIdC);
    assume(tids).contains(taskIdD);
    assume(tids).contains(taskIdE);

    await dependencyResolver.terminate();
  }, mock));
 i.on('error', err => {
   i.stop();
   assume(i.keepGoing).is.not.ok();
   done();
 });
Example #30
0
 server.once('register', function (address) {
   assume(address).to.contain(http.port);
   next();
 });