forked from yfinkelstein/node-zookeeper
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test session expiration by reusing client id and password
- Loading branch information
1 parent
08ee378
commit bce1210
Showing
2 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// test session expiration as described in zk FAQ | ||
var ZK = require('../lib/zookeeper'); | ||
var assert = require('assert'); | ||
var connect = (process.argv[2] || 'localhost:2181'); | ||
var timeout = 5000; | ||
|
||
var zk = new ZK({connect: connect, timeout: timeout, debug_level: ZK.ZOO_LOG_LEVEL_INFO, host_order_deterministic: false}); | ||
|
||
var zkClosed = false; | ||
zk.on('close', function() { zkClosed = true;} ); | ||
|
||
zk.connect(function (err) { | ||
if(err) throw err; | ||
assert.equal(zk.client_password.length, 32); | ||
|
||
var zk2 = new ZK({connect: connect, timeout: timeout, debug_level: ZK.ZOO_LOG_LEVEL_INFO, host_order_deterministic: false, | ||
client_id: zk.client_id,client_password: zk.client_password}); | ||
zk2.connect(function (err) { | ||
if(err) throw err; | ||
zk2.close(); | ||
zk.a_create ('/test_end_session', 'x', ZK.ZOO_SEQUENCE |ZK.ZOO_EPHEMERAL, function (rc, error, path) { | ||
console.log ("zk node create result: %d, error: '%s', path=%s", rc, error, path); | ||
assert(rc != 0); | ||
assert(zkClosed); | ||
}); | ||
}); | ||
}); |