hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prasan...@apache.org
Subject [33/39] hive git commit: HIVE-10655 : [PTest2] Propagate additionalProfiles flag to the source-prep.vm (Szehon, reviewed by Brock)
Date Tue, 12 May 2015 01:24:19 GMT
HIVE-10655 : [PTest2] Propagate additionalProfiles flag to the source-prep.vm (Szehon, reviewed
by Brock)


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

Branch: refs/heads/llap
Commit: 588d145ac9e37ad8ea29b9310af2c33d5d59d9b4
Parents: 913229c
Author: Szehon Ho <szehon@cloudera.com>
Authored: Mon May 11 01:39:40 2015 -0500
Committer: Szehon Ho <szehon@cloudera.com>
Committed: Mon May 11 01:39:40 2015 -0500

----------------------------------------------------------------------
 .../org/apache/hive/ptest/execution/PTest.java  | 12 ++++++-
 .../ptest/execution/conf/TestConfiguration.java | 12 ++++---
 .../execution/conf/TestTestConfiguration.java   | 38 +++++++++++++++-----
 .../resources/test-configuration.properties     |  2 ++
 4 files changed, 51 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/588d145a/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/PTest.java
----------------------------------------------------------------------
diff --git a/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/PTest.java b/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/PTest.java
index 696b790..7217ef9 100644
--- a/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/PTest.java
+++ b/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/PTest.java
@@ -33,6 +33,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 
+import com.google.common.annotations.VisibleForTesting;
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.CommandLineParser;
 import org.apache.commons.cli.GnuParser;
