ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From swa...@apache.org
Subject git commit: AMBARI-5707. Mini HBase cluster setup for unit testing. (swagle)
Date Tue, 04 Nov 2014 01:24:54 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-metrics-dev 8dd3aabe0 -> c1b0d25af


AMBARI-5707. Mini HBase cluster setup for unit testing. (swagle)


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

Branch: refs/heads/branch-metrics-dev
Commit: c1b0d25afc83490982238f2d30c4699afffed121
Parents: 8dd3aab
Author: Siddharth Wagle <swagle@hortonworks.com>
Authored: Mon Nov 3 17:24:42 2014 -0800
Committer: Siddharth Wagle <swagle@hortonworks.com>
Committed: Mon Nov 3 17:24:42 2014 -0800

----------------------------------------------------------------------
 .../pom.xml                                     |  23 +++-
 .../timeline/AbstractMiniHBaseClusterTest.java  | 113 +++++++++++++++++++
 .../timeline/TestPhoenixTransactSQL.java        |  14 +--
 .../4.2.0/phoenix-core-tests-4.2.0.jar          | Bin 0 -> 992828 bytes
 .../4.2.0/phoenix-core-tests-4.2.0.pom          |   9 ++
 .../phoenix-core-tests/maven-metadata-local.xml |  12 ++
 6 files changed, 161 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c1b0d25a/ambari-metrics/ambari-metrics-hadoop-timelineservice/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-hadoop-timelineservice/pom.xml b/ambari-metrics/ambari-metrics-hadoop-timelineservice/pom.xml
index b147936..346b89d 100644
--- a/ambari-metrics/ambari-metrics-hadoop-timelineservice/pom.xml
+++ b/ambari-metrics/ambari-metrics-hadoop-timelineservice/pom.xml
@@ -38,6 +38,13 @@
     <hadoop.version>2.4.0</hadoop.version>
   </properties>
 
+  <repositories>
+    <repository>
+      <id>phoenix-core-tests</id>
+      <name>Phoenix Unit tests</name>
+      <url>file://${project.basedir}/src/test/resources/lib</url>
+    </repository>
+  </repositories>
   <build>
     <plugins>
       <plugin>
@@ -257,12 +264,24 @@
       <version>3.2</version>
       <scope>test</scope>
     </dependency>
-
     <!-- for unit tests only -->
     <dependency>
       <groupId>org.apache.phoenix</groupId>
       <artifactId>phoenix-core</artifactId>
-      <version>4.0.0-incubating</version>
+      <version>4.2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.phoenix</groupId>
+      <artifactId>phoenix-core-tests</artifactId>
+      <version>4.2.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hbase</groupId>
+      <artifactId>hbase-it</artifactId>
+      <version>0.98.4-hadoop2</version>
+      <scope>test</scope>
+      <classifier>tests</classifier>
     </dependency>
     <dependency>
       <groupId>org.powermock</groupId>

