mirror of https://github.com/grpc/grpc-node.git
Add granular verbosity option to xDS interop client
This commit is contained in:
parent
36db24e39f
commit
62bd1cab68
|
@ -39,6 +39,8 @@ const loadedProto = grpc.loadPackageDefinition(packageDefinition) as unknown as
|
|||
|
||||
const REQUEST_TIMEOUT_SEC = 20;
|
||||
|
||||
const VERBOSITY = Number.parseInt(process.env.NODE_XDS_INTEROP_VERBOSITY ?? '0');
|
||||
|
||||
interface CallEndNotifier {
|
||||
onCallSucceeded(peerName: string): void;
|
||||
onCallFailed(message: string): void;
|
||||
|
@ -54,7 +56,9 @@ class CallSubscriber {
|
|||
constructor(private callGoal: number, private onFinished: () => void) {}
|
||||
|
||||
addCallStarted(): void {
|
||||
console.log('Call started');
|
||||
if (VERBOSITY >= 2) {
|
||||
console.log('Call started');
|
||||
}
|
||||
this.callsStarted += 1;
|
||||
}
|
||||
|
||||
|
@ -65,7 +69,9 @@ class CallSubscriber {
|
|||
}
|
||||
|
||||
addCallSucceeded(peerName: string): void {
|
||||
console.log(`Call to ${peerName} succeeded`);
|
||||
if (VERBOSITY >= 2) {
|
||||
console.log(`Call to ${peerName} succeeded`);
|
||||
}
|
||||
if (peerName in this.callsSucceededByPeer) {
|
||||
this.callsSucceededByPeer[peerName] += 1;
|
||||
} else {
|
||||
|
@ -76,7 +82,9 @@ class CallSubscriber {
|
|||
this.maybeOnFinished();
|
||||
}
|
||||
addCallFailed(message: string): void {
|
||||
console.log(`Call failed with message ${message}`);
|
||||
if (VERBOSITY >= 2) {
|
||||
console.log(`Call failed with message ${message}`);
|
||||
}
|
||||
this.callsFinished += 1;
|
||||
this.failureMessageCount.set(message, (this.failureMessageCount.get(message) ?? 0) + 1);
|
||||
this.maybeOnFinished();
|
||||
|
@ -87,9 +95,11 @@ class CallSubscriber {
|
|||
}
|
||||
|
||||
getFinalStats(): LoadBalancerStatsResponse {
|
||||
console.log(`Out of a total of ${this.callGoal} calls requested, ${this.callsFinished} finished. ${this.callsSucceeded} succeeded`);
|
||||
for (const [message, count] of this.failureMessageCount) {
|
||||
console.log(`${count} failed with the message ${message}`);
|
||||
if (VERBOSITY >= 1) {
|
||||
console.log(`Out of a total of ${this.callGoal} calls requested, ${this.callsFinished} finished. ${this.callsSucceeded} succeeded`);
|
||||
for (const [message, count] of this.failureMessageCount) {
|
||||
console.log(`${count} failed with the message ${message}`);
|
||||
}
|
||||
}
|
||||
return {
|
||||
rpcs_by_peer: this.callsSucceededByPeer,
|
||||
|
|
Loading…
Reference in New Issue