You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/09/30 02:20:08 UTC
[dubbo] branch master updated: add latch waiting for registration
finished (#8960)
This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/master by this push:
new 1cec28d add latch waiting for registration finished (#8960)
1cec28d is described below
commit 1cec28d1dc767694520e5ec322dee7862a9fd13c
Author: zrlw <zr...@sina.com>
AuthorDate: Thu Sep 30 10:19:56 2021 +0800
add latch waiting for registration finished (#8960)
---
.../registry/zookeeper/ZookeeperServiceDiscoveryTest.java | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/dubbo-registry/dubbo-registry-zookeeper/src/test/java/org/apache/dubbo/registry/zookeeper/ZookeeperServiceDiscoveryTest.java b/dubbo-registry/dubbo-registry-zookeeper/src/test/java/org/apache/dubbo/registry/zookeeper/ZookeeperServiceDiscoveryTest.java
index 3db2de4..2d6261a 100644
--- a/dubbo-registry/dubbo-registry-zookeeper/src/test/java/org/apache/dubbo/registry/zookeeper/ZookeeperServiceDiscoveryTest.java
+++ b/dubbo-registry/dubbo-registry-zookeeper/src/test/java/org/apache/dubbo/registry/zookeeper/ZookeeperServiceDiscoveryTest.java
@@ -80,12 +80,25 @@ public class ZookeeperServiceDiscoveryTest {
}
@Test
- public void testRegistration() {
+ public void testRegistration() throws InterruptedException {
DefaultServiceInstance serviceInstance = createServiceInstance(SERVICE_NAME, LOCALHOST, NetUtils.getAvailablePort());
+ CountDownLatch latch = new CountDownLatch(1);
+
+ // Add Listener
+ discovery.addServiceInstancesChangedListener(
+ new ServiceInstancesChangedListener(Sets.newSet(SERVICE_NAME), discovery) {
+ @Override
+ public void onEvent(ServiceInstancesChangedEvent event) {
+ latch.countDown();
+ }
+ });
+
discovery.register(serviceInstance);
+ latch.await();
+
List<ServiceInstance> serviceInstances = discovery.getInstances(SERVICE_NAME);
assertTrue(serviceInstances.contains(serviceInstance));