Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F400B7725 for ; Thu, 3 Nov 2011 04:12:09 +0000 (UTC) Received: (qmail 83868 invoked by uid 500); 3 Nov 2011 04:12:09 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 83820 invoked by uid 500); 3 Nov 2011 04:12:09 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 83813 invoked by uid 99); 3 Nov 2011 04:12:08 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Nov 2011 04:12:08 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Nov 2011 04:12:07 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 5CA902388CBF for ; Thu, 3 Nov 2011 04:11:47 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1196939 - in /hbase/trunk/src/test/bin: ./ test-util.sh Date: Thu, 03 Nov 2011 04:11:47 -0000 To: commits@hbase.apache.org From: stack@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111103041147.5CA902388CBF@eris.apache.org> Author: stack Date: Thu Nov 3 04:11:46 2011 New Revision: 1196939 URL: http://svn.apache.org/viewvc?rev=1196939&view=rev Log: HBASE-4480 Testing script to simplify local testing Added: hbase/trunk/src/test/bin/ hbase/trunk/src/test/bin/test-util.sh (with props) Added: hbase/trunk/src/test/bin/test-util.sh URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/bin/test-util.sh?rev=1196939&view=auto ============================================================================== --- hbase/trunk/src/test/bin/test-util.sh (added) +++ hbase/trunk/src/test/bin/test-util.sh Thu Nov 3 04:11:46 2011 @@ -0,0 +1,167 @@ +#!/usr/bin/env bash +# +#/** +# * Copyright 2007 The Apache Software Foundation +# * +# * 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. +# */ + +usage() +{ +cat << EOF +usage: $0 [options] [test-name...] + +Run a set of hbase tests. Individual tests may be specified on the +command line or in a file using -f, with one test per line. Runs all +tests by default. Each specified tests should include the fully +qualified package name. + +options: + -h Show this message + -c Run 'mvn clean' before running the tests + -f FILE Run the additional tests listed in the FILE + -u Only run unit tests. Default is to run + unit and integration tests + -n N Run each test N times. Default = 1. + -s N Print N slowest tests + -H Print which tests are hanging (if any) +EOF +} + +testFile= +doClean="" +testType=verify +numIters=1 +showSlowest= +showHanging= + +# normalize path refs for surefire +if [[ "$0" != /* ]]; then + # relative path + scriptDir=`pwd`/$(dirname $0) +else + # absolute path + scriptDir=$(dirname $0) +fi +testDir=$scriptDir/../../../target/surefire-reports + +while getopts "hcHun:s:f:" OPTION +do + case $OPTION in + h) + usage + exit 0 + ;; + c) + doClean="clean" + ;; + H) + showHanging=1 + ;; + u) + testType=test + ;; + n) + numIters=$OPTARG + ;; + s) + showSlowest=$OPTARG + ;; + f) + testFile=$OPTARG + ;; + ?) + usage + exit 1 + esac +done + +testIdx=0 + +# add tests specified in a file +if [ ! -z $testFile ]; then + exec 3<$testFile + + while read <&3 line ; do + if [ ! -z "$line" ]; then + test[$testIdx]="$line" + fi + testIdx=$(($testIdx+1)) + done +fi + +# add tests specified on cmd line +if [ ! -z $BASH_ARGC ]; then + shift $(($OPTIND - 1)) + for (( i = $OPTIND; i <= $BASH_ARGC; i++ )) + do + test[$testIdx]=$1; + testIdx=$(($testIdx+1)) + shift + done +fi + +echo "Running tests..." +numTests=${#test[@]} + +for (( i = 1 ; i <= $numIters; i++ )) +do + if [[ $numTests > 0 ]]; then + #Now loop through each test + for (( j = 0; j < $numTests; j++ )) + do + nice -10 mvn $doClean $testType -Dtest=${test[$j]} + if [ $? -ne 0 ]; then + echo "${test[$j]} failed, iteration: $i" + exit 1 + fi + done + else + echo "EXECUTING ALL TESTS" + nice -10 mvn $doClean $testType + fi +done + +# Print a report of the slowest running tests +if [ ! -z $showSlowest ]; then + + testNameIdx=0 + for (( i = 0; i < ${#test[@]}; i++ )) + do + testNames[$i]=$testDir/'TEST-'${test[$i]}'.xml' + done + + echo "Slowest $showSlowest tests:" + + awk '//,""); \ + split($7,testname,"="); \ + split($3,time,"="); \ + print testname[2]"\t"time[2]}' \ + ${testNames[@]} \ + | sort -k2,2rn \ + | head -n $showSlowest +fi + +# Print a report of tests that hung +if [ ! -z $showHanging ]; then + echo "Hanging tests:" + find $testDir -type f -name *.xml -size 0k \ + | xargs basename \ + | cut -d"." -f -1 +fi Propchange: hbase/trunk/src/test/bin/test-util.sh ------------------------------------------------------------------------------ svn:executable = *