<commit_before>'use strict';

var assert = require('assert');

var createStatsdClient = require('./helpers').createStatsdClient;
var createTCPServer = require('./helpers').createTCPServer;
var createUDPServer = require('./helpers').createUDPServer;

module.exports = function runBufferTestSuite() {
  describe('#buffer', function () {
    var server;
    var statsd;

    afterEach(function () {
      server = null;
      statsd = null;
    });

    ['main client', /*'child client', 'child of child client'*/].forEach(function (description, index) {
      describe(description, function () {
        describe('UDP', function () {
          it('should aggregate packets when maxBufferSize is set to non-zero', function (done) {
            server = createUDPServer(function (address) {
              statsd = createStatsdClient({
                host: address.address, 
                port: address.port,
                maxBufferSize: 12
              }, index);
              statsd.increment('a', 1);
              statsd.increment('b', 2);
            });
            server.on('metrics', function (metrics) {
              assert.equal(metrics, 'a:1|c\nb:2|c\n');
              server.close();
              done();
            });
          });

          it('should not aggregate packets when maxBufferSize is set to zero', function (done) {
            var noOfMessages = 0;
            var expected = ['a:1|c', 'b:2|c'];<commit_msg>Uncomment multiple clients in test/buffer.js<commit_after>'use strict';

var assert = require('assert');

var createStatsdClient = require('./helpers').createStatsdClient;
var createTCPServer = require('./helpers').createTCPServer;
var createUDPServer = require('./helpers').createUDPServer;

module.exports = function runBufferTestSuite() {
  describe('#buffer', function () {
    var server;
    var statsd;

    afterEach(function () {
      server = null;
      statsd = null;
    });

    ['main client', 'child client', 'child of child client'].forEach(function (description, index) {
      describe(description, function () {
        describe('UDP', function () {
          it('should aggregate packets when maxBufferSize is set to non-zero', function (done) {
            server = createUDPServer(function (address) {
              statsd = createStatsdClient({
                host: address.address, 
                port: address.port,
                maxBufferSize: 12
              }, index);
              statsd.increment('a', 1);
              statsd.increment('b', 2);
            });
            server.on('metrics', function (metrics) {
              assert.equal(metrics, 'a:1|c\nb:2|c\n');
              server.close();
              done();
            });
          });

          it('should not aggregate packets when maxBufferSize is set to zero', function (done) {
            var noOfMessages = 0;
            var expected = ['a:1|c', 'b:2|c'];
{'fraction_non_alphanumeric': 0.13456917267421903, 'fraction_numerical': 0.006179196704428424, 'mean_word_length': 2.219889502762431, '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': '56327', 'n_tokens_mistral': 781, 'n_tokens_neox': 766, 'n_words': 193}