You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2020/03/21 10:16:55 UTC
[servicecomb-java-chassis] branch master updated: [SCB-1779]add
some logs to help find random fail ut to find reasons
This is an automated email from the ASF dual-hosted git repository.
liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git
The following commit(s) were added to refs/heads/master by this push:
new 93d2e61 [SCB-1779]add some logs to help find random fail ut to find reasons
93d2e61 is described below
commit 93d2e61c66ab3db4a18cb40b6c9d538ba0210755
Author: liubao68 <bi...@qq.com>
AuthorDate: Sat Mar 21 16:58:04 2020 +0800
[SCB-1779]add some logs to help find random fail ut to find reasons
---
.../instance/TestInstanceCacheChecker.java | 88 +++++++++++++---------
1 file changed, 54 insertions(+), 34 deletions(-)
diff --git a/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/diagnosis/instance/TestInstanceCacheChecker.java b/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/diagnosis/instance/TestInstanceCacheChecker.java
index 92903ee..01d7cca 100644
--- a/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/diagnosis/instance/TestInstanceCacheChecker.java
+++ b/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/diagnosis/instance/TestInstanceCacheChecker.java
@@ -16,8 +16,10 @@
*/
package org.apache.servicecomb.serviceregistry.diagnosis.instance;
-import java.util.ArrayList;
-import java.util.Arrays;
+import io.vertx.core.json.Json;
+import mockit.Deencapsulation;
+import mockit.Mock;
+import mockit.MockUp;
import org.apache.servicecomb.foundation.common.Holder;
import org.apache.servicecomb.foundation.common.testing.MockClock;
@@ -37,13 +39,16 @@ import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-import io.vertx.core.json.Json;
-import mockit.Deencapsulation;
-import mockit.Mock;
-import mockit.MockUp;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
public class TestInstanceCacheChecker {
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestInstanceCacheChecker.class);
+
AppManager originalAppManager = RegistryUtils.getAppManager();
ServiceRegistry serviceRegistry = ServiceRegistryFactory.createLocal();
@@ -84,10 +89,15 @@ public class TestInstanceCacheChecker {
@Test
public void check_microserviceManager_empty() {
- appId = "notExist";
- RegistryUtils.getAppManager().getOrCreateMicroserviceVersions(appId, microserviceName);
- InstanceCacheSummary instanceCacheSummary = checker.check();
- Assert.assertEquals(Json.encode(expectedSummary), Json.encode(instanceCacheSummary));
+ try {
+ appId = "notExist";
+ RegistryUtils.getAppManager().getOrCreateMicroserviceVersions(appId, microserviceName);
+ InstanceCacheSummary instanceCacheSummary = checker.check();
+ Assert.assertEquals(Json.encode(expectedSummary), Json.encode(instanceCacheSummary));
+ } catch (Exception e) {
+ LOGGER.error("", e);
+ Assert.fail();
+ }
}
protected Holder<MicroserviceInstances> createFindServiceInstancesResult() {
@@ -130,18 +140,23 @@ public class TestInstanceCacheChecker {
.getOrCreateMicroserviceVersionRule(appId, microserviceName, DefinitionConst.VERSION_RULE_ALL);
findHolder.value = null;
- InstanceCacheSummary instanceCacheSummary = checker.check();
-
- InstanceCacheResult instanceCacheResult = new InstanceCacheResult();
- instanceCacheResult.setAppId(appId);
- instanceCacheResult.setMicroserviceName(microserviceName);
- instanceCacheResult.setStatus(Status.UNKNOWN);
- instanceCacheResult.setDetail("failed to find instances from service center");
- instanceCacheResult.setPulledInstances(new ArrayList<>());
- expectedSummary.getProducers().add(instanceCacheResult);
- expectedSummary.setStatus(Status.UNKNOWN);
-
- Assert.assertEquals(Json.encode(expectedSummary), Json.encode(instanceCacheSummary));
+ try {
+ InstanceCacheSummary instanceCacheSummary = checker.check();
+
+ InstanceCacheResult instanceCacheResult = new InstanceCacheResult();
+ instanceCacheResult.setAppId(appId);
+ instanceCacheResult.setMicroserviceName(microserviceName);
+ instanceCacheResult.setStatus(Status.UNKNOWN);
+ instanceCacheResult.setDetail("failed to find instances from service center");
+ instanceCacheResult.setPulledInstances(new ArrayList<>());
+ expectedSummary.getProducers().add(instanceCacheResult);
+ expectedSummary.setStatus(Status.UNKNOWN);
+
+ Assert.assertEquals(Json.encode(expectedSummary), Json.encode(instanceCacheSummary));
+ } catch (Exception e) {
+ LOGGER.error("", e);
+ Assert.fail();
+ }
}
@Test
@@ -162,18 +177,23 @@ public class TestInstanceCacheChecker {
.getOrCreateMicroserviceVersionRule(appId, microserviceName, DefinitionConst.VERSION_RULE_ALL);
findHolder.value.setMicroserviceNotExist(true);
- InstanceCacheSummary instanceCacheSummary = checker.check();
-
- InstanceCacheResult instanceCacheResult = new InstanceCacheResult();
- instanceCacheResult.setAppId(appId);
- instanceCacheResult.setMicroserviceName(microserviceName);
- instanceCacheResult.setStatus(Status.UNKNOWN);
- instanceCacheResult.setDetail("microservice is not exist anymore, will be deleted from memory in next pull");
- instanceCacheResult.setPulledInstances(new ArrayList<>());
- expectedSummary.getProducers().add(instanceCacheResult);
- expectedSummary.setStatus(Status.UNKNOWN);
-
- Assert.assertEquals(Json.encode(expectedSummary), Json.encode(instanceCacheSummary));
+ try {
+ InstanceCacheSummary instanceCacheSummary = checker.check();
+
+ InstanceCacheResult instanceCacheResult = new InstanceCacheResult();
+ instanceCacheResult.setAppId(appId);
+ instanceCacheResult.setMicroserviceName(microserviceName);
+ instanceCacheResult.setStatus(Status.UNKNOWN);
+ instanceCacheResult.setDetail("microservice is not exist anymore, will be deleted from memory in next pull");
+ instanceCacheResult.setPulledInstances(new ArrayList<>());
+ expectedSummary.getProducers().add(instanceCacheResult);
+ expectedSummary.setStatus(Status.UNKNOWN);
+
+ Assert.assertEquals(Json.encode(expectedSummary), Json.encode(instanceCacheSummary));
+ } catch (Exception e) {
+ LOGGER.error("", e);
+ Assert.fail();
+ }
}
@Test