diff options
author | Lianhao Lu <lianhao.lu@intel.com> | 2018-11-07 16:39:31 +0800 |
---|---|---|
committer | Lianhao Lu <lianhao.lu@intel.com> | 2018-11-09 08:52:35 +0800 |
commit | de0e18b974cb40cbbfac1accdc7d4b460ccd4186 (patch) | |
tree | c7609fcf1a94013f3b1535e79f173d66a916cc64 /s3p/generate.sh | |
parent | 3bd15a55aeb69c1caad1a1f32175cb3b7797733a (diff) |
Added JMeter scripts for stability test
Added the scripts and JMeter scenario for stability test
Change-Id: If495321e54e56d688cfadd53894a0361f283079d
Issue-ID: POLICY-837
Signed-off-by: Lianhao Lu <lianhao.lu@intel.com>
Diffstat (limited to 's3p/generate.sh')
-rwxr-xr-x | s3p/generate.sh | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/s3p/generate.sh b/s3p/generate.sh new file mode 100755 index 00000000..d28da1e8 --- /dev/null +++ b/s3p/generate.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +function print_usage_and_exit { + [ -z "$1" ] || echo "Error: $1" + echo "Usage: $0 <output_dir> <random_number>" + echo " - <output_dir>: directory where the generated csar file will be put into" + echo " - <random_number>: random number to choose which csar template to use" + exit 1 +} + +[ "$#" -ne 2 ] && print_usage_and_exit +OUTPUT=$1 +SEED=$2 +[ -d $OUTPUT ] || mkdir -p $OUTPUT +[ -d $OUTPUT ] || print_usage_and_exit "$OUTPUT is not a valid directory" +[[ $SEED =~ ^[0-9]+$ ]] || print_usage_and_exit "$SEED is not a integer" + + +ROOT_DIR=`dirname $(readlink -f $0)` +TMP_DIR=$ROOT_DIR/csar_tmp + +declare -A TEMPLATES +#fill templates +for path in $ROOT_DIR/templates/*; do + [ -d "$path" ] || continue # not directory, skip + dirname="$(basename "${path}")" + TEMPLATES[$dirname]=${path} +done +KEYS=(${!TEMPLATES[@]}) + +key=${KEYS[$(( 10#$SEED % ${#KEYS[@]} ))]} +src=${TEMPLATES[$key]} + +rm -rf $TMP_DIR +cp -r -f $src $TMP_DIR +find $TMP_DIR -type f | xargs sed -i "s/##RANDOM_RESOURCE_NAME##/s3p_${SEED}_${key}/g" +cd $TMP_DIR +echo $key +echo $src +zip -r "$ROOT_DIR/s3p_${SEED}_${key}.csar" * + +rm -f "$OUTPUT/s3p_${SEED}_${key}.csar" +mv -f "$ROOT_DIR/s3p_${SEED}_${key}.csar" $OUTPUT/ + +cd $ROOT_DIR +rm -rf $TMP_DIR |