http://git-wip-us.apache.org/repos/asf/ambari/blob/c1b0d25a/ambari-metrics/ambari-metrics-hadoop-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/AbstractMiniHBaseClusterTest.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-hadoop-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/AbstractMiniHBaseClusterTest.java
b/ambari-metrics/ambari-metrics-hadoop-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/AbstractMiniHBaseClusterTest.java
new file mode 100644
index 0000000..db39250
--- /dev/null
+++ b/ambari-metrics/ambari-metrics-hadoop-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/AbstractMiniHBaseClusterTest.java
@@ -0,0 +1,113 @@
+/**
+ * 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.hadoop.yarn.server.applicationhistoryservice.metrics.timeline;
+
+import org.apache.phoenix.jdbc.PhoenixEmbeddedDriver;
+import org.apache.phoenix.jdbc.PhoenixTestDriver;
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.util.PropertiesUtil;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+
+import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB;
+import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+public abstract class AbstractMiniHBaseClusterTest extends BaseTest {
+
+  protected static String getUrl() {
+    return TestUtil.PHOENIX_CONNECTIONLESS_JDBC_URL;
+  }
+
+  protected static String getUrl(String tenantId) {
+    return getUrl() + ';' + TENANT_ID_ATTRIB + '=' + tenantId;
+  }
+
+  protected static PhoenixTestDriver driver;
+
+  private static void startServer(String url) throws Exception {
+    assertNull(driver);
+    // only load the test driver if we are testing locally - for integration tests, we want
to
+    // test on a wider scale
+    if (PhoenixEmbeddedDriver.isTestUrl(url)) {
+      driver = initDriver(ReadOnlyProps.EMPTY_PROPS);
+      assertTrue(DriverManager.getDriver(url) == driver);
+      driver.connect(url, PropertiesUtil.deepCopy(TEST_PROPERTIES));
+    }
+  }
+
+  protected static synchronized PhoenixTestDriver initDriver(ReadOnlyProps props) throws
Exception {
+    if (driver == null) {
+      driver = new PhoenixTestDriver(props);
+      DriverManager.registerDriver(driver);
+    }
+    return driver;
+  }
+
+  private String connUrl;
+
+  @Before
+  public void setup() throws Exception {
+    connUrl = getUrl();
+    startServer(connUrl);
+  }
+
+  @Test
+  public void testStorageSystemInitialized() throws Exception {
+    String sampleDDL = "CREATE TABLE TEST_METRICS (TEST_COLUMN VARCHAR " +
+      "CONSTRAINT pk PRIMARY KEY (TEST_COLUMN)) DATA_BLOCK_ENCODING='FAST_DIFF', " +
+      "IMMUTABLE_ROWS=true, TTL=86400, COMPRESSION='SNAPPY'";
+
+    Connection conn = null;
+    PreparedStatement stmt = null;
+    try {
+      conn = DriverManager.getConnection(connUrl);
+      stmt = conn.prepareStatement(sampleDDL);
+      stmt.execute();
+      conn.commit();
+    } finally {
+      if (stmt != null) {
+        stmt.close();
+      }
+      if (conn != null) {
+        conn.close();
+      }
+    }
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    if (driver != null) {
+      try {
+        driver.close();
+      } finally {
+        PhoenixTestDriver phoenixTestDriver = driver;
+        driver = null;
+        DriverManager.deregisterDriver(phoenixTestDriver);
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/c1b0d25a/ambari-metrics/ambari-metrics-hadoop-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TestPhoenixTransactSQL.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-hadoop-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TestPhoenixTransactSQL.java
b/ambari-metrics/ambari-metrics-hadoop-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TestPhoenixTransactSQL.java
index f92a7d0..b0f0153 100644
--- a/ambari-metrics/ambari-metrics-hadoop-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TestPhoenixTransactSQL.java
+++ b/ambari-metrics/ambari-metrics-hadoop-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/TestPhoenixTransactSQL.java
@@ -17,18 +17,14 @@
  */
 package org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline;
 
-import org.apache.hadoop.metrics2.sink.timeline.TimelineMetric;
-import org.apache.hadoop.yarn.util.timeline.TimelineUtils;
-import org.codehaus.jackson.map.ObjectMapper;
 import org.junit.Assert;
 import org.junit.Test;
+
 import java.util.Arrays;
-import java.util.HashMap;
 
-import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.AbstractTimelineAggregator.*;
 import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.PhoenixTransactSQL.Condition;
 
