<commit_before>var helper = require('./specHelper');
var cluster = require('cluster');
var http = require('http');

describe("clustering", function() {

  beforeEach(function() {
    helper.testComplete(false);
  });

  it ('should be able to delegate requests to children', function() {
      waitsFor(helper.testComplete, "child to come online process a request and die", 5000);
      cluster.setupMaster( {
        exec: './src/test/javascript/cluster_child.js',
        silent: false
      } );
      console.log( "master: forking" );
      var child = cluster.fork();
      expect( cluster.workers[1] ).toBe( child );
      var body = '';
      child.on('listening', function() {
        console.log( "master: child is listening" );
        http.get( { port: 8000 }, function(response) {
          response.on('data', function(d) {
            body += d.toString();
          });
          response.on('end', function() {
            expect( body ).toContain( child.process.pid );
            expect( body ).toContain( "worker#1" );
            child.on( 'disconnect', function() {
              console.log( "master: disconnected, killing" );
              child.kill();
            });
            child.on('exit', function() {
              console.log( "master: child exited" );
              helper.testComplete(true);
            })
            console.log( "master: disconnecting" );
            child.disconnect();
          });
        } );
      })
      child.on( 'online', function() {
        console.log( "master: child is online" );
      })
  });


});
<commit_msg>Increase cluster-test timeout for slow CI machines.<commit_after>var helper = require('./specHelper');
var cluster = require('cluster');
var http = require('http');

describe("clustering", function() {

  beforeEach(function() {
    helper.testComplete(false);
  });

  it ('should be able to delegate requests to children', function() {
      waitsFor(helper.testComplete, "child to come online process a request and die", 10000);
      cluster.setupMaster( {
        exec: './src/test/javascript/cluster_child.js',
        silent: false
      } );
      console.log( "master: forking" );
      var child = cluster.fork();
      expect( cluster.workers[1] ).toBe( child );
      var body = '';
      child.on('listening', function() {
        console.log( "master: child is listening" );
        http.get( { port: 8000 }, function(response) {
          response.on('data', function(d) {
            body += d.toString();
          });
          response.on('end', function() {
            expect( body ).toContain( child.process.pid );
            expect( body ).toContain( "worker#1" );
            child.on( 'disconnect', function() {
              console.log( "master: disconnected, killing" );
              child.kill();
            });
            child.on('exit', function() {
              console.log( "master: child exited" );
              helper.testComplete(true);
            })
            console.log( "master: disconnecting" );
            child.disconnect();
          });
        } );
      })
      child.on( 'online', function() {
        console.log( "master: child is online" );
      })
  });


});

{'fraction_non_alphanumeric': 0.1563375895359701, 'fraction_numerical': 0.006540018685767673, 'mean_word_length': 2.0914340712223294, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3610306', 'n_tokens_mistral': 899, 'n_tokens_neox': 863, 'n_words': 212}