You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ja...@apache.org on 2014/08/09 02:17:44 UTC

[1/2] git commit: PHOENIX-1155 Rename tracing test classes for consistency

Repository: phoenix
Updated Branches:
  refs/heads/master bf26ef233 -> 50e16f88d


PHOENIX-1155 Rename tracing test classes for consistency


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/4b45e90c
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/4b45e90c
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/4b45e90c

Branch: refs/heads/master
Commit: 4b45e90c820046eee06da25d55bab9d4843f602f
Parents: 0154216
Author: James Taylor <jt...@salesforce.com>
Authored: Fri Aug 8 17:20:52 2014 -0700
Committer: James Taylor <jt...@salesforce.com>
Committed: Fri Aug 8 17:20:52 2014 -0700

----------------------------------------------------------------------
 .../trace/Hadoop1TracingTestEnabler.java        |   2 -
 .../phoenix/trace/PhoenixTraceReaderIT.java     | 184 +++++++++++++++++++
 .../phoenix/trace/PhoenixTracingEndToEndIT.java |   7 +
 .../apache/phoenix/trace/TraceReaderTest.java   | 181 ------------------
 4 files changed, 191 insertions(+), 183 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/4b45e90c/phoenix-core/src/it/java/org/apache/phoenix/trace/Hadoop1TracingTestEnabler.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/trace/Hadoop1TracingTestEnabler.java b/phoenix-core/src/it/java/org/apache/phoenix/trace/Hadoop1TracingTestEnabler.java
index 07e2305..9a592d3 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/trace/Hadoop1TracingTestEnabler.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/trace/Hadoop1TracingTestEnabler.java
@@ -22,8 +22,6 @@ import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.junit.runner.notification.RunNotifier;
 import org.junit.runners.BlockJUnit4ClassRunner;
 import org.junit.runners.model.FrameworkMethod;

