Skip to content

Commit a69b884

Browse files
author
Dongming
committed
[FAB-4433] PTE supports more accurate constant rate
[FAB-4449] add catch error in eventRegister Change-Id: I61c3bbab4f8590f6976e179746ea48b06b30da86 Signed-off-by: Dongming <[email protected]>
1 parent 936c734 commit a69b884

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

test/tools/PTE/pte-execRequest.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ var tLocal;
6060
var i = 0;
6161
var inv_m = 0; // counter of invoke move
6262
var inv_q = 0; // counter of invoke query
63+
var evtTimeout = 0; // counter of event timeout
6364
var IDone=0;
6465
var QDone=0;
6566
var recHist;
@@ -644,12 +645,12 @@ function eventRegister(tx, cb) {
644645
evtRcv++;
645646

646647
if (code !== 'VALID') {
647-
console.log('[Nid:id:chan:org=%d:%d:%s%s eventRegister] The invoke transaction was invalid, code = ', Nid, pid, channelName, org, code);
648+
console.log('[Nid:id:chan:org=%d:%d:%s:%s eventRegister] The invoke transaction was invalid, code = ', Nid, pid, channelName, org, code);
648649
reject();
649650
} else {
650651
if ( ( IDone == 1 ) && ( inv_m == evtRcv ) ) {
651652
tCurr = new Date().getTime();
652-
console.log('[Nid:id:chan:org=%d:%d:%s%s eventRegister] completed %d(%d) %s(%s) in %d ms, timestamp: start %d end %d', Nid, pid, channelName, org, evtRcv, inv_m, transType, invokeType, tCurr-tLocal, tLocal, tCurr);
653+
console.log('[Nid:id:chan:org=%d:%d:%s:%s eventRegister] completed Rcvd(sent)=%d(%d) %s(%s) in %d ms, timestamp: start %d end %d, #event timeout: %d', Nid, pid, channelName, org, evtRcv, inv_m, transType, invokeType, tCurr-tLocal, tLocal, tCurr, evtTimeout);
653654
if (invokeCheck.toUpperCase() == 'TRUE') {
654655
arg0 = keyStart + inv_m - 1;
655656
inv_q = inv_m - 1;
@@ -660,6 +661,9 @@ function eventRegister(tx, cb) {
660661
}
661662
}
662663
});
664+
}).catch((err) => {
665+
evtTimeout++;
666+
//console.log('[Nid:id:chan:org=%d:%d:%s:%s eventRegister] number of events timeout=%d %s(%s) in %d ms, timestamp: start %d end %d', Nid, pid, channelName, org, evtTimeout, transType, invokeType, tCurr-tLocal, tLocal, tCurr);
663667
});
664668

665669
eventPromises.push(txPromise);
@@ -695,12 +699,12 @@ function eventRegister_latency(tx, cb) {
695699
eh.unregisterTxEvent(deployId);
696700

697701
if (code !== 'VALID') {
698-
console.log('[Nid:id:chan:org=%d:%d:%s%s eventRegister_latency] The invoke transaction was invalid, code = ', Nid, pid, channelName, org, code);
702+
console.log('[Nid:id:chan:org=%d:%d:%s:%s eventRegister_latency] The invoke transaction was invalid, code = ', Nid, pid, channelName, org, code);
699703
reject();
700704
} else {
701705
if ( ( IDone == 1 ) && ( inv_m == evtRcv ) ) {
702706
tCurr = new Date().getTime();
703-
console.log('[Nid:id:chan:org=%d:%d:%s%s eventRegister_latency] completed %d %s(%s) in %d ms, timestamp: start %d end %d', Nid, pid, channelName, org, inv_m, transType, invokeType, tCurr-tLocal, tLocal, tCurr);
707+
console.log('[Nid:id:chan:org=%d:%d:%s:%s eventRegister_latency] completed %d %s(%s) in %d ms, timestamp: start %d end %d', Nid, pid, channelName, org, inv_m, transType, invokeType, tCurr-tLocal, tLocal, tCurr);
704708
if (invokeCheck.toUpperCase() == 'TRUE') {
705709
arg0 = keyStart + inv_m - 1;
706710
inv_q = inv_m - 1;
@@ -923,6 +927,7 @@ function getRandomNum(min0, max0) {
923927
function invoke_move_const(freq) {
924928
inv_m++;
925929

930+
var t1 = new Date().getTime();
926931
getMoveRequest();
927932

928933
chain.sendTransactionProposal(request_invoke)
@@ -956,9 +961,11 @@ function invoke_move_const(freq) {
956961
if ( devFreq > 0 ) {
957962
freq_n=getRandomNum(freq-devFreq, freq+devFreq);
958963
}
964+
tCurr = new Date().getTime();
965+
t1 = tCurr - t1;
959966
setTimeout(function(){
960967
invoke_move_const(freq);
961-
},freq_n);
968+
},freq_n-t1);
962969
} else {
963970
tCurr = new Date().getTime();
964971
console.log('[Nid:id:chan:org=%d:%d:%s:%s invoke_move_const] completed %d %s(%s) in %d ms, timestamp: start %d end %d', Nid, pid, channelName, org, inv_m, transType, invokeType, tCurr-tLocal, tLocal, tCurr);

0 commit comments

Comments
 (0)