You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by su...@apache.org on 2022/12/09 08:56:41 UTC

[shardingsphere] branch master updated: Fix occasional test exceptions for ShardingSphereDataCollectorTest. (#22767)

This is an automated email from the ASF dual-hosted git repository.

sunnianjun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 8dc3fdc76a0 Fix occasional test exceptions for ShardingSphereDataCollectorTest. (#22767)
8dc3fdc76a0 is described below

commit 8dc3fdc76a07369319ac43ee677d416b5e56f83f
Author: Chuxin Chen <ch...@qq.com>
AuthorDate: Fri Dec 9 16:56:35 2022 +0800

    Fix occasional test exceptions for ShardingSphereDataCollectorTest. (#22767)
---
 .../core/execute/ShardingSphereDataScheduleCollector.java      |  2 +-
 .../pipeline/core/execute/ShardingSphereDataCollectorTest.java | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/execute/ShardingSphereDataScheduleCollector.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/execute/ShardingSphereDataScheduleCollector.java
index 756e499c216..d23cd9887a3 100644
--- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/execute/ShardingSphereDataScheduleCollector.java
+++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/execute/ShardingSphereDataScheduleCollector.java
@@ -65,7 +65,7 @@ public final class ShardingSphereDataScheduleCollector {
     }
     
     @RequiredArgsConstructor
-    private static final class ShardingSphereDataCollectorRunnable implements Runnable {
+    protected static final class ShardingSphereDataCollectorRunnable implements Runnable {
         
         private final ContextManager contextManager;
         
diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/execute/ShardingSphereDataCollectorTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/execute/ShardingSphereDataCollectorTest.java
index c4c0dfff998..46c89d42ace 100644
--- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/execute/ShardingSphereDataCollectorTest.java
+++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/execute/ShardingSphereDataCollectorTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.data.pipeline.core.execute;
 
+import org.apache.shardingsphere.data.pipeline.core.execute.ShardingSphereDataScheduleCollector.ShardingSphereDataCollectorRunnable;
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
 import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
 import org.apache.shardingsphere.infra.metadata.data.ShardingSphereData;
@@ -37,24 +38,23 @@ import java.util.Map;
 import java.util.Properties;
 
 import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.atLeastOnce;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 public final class ShardingSphereDataCollectorTest {
     
     @Test
-    public void assertCollect() throws InterruptedException {
+    public void assertCollect() {
         ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         ShardingSphereData shardingSphereData = mockShardingSphereData();
         when(contextManager.getMetaDataContexts().getShardingSphereData()).thenReturn(shardingSphereData);
         ShardingSphereMetaData metaData = mockMetaData();
         when(contextManager.getMetaDataContexts().getMetaData()).thenReturn(metaData);
         when(contextManager.getMetaDataContexts().getMetaData().getProps()).thenReturn(new ConfigurationProperties(new Properties()));
-        new ShardingSphereDataScheduleCollector(contextManager).start();
-        Thread.sleep(100L);
-        verify(contextManager, atLeastOnce()).getInstanceContext();
+        new ShardingSphereDataCollectorRunnable(contextManager).run();
+        verify(contextManager, times(1)).getInstanceContext();
     }
     
     private ShardingSphereData mockShardingSphereData() {