diff --git dev-support/jenkins-common.sh dev-support/jenkins-common.sh index 64f486fc2bd181cbf1882c6bba98e23a6abf9f8f..87394bf5ed7ccfeb0e08ce460dbe155a81ac4a88 100644 --- dev-support/jenkins-common.sh +++ dev-support/jenkins-common.sh @@ -17,6 +17,7 @@ JIRA_ROOT_URL="https://issues.apache.org" JENKINS_URL="https://builds.apache.org" JENKINS_QUEUE_QUERY="/queue/api/json?tree=items[task[name],inQueueSince,actions[parameters[name,value]],why]" +SKIP_QUEUE_CHECK="false" fail() { echo "$@" 1>&2 @@ -78,6 +79,11 @@ is_check_no_precommit_tests_set() { grep -q "NO PRECOMMIT TESTS" $1 } +# Checks if a JIRA has 'SKIP QUEUE CHECK' enabled +is_skip_queue_check_set() { + grep -q "SKIP PRECOMMIT QUEUE CHECK" $1 +} + # Gets the URL for the JIRA patch attached get_jira_patch_url() { grep -o '"/jira/secure/attachment/[0-9]*/[^"]*' $1 | grep -v -e 'htm[l]*$' | sort | tail -1 | \ diff --git dev-support/jenkins-execute-build.sh dev-support/jenkins-execute-build.sh index 35392dd565861aa2e4a62fd91749001289e688c5..84e4406fa0942503a6ccfdb2303c4b9ff37afa5d 100644 --- dev-support/jenkins-execute-build.sh +++ dev-support/jenkins-execute-build.sh @@ -52,7 +52,7 @@ call_ptest_server() { java -cp "$PTEST_CLASSPATH" org.apache.hive.ptest.api.client.PTestClient --command testStart \ --outputDir "$PTEST_BUILD_DIR/hive/testutils/ptest2/target" --password "$JIRA_PASSWORD" \ - --jenkinsQueueUrl "$JENKINS_URL$JENKINS_QUEUE_QUERY" "$@" + --jenkinsQueueUrl "$JENKINS_URL$JENKINS_QUEUE_QUERY" --skipQueueCheck "$SKIP_QUEUE_CHECK" "$@" } # Unpack all test results @@ -109,6 +109,10 @@ if [ -n "$JIRA_ISSUE" ]; then fail "attachment $attachment_id is already tested for $JIRA_ISSUE" fi + if is_skip_queue_check_set $JIRA_INFO_FILE; then + SKIP_QUEUE_CHECK="true" + fi + # Use the BUILD_PROFILE if it is provided. if [ -z ${BUILD_PROFILE} ]; then BUILD_PROFILE=`get_branch_profile $JIRA_PATCH_URL $JIRA_INFO_FILE` diff --git testutils/ptest2/src/main/java/org/apache/hive/ptest/api/client/JenkinsQueueUtil.java testutils/ptest2/src/main/java/org/apache/hive/ptest/api/client/JenkinsQueueUtil.java index f33516447ec8decd34c578732584d15e1f1a6129..89e48b9f2b41b2b470ef0333ec09fb026ced1083 100644 --- testutils/ptest2/src/main/java/org/apache/hive/ptest/api/client/JenkinsQueueUtil.java +++ testutils/ptest2/src/main/java/org/apache/hive/ptest/api/client/JenkinsQueueUtil.java @@ -67,6 +67,9 @@ public static boolean isJiraAlreadyInQueue(CommandLine commandLine) { commandLine.hasOption(PTestClient.JIRA))) { return false; } + if (isSkipQueueCheck(commandLine)) { + return false; + } try { System.out.println("Checking " + JOB_NAME + " queue..."); String queueJson = httpGet(commandLine.getOptionValue(PTestClient.JENKINS_QUEUE_URL)); @@ -82,12 +85,31 @@ public static boolean isJiraAlreadyInQueue(CommandLine commandLine) { return true; } - } catch (IOException e) { + } catch (Exception e) { + //If any errors happen during this check we should catch them and return false so that the + // build can progress System.err.println("Error checking " + JOB_NAME + " build queue: " + e); } return false; } + /** + * If SKIP_QUEUE_CHECK flag is set to true, we won't check the queue status. + * Useful for changes with big sizes that have to be rebased frequently to avoid conflicts on + * patch application. + * @param commandLine + * @return + */ + private static boolean isSkipQueueCheck(CommandLine commandLine) { + if (commandLine.hasOption(PTestClient.SKIP_QUEUE_CHECK)) { + if ("TRUE".equalsIgnoreCase(commandLine.getOptionValue(PTestClient.SKIP_QUEUE_CHECK))) { + System.out.println("Not checking job queue status."); + return true; + } + } + return false; + } + /** * Parses raw json to produce a list of Jira number strings. * @param queueJson diff --git testutils/ptest2/src/main/java/org/apache/hive/ptest/api/client/PTestClient.java testutils/ptest2/src/main/java/org/apache/hive/ptest/api/client/PTestClient.java index 9970c360542b9f52420a81536a5e90554e2f1790..44ab439521b04f0ab7f6e0739b9df1e090aeb39d 100644 --- testutils/ptest2/src/main/java/org/apache/hive/ptest/api/client/PTestClient.java +++ testutils/ptest2/src/main/java/org/apache/hive/ptest/api/client/PTestClient.java @@ -86,6 +86,7 @@ private static final String TEST_HANDLE = "testHandle"; private static final String CLEAR_LIBRARY_CACHE = "clearLibraryCache"; public static final String JENKINS_QUEUE_URL = "jenkinsQueueUrl"; + public static final String SKIP_QUEUE_CHECK = "skipQueueCheck"; private static final int MAX_RETRIES = 10; private final String mApiEndPoint; private final String mLogsEndpoint; @@ -300,6 +301,7 @@ public static void main(String[] args) throws Exception { options.addOption(null, CLEAR_LIBRARY_CACHE, false, "Before starting the test, delete the ivy and maven directories (Optional for testStart)"); options.addOption(null, LOGS_ENDPOINT, true, "URL to get the logs"); options.addOption(null, JENKINS_QUEUE_URL, true, "URL for quering Jenkins job queue"); + options.addOption(null, SKIP_QUEUE_CHECK, true, "Whether or not skip checking precommit queue for duplicate jiras"); CommandLine commandLine = parser.parse(options, args);