| #! /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 |
| # |
| # 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. |
| |
| bin_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) |
| at_home=$( cd "$( dirname "$bin_dir" )" && pwd ) |
| source "${bin_dir}/build" |
| at_version=2.0.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/log4j.properties" |
| if [ ! -f "$log4j_config" ]; then |
| log4j_config="$at_home/conf/log4j.properties.example" |
| if [ ! -f "$log4j_config" ]; then |
| echo "Could not find logj4.properties or log4j.properties.example in $at_home/conf" |
| exit 1 |
| fi |
| 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 |
| build_shade_jar |
| CP="$at_home/target/accumulo-testing-shaded.jar:$(get_hadoop_client)" |
| 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 |
| mkdir -p "$2" |
| start_cluster |
| CLASSPATH="$CP" java -Dlog4j.configuration="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 -Dlog4j.configuration="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 -Dlog4j.configuration="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 -Dlog4j.configuration="file:$log4j_config" ${perf_pkg}.Compare "$2" "$3" |
| ;; |
| csv) |
| CLASSPATH="$CP" java -Dlog4j.configuration="file:$log4j_config" ${perf_pkg}.Csv "${@:2}" |
| ;; |
| list) |
| CLASSPATH="$CP" java -Dlog4j.configuration="file:$log4j_config" ${perf_pkg}.ListTests |
| ;; |
| *) |
| echo "Unknown command : $1" |
| print_usage |
| exit 1 |
| esac |
| |