HBASE-26920 Fix missing braces warnings in TestProcedureMember (#4315)
[hbase.git] / dev-support / flaky-tests / run-flaky-tests.Jenkinsfile
blob9bc6ab4d27a49539b11d892614a830f1c93f876e
1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements.  See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership.  The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License.  You may obtain a copy of the License at
8 //
9 //   http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing,
12 // software distributed under the License is distributed on an
13 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, either express or implied.  See the License for the
15 // specific language governing permissions and limitations
16 // under the License.
17 pipeline {
18   agent {
19     node {
20       label 'hbase'
21     }
22   }
23   triggers {
24     cron('H H/4 * * *') // Every four hours. See https://jenkins.io/doc/book/pipeline/syntax/#cron-syntax
25   }
26   options {
27     // this should roughly match how long we tell the flaky dashboard to look at
28     buildDiscarder(logRotator(numToKeepStr: '50'))
29     timeout (time: 2, unit: 'HOURS')
30     timestamps()
31   }
32   environment {
33     ASF_NIGHTLIES = 'https://nightlies.apache.org'
34   }
35   parameters {
36     booleanParam(name: 'DEBUG', defaultValue: false, description: 'Produce a lot more meta-information.')
37   }
38   tools {
39     // this should match what the yetus nightly job for the branch will use
40     maven 'maven_latest'
41     jdk "jdk_1.8_latest"
42   }
43   stages {
44     stage ('run flaky tests') {
45       steps {
46         sh '''#!/usr/bin/env bash
47           set -e
48           declare -a curl_args=(--fail)
49           tmpdir=$(realpath target)
50           declare -a mvn_args=(--batch-mode -fn -Dbuild.id="${BUILD_ID}" -Dmaven.repo.local="${WORKSPACE}/local-repository" -Djava.io.tmpdir=${tmpdir})
51           if [ "${DEBUG}" = "true" ]; then
52             curl_args=("${curl_args[@]}" -v)
53             mvn_args=("${mvn_args[@]}" -X)
54             set -x
55           fi
56           curl "${curl_args[@]}" -o includes.txt "${JENKINS_URL}/job/HBase-Find-Flaky-Tests/job/${BRANCH_NAME}/lastSuccessfulBuild/artifact/output/includes"
57           if [ -s includes.txt ]; then
58             rm -rf local-repository/org/apache/hbase
59             mvn clean "${mvn_args[@]}"
60             rm -rf "target/machine" && mkdir -p "target/machine"
61             if [ -x dev-support/gather_machine_environment.sh ]; then
62               "./dev-support/gather_machine_environment.sh" "target/machine"
63               echo "got the following saved stats in 'target/machine'"
64               ls -lh "target/machine"
65             else
66               echo "Skipped gathering machine environment because we couldn't read the script to do so."
67             fi
68             mvn -T0.25C package "${mvn_args[@]}" -Dtest="$(cat includes.txt)" -Dmaven.test.redirectTestOutputToFile=true -Dsurefire.firstPartForkCount=0.25C -Dsurefire.secondPartForkCount=0.25C
69           else
70             echo "set of flaky tests is currently empty."
71           fi
72 '''
73       }
74     }
75   }
76   post {
77     always {
78       junit testResults: "**/surefire-reports/*.xml", allowEmptyResults: true
79       sshPublisher(publishers: [
80         sshPublisherDesc(configName: 'Nightlies',
81           transfers: [
82             sshTransfer(remoteDirectory: "hbase/${JOB_NAME}/${BUILD_NUMBER}",
83               sourceFiles: "**/surefire-reports/*,**/test-data/*"
84             )
85           ]
86         )
87       ])
88       sh '''#!/bin/bash -e
89         ./dev-support/gen_redirect_html.py "${ASF_NIGHTLIES}/hbase/${JOB_NAME}/${BUILD_NUMBER}" > test_logs.html
90       '''
91       archiveArtifacts artifacts: 'includes.txt,test_logs.html,target/machine/*'
92     }
93   }