@@ -80,6 +81,7 @@ public class PTest {
   private final String mBuildTag;
   private final SSHCommandExecutor mSshCommandExecutor;
   private final RSyncCommandExecutor mRsyncCommandExecutor;
+  private final ImmutableMap<String, String> templateDefaults;
 
   public PTest(final TestConfiguration configuration, final ExecutionContext executionContext,
       final String buildTag, final File logDir, final LocalCommandFactory localCommandFactory,
@@ -124,7 +126,10 @@ public class PTest {
     put("mavenArgs", configuration.getMavenArgs()).
     put("mavenBuildArgs", configuration.getMavenBuildArgs()).
     put("mavenTestArgs", configuration.getMavenTestArgs());
-    final ImmutableMap<String, String> templateDefaults = templateDefaultsBuilder.build();
+    if (!Strings.isNullOrEmpty(configuration.getAdditionalProfiles())) {
+      templateDefaultsBuilder.put("additionalProfiles", configuration.getAdditionalProfiles());
+    }
+    templateDefaults = templateDefaultsBuilder.build();
     TestParser testParser = new TestParser(configuration.getContext(), configuration.getTestCasePropertyName(),
         new File(mExecutionContext.getLocalWorkingDirectory(), configuration.getRepositoryName()
+ "-source"),
         logger);
@@ -360,4 +365,9 @@ public class PTest {
     }
     System.exit(exitCode);
   }
+
+  @VisibleForTesting
+  public Map<String, String> getTemplateDefaults() {
+    return templateDefaults;
+  }
 }

http://git-wip-us.apache.org/repos/asf/hive/blob/588d145a/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/conf/TestConfiguration.java
----------------------------------------------------------------------
diff --git a/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/conf/TestConfiguration.java
b/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/conf/TestConfiguration.java
index 71c513d..ac4bafb 100644
--- a/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/conf/TestConfiguration.java
+++ b/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/conf/TestConfiguration.java
@@ -50,6 +50,7 @@ public class TestConfiguration {
   private static final String MAVEN_ARGS = "mavenArgs";
   private static final String MAVEN_BUILD_ARGS = "mavenBuildArgs";
   private static final String MAVEN_TEST_ARGS = "mavenTestArgs";
+  private static final String ADDITIONAL_PROFILES = "additionalProfiles";
   private static final String ANT_ARGS = "antArgs";
   private static final String JIRA_URL = "jiraUrl";
   private static final String JIRA_USER = "jiraUser";
@@ -69,6 +70,7 @@ public class TestConfiguration {
   private String mavenBuildArgs;
   private String mavenTestArgs;
   private String mavenEnvOpts;
+  private String additionalProfiles;
   private String repositoryType;
   private String repository;
   private String repositoryName;
@@ -114,6 +116,7 @@ public class TestConfiguration {
     mavenBuildArgs = context.getString(MAVEN_BUILD_ARGS, "").trim();
     mavenTestArgs =  context.getString(MAVEN_TEST_ARGS, "").trim();
     mavenEnvOpts =  context.getString(MAVEN_ENV_OPTS, "").trim();
+    additionalProfiles = context.getString(ADDITIONAL_PROFILES, "").trim();
     javaHome =  context.getString(JAVA_HOME, "").trim();
     javaHomeForTests = context.getString(JAVA_HOME_TEST, "").trim();
     patch = Strings.nullToEmpty(null);
@@ -125,6 +128,7 @@ public class TestConfiguration {
     logsURL = context.getString(LOGS_URL, "").trim();
     testCasePropertyName = context.getString(TEST_CASE_PROPERTY_NAME, "testcase").trim();
     sshOpts = context.getString(SSH_OPTS, "").trim();
+
   }
   public Context getContext() {
     return context;
@@ -192,12 +196,11 @@ public class TestConfiguration {
   public String getMavenBuildArgs() {
     return mavenBuildArgs;
   }
-  public String getMavenTestArgs() {
-    return mavenTestArgs;
-  }
+  public String getMavenTestArgs() { return mavenTestArgs; }
   public String getMavenEnvOpts() {
     return mavenEnvOpts;
   }
+  public String getAdditionalProfiles() { return additionalProfiles; }
   public String getJavaHome() {
     return javaHome;
   }
@@ -249,6 +252,7 @@ public class TestConfiguration {
   public void setMavenEnvOpts(String mavenEnvOpts) {
     this.mavenEnvOpts = Strings.nullToEmpty(mavenEnvOpts);
   }
+  public void setAdditionalProfiles(String additionalProfiles) { this.additionalProfiles
= additionalProfiles;  }
   @Override
   public String toString() {
     return "TestConfiguration [antArgs=" + antArgs + ", antTestArgs="
@@ -262,7 +266,7 @@ public class TestConfiguration {
         + jiraUrl + ", jiraUser=" + jiraUser + ", jiraPassword=" + jiraPassword
         + ", testCasePropertyName=" + testCasePropertyName + ", buildTool="
         + buildTool + ", jiraName=" + jiraName + ", clearLibraryCache="
-        + clearLibraryCache + "]";
+        + clearLibraryCache + ", additionalProfiles=" + additionalProfiles + "]";
   }
   public static TestConfiguration fromInputStream(InputStream inputStream, Logger logger)
       throws IOException {

http://git-wip-us.apache.org/repos/asf/hive/blob/588d145a/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/conf/TestTestConfiguration.java
----------------------------------------------------------------------
diff --git a/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/conf/TestTestConfiguration.java
b/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/conf/TestTestConfiguration.java
index 1e0efa0..848faf2 100644
--- a/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/conf/TestTestConfiguration.java
+++ b/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/conf/TestTestConfiguration.java
@@ -18,22 +18,25 @@
  */
 package org.apache.hive.ptest.execution.conf;
 
-import java.util.Properties;
-import java.util.Set;
-
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import com.google.common.io.Resources;
 import junit.framework.Assert;
-
+import org.apache.hive.ptest.execution.PTest;
 import org.apache.hive.ptest.execution.context.ExecutionContext;
 import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-import com.google.common.io.Resources;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
 
 public class TestTestConfiguration {
 
+  public TemporaryFolder baseDir = new TemporaryFolder();
   private static final Logger LOG = LoggerFactory
       .getLogger(TestTestConfiguration.class);
 
@@ -55,6 +58,7 @@ public class TestTestConfiguration {
     Assert.assertEquals("trunk", conf.getBranch());
     Assert.assertEquals("/tmp/hive-ptest-units/working/dir/working", executionContext.getLocalWorkingDirectory());
     Assert.assertEquals("-Dtest.continue.on.failure=true -Dtest.silent=false", conf.getAntArgs());
+    Assert.assertEquals("hadoop-1,hadoop-2", conf.getAdditionalProfiles());
     Assert.assertNotNull(conf.toString());
 
     Assert.assertEquals("", conf.getPatch());
@@ -72,7 +76,6 @@ public class TestTestConfiguration {
 
     conf.setAntArgs("AntArgs");
     Assert.assertEquals("AntArgs", conf.getAntArgs());
-
   }
   @Test
   public void testContext() throws Exception {
@@ -82,4 +85,23 @@ public class TestTestConfiguration {
     Assert.assertEquals(context.getParameters(), (new TestConfiguration(context, LOG)).getContext().getParameters());
 
   }
+
+  @Test
+  public void testPTest() throws Exception {
+    Host testHost = new Host("test", "test", new String[1], 1);
+    Set<Host> testHosts = new HashSet<Host>();
+    testHosts.add(testHost);
+
+    TestConfiguration conf = TestConfiguration.fromInputStream(
+      Resources.getResource("test-configuration.properties").openStream(), LOG);
+    ExecutionContext execContext = new ExecutionContext(null, testHosts, "test", null);
+    PTest.Builder mPTestBuilder = new PTest.Builder();
+    PTest ptest = mPTestBuilder.build(conf, execContext, "1234", baseDir.newFolder(), null,
null, null, null);
+    Map<String, String> templateDefaults = ptest.getTemplateDefaults();
+    Assert.assertEquals("git://github.com/apache/hive.git", templateDefaults.get("repository"));
+    Assert.assertEquals("apache-github", templateDefaults.get("repositoryName"));
+    Assert.assertEquals("trunk", templateDefaults.get("branch"));
+    Assert.assertEquals("-Dtest.continue.on.failure=true -Dtest.silent=false", templateDefaults.get("antArgs"));
+    Assert.assertEquals("hadoop-1,hadoop-2", templateDefaults.get("additionalProfiles"));
+  }
 }

http://git-wip-us.apache.org/repos/asf/hive/blob/588d145a/testutils/ptest2/src/test/resources/test-configuration.properties
----------------------------------------------------------------------
diff --git a/testutils/ptest2/src/test/resources/test-configuration.properties b/testutils/ptest2/src/test/resources/test-configuration.properties
index 8a83bf2..caba9ea 100644
--- a/testutils/ptest2/src/test/resources/test-configuration.properties
+++ b/testutils/ptest2/src/test/resources/test-configuration.properties
@@ -17,6 +17,8 @@ branch = trunk
 
 antArgs = -Dtest.continue.on.failure=true -Dtest.silent=false
 
+additionalProfiles = hadoop-1,hadoop-2
+
 qFileTests = clientNegative
 qFileTest.clientNegative.driver = TestNegativeCliDriver
 qFileTest.clientNegative.directory = ql/src/test/queries/clientnegative


Mime
View raw message