test formatting

This commit is contained in:
Brandon Nozaki Miller 2016-01-10 02:46:09 -08:00
parent 8802aeeb0b
commit b3b99482e1
3 changed files with 171 additions and 182 deletions

View file

@ -3,9 +3,7 @@
"spec_files": [ "spec_files": [
"/support/jasmineTest/testFile.js", "/support/jasmineTest/testFile.js",
"/support/jasmineTest/Unix/unixSocketClient.spec.js", "/support/jasmineTest/TCP/tcpSocketClient.spec.js"
"/support/jasmineTest/UDP/udpSocketClient.spec.js"
] ]

View file

@ -6,214 +6,205 @@ ipc.config.id ='testClient';
ipc.config.retry = 600; ipc.config.retry = 600;
describe('TCP Socket verification of client', describe('TCP Socket verification of client',
function(){ function(){
it(
it(
'Verify retry attempts by TCP client to connect to the server as per the value set in "maxRetries" parameter.', 'Verify retry attempts by TCP client to connect to the server as per the value set in "maxRetries" parameter.',
function(done){ function(done){
let tcpRetryAttempt = 3; //variable created to count the attempt made by client to connect to the server. let tcpRetryAttempt = 3; //variable created to count the attempt made by client to connect to the server.
ipc.config.maxRetries = 3; ipc.config.maxRetries = 3;
ipc.config.stopRetrying = false; ipc.config.stopRetrying = false;
ipc.connectToNet( ipc.connectToNet(
'tcpFakeServer', 'tcpFakeServer',
8002, 8002,
function(){ function(){
ipc.of.tcpFakeServer.on( ipc.of.tcpFakeServer.on(
'disconnect', 'disconnect',
function(){ function(){
if(ipc.of.tcpFakeServer.retriesRemaining == 0){ if(ipc.of.tcpFakeServer.retriesRemaining == 0){
expect(tcpRetryAttempt).toBe(ipc.of.tcpFakeServer.retriesRemaining); expect(tcpRetryAttempt).toBe(ipc.of.tcpFakeServer.retriesRemaining);
expect(ipc.of.tcpFakeServer.socket.destroyed).toBe(true); expect(ipc.of.tcpFakeServer.socket.destroyed).toBe(true);
}else if(ipc.of.tcpFakeServer.retriesRemaining < 0){ }else if(ipc.of.tcpFakeServer.retriesRemaining < 0){
expect(tcpRetryAttempt).not.toBeLessThan(0); expect(tcpRetryAttempt).not.toBeLessThan(0);
expect(ipc.of.tcpFakeServer.retriesRemaining).not.toBeLessThan(0); expect(ipc.of.tcpFakeServer.retriesRemaining).not.toBeLessThan(0);
ipc.of.tcpFakeServer.on(
'error',
function(err){
console.log('Error is: ', err);
ipc.disconnect('tcpFakeServer');
}
);
}
tcpRetryAttempt--;
}
);
}
);
setTimeout(
function(){
ipc.disconnect('tcpFakeServer');
done();
},2500
);
}
);
it(
'Verify TCP client does not connect to the TCPserver when "stopRetrying" value is set to true.',
function(done){
let tcpRetryAttempt = 3; //variable created to count the attempt made by client to connect to the server.
ipc.config.maxRetries = 3;
ipc.config.stopRetrying = true;
ipc.config.silent=true;
ipc.connectToNet(
'tcpFakeServer',
8002,
function(){
ipc.of.tcpFakeServer.on(
'disconnect',
function(){
if(ipc.of.tcpFakeServer.retriesRemaining == 3){
expect(tcpRetryAttempt).toBe(ipc.of.tcpFakeServer.retriesRemaining);
expect(ipc.of.tcpFakeServer.socket.destroyed).toBe(true);
}
else if(ipc.of.tcpFakeServer.retriesRemaining < 3){
expect(tcpRetryAttempt).not.toBeLessThan(3);
expect(ipc.of.tcpFakeServer.retriesRemaining).not.toBeLessThan(3);
ipc.of.tcpFakeServer.on( ipc.of.tcpFakeServer.on(
'error', 'error',
function(err){ function(err){
console.log('Error is: ', err); console.log('Error is: ', err);
ipc.disconnect('tcpFakeServer'); ipc.disconnect('tcpFakeServer');
} }
); );
} }
tcpRetryAttempt--; tcpRetryAttempt--;
} }
); );
} }
); );
// Wait time is added to verify the fail case scenario of additional retry attempt by client than expected. setTimeout(
setTimeout( function(){
function(){ ipc.disconnect('tcpFakeServer');
ipc.disconnect('tcpFakeServer'); done();
done(); },700
},2500 );
); }
} );
);
it( it(
'Verify TCP client does not connect to the TCPserver when "stopRetrying" value is set to true.', 'Verify TCP client connects to server named "tcpServer" and receives message.',
function(done){ function(done){
ipc.connectToNet(
'tcpServer',
8300,
function(){
ipc.of.tcpServer.on(
'connect',
function(){
let tcpRetryAttempt = 3; //variable created to count the attempt made by client to connect to the server. ipc.of.tcpServer.emit(
ipc.config.maxRetries = 3; 'message',
ipc.config.stopRetrying = true; {
ipc.config.silent=true; id : ipc.config.id,
message : 'Hello from testClient.'
ipc.connectToNet(
'tcpFakeServer',
8002,
function(){
ipc.of.tcpFakeServer.on(
'disconnect',
function(){
if(ipc.of.tcpFakeServer.retriesRemaining == 3){
expect(tcpRetryAttempt).toBe(ipc.of.tcpFakeServer.retriesRemaining);
expect(ipc.of.tcpFakeServer.socket.destroyed).toBe(true);
}
else if(ipc.of.tcpFakeServer.retriesRemaining < 3){
expect(tcpRetryAttempt).not.toBeLessThan(3);
expect(ipc.of.tcpFakeServer.retriesRemaining).not.toBeLessThan(3);
ipc.of.tcpFakeServer.on(
'error',
function(err){
console.log('Error is: ', err);
ipc.disconnect('tcpFakeServer');
}
);
}
tcpRetryAttempt--;
} }
); );
}
);
// Wait time is added to verify the fail case scenario of additional retry attempt by client than expected.
setTimeout(
function(){
ipc.disconnect('tcpFakeServer');
done();
},700
);
}
);
it(
'Verify TCP client connects to server named "tcpServer" and receives message.',
function(done){
ipc.connectToNet(
'tcpServer',
8300,
function(){
ipc.of.tcpServer.on( ipc.of.tcpServer.on(
'connect', 'message',
function(){ function(data,socket){
ipc.of.tcpServer.emit(
'message',
{
id : ipc.config.id,
message : 'Hello from testClient.'
}
);
ipc.of.tcpServer.on(
'message',
function(data,socket){
expect(data.id).toBe('tcpServer');
expect(data.message).toBe('I am TCP server!');
ipc.disconnect('tcpServer');
done();
}
);
expect(data.id).toBe('tcpServer');
expect(data.message).toBe('I am TCP server!');
ipc.disconnect('tcpServer');
done();
} }
); );
} }
); );
} }
); );
}
it(
'Verify TCP client queues the requests being sent to the server synchronously until it receives the response from server.',
function(done){
ipc.config.sync = true;
let responseCounter = 0;
ipc.connectToNet(
'tcpServerSync',
8400,
function(){
ipc.of.tcpServerSync.on(
'connect',
function(){
for(let i=0; i<5; i++){
ipc.of.tcpServerSync.emit(
'message',
{
id : ipc.config.id,
message : 'TCP Client Request '+ i
}
);
}
ipc.of.tcpServerSync.on(
'message',
function(data){
if (data.message != null){
responseCounter++;
expect(data.message).toBe('Response from TCP server');
}
if (responseCounter == 5){
expect(responseCounter).toBe(5);
ipc.disconnect('tcpServerSync');
done();
}
}
);
ipc.of.tcpServerSync.on(
'error',
function(err){
console.log('Error is: ', err); done();
ipc.disconnect('tcpServerSync');
}
);
}
);
}
);
}
); );
it(
'Verify TCP client queues the requests being sent to the server synchronously until it receives the response from server.',
function(done){
ipc.config.sync = true;
let responseCounter = 0;
} ipc.connectToNet(
'tcpServerSync',
8400,
function(){
ipc.of.tcpServerSync.on(
'connect',
function(){
for(let i=0; i<5; i++){
ipc.of.tcpServerSync.emit(
'message',
{
id : ipc.config.id,
message : 'TCP Client Request '+ i
}
);
}
ipc.of.tcpServerSync.on(
'message',
function(data){
if (data.message != null){
responseCounter++;
expect(data.message).toBe('Response from TCP server');
}
if (responseCounter == 5){
expect(responseCounter).toBe(5);
ipc.disconnect('tcpServerSync');
done();
}
}
);
ipc.of.tcpServerSync.on(
'error',
function(err){
console.log('Error is: ', err); done();
ipc.disconnect('tcpServerSync');
}
);
}
);
}
);
}
);
}
); );

View file

@ -58,7 +58,7 @@ describe(
} }
); );
it( it(
'Verify UDP server of type udp6 connects to UDP server named "udp6Server" and receives message.', 'Verify UDP server of type udp6 connects to UDP server named "udp6Server" and receives message.',
function(done){ function(done){
ipc.config.networkPort=8099; ipc.config.networkPort=8099;