-public class TestPhoenixTransactSQL {
+public class TestPhoenixTransactSQL extends AbstractMiniHBaseClusterTest {
   @Test
   public void testConditionClause() throws Exception {
     Condition condition = new Condition(
@@ -36,10 +32,12 @@ public class TestPhoenixTransactSQL {
         1407959718L, 1407959918L, null, false);
 
     String preparedClause = condition.getConditionClause();
-    String expectedClause = "METRIC_NAME IN (?,?) AND HOSTNAME = ? AND APP_ID" +
-      " = ? AND INSTANCE_ID = ? AND START_TIME >= ? AND START_TIME < ?";
+    String expectedClause = "METRIC_NAME IN (?, ?) AND HOSTNAME = ? AND " +
+      "APP_ID = ? AND INSTANCE_ID = ? AND SERVER_TIME >= ? AND SERVER_TIME < ?";
 
     Assert.assertNotNull(preparedClause);
     Assert.assertEquals(expectedClause, preparedClause);
   }
+
+
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/c1b0d25a/ambari-metrics/ambari-metrics-hadoop-timelineservice/src/test/resources/lib/org/apache/phoenix/phoenix-core-tests/4.2.0/phoenix-core-tests-4.2.0.jar
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-hadoop-timelineservice/src/test/resources/lib/org/apache/phoenix/phoenix-core-tests/4.2.0/phoenix-core-tests-4.2.0.jar
b/ambari-metrics/ambari-metrics-hadoop-timelineservice/src/test/resources/lib/org/apache/phoenix/phoenix-core-tests/4.2.0/phoenix-core-tests-4.2.0.jar
new file mode 100644
index 0000000..468409a
Binary files /dev/null and b/ambari-metrics/ambari-metrics-hadoop-timelineservice/src/test/resources/lib/org/apache/phoenix/phoenix-core-tests/4.2.0/phoenix-core-tests-4.2.0.jar
differ

http://git-wip-us.apache.org/repos/asf/ambari/blob/c1b0d25a/ambari-metrics/ambari-metrics-hadoop-timelineservice/src/test/resources/lib/org/apache/phoenix/phoenix-core-tests/4.2.0/phoenix-core-tests-4.2.0.pom
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-hadoop-timelineservice/src/test/resources/lib/org/apache/phoenix/phoenix-core-tests/4.2.0/phoenix-core-tests-4.2.0.pom
b/ambari-metrics/ambari-metrics-hadoop-timelineservice/src/test/resources/lib/org/apache/phoenix/phoenix-core-tests/4.2.0/phoenix-core-tests-4.2.0.pom
new file mode 100644
index 0000000..83c7106
--- /dev/null
+++ b/ambari-metrics/ambari-metrics-hadoop-timelineservice/src/test/resources/lib/org/apache/phoenix/phoenix-core-tests/4.2.0/phoenix-core-tests-4.2.0.pom
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.phoenix</groupId>
+  <artifactId>phoenix-core-tests</artifactId>
+  <version>4.2.0</version>
+  <description>POM was created from install:install-file</description>
+</project>

http://git-wip-us.apache.org/repos/asf/ambari/blob/c1b0d25a/ambari-metrics/ambari-metrics-hadoop-timelineservice/src/test/resources/lib/org/apache/phoenix/phoenix-core-tests/maven-metadata-local.xml
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-hadoop-timelineservice/src/test/resources/lib/org/apache/phoenix/phoenix-core-tests/maven-metadata-local.xml
b/ambari-metrics/ambari-metrics-hadoop-timelineservice/src/test/resources/lib/org/apache/phoenix/phoenix-core-tests/maven-metadata-local.xml
new file mode 100644
index 0000000..53bbfc2
--- /dev/null
+++ b/ambari-metrics/ambari-metrics-hadoop-timelineservice/src/test/resources/lib/org/apache/phoenix/phoenix-core-tests/maven-metadata-local.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata>
+  <groupId>org.apache.phoenix</groupId>
+  <artifactId>phoenix-core-tests</artifactId>
+  <versioning>
+    <release>4.2.0</release>
+    <versions>
+      <version>4.2.0</version>
+    </versions>
+    <lastUpdated>20141103224551</lastUpdated>
+  </versioning>
+</metadata>


Mime
View raw message