servicecomb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] zhengyangyong commented on a change in pull request #562: [SCB-358] fix bug for monitor output id that register only name without any tags
Date Thu, 01 Mar 2018 00:04:31 GMT
zhengyangyong commented on a change in pull request #562: [SCB-358] fix bug for monitor output
id that register only name without any tags
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/562#discussion_r171427043
 
 

 ##########
 File path: metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestHealthCheckerPublisher.java
 ##########
 @@ -24,46 +24,61 @@
 import org.apache.servicecomb.foundation.metrics.health.HealthCheckerManager;
 import org.apache.servicecomb.metrics.core.publish.HealthCheckerPublisher;
 import org.junit.Assert;
-import org.junit.BeforeClass;
 import org.junit.Test;
 
 public class TestHealthCheckerPublisher {
+  private HealthChecker good = new HealthChecker() {
+    @Override
+    public String getName() {
+      return "test";
+    }
 
-  @BeforeClass
-  public static void setup() {
-    HealthCheckerManager.getInstance().register(new HealthChecker() {
-      @Override
-      public String getName() {
-        return "test";
-      }
+    @Override
+    public HealthCheckResult check() {
+      return new HealthCheckResult(true, "info", "extra data");
+    }
+  };
 
-      @Override
-      public HealthCheckResult check() {
-        return new HealthCheckResult(true, "info", "extra data");
-      }
-    });
+  private HealthChecker bad = new HealthChecker() {
+    @Override
+    public String getName() {
+      return "test2";
+    }
 
-    HealthCheckerManager.getInstance().register(new HealthChecker() {
-      @Override
-      public String getName() {
-        return "test2";
-      }
+    @Override
+    public HealthCheckResult check() {
+      return new HealthCheckResult(false, "info2", "extra data 2");
+    }
+  };
 
-      @Override
-      public HealthCheckResult check() {
-        return new HealthCheckResult(false, "info2", "extra data 2");
-      }
-    });
+
+  private void reset() {
+    HealthCheckerManager.getInstance().unregister(good.getName());
+    HealthCheckerManager.getInstance().unregister(bad.getName());
+  }
+
+  @Test
+  public void checkHealthGood() {
+    reset();
+    HealthCheckerManager.getInstance().register(good);
+    HealthCheckerPublisher publisher = new HealthCheckerPublisher();
+    Assert.assertEquals(true, publisher.checkHealth());
   }
 
   @Test
-  public void checkHealth() {
+  public void checkHealthBad() {
+    reset();
 
 Review comment:
   Done

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message