http://git-wip-us.apache.org/repos/asf/phoenix/blob/4b45e90c/phoenix-core/src/it/java/org/apache/phoenix/trace/PhoenixTraceReaderIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/trace/PhoenixTraceReaderIT.java b/phoenix-core/src/it/java/org/apache/phoenix/trace/PhoenixTraceReaderIT.java
new file mode 100644
index 0000000..f0a47bb
--- /dev/null
+++ b/phoenix-core/src/it/java/org/apache/phoenix/trace/PhoenixTraceReaderIT.java
@@ -0,0 +1,184 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.trace;
+
+import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.phoenix.end2end.HBaseManagedTimeTest;
+import org.apache.phoenix.metrics.MetricInfo;
+import org.apache.phoenix.metrics.PhoenixAbstractMetric;
+import org.apache.phoenix.metrics.PhoenixMetricTag;
+import org.apache.phoenix.metrics.PhoenixMetricsRecord;
+import org.apache.phoenix.trace.Hadoop1TracingTestEnabler.Hadoop1Disabled;
+import org.apache.phoenix.trace.TraceReader.SpanInfo;
+import org.apache.phoenix.trace.TraceReader.TraceHolder;
+import org.cloudera.htrace.Span;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+/**
+ * Test that the {@link TraceReader} will correctly read traces written by the
+ * {@link PhoenixTableMetricsWriter}
+ */
+@RunWith(Hadoop1TracingTestEnabler.class)
+@Hadoop1Disabled("tracing")
+@Category(HBaseManagedTimeTest.class)
+public class PhoenixTraceReaderIT extends BaseTracingTestIT {
+
+    private static final Log LOG = LogFactory.getLog(PhoenixTraceReaderIT.class);
+
+    @Test
+    public void singleSpan() throws Exception {
+        PhoenixTableMetricsWriter sink = new PhoenixTableMetricsWriter();
+        Properties props = new Properties(TEST_PROPERTIES);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
+        sink.initForTesting(conn);
+
+        // create a simple metrics record
+        long traceid = 987654;
+        PhoenixMetricsRecord record =
+                createAndFlush(sink, traceid, Span.ROOT_SPAN_ID, 10, "root", 12, 13,
+                    "host-name.value", "test annotation for a span");
+
+        // start a reader
+        validateTraces(Collections.singletonList(record), conn, traceid);
+    }
+
+    private PhoenixMetricsRecord createAndFlush(PhoenixTableMetricsWriter sink, long traceid,
+            long parentid, long spanid, String desc, long startTime, long endTime, String hostname,
+            String... tags) {
+        PhoenixMetricsRecord record =
+                createRecord(traceid, parentid, spanid, desc, startTime, endTime, hostname, tags);
+        sink.addMetrics(record);
+        sink.flush();
+        return record;
+    }
+
+    /**
+     * Test multiple spans, within the same trace. Some spans are independent of the parent span,
+     * some are child spans
+     * @throws Exception on failure
+     */
+    @Test
+    public void testMultipleSpans() throws Exception {
+        // hook up a phoenix sink
+        PhoenixTableMetricsWriter sink = new PhoenixTableMetricsWriter();
+        Connection conn = getConnectionWithoutTracing();
+        sink.initForTesting(conn);
+
+        // create a simple metrics record
+        long traceid = 12345;
+        List<PhoenixMetricsRecord> records = new ArrayList<PhoenixMetricsRecord>();
+        PhoenixMetricsRecord record =
+                createAndFlush(sink, traceid, Span.ROOT_SPAN_ID, 7777, "root", 10, 30,
+                    "hostname.value", "root-span tag");
+        records.add(record);
+
+        // then create a child record
+        record =
+                createAndFlush(sink, traceid, 7777, 6666, "c1", 11, 15, "hostname.value",
+                    "first child");
+        records.add(record);
+
+        // create a different child
+        record =
+                createAndFlush(sink, traceid, 7777, 5555, "c2", 11, 18, "hostname.value",
+                    "second child");
+        records.add(record);
+
+        // create a child of the second child
+        record =
+                createAndFlush(sink, traceid, 5555, 4444, "c3", 12, 16, "hostname.value",
+                    "third child");
+        records.add(record);
+
+        // flush all the values to the table
+        sink.flush();
+
+        // start a reader
+        validateTraces(records, conn, traceid);
+    }
+
+    private void validateTraces(List<PhoenixMetricsRecord> records, Connection conn, long traceid)
+            throws Exception {
+        TraceReader reader = new TraceReader(conn);
+        Collection<TraceHolder> traces = reader.readAll(1);
+        assertEquals("Got an unexpected number of traces!", 1, traces.size());
+        // make sure the trace matches what we wrote
+        TraceHolder trace = traces.iterator().next();
+        assertEquals("Got an unexpected traceid", traceid, trace.traceid);
+        assertEquals("Got an unexpected number of spans", records.size(), trace.spans.size());
+
+        validateTrace(records, trace);
+    }
+
+    /**
+     * @param records
+     * @param trace
+     */
+    private void validateTrace(List<PhoenixMetricsRecord> records, TraceHolder trace) {
+        // drop each span into a sorted list so we get the expected ordering
+        Iterator<SpanInfo> spanIter = trace.spans.iterator();
+        for (PhoenixMetricsRecord record : records) {
+            SpanInfo spanInfo = spanIter.next();
+            LOG.info("Checking span:\n" + spanInfo);
+            Iterator<PhoenixAbstractMetric> metricIter = record.metrics().iterator();
+            assertEquals("Got an unexpected span id", metricIter.next().value(), spanInfo.id);
+            long parentId = (Long) metricIter.next().value();
+            if (parentId == Span.ROOT_SPAN_ID) {
+                assertNull("Got a parent, but it was a root span!", spanInfo.parent);
+            } else {
+                assertEquals("Got an unexpected parent span id", parentId, spanInfo.parent.id);
+            }
+            assertEquals("Got an unexpected start time", metricIter.next().value(), spanInfo.start);
+            assertEquals("Got an unexpected end time", metricIter.next().value(), spanInfo.end);
+
+            Iterator<PhoenixMetricTag> tags = record.tags().iterator();
+
+            int annotationCount = 0;
+            while (tags.hasNext()) {
+                // hostname is a tag, so we differentiate it
+                PhoenixMetricTag tag = tags.next();
+                if (tag.name().equals(MetricInfo.HOSTNAME.traceName)) {
+                    assertEquals("Didn't store correct hostname value", tag.value(),
+                        spanInfo.hostname);
+                } else {
+                    int count = annotationCount++;
+                    assertEquals("Didn't get expected annotation", count + " - " + tag.value(),
+                        spanInfo.annotations.get(count));
+                }
+            }
+            assertEquals("Didn't get expected number of annotations", annotationCount,
+                spanInfo.annotationCount);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/phoenix/blob/4b45e90c/phoenix-core/src/it/java/org/apache/phoenix/trace/PhoenixTracingEndToEndIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/trace/PhoenixTracingEndToEndIT.java b/phoenix-core/src/it/java/org/apache/phoenix/trace/PhoenixTracingEndToEndIT.java
index 955d640..0fe4538 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/trace/PhoenixTracingEndToEndIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/trace/PhoenixTracingEndToEndIT.java
@@ -31,6 +31,7 @@ import java.util.concurrent.TimeUnit;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.phoenix.coprocessor.BaseScannerRegionObserver;
+import org.apache.phoenix.end2end.HBaseManagedTimeTest;
 import org.apache.phoenix.metrics.Metrics;
 import org.apache.phoenix.metrics.TracingTestCompat;
 import org.apache.phoenix.trace.Hadoop1TracingTestEnabler.Hadoop1Disabled;
@@ -44,6 +45,7 @@ import org.cloudera.htrace.TraceScope;
 import org.junit.After;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
 import org.junit.runner.RunWith;
 
 /**
@@ -51,6 +53,7 @@ import org.junit.runner.RunWith;
  */
 @RunWith(Hadoop1TracingTestEnabler.class)
 @Hadoop1Disabled("tracing")
+@Category(HBaseManagedTimeTest.class)
 public class PhoenixTracingEndToEndIT extends BaseTracingTestIT {
 
     private static final Log LOG = LogFactory.getLog(PhoenixTracingEndToEndIT.class);
@@ -138,6 +141,7 @@ public class PhoenixTracingEndToEndIT extends BaseTracingTestIT {
         // look for the writes to make sure they were made
         Connection conn = getConnectionWithoutTracing();
         checkStoredTraces(conn, new TraceChecker() {
+            @Override
             public boolean foundTrace(TraceHolder trace, SpanInfo info) {
                 if (info.description.equals("child 1")) {
                     assertEquals("Not all annotations present", 1, info.annotationCount);
@@ -215,6 +219,7 @@ public class PhoenixTracingEndToEndIT extends BaseTracingTestIT {
          * where '*' is a generically named thread (e.g phoenix-1-thread-X)
          */
         boolean indexingCompleted = checkStoredTraces(conn, new TraceChecker() {
+            @Override
             public boolean foundTrace(TraceHolder trace, SpanInfo span) {
                 String traceInfo = trace.toString();
                 // skip logging traces that are just traces about tracing
@@ -339,6 +344,7 @@ public class PhoenixTracingEndToEndIT extends BaseTracingTestIT {
         assertTrue("Get expected updates to trace table", updated.await(200, TimeUnit.SECONDS));
         // don't trace reads either
         boolean found = checkStoredTraces(conn, new TraceChecker() {
+            @Override
             public boolean foundTrace(TraceHolder trace) {
                 String traceInfo = trace.toString();
                 return traceInfo.contains(BaseScannerRegionObserver.SCANNER_OPENED_TRACE_INFO);
@@ -386,6 +392,7 @@ public class PhoenixTracingEndToEndIT extends BaseTracingTestIT {
     private static class CountDownConnection extends DelegatingConnection {
         private CountDownLatch commit;
 
+        @SuppressWarnings("unchecked")
         public CountDownConnection(Connection conn, CountDownLatch commit) {
             super(conn);
             this.commit = commit;

http://git-wip-us.apache.org/repos/asf/phoenix/blob/4b45e90c/phoenix-core/src/it/java/org/apache/phoenix/trace/TraceReaderTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/trace/TraceReaderTest.java b/phoenix-core/src/it/java/org/apache/phoenix/trace/TraceReaderTest.java
deleted file mode 100644
index 5ea677e..0000000
--- a/phoenix-core/src/it/java/org/apache/phoenix/trace/TraceReaderTest.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.phoenix.trace;
-
-import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.phoenix.metrics.MetricInfo;
-import org.apache.phoenix.metrics.PhoenixAbstractMetric;
-import org.apache.phoenix.metrics.PhoenixMetricTag;
-import org.apache.phoenix.metrics.PhoenixMetricsRecord;
-import org.apache.phoenix.trace.Hadoop1TracingTestEnabler.Hadoop1Disabled;
-import org.apache.phoenix.trace.TraceReader.SpanInfo;
-import org.apache.phoenix.trace.TraceReader.TraceHolder;
-import org.cloudera.htrace.Span;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Test that the {@link TraceReader} will correctly read traces written by the
- * {@link PhoenixTableMetricsWriter}
- */
-@RunWith(Hadoop1TracingTestEnabler.class)
-@Hadoop1Disabled("tracing")
-public class TraceReaderTest extends BaseTracingTestIT {
-
-    private static final Log LOG = LogFactory.getLog(TraceReaderTest.class);
-
-    @Test
-    public void singleSpan() throws Exception {
-        PhoenixTableMetricsWriter sink = new PhoenixTableMetricsWriter();
-        Properties props = new Properties(TEST_PROPERTIES);
-        Connection conn = DriverManager.getConnection(getUrl(), props);
-        sink.initForTesting(conn);
-
-        // create a simple metrics record
-        long traceid = 987654;
-        PhoenixMetricsRecord record =
-                createAndFlush(sink, traceid, Span.ROOT_SPAN_ID, 10, "root", 12, 13,
-                    "host-name.value", "test annotation for a span");
-
-        // start a reader
-        validateTraces(Collections.singletonList(record), conn, traceid);
-    }
-
-    private PhoenixMetricsRecord createAndFlush(PhoenixTableMetricsWriter sink, long traceid,
-            long parentid, long spanid, String desc, long startTime, long endTime, String hostname,
-            String... tags) {
-        PhoenixMetricsRecord record =
-                createRecord(traceid, parentid, spanid, desc, startTime, endTime, hostname, tags);
-        sink.addMetrics(record);
-        sink.flush();
-        return record;
-    }
-
-    /**
-     * Test multiple spans, within the same trace. Some spans are independent of the parent span,
-     * some are child spans
-     * @throws Exception on failure
-     */
-    @Test
-    public void testMultipleSpans() throws Exception {
-        // hook up a phoenix sink
-        PhoenixTableMetricsWriter sink = new PhoenixTableMetricsWriter();
-        Connection conn = getConnectionWithoutTracing();
-        sink.initForTesting(conn);
-
-        // create a simple metrics record
-        long traceid = 12345;
-        List<PhoenixMetricsRecord> records = new ArrayList<PhoenixMetricsRecord>();
-        PhoenixMetricsRecord record =
-                createAndFlush(sink, traceid, Span.ROOT_SPAN_ID, 7777, "root", 10, 30,
-                    "hostname.value", "root-span tag");
-        records.add(record);
-
-        // then create a child record
-        record =
-                createAndFlush(sink, traceid, 7777, 6666, "c1", 11, 15, "hostname.value",
-                    "first child");
-        records.add(record);
-
-        // create a different child
-        record =
-                createAndFlush(sink, traceid, 7777, 5555, "c2", 11, 18, "hostname.value",
-                    "second child");
-        records.add(record);
-
-        // create a child of the second child
-        record =
-                createAndFlush(sink, traceid, 5555, 4444, "c3", 12, 16, "hostname.value",
-                    "third child");
-        records.add(record);
-
-        // flush all the values to the table
-        sink.flush();
-
-        // start a reader
-        validateTraces(records, conn, traceid);
-    }
-
-    private void validateTraces(List<PhoenixMetricsRecord> records, Connection conn, long traceid)
-            throws Exception {
-        TraceReader reader = new TraceReader(conn);
-        Collection<TraceHolder> traces = reader.readAll(1);
-        assertEquals("Got an unexpected number of traces!", 1, traces.size());
-        // make sure the trace matches what we wrote
-        TraceHolder trace = traces.iterator().next();
-        assertEquals("Got an unexpected traceid", traceid, trace.traceid);
-        assertEquals("Got an unexpected number of spans", records.size(), trace.spans.size());
-
-        validateTrace(records, trace);
-    }
-
-    /**
-     * @param records
-     * @param trace
-     */
-    private void validateTrace(List<PhoenixMetricsRecord> records, TraceHolder trace) {
-        // drop each span into a sorted list so we get the expected ordering
-        Iterator<SpanInfo> spanIter = trace.spans.iterator();
-        for (PhoenixMetricsRecord record : records) {
-            SpanInfo spanInfo = spanIter.next();
-            LOG.info("Checking span:\n" + spanInfo);
-            Iterator<PhoenixAbstractMetric> metricIter = record.metrics().iterator();
-            assertEquals("Got an unexpected span id", metricIter.next().value(), spanInfo.id);
-            long parentId = (Long) metricIter.next().value();
-            if (parentId == Span.ROOT_SPAN_ID) {
-                assertNull("Got a parent, but it was a root span!", spanInfo.parent);
-            } else {
-                assertEquals("Got an unexpected parent span id", parentId, spanInfo.parent.id);
-            }
-            assertEquals("Got an unexpected start time", metricIter.next().value(), spanInfo.start);
-            assertEquals("Got an unexpected end time", metricIter.next().value(), spanInfo.end);
-
-            Iterator<PhoenixMetricTag> tags = record.tags().iterator();
-
-            int annotationCount = 0;
-            while (tags.hasNext()) {
-                // hostname is a tag, so we differentiate it
-                PhoenixMetricTag tag = tags.next();
-                if (tag.name().equals(MetricInfo.HOSTNAME.traceName)) {
-                    assertEquals("Didn't store correct hostname value", tag.value(),
-                        spanInfo.hostname);
-                } else {
-                    int count = annotationCount++;
-                    assertEquals("Didn't get expected annotation", count + " - " + tag.value(),
-                        spanInfo.annotations.get(count));
-                }
-            }
-            assertEquals("Didn't get expected number of annotations", annotationCount,
-                spanInfo.annotationCount);
-        }
-    }
-}
\ No newline at end of file


[2/2] git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/phoenix

Posted by ja...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/phoenix


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/50e16f88
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/50e16f88
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/50e16f88

Branch: refs/heads/master
Commit: 50e16f88d52a0ff14f684f0f9f501a040c6278e0
Parents: 4b45e90 bf26ef2
Author: James Taylor <jt...@salesforce.com>
Authored: Fri Aug 8 17:21:11 2014 -0700
Committer: James Taylor <jt...@salesforce.com>
Committed: Fri Aug 8 17:21:11 2014 -0700

----------------------------------------------------------------------
 .../phoenix/end2end/index/MutableIndexFailureIT.java    | 12 +++++++-----
 .../phoenix/coprocessor/MetaDataRegionObserver.java     |  8 ++++++--
 2 files changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------