You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by br...@apache.org on 2014/10/16 00:19:45 UTC

svn commit: r1632192 - in /hive/trunk/testutils/ptest2/src: main/java/org/apache/hive/ptest/execution/JIRAService.java main/java/org/apache/hive/ptest/execution/PTest.java test/java/org/apache/hive/ptest/execution/TestJIRAService.java

Author: brock
Date: Wed Oct 15 22:19:45 2014
New Revision: 1632192

URL: http://svn.apache.org/r1632192
Log:
HIVE-8351 - Allow testing of both hadoop-1 and hadoop-2 for precommits (Mohit Sabharwal via Brock)

Modified:
    hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/JIRAService.java
    hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/PTest.java
    hive/trunk/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/TestJIRAService.java

Modified: hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/JIRAService.java
URL: http://svn.apache.org/viewvc/hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/JIRAService.java?rev=1632192&r1=1632191&r2=1632192&view=diff
==============================================================================
--- hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/JIRAService.java (original)
+++ hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/JIRAService.java Wed Oct 15 22:19:45 2014
@@ -87,7 +87,7 @@ class JIRAService {
       List<String> messages) {
     DefaultHttpClient httpClient = new DefaultHttpClient();
     try {
-      String buildTag = formatBuildTag(mBuildTag);
+      BuildInfo buildInfo = formatBuildTag(mBuildTag);
       String buildTagForLogs = formatBuildTagForLogs(mBuildTag);
       List<String> comments = Lists.newArrayList();
       comments.add("");
@@ -120,8 +120,10 @@ class JIRAService {
         }
         comments.add("");
       }
-      comments.add("Test results: " + mJenkinsURL + "/" + buildTag + "/testReport");
-      comments.add("Console output: " + mJenkinsURL + "/" + buildTag + "/console");
+      comments.add("Test results: " + mJenkinsURL + "/" +
+          buildInfo.getFormattedBuildTag() + "/testReport");
+      comments.add("Console output: " + mJenkinsURL + "/" +
+          buildInfo.getFormattedBuildTag() + "/console");
       comments.add("Test logs: " + mLogsURL + buildTagForLogs);
       comments.add("");
       if(!messages.isEmpty()) {
@@ -137,6 +139,9 @@ class JIRAService {
         comments.add("");
         comments.add("ATTACHMENT ID: " + attachmentId);
       }
+      if(!buildInfo.getBuildName().isEmpty()) {
+        comments.add(" - " + buildInfo.getBuildName());
+      }
       mLogger.info("Comment: " + Joiner.on("\n").join(comments));
       String body = Joiner.on("\n").join(comments);
       String url = String.format("%s/rest/api/2/issue/%s/comment", mUrl, mName);
@@ -193,16 +198,36 @@ class JIRAService {
     }
   }
 
+
+  public static class BuildInfo {
+    private String buildName;
+    private String formattedBuildTag;
+
+    public BuildInfo (String buildName, String formattedBuildTag) {
+      this.buildName = buildName;
+      this.formattedBuildTag = formattedBuildTag;
+    }
+
+    public String getBuildName() {
+      return buildName;
+    }
+
+    public String getFormattedBuildTag() {
+      return formattedBuildTag;
+    }
+  }
+
   /**
    * Hive-Build-123 to Hive-Build/123
    */
   @VisibleForTesting
-  static String formatBuildTag(String buildTag) {
+  static BuildInfo formatBuildTag(String buildTag) {
     if(buildTag.contains("-")) {
       int lastDashIndex = buildTag.lastIndexOf("-");
       String buildName = buildTag.substring(0, lastDashIndex);
       String buildId = buildTag.substring(lastDashIndex + 1);
-      return buildName + "/" + buildId;
+      String formattedBuildTag = buildName + "/" + buildId;
+      return new BuildInfo(buildName, formattedBuildTag);
     }
     throw new IllegalArgumentException("Build tag '" + buildTag + "' must contain a -");
   }

Modified: hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/PTest.java
URL: http://svn.apache.org/viewvc/hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/PTest.java?rev=1632192&r1=1632191&r2=1632192&view=diff
==============================================================================
--- hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/PTest.java (original)
+++ hive/trunk/testutils/ptest2/src/main/java/org/apache/hive/ptest/execution/PTest.java Wed Oct 15 22:19:45 2014
@@ -287,77 +287,77 @@ public class PTest {
     String buildTag = System.getenv("BUILD_TAG") == null ? "undefined-"
         + System.currentTimeMillis() : System.getenv("BUILD_TAG");
         File logDir = Dirs.create(new File(executionContextConfiguration.getGlobalLogDirectory(), buildTag));
-        LogDirectoryCleaner cleaner = new LogDirectoryCleaner(new File(executionContextConfiguration.
-            getGlobalLogDirectory()), 5);
-        cleaner.setName("LogCleaner-" + executionContextConfiguration.getGlobalLogDirectory());
-        cleaner.setDaemon(true);
-        cleaner.start();
-        TestConfiguration conf = TestConfiguration.fromFile(testConfigurationFile, LOG);
-        String repository = Strings.nullToEmpty(commandLine.getOptionValue(REPOSITORY)).trim();
-        if(!repository.isEmpty()) {
-          conf.setRepository(repository);
-        }
-        String repositoryName = Strings.nullToEmpty(commandLine.getOptionValue(REPOSITORY_NAME)).trim();
-        if(!repositoryName.isEmpty()) {
-          conf.setRepositoryName(repositoryName);
-        }
-        String branch = Strings.nullToEmpty(commandLine.getOptionValue(BRANCH)).trim();
-        if(!branch.isEmpty()) {
-          conf.setBranch(branch);
-        }
-        String patch = Strings.nullToEmpty(commandLine.getOptionValue(PATCH)).trim();
-        if(!patch.isEmpty()) {
-          conf.setPatch(patch);
-        }
-        String javaHome = Strings.nullToEmpty(commandLine.getOptionValue(JAVA_HOME)).trim();
-        if(!javaHome.isEmpty()) {
-          conf.setJavaHome(javaHome);
-        }
-        String javaHomeForTests = Strings.nullToEmpty(commandLine.getOptionValue(JAVA_HOME_TEST)).trim();
-        if(!javaHomeForTests.isEmpty()) {
-          conf.setJavaHomeForTests(javaHomeForTests);
-        }
-        String antTestArgs = Strings.nullToEmpty(commandLine.getOptionValue(ANT_TEST_ARGS)).trim();
-        if(!antTestArgs.isEmpty()) {
-          conf.setAntTestArgs(antTestArgs);
-        }
-        String antEnvOpts = Strings.nullToEmpty(commandLine.getOptionValue(ANT_ENV_OPTS)).trim();
-        if(!antEnvOpts.isEmpty()) {
-          conf.setAntEnvOpts(antEnvOpts);
-        }
-        String antTestTarget = Strings.nullToEmpty(commandLine.getOptionValue(ANT_TEST_TARGET)).trim();
-        if(!antTestTarget.isEmpty()) {
-          conf.setAntTestTarget(antTestTarget);
-        }
-        String[] supplementalAntArgs = commandLine.getOptionValues(ANT_ARG);
-        if(supplementalAntArgs != null && supplementalAntArgs.length > 0) {
-          String antArgs = Strings.nullToEmpty(conf.getAntArgs());
-          if(!(antArgs.isEmpty() || antArgs.endsWith(" "))) {
-            antArgs += " ";
-          }
-          antArgs += "-" + ANT_ARG + Joiner.on(" -" + ANT_ARG).join(supplementalAntArgs);
-          conf.setAntArgs(antArgs);
-        }
-        ExecutionContextProvider executionContextProvider = null;
-        ExecutionContext executionContext = null;
-        int exitCode = 0;
-        try {
-          executionContextProvider = executionContextConfiguration
-              .getExecutionContextProvider();
-          executionContext = executionContextProvider.createExecutionContext();
-          LocalCommandFactory localCommandFactory = new LocalCommandFactory(LOG);
-          PTest ptest = new PTest(conf, executionContext, buildTag, logDir,
-              localCommandFactory, new SSHCommandExecutor(LOG, localCommandFactory, conf.getSshOpts()),
-              new RSyncCommandExecutor(LOG, 10, localCommandFactory), LOG);
-          exitCode = ptest.run();
-        } finally {
-          if(executionContext != null) {
-            executionContext.terminate();
-          }
-          if(executionContextProvider != null) {
-            executionContextProvider.close();
-          }
-        }
-        System.exit(exitCode);
+    LogDirectoryCleaner cleaner = new LogDirectoryCleaner(new File(executionContextConfiguration.
+        getGlobalLogDirectory()), 5);
+    cleaner.setName("LogCleaner-" + executionContextConfiguration.getGlobalLogDirectory());
+    cleaner.setDaemon(true);
+    cleaner.start();
+    TestConfiguration conf = TestConfiguration.fromFile(testConfigurationFile, LOG);
+    String repository = Strings.nullToEmpty(commandLine.getOptionValue(REPOSITORY)).trim();
+    if(!repository.isEmpty()) {
+      conf.setRepository(repository);
+    }
+    String repositoryName = Strings.nullToEmpty(commandLine.getOptionValue(REPOSITORY_NAME)).trim();
+    if(!repositoryName.isEmpty()) {
+      conf.setRepositoryName(repositoryName);
+    }
+    String branch = Strings.nullToEmpty(commandLine.getOptionValue(BRANCH)).trim();
+    if(!branch.isEmpty()) {
+      conf.setBranch(branch);
+    }
+    String patch = Strings.nullToEmpty(commandLine.getOptionValue(PATCH)).trim();
+    if(!patch.isEmpty()) {
+      conf.setPatch(patch);
+    }
+    String javaHome = Strings.nullToEmpty(commandLine.getOptionValue(JAVA_HOME)).trim();
+    if(!javaHome.isEmpty()) {
+      conf.setJavaHome(javaHome);
+    }
+    String javaHomeForTests = Strings.nullToEmpty(commandLine.getOptionValue(JAVA_HOME_TEST)).trim();
+    if(!javaHomeForTests.isEmpty()) {
+      conf.setJavaHomeForTests(javaHomeForTests);
+    }
+    String antTestArgs = Strings.nullToEmpty(commandLine.getOptionValue(ANT_TEST_ARGS)).trim();
+    if(!antTestArgs.isEmpty()) {
+      conf.setAntTestArgs(antTestArgs);
+    }
+    String antEnvOpts = Strings.nullToEmpty(commandLine.getOptionValue(ANT_ENV_OPTS)).trim();
+    if(!antEnvOpts.isEmpty()) {
+      conf.setAntEnvOpts(antEnvOpts);
+    }
+    String antTestTarget = Strings.nullToEmpty(commandLine.getOptionValue(ANT_TEST_TARGET)).trim();
+    if(!antTestTarget.isEmpty()) {
+      conf.setAntTestTarget(antTestTarget);
+    }
+    String[] supplementalAntArgs = commandLine.getOptionValues(ANT_ARG);
+    if(supplementalAntArgs != null && supplementalAntArgs.length > 0) {
+      String antArgs = Strings.nullToEmpty(conf.getAntArgs());
+      if(!(antArgs.isEmpty() || antArgs.endsWith(" "))) {
+        antArgs += " ";
+      }
+      antArgs += "-" + ANT_ARG + Joiner.on(" -" + ANT_ARG).join(supplementalAntArgs);
+      conf.setAntArgs(antArgs);
+    }
+    ExecutionContextProvider executionContextProvider = null;
+    ExecutionContext executionContext = null;
+    int exitCode = 0;
+    try {
+      executionContextProvider = executionContextConfiguration
+          .getExecutionContextProvider();
+      executionContext = executionContextProvider.createExecutionContext();
+      LocalCommandFactory localCommandFactory = new LocalCommandFactory(LOG);
+      PTest ptest = new PTest(conf, executionContext, buildTag, logDir,
+          localCommandFactory, new SSHCommandExecutor(LOG, localCommandFactory, conf.getSshOpts()),
+          new RSyncCommandExecutor(LOG, 10, localCommandFactory), LOG);
+      exitCode = ptest.run();
+    } finally {
+      if(executionContext != null) {
+        executionContext.terminate();
+      }
+      if(executionContextProvider != null) {
+        executionContextProvider.close();
+      }
+    }
+    System.exit(exitCode);
   }
 }

Modified: hive/trunk/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/TestJIRAService.java
URL: http://svn.apache.org/viewvc/hive/trunk/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/TestJIRAService.java?rev=1632192&r1=1632191&r2=1632192&view=diff
==============================================================================
--- hive/trunk/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/TestJIRAService.java (original)
+++ hive/trunk/testutils/ptest2/src/test/java/org/apache/hive/ptest/execution/TestJIRAService.java Wed Oct 15 22:19:45 2014
@@ -18,17 +18,24 @@
  */
 package org.apache.hive.ptest.execution;
 
+import com.google.common.collect.Lists;
+
 import java.util.List;
 import junit.framework.Assert;
+
+import org.apache.hive.ptest.execution.JIRAService.BuildInfo;
 import org.junit.Test;
-import com.google.common.collect.Lists;
 
 public class TestJIRAService  {
 
   @Test
   public void testFormatBuildTagPositive() throws Throwable {
-    Assert.assertEquals("abc/123", JIRAService.formatBuildTag("abc-123"));
-    Assert.assertEquals("a-b-c/123", JIRAService.formatBuildTag("a-b-c-123"));
+    BuildInfo buildInfo = JIRAService.formatBuildTag("abc-123");
+    Assert.assertEquals("abc/123", buildInfo.getFormattedBuildTag());
+    Assert.assertEquals("abc", buildInfo.getBuildName());
+    buildInfo = JIRAService.formatBuildTag("PreCommit-HIVE-TRUNK-Build-1115");
+    Assert.assertEquals("PreCommit-HIVE-TRUNK-Build/1115", buildInfo.getFormattedBuildTag());
+    Assert.assertEquals("PreCommit-HIVE-TRUNK-Build", buildInfo.getBuildName());
   }
   @Test(expected=IllegalArgumentException.class)
   public void testFormatBuildTagNoDashSlash() throws Throwable {