| #! /usr/bin/env bash |
| # |
| # 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 |
| # |
| # https://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. |
| # |
| |
| # This script intentionally does not use other accumulo-testing scripts and |
| # config and only relies on cluster-control.sh script to get all environmental |
| # information. |
| |
| bin_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) |
| at_home=$(cd "$(dirname "$bin_dir")" && pwd) |
| at_version=2.1.0-SNAPSHOT |
| |
| function print_usage() { |
| cat <<EOF |
| |
| Usage: performance-test <command> (<argument>) |
| |
| Possible commands: |
| run <output dir> [filter] Runs performance tests. |
| compare <result 1> <result 2> Compares results of two test. |
| csv {files} Converts results to CSV |
| list List the performance test |
| EOF |
| } |
| |
| function build_shade_jar() { |
| at_shaded_jar="$at_home/target/accumulo-testing-shaded.jar" |
| if [ ! -f "$at_shaded_jar" ]; then |
| echo "Building $at_shaded_jar" |
| cd "$at_home" || exit 1 |
| mvn clean package -P create-shade-jar -D skipTests -D accumulo.version="$(get_version 'ACCUMULO')" -D hadoop.version="$(get_version 'HADOOP')" -D zookeeper.version="$(get_version 'ZOOKEEPER')" |
| fi |
| } |
| |
| log4j_config="$at_home/conf/log4j2.properties" |
| if [ ! -f "$log4j_config" ]; then |
| echo "Could not find log4j2.properties in $at_home/conf" |
| exit 1 |
| fi |
| |
| if [ ! -f "$at_home/conf/cluster-control.sh" ]; then |
| echo "Could not find cluster-control.sh" |
| exit 1 |
| fi |
| |
| source "$at_home"/conf/cluster-control.sh |
| export TEST_JAR_PATH="${at_home}/target/accumulo-testing-shaded.jar" |
| if [[ ! -f $TEST_JAR_PATH ]]; then |
| build_shade_jar |
| fi |
| CP="$at_shaded_jar:$(get_hadoop_client)" |
| export CLASSPATH="$at_shaded_jar:$CLASSPATH" |
| perf_pkg="org.apache.accumulo.testing.performance.impl" |
| case "$1" in |
| run) |
| if [ -z "$2" ]; then |
| echo "ERROR: <output dir> needs to be set" |
| print_usage |
| exit 1 |
| fi |
| # don't start unless we can find the class provided |
| found=false |
| CLASSPATH="$CP" java $JAVA_OPTS -Dlog4j.configurationFile="file:$log4j_config" ${perf_pkg}.ListTests | while read -r test_class; do |
| if [[ $test_class == "$3" ]]; then |
| found=true |
| fi |
| done |
| if [[ ! $found ]]; then |
| echo "ERROR: Did not find test class: $3" |
| print_usage |
| exit 1 |
| fi |
| mkdir -p "$2" |
| start_cluster |
| CLASSPATH="$CP" java $JAVA_OPTS -Dlog4j.configurationFile="file:$log4j_config" ${perf_pkg}.ListTests | while read -r test_class; do |
| if [[ -z $3 || $test_class == *$3* ]]; then |
| echo "Running test $test_class" |
| pt_tmp=$(mktemp -d -t accumulo_pt_XXXXXXX) |
| setup_accumulo |
| get_config_file accumulo.properties "$pt_tmp" |
| CLASSPATH="$CP" java $JAVA_OPTS -Dlog4j.configurationFile="file:$log4j_config" ${perf_pkg}.MergeSiteConfig "$test_class" "$pt_tmp" |
| put_config_file "$pt_tmp/accumulo.properties" |
| put_server_code "$at_home/target/accumulo-testing-$at_version.jar" |
| start_accumulo |
| get_config_file accumulo-client.properties "$pt_tmp" |
| CLASSPATH="$CP" java $JAVA_OPTS -Dlog4j.configurationFile="file:$log4j_config" ${perf_pkg}.PerfTestRunner "$pt_tmp/accumulo-client.properties" "$test_class" "$(get_version 'ACCUMULO')" "$2" |
| fi |
| done |
| stop_cluster |
| ;; |
| compare) |
| CLASSPATH="$CP" java $JAVA_OPTS -Dlog4j.configurationFile="file:$log4j_config" ${perf_pkg}.Compare "$2" "$3" |
| ;; |
| csv) |
| CLASSPATH="$CP" java $JAVA_OPTS -Dlog4j.configurationFile="file:$log4j_config" ${perf_pkg}.Csv "${@:2}" |
| ;; |
| list) |
| CLASSPATH="$CP" java $JAVA_OPTS -Dlog4j.configurationFile="file:$log4j_config" ${perf_pkg}.ListTests |
| ;; |
| *) |
| echo "Unknown command : $1" |
| print_usage |
| exit 1 |
| ;; |
| esac |