Skip to content

Commit

Permalink
Merge pull request #53 from uber-common/port_test_issue
Browse files Browse the repository at this point in the history
Fix the already broken build
  • Loading branch information
dongxiaoman authored Apr 17, 2018
2 parents 7240487 + 5449532 commit d7106ec
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ node_js:
notifications:
email:
- [email protected]

before_install:
- if [[ `npm -v` != 2* ]]; then npm i -g npm@2; fi
4 changes: 2 additions & 2 deletions lib/kafka_base_producer.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,12 @@ KafkaBaseProducer.prototype._produce = function _produce(msg, callback) {
/* eslint-disable callback-return */
function onResponse(err, result) {

self.pendingWrites--;

if (callback) {
callback(err, result);
}

self.pendingWrites--;

if (self.closing) {
self._tryClose();
}
Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": {
"@sinonjs/formatio": "^2.0.0",
"error": "^7.0.1",
"lb_pool": "^1.2.0",
"lb_pool": "^1.7.1",
"pkginfo": "^0.4.1",
"sinon": "^4.5.0"
},
Expand All @@ -29,7 +29,7 @@
"opn": "^0.1.2",
"pre-commit": "0.0.9",
"proxyquire": "*",
"rewire": "*",
"rewire": "3.0.2",
"should": "*",
"sinon": "*",
"tape": "^4.2.0",
Expand All @@ -50,8 +50,12 @@
"view-cover": "opn ./coverage/*/index.html"
},
"engine": {
"node": ">= 0.10.x"
"node": ">= 0.10.32"
},
"engines": {
"node": "^0.10.32",
"npm": "2.15.11"
},
"pre-commit": [
"check-licence",
"lint",
Expand Down
14 changes: 8 additions & 6 deletions test/test_kafka_producer.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,15 @@ test('Test generate audit msg', function testKafkaProducerGenerateAuditMsg(asser
proxyHost: 'localhost',
proxyPort: PORT,
enableAudit: true,
auditTimeBucketIntervalInSec: 1
auditTimeBucketIntervalInSec: 1,
timeout: 0,
maxRetries: 0
};
var producer = new KafkaProducer(configs);
producer.connect(onConnect);
function onConnect() {
assert.equal(producer.producer.restClient.enable, true);
for (var i = 0; i < 5120000; i++) {
for (var i = 0; i < 512000; i++) {
producer.produce('testTopic0', 'Important message', Date.now() / 1000.0);
}
producer.produce('testTopic1', 'Important message', Date.now() / 1000.0);
Expand Down Expand Up @@ -491,18 +493,18 @@ test('Test generate audit msg', function testKafkaProducerGenerateAuditMsg(asser
}
/* eslint-enable block-scoped-var */

assert.equal(cntTestTopic0, 5120000);
assert.equal(cntTestTopic0, 512000);
assert.equal(cntTestTopic1, 2);
assert.equal(cntTestTopic2, 3);
assert.end();
/* jshint camelcase: true */
/* eslint-enable camelcase */

/* eslint-disable no-undef,block-scoped-var */
server.stop();
setTimeout(function stopTest1() {
server.stop();
producer.close();
}, 2000);
}, 5000);
/* eslint-enable no-undef,block-scoped-var */
}
});
Expand Down Expand Up @@ -557,7 +559,7 @@ test('kafkaProducer handle no meta data situation', function testKafkaProducerHa
function test2(next) {
kafkaProducer.produce('hp_testTopic0', 'Important message', Date.now() / 1000.0,
function assertErrorThrows2(err) {
assert.equal(err.reason, 'connect ECONNREFUSED');
assert.true(err.reason.indexOf('connect ECONNREFUSED') >= 0);
next();
});
}
Expand Down
14 changes: 7 additions & 7 deletions test/test_kafka_rest_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ test('KafkaRestClient handle failed post with retries', function testKafkaRestCl
function test1(next) {
restClient.produce(getProduceMessage('testTopic0', 'msg0', timeStamp, 'binary'),
function assertHttpErrorReason(err) {
assert.equal(err.reason, 'connect ECONNREFUSED');
assert.true(err.reason.indexOf('connect ECONNREFUSED') >= 0);
next();
});
},
function test2(next) {
restClient.produce(getProduceMessage('hp.testTopic1', 'msg1', timeStamp, 'binary'),
function assertErrorThrows(err) {
assert.equal(err.reason, 'connect ECONNREFUSED');
assert.true(err.reason.indexOf('connect ECONNREFUSED') >= 0);
next();
});
}
Expand All @@ -110,7 +110,7 @@ test('KafkaRestClient handle failed post with retries', function testKafkaRestCl
function test3(next) {
restClient.produce(getProduceMessage('testTopic0', 'msg1', timeStamp, 'binary'),
function assertErrorThrows(err) {
assert.equal(err.reason, 'connect ECONNREFUSED');
assert.true(err.reason.indexOf('connect ECONNREFUSED') >= 0);
next();
});
},
Expand Down Expand Up @@ -149,14 +149,14 @@ test('KafkaRestClient handle not cached topics', function testKafkaRestClientHan
function test1(next) {
restClient.produce(getProduceMessage('hp-testTopic-not-in-map', 'msg0', timeStamp, 'binary'),
function assertErrorThrows(err) {
assert.equal(err.reason, 'connect ECONNREFUSED');
assert.true(err.reason.indexOf('connect ECONNREFUSED') >= 0);
next();
});
},
function test2(next) {
restClient.produce(getProduceMessage('testTopic-not-in-map', 'msg0', timeStamp, 'binary'),
function assertHttpErrorReason(err) {
assert.equal(err.reason, 'connect ECONNREFUSED');
assert.true(err.reason.indexOf('connect ECONNREFUSED') >= 0);
server.start();
restClient.produce(getProduceMessage('testTopic-not-in-map', 'msg0', timeStamp, 'binary'),
function assertHttpErrorReason2(err2) {
Expand Down Expand Up @@ -190,14 +190,14 @@ test('KafkaRestClient handle post with blacklist client', function testKafkaRest
function test1(next) {
restClient.produce(getProduceMessage('testTopic0', 'msg0', timeStamp, 'binary'),
function assertHttpErrorReason(err) {
assert.equal(err.reason, 'connect ECONNREFUSED');
assert.true(err.reason.indexOf('connect ECONNREFUSED') >= 0);
next();
});
},
function test2(next) {
restClient.produce(getProduceMessage('testTopic1', 'msg0', timeStamp, 'binary'),
function assertErrorThrows(err, resp) {
assert.equal(err.reason, 'connect ECONNREFUSED');
assert.true(err.reason.indexOf('connect ECONNREFUSED') >= 0);
assert.equal(resp, undefined);
next();
});
Expand Down

0 comments on commit d7106ec

Please sign in to comment.