Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into ts-exports
Browse files Browse the repository at this point in the history
Bumping versions
  • Loading branch information
Alberto Ricart committed Oct 20, 2017
2 parents bf71f4b + 09418f6 commit 67046cf
Show file tree
Hide file tree
Showing 26 changed files with 130 additions and 198 deletions.
12 changes: 6 additions & 6 deletions .travis.yml
Expand Up @@ -2,16 +2,16 @@ language: node_js
sudo: false

node_js:
- "0.12"
- "4"
- "6"
- "7"
- "8"

before_script:
- wget https://github.com/nats-io/gnatsd/releases/download/v0.9.4/gnatsd-v0.9.4-linux-amd64.zip -qO tmp.zip
- wget https://github.com/nats-io/gnatsd/releases/download/v1.0.4/gnatsd-v1.0.4-linux-amd64.zip -qO tmp.zip
- unzip tmp.zip
- mv gnatsd-v0.9.4-linux-amd64 gnatsd
- mv gnatsd-v1.0.4-linux-amd64 gnatsd

after_success:
- npm run coveralls
script:
- if [[ "$TRAVIS_NODE_VERSION" == 4 ]]; then npm test; fi
- if [[ "$TRAVIS_NODE_VERSION" == 6 ]]; then npm test; fi
- if [[ "$TRAVIS_NODE_VERSION" == 8 ]]; then npm run coveralls; fi
11 changes: 10 additions & 1 deletion README.md
Expand Up @@ -256,7 +256,16 @@ nc.on('close', function() {

```

See examples and benchmarks for more information..
See examples and benchmarks for more information.


## Supported Node Versions

Support policy for Nodejs versions follows
[Nodejs release support]( https://github.com/nodejs/Release).
We will support and build node-nats on even Nodejs versions that are current
or in maintenance.


## License

Expand Down
2 changes: 1 addition & 1 deletion lib/nats.js
Expand Up @@ -21,7 +21,7 @@ var net = require('net'),
/**
* Constants
*/
var VERSION = '0.7.20',
var VERSION = '0.7.24',

DEFAULT_PORT = 4222,
DEFAULT_PRE = 'nats://localhost:',
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "nats",
"version": "0.7.20",
"version": "0.7.24",
"description": "Node.js client for NATS, a lightweight, high-performance cloud native messaging system",
"keywords": [
"nats",
Expand Down
9 changes: 4 additions & 5 deletions test/auth.js
Expand Up @@ -20,8 +20,8 @@ describe('Authorization', function() {
});

// Shutdown our server after we are done
after(function() {
server.kill();
after(function(done) {
nsc.stop_server(server, done);
});

it('should fail to connect with no credentials ', function(done) {
Expand Down Expand Up @@ -83,8 +83,8 @@ describe('Token Authorization', function() {
});

// Shutdown our server after we are done
after(function() {
server.kill();
after(function(done) {
server = nsc.stop_server(server, done);
});

it('should fail to connect with no credentials ', function(done) {
Expand Down Expand Up @@ -128,5 +128,4 @@ describe('Token Authorization', function() {
setTimeout(done, 100);
});
});

});
5 changes: 2 additions & 3 deletions test/autounsub.js
Expand Up @@ -17,8 +17,8 @@ describe('Max responses and Auto-unsub', function() {
});

// Shutdown our server after we are done
after(function() {
server.kill();
after(function(done) {
nsc.stop_server(server, done);
});

it('should only received max responses requested', function(done) {
Expand Down Expand Up @@ -188,5 +188,4 @@ describe('Max responses and Auto-unsub', function() {
});

});

});
4 changes: 2 additions & 2 deletions test/basics.js
Expand Up @@ -17,8 +17,8 @@ describe('Basics', function() {
});

// Shutdown our server
after(function() {
nsc.stop_server(server);
after(function(done) {
nsc.stop_server(server, done);
});

it('should do basic subscribe and unsubscribe', function(done) {
Expand Down
4 changes: 2 additions & 2 deletions test/binary.js
Expand Up @@ -18,8 +18,8 @@ describe('Binary', function() {
});

// Shutdown our server
after(function() {
server.kill();
after(function(done) {
nsc.stop_server(server, done);
});


Expand Down
4 changes: 2 additions & 2 deletions test/buffer.js
Expand Up @@ -17,8 +17,8 @@ describe('Buffer', function() {
});

// Shutdown our server
after(function() {
server.kill();
after(function(done) {
nsc.stop_server(server, done);
});

it('should allow sending and receiving raw buffers', function(done) {
Expand Down
4 changes: 2 additions & 2 deletions test/callbacks.js
Expand Up @@ -17,8 +17,8 @@ describe('Callbacks', function() {
});

// Shutdown our server
after(function() {
server.kill();
after(function(done) {
nsc.stop_server(server, done);
});

it('should properly do a publish callback after connection is closed', function(done) {
Expand Down
15 changes: 9 additions & 6 deletions test/cluster.js
Expand Up @@ -32,9 +32,8 @@ describe('Cluster', function() {
});

// Shutdown our server
after(function() {
s1.kill();
s2.kill();
after(function(done) {
nsc.stop_cluster([s1, s2], done);
});

it('should accept servers options', function(done) {
Expand Down Expand Up @@ -152,11 +151,15 @@ describe('Cluster', function() {
var startTime;
var numAttempts = 0;
nc.on('connect', function() {
s1.kill();
startTime = new Date();
nsc.stop_server(s1, function(){
s1 = null;
startTime = new Date();
});
});
nc.on('reconnect', function() {
s2.kill();
nsc.stop_server(s2, function(){
s2 = null;
});
});
nc.on('reconnecting', function(client) {
var elapsed = new Date() - startTime;
Expand Down
4 changes: 2 additions & 2 deletions test/connect.js
Expand Up @@ -18,8 +18,8 @@ describe('Basic Connectivity', function() {
});

// Shutdown our server after we are done
after(function() {
server.kill();
after(function(done) {
nsc.stop_server(server, done);
});


Expand Down
4 changes: 2 additions & 2 deletions test/dsub.js
Expand Up @@ -18,8 +18,8 @@ describe('Double SUBS', function() {
});

// Shutdown our server after we are done
after(function() {
server.kill();
after(function(done) {
nsc.stop_server(server, done);
});

it('should not send multiple subscriptions on startup', function(done) {
Expand Down
117 changes: 5 additions & 112 deletions test/dyncluster.js
Expand Up @@ -18,9 +18,11 @@ describe('Dynamic Cluster - Connect URLs', function() {
// this to enable per test cleanup
var servers;
// Shutdown our servers
afterEach(function() {
nsc.stop_cluster(servers);
servers = [];
afterEach(function(done) {
nsc.stop_cluster(servers, function() {
servers = [];
done();
});
});

it('adding cluster performs update', function(done) {
Expand Down Expand Up @@ -159,113 +161,4 @@ describe('Dynamic Cluster - Connect URLs', function() {
}
});
});

it('error connecting raises error and closes', function(done) {
reconnectTest(55421, 55420, true, done);
});

it('error connecting raises error and closes - non tls', function(done) {
reconnectTest(55521, 55520, false, done);
});

function reconnectTest(port, route_port, use_certs, done) {
var config = {
tls: {
cert_file: path.resolve(process.cwd(), "./test/certs/server-cert.pem"),
key_file: path.resolve(process.cwd(), "./test/certs/server-key.pem"),
ca_file: path.resolve(process.cwd(), "./test/certs/ca.pem"),
verify: false,
timeout: 2.0
},
authorization: {
user: "test",
// password is 'test'
password: "$2a$10$P6A99S9.wOT3yzNcz0OY/OBatni9Jl01AMuzRUkhXei6nOadn6R4C",
timeout: 2.0
}
};

if (!use_certs) {
delete config.tls;
}

// write two normal configs
var normal = JSON.parse(JSON.stringify(config));
var normal_conf = path.resolve(os.tmpdir(), 'normalauth_' + nuid.next() + '.conf');
ncu.writeFile(normal_conf, ncu.j(normal));

// one that has bad timeout
var short = JSON.parse(JSON.stringify(normal));

if (use_certs) {
short.tls.timeout = 0.0001;
}
short.authorization.timeout = 0.0001;
var short_conf = path.resolve(os.tmpdir(), 'shortconf_' + nuid.next() + '.conf');
ncu.writeFile(short_conf, ncu.j(short));

// start a new cluster with single server
servers = nsc.start_cluster([port], route_port, ['-c', normal_conf], function() {
process.nextTick(function() {
var others = nsc.add_member_with_delay([port + 1], route_port, 250, ['-c', short_conf], function() {
// add the second server
servers.push(others[0]);
process.nextTick(function() {
startClient();
});
});
});
});

function startClient() {
// connect the client
var opts = {
port: port,
reconnectTimeWait: 100,
maxReconnectAttempts: 2,
user: 'test',
password: 'test',
noRandomize: true,
tls: {
rejectUnauthorized: false
}
};
if (!use_certs) {
delete opts.tls;
}

var nc = NATS.connect(opts);
var connected = false;
nc.on('connect', function(c) {
if (!connected) {
// should(nc.servers.length).be.equal(2);
// now we disconnect first server
connected = true;
process.nextTick(function() {
servers[0].kill();
});
}
});

var errors = [];
nc.on('error', function(e) {
// save the error
errors.push(e);
});
nc.on('close', function() {
should.ok(connected);
// for tls the error isn't always raised so we'll just trust
// that we we tried connecting to the bad server
should.ok(errors.length === 1 || disconnects.indexOf((port + 1) + '') !== -1);
done();
});
var disconnects = [];
nc.on('disconnect', function() {
var p = nc.currentServer.url.port;
if (disconnects.indexOf(p) === -1) {
disconnects.push(p);
}
});
}
}
});
4 changes: 2 additions & 2 deletions test/errors.js
Expand Up @@ -17,8 +17,8 @@ describe('Errors', function() {
});

// Shutdown our server after we are done
after(function() {
server.kill();
after(function(done) {
nsc.stop_server(server, done);
});

it('should throw errors on connect', function(done) {
Expand Down
4 changes: 2 additions & 2 deletions test/json.js
Expand Up @@ -18,8 +18,8 @@ describe('JSON payloads', function() {
});

// Shutdown our server
after(function() {
server.kill();
after(function(done) {
nsc.stop_server(server, done);
});


Expand Down
6 changes: 3 additions & 3 deletions test/perms.js
Expand Up @@ -28,7 +28,7 @@ describe('Auth Basics', function() {
},
SUB: {
subscribe: "bar",
publish: "bar",
publish: "bar"
},
PUB: {
subscribe: "foo",
Expand Down Expand Up @@ -58,8 +58,8 @@ describe('Auth Basics', function() {
});

// Shutdown our server
after(function() {
nsc.stop_server(server);
after(function(done) {
nsc.stop_server(server, done);
});

it('bar cannot subscribe/pub foo', function(done) {
Expand Down
4 changes: 2 additions & 2 deletions test/queues.js
Expand Up @@ -17,8 +17,8 @@ describe('Queues', function() {
});

// Shutdown our server
after(function() {
server.kill();
after(function(done) {
nsc.stop_server(server, done);
});

it('should deliver a message to single member of a queue group', function(done) {
Expand Down

0 comments on commit 67046cf

Please sign in to comment.