asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Till Westmann (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: [NO ISSUE] More tests for the Tracer
Date Wed, 01 Nov 2017 15:56:59 GMT
Till Westmann has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/2119

Change subject: [NO ISSUE] More tests for the Tracer
......................................................................

[NO ISSUE] More tests for the Tracer

Change-Id: I9722c87232437c9ff3497ab9d1bcbef226094e0d
---
M hyracks-fullstack/hyracks/hyracks-util/src/test/java/org/apache/hyracks/util/trace/TraceTest.java
1 file changed, 27 insertions(+), 4 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/19/2119/1

diff --git a/hyracks-fullstack/hyracks/hyracks-util/src/test/java/org/apache/hyracks/util/trace/TraceTest.java
b/hyracks-fullstack/hyracks/hyracks-util/src/test/java/org/apache/hyracks/util/trace/TraceTest.java
index 02bf41c..a6ed4c8 100644
--- a/hyracks-fullstack/hyracks/hyracks-util/src/test/java/org/apache/hyracks/util/trace/TraceTest.java
+++ b/hyracks-fullstack/hyracks/hyracks-util/src/test/java/org/apache/hyracks/util/trace/TraceTest.java
@@ -49,14 +49,29 @@
         return handler;
     }
 
-    private JsonNode validate(String line) throws IOException {
-        return mapper.readTree(line);
+    public JsonNode validate(String line) throws IOException {
+        final JsonNode traceRecord = mapper.readTree(line);
+
+        Assert.assertTrue(traceRecord.has("ph"));
+
+        Assert.assertTrue(traceRecord.has("pid"));
+        Integer.parseInt(traceRecord.get("pid").asText());
+
+        Assert.assertTrue(traceRecord.has("tid"));
+        Long.parseLong(traceRecord.get("tid").asText());
+
+        Assert.assertTrue(traceRecord.has("ts"));
+        Long.parseLong(traceRecord.get("ts").asText());
+
+        return traceRecord;
     }
 
     @Test
     public void testInstant() throws IOException {
         final ByteArrayOutputStream os = new ByteArrayOutputStream();
         final StreamHandler handler = redirectTraceLog(os);
+
+        // test with initial categories
 
         TraceCategoryRegistry registry = new TraceCategoryRegistry();
         long cat1 = registry.get("CAT1");
@@ -72,8 +87,13 @@
 
         String[] lines = os.toString().split("\n");
         for (String line : lines) {
-            Assert.assertFalse(validate(line).get("cat").equals("CAT3"));
+            final JsonNode traceRecord = validate(line);
+            Assert.assertEquals("i", traceRecord.get("ph").asText());
+            Assert.assertNotEquals("CAT3", traceRecord.get("cat").asText());
         }
+
+        // test with modified categories
+
         tracer.setCategories("CAT1", "CAT3");
         os.reset();
 
@@ -82,9 +102,12 @@
         tracer.instant("test3", cat3, ITracer.Scope.p, null);
 
         handler.flush();
+
         lines = os.toString().split("\n");
         for (String line : lines) {
-            Assert.assertFalse(validate(line).get("cat").equals("CAT2"));
+            final JsonNode traceRecord = validate(line);
+            Assert.assertEquals("i", traceRecord.get("ph").asText());
+            Assert.assertNotEquals("CAT2", validate(line).get("cat").asText());
         }
     }
 }

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/2119
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9722c87232437c9ff3497ab9d1bcbef226094e0d
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Till Westmann <tillw@apache.org>

Mime
View raw message