fixed test issues with expectedClientID and added fail tests for registration with correct id
This commit is contained in:
parent
a29f414540
commit
0e3793c805
4 changed files with 169 additions and 11 deletions
|
@ -1,10 +1,11 @@
|
|||
var ipc=require('../../../node-ipc'),
|
||||
expectedClient=ipc.config.id+'-client';
|
||||
var ipc=require('../../../node-ipc');
|
||||
|
||||
ipc.config.id = __dirname.split('/');
|
||||
ipc.config.id = ipc.config.id[ipc.config.id.length-1]
|
||||
ipc.config.maxRetries=1;
|
||||
|
||||
expectedClient=ipc.config.id+'-client';
|
||||
|
||||
ipc.connectTo(
|
||||
'testHarness',
|
||||
function(){
|
||||
|
@ -51,7 +52,7 @@ ipc.server.on(
|
|||
}else{
|
||||
ipc.of.testHarness.emit(
|
||||
'fail',
|
||||
test+' : detected wrong id of '+id
|
||||
test+' : detected wrong id of '+socket.id+' expecting :: '+expectedClient
|
||||
);
|
||||
}
|
||||
ipc.of.testHarness.emit(
|
||||
|
@ -70,10 +71,17 @@ ipc.server.on(
|
|||
'tcp-client-message'
|
||||
);
|
||||
|
||||
var test='tcp-client-registered with proper id'
|
||||
|
||||
if(socket.id==expectedClient){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
'tcp-client-registered with proper id'
|
||||
test
|
||||
);
|
||||
}else{
|
||||
ipc.of.testHarness.emit(
|
||||
'fail',
|
||||
test+' : detected wrong id of '+id+' expecting :: '+expectedClient
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
36
testHarness/tests/udp-socket-test/client.js
Normal file
36
testHarness/tests/udp-socket-test/client.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
var ipc=require('../../../node-ipc'),
|
||||
server=__dirname.split('/'),
|
||||
server=server[server.length-1]
|
||||
|
||||
ipc.config.id = server+'-client';
|
||||
|
||||
ipc.serveNet(
|
||||
8002, // tcp test uses default of 8000 udp server.js using 8001 increment to ensure no collision
|
||||
'udp4',
|
||||
function(){
|
||||
setTimeout( //wait to ensure UDP server.js running
|
||||
function(){
|
||||
ipc.server.emit(
|
||||
{
|
||||
address : 'localhost',
|
||||
port : 8001
|
||||
},
|
||||
'test-test',
|
||||
{
|
||||
id : ipc.config.id
|
||||
}
|
||||
);
|
||||
|
||||
setTimeout( //wait to ensure test-test event sent
|
||||
function(){
|
||||
process.exit(0);
|
||||
},
|
||||
400
|
||||
);
|
||||
},
|
||||
400
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.start();
|
101
testHarness/tests/udp-socket-test/server.js
Normal file
101
testHarness/tests/udp-socket-test/server.js
Normal file
|
@ -0,0 +1,101 @@
|
|||
var ipc=require('../../../node-ipc');
|
||||
|
||||
ipc.config.id = __dirname.split('/');
|
||||
ipc.config.id = ipc.config.id[ipc.config.id.length-1]
|
||||
ipc.config.maxRetries=1;
|
||||
|
||||
var expectedClient=ipc.config.id+'-client'
|
||||
|
||||
ipc.connectTo(
|
||||
'testHarness',
|
||||
function(){
|
||||
ipc.of.testHarness.on(
|
||||
'connect',
|
||||
function(){
|
||||
ipc.of.testHarness.emit(
|
||||
'start.test',
|
||||
{
|
||||
id : ipc.config.id,
|
||||
duration: 1200
|
||||
}
|
||||
);
|
||||
|
||||
ipc.serveNet(
|
||||
8001, // tcp test uses default of 8000 increment to ensure no collision
|
||||
'udp4',
|
||||
function(){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
'udp-server-started'
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.on(
|
||||
'test-test',
|
||||
function(data,socket){
|
||||
var event={
|
||||
id : 'udp-client-id',
|
||||
address : 'udp-client-address',
|
||||
port : 'udp-client-port'
|
||||
}
|
||||
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
'udp-client-message'
|
||||
);
|
||||
|
||||
if(socket.id==expectedClient){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
event.id
|
||||
);
|
||||
}else{
|
||||
ipc.of.testHarness.emit(
|
||||
'fail',
|
||||
event.id+' : detected wrong id of '+socket.id+' expecting :: '+expectedClient
|
||||
);
|
||||
}
|
||||
|
||||
if(socket.address=='127.0.0.1'){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
event.address
|
||||
);
|
||||
}else{
|
||||
ipc.of.testHarness.emit(
|
||||
'fail',
|
||||
event.port
|
||||
);
|
||||
}
|
||||
|
||||
if(socket.port==8002){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
event.port
|
||||
);
|
||||
}else{
|
||||
ipc.of.testHarness.emit(
|
||||
'fail',
|
||||
event.port
|
||||
);
|
||||
}
|
||||
|
||||
ipc.of.testHarness.emit(
|
||||
'end.test'
|
||||
);
|
||||
|
||||
setTimeout( //wait to ensure events sent to testHarness
|
||||
function(){
|
||||
process.exit(0);
|
||||
},
|
||||
400
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.start();
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
|
@ -1,10 +1,11 @@
|
|||
var ipc = require('../../../node-ipc'),
|
||||
expectedClient=ipc.config.id+'-client';
|
||||
var ipc = require('../../../node-ipc');
|
||||
|
||||
ipc.config.id = __dirname.split('/');
|
||||
ipc.config.id = ipc.config.id[ipc.config.id.length-1]
|
||||
ipc.config.maxRetries=1;
|
||||
|
||||
var expectedClient=ipc.config.id+'-client';
|
||||
|
||||
ipc.connectTo(
|
||||
'testHarness',
|
||||
function(){
|
||||
|
@ -15,7 +16,7 @@ ipc.connectTo(
|
|||
'start.test',
|
||||
{
|
||||
id : ipc.config.id,
|
||||
duration: 1200
|
||||
duration: 1400
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -43,7 +44,7 @@ ipc.server.on(
|
|||
'socket.disconnected',
|
||||
function(socket,id){
|
||||
var test='unix-server-detected-correct-id-disconnection';
|
||||
if(id==ipc.config.id+'-client'){
|
||||
if(id==expectedClient){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
test
|
||||
|
@ -51,14 +52,19 @@ ipc.server.on(
|
|||
}else{
|
||||
ipc.of.testHarness.emit(
|
||||
'fail',
|
||||
test+' : detected wrong id of '+id
|
||||
test+' : detected wrong id of '+id+' expecting :: '+expectedClient
|
||||
);
|
||||
}
|
||||
ipc.of.testHarness.emit(
|
||||
'end.test'
|
||||
);
|
||||
|
||||
process.exit(0);
|
||||
setTimeout(
|
||||
function(){
|
||||
process.exit(0);
|
||||
},
|
||||
400
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -70,10 +76,17 @@ ipc.server.on(
|
|||
'unix-client-message'
|
||||
);
|
||||
|
||||
var test='unix-client-registered with proper id'
|
||||
|
||||
if(socket.id==expectedClient){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
'unix-client-registered with proper id'
|
||||
test
|
||||
);
|
||||
}else{
|
||||
ipc.of.testHarness.emit(
|
||||
'fail',
|
||||
test+' : detected wrong id of '+socket.id+' expecting :: '+expectedClient
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue