This is an automated email from the ASF dual-hosted git repository.
xianjingfeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-uniffle.git
The following commit(s) were added to refs/heads/master by this push:
new 60e3be859 [MINOR] test: flaky test GrpcServerTest.testGrpcExecutorPool
(#1321)
60e3be859 is described below
commit 60e3be8591e2bf5b23e150f12e18821fcded1adc
Author: xianjingfeng <[email protected]>
AuthorDate: Fri Nov 17 17:00:03 2023 +0800
[MINOR] test: flaky test GrpcServerTest.testGrpcExecutorPool (#1321)
### What changes were proposed in this pull request?
fix flaky test GrpcServerTest.testGrpcExecutorPool
### Why are the changes needed?
GrpcServerTest.testGrpcExecutorPool:83 expected: <1.0> but was: <0.0>
The cause of the problem:
The metric GRPC_SERVER_EXECUTOR_BLOCKING_QUEUE_SIZE_KEY is updated only
when there is thread be executed. So if the first two threads have already
started executing, and then the third thread is submitted, this metric will not
be updated.
### Does this PR introduce any user-facing change?
No.
### How was this patch tested?
Repeat it for 100 times in my development enviroment.
---
common/src/main/java/org/apache/uniffle/common/rpc/GrpcServer.java | 7 +++++++
.../test/java/org/apache/uniffle/common/rpc/GrpcServerTest.java | 1 +
2 files changed, 8 insertions(+)
diff --git a/common/src/main/java/org/apache/uniffle/common/rpc/GrpcServer.java
b/common/src/main/java/org/apache/uniffle/common/rpc/GrpcServer.java
index 38ae7a88f..cd7f88952 100644
--- a/common/src/main/java/org/apache/uniffle/common/rpc/GrpcServer.java
+++ b/common/src/main/java/org/apache/uniffle/common/rpc/GrpcServer.java
@@ -27,6 +27,7 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists;
import com.google.common.collect.Queues;
import io.grpc.BindableService;
@@ -179,6 +180,12 @@ public class GrpcServer implements ServerInterface {
GRPCMetrics.GRPC_SERVER_EXECUTOR_BLOCKING_QUEUE_SIZE_KEY,
getQueue().size());
super.afterExecute(r, t);
}
+
+ @VisibleForTesting
+ void correctMetrics() {
+ grpcMetrics.setGauge(
+ GRPCMetrics.GRPC_SERVER_EXECUTOR_BLOCKING_QUEUE_SIZE_KEY,
getQueue().size());
+ }
}
@Override
diff --git
a/common/src/test/java/org/apache/uniffle/common/rpc/GrpcServerTest.java
b/common/src/test/java/org/apache/uniffle/common/rpc/GrpcServerTest.java
index 9b4a11e8b..63dc27a57 100644
--- a/common/src/test/java/org/apache/uniffle/common/rpc/GrpcServerTest.java
+++ b/common/src/test/java/org/apache/uniffle/common/rpc/GrpcServerTest.java
@@ -77,6 +77,7 @@ public class GrpcServerTest {
Thread.yield();
}
Thread.sleep(120);
+ executor.correctMetrics();
double activeThreads =
grpcMetrics.getGaugeMap().get(GRPC_SERVER_EXECUTOR_ACTIVE_THREADS_KEY).get();
assertEquals(2, activeThreads);