Fixed a nasty bug that was for debugging but was logging sudo pass to log file! Also fixed the script to work properly for logging random data generation and advanced mode
This commit is contained in:
+49
-26
@@ -40,7 +40,6 @@ verify-prerequisites() {
|
|||||||
initialize-environment() {
|
initialize-environment() {
|
||||||
check-sudo-pass "Installing dependencies requires sudo permissions."
|
check-sudo-pass "Installing dependencies requires sudo permissions."
|
||||||
if [[ "$?" == 0 ]]; then
|
if [[ "$?" == 0 ]]; then
|
||||||
log-info "Sudo pass: $PASSWORD"
|
|
||||||
declare title="Initialize Local Environment"
|
declare title="Initialize Local Environment"
|
||||||
|
|
||||||
if (prompt-yes-no "$title"); then
|
if (prompt-yes-no "$title"); then
|
||||||
@@ -82,9 +81,9 @@ deploy-and-run-benchmarkers() {
|
|||||||
|
|
||||||
cd ansible
|
cd ansible
|
||||||
|
|
||||||
ansible-playbook -i inventories/local -e vpc_id="$VPC_ID" deploy_benchmarker.yml > "$ANSIBLE_LOG_FILE" 2>&1 &
|
ansible-playbook -i inventories/local -e vpc_id="$VPC_ID" --tags deploy deploy_benchmarker.yml > "$ANSIBLE_LOG_FILE" 2>&1 &
|
||||||
pid=$!
|
pid=$!
|
||||||
log-info "Running ansible-playbook 'deploy_benchmarker.yml' with no tags and logging output to file [$ANSIBLE_LOG_FILE]"
|
log-info "Running ansible-playbook 'deploy_benchmarker.yml' with tags [deploy] and logging output to file [$ANSIBLE_LOG_FILE]"
|
||||||
|
|
||||||
show-tail-box "$title" $pid "$ANSIBLE_LOG_FILE"
|
show-tail-box "$title" $pid "$ANSIBLE_LOG_FILE"
|
||||||
|
|
||||||
@@ -120,13 +119,14 @@ destroy-all() {
|
|||||||
|
|
||||||
randomly-populate-dynamodb() {
|
randomly-populate-dynamodb() {
|
||||||
declare title="Populate DynamoDB with Random Data"
|
declare title="Populate DynamoDB with Random Data"
|
||||||
|
declare log_file=/tmp/dynamodb-data-population.log
|
||||||
|
|
||||||
if (prompt-yes-no "$title"); then
|
if (prompt-yes-no "$title"); then
|
||||||
./scripts/randomly-generate-high-velocity-data.sh /tmp/dynamodb-population.log &
|
./scripts/randomly-generate-high-velocity-data.sh -i 5000 > "$log_file" 2>&1 &
|
||||||
pid=$!
|
pid=$!
|
||||||
log-info "Running randomly-generate-high-velocity-data script and logging to [$ANSIBLE_LOG_FILE]"
|
log-info "Running randomly-generate-high-velocity-data script and logging to [$log_file]"
|
||||||
|
|
||||||
show-tail-box "$title" $pid "$ANSIBLE_LOG_FILE"
|
show-tail-box "$title" $pid "$log_file"
|
||||||
|
|
||||||
msg-box "Successfully populated DynamoDB with random data!"
|
msg-box "Successfully populated DynamoDB with random data!"
|
||||||
log-info "Successfully populated DynamoDB with random data"
|
log-info "Successfully populated DynamoDB with random data"
|
||||||
@@ -138,9 +138,12 @@ randomly-populate-dynamodb() {
|
|||||||
custom-selections() {
|
custom-selections() {
|
||||||
declare title="Customize What to Run (Advanced Mode)"
|
declare title="Customize What to Run (Advanced Mode)"
|
||||||
declare choices
|
declare choices
|
||||||
|
declare prompted_for_sudo_pass=false
|
||||||
|
declare prompted_for_vpc_id=false
|
||||||
|
declare requires_vpc_id=false
|
||||||
declare tags=""
|
declare tags=""
|
||||||
|
|
||||||
choices=$(whiptail --separate-output --checklist --fb "$title" "$BOX_HEIGHT" "$BOX_WIDTH" 13 \
|
choices=$(whiptail --separate-output --checklist --fb "$title" "$CHECKBOX_HEIGHT" "$CHECKBOX_WIDTH" 13 \
|
||||||
"PREREQUISITES" "Install Prerequisites for Local Machine" OFF \
|
"PREREQUISITES" "Install Prerequisites for Local Machine" OFF \
|
||||||
"INITIALIZE_ELK" "Initialize Local Elastic Stack" OFF \
|
"INITIALIZE_ELK" "Initialize Local Elastic Stack" OFF \
|
||||||
"START_ELK" "Start Local Elastic Stack" OFF \
|
"START_ELK" "Start Local Elastic Stack" OFF \
|
||||||
@@ -159,55 +162,75 @@ custom-selections() {
|
|||||||
for choice in $choices; do
|
for choice in $choices; do
|
||||||
case "$choice" in
|
case "$choice" in
|
||||||
"PREREQUISITES")
|
"PREREQUISITES")
|
||||||
tags+="prerequisites"
|
tags+="prerequisites,"
|
||||||
|
check-sudo-pass "Installing dependencies requires sudo permissions."
|
||||||
|
prompted_for_sudo_pass=true
|
||||||
;;
|
;;
|
||||||
"INITIALIZE_ELK")
|
"INITIALIZE_ELK")
|
||||||
tags+="init_elk"
|
tags+="init_elk,"
|
||||||
;;
|
;;
|
||||||
"START_ELK")
|
"START_ELK")
|
||||||
tags+="elk"
|
tags+="elk,"
|
||||||
;;
|
;;
|
||||||
"DEPLOY_CDK")
|
"DEPLOY_CDK")
|
||||||
tags+="cdk"
|
tags+="cdk,"
|
||||||
;;
|
requires_vpc_id=true
|
||||||
"UPLOAD_BIN")
|
|
||||||
tags+="upload"
|
|
||||||
;;
|
|
||||||
"RUN_BENCHMARKERS")
|
|
||||||
tags+="run"
|
|
||||||
if [[ -z $VPC_ID ]]; then
|
if [[ -z $VPC_ID ]]; then
|
||||||
prompt-for-vpc-id
|
prompt-for-vpc-id
|
||||||
|
prompted_for_vpc_id=true
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
"UPLOAD_BIN")
|
||||||
|
tags+="upload,"
|
||||||
|
;;
|
||||||
|
"RUN_BENCHMARKERS")
|
||||||
|
tags+="run,"
|
||||||
|
requires_vpc_id=true
|
||||||
|
if [[ -z $VPC_ID ]]; then
|
||||||
|
prompt-for-vpc-id
|
||||||
|
prompted_for_vpc_id=true
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"STOP_ELK")
|
"STOP_ELK")
|
||||||
tags+="stop_elk"
|
tags+="stop_elk,"
|
||||||
;;
|
;;
|
||||||
"DESTROY")
|
"DESTROY")
|
||||||
tags+="destroy"
|
tags+="destroy,"
|
||||||
;;
|
;;
|
||||||
"DESTROY_KEY")
|
"DESTROY_KEY")
|
||||||
tags+="destroy_key_pair"
|
tags+="destroy_key_pair,"
|
||||||
;;
|
;;
|
||||||
"RUN_DYNAMODB")
|
"RUN_DYNAMODB")
|
||||||
tags+="dynamodb"
|
tags+="dynamodb,"
|
||||||
;;
|
;;
|
||||||
"RUN_DAX")
|
"RUN_DAX")
|
||||||
tags+="dax"
|
tags+="dax,"
|
||||||
;;
|
;;
|
||||||
"RUN_CRUD")
|
"RUN_CRUD")
|
||||||
tags+="crud"
|
tags+="crud,"
|
||||||
;;
|
;;
|
||||||
"RUN_READ_ONLY")
|
"RUN_READ_ONLY")
|
||||||
tags+="read-only"
|
tags+="read-only,"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
tags=$(echo "$tags" | sed 's/\(.*\),/\1/')
|
||||||
|
|
||||||
if (prompt-yes-no "$title"); then
|
|
||||||
|
if (prompt-yes-no "Advanced Mode: Deploy tasks with tags: [$tags]"); then
|
||||||
cd ansible
|
cd ansible
|
||||||
|
args=""
|
||||||
|
|
||||||
ansible-playbook -i inventories/local --tags "$tags" deploy_benchmarker.yml > "$ANSIBLE_LOG_FILE" 2>&1 &
|
if [[ $prompted_for_sudo_pass == true ]]; then
|
||||||
|
args+=" -e ansible_become_password='$PASSWORD'"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $requires_vpc_id == true && $prompted_for_vpc_id == true ]]; then
|
||||||
|
args+=" -e vpc_id=$VPC_ID"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ansible-playbook -i inventories/local $args --tags "$tags" deploy_benchmarker.yml > "$ANSIBLE_LOG_FILE" 2>&1 &
|
||||||
pid=$!
|
pid=$!
|
||||||
log-info "Running ansible-playbook 'deploy_benchmarker.yml' with [$tags] tags and logging output to file [$ANSIBLE_LOG_FILE]"
|
log-info "Running ansible-playbook 'deploy_benchmarker.yml' with [$tags] tags and logging output to file [$ANSIBLE_LOG_FILE]"
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -15,7 +15,7 @@ bold=$(tput bold)
|
|||||||
|
|
||||||
log-error() {
|
log-error() {
|
||||||
if [[ -z $2 ]]; then
|
if [[ -z $2 ]]; then
|
||||||
echo -e "${red}${bold}ERROR:${default}${red} $1${default}"
|
echo -e "ERROR: $1"
|
||||||
else
|
else
|
||||||
echo -e "${red}${bold}ERROR:${default}${red} $1${default}"
|
echo -e "${red}${bold}ERROR:${default}${red} $1${default}"
|
||||||
echo -e "${red}${bold}ERROR:${default}${red} $1${default}" >> "$BENCHMARK_LOG_FILE"
|
echo -e "${red}${bold}ERROR:${default}${red} $1${default}" >> "$BENCHMARK_LOG_FILE"
|
||||||
@@ -24,7 +24,7 @@ log-error() {
|
|||||||
|
|
||||||
log-warn() {
|
log-warn() {
|
||||||
if [[ -z $2 ]]; then
|
if [[ -z $2 ]]; then
|
||||||
echo -e "${gold}${bold}WARN:${default}${gold} $1${default}"
|
echo -e "WARN: $1"
|
||||||
else
|
else
|
||||||
echo -e "${gold}${bold}WARN:${default}${gold} $1${default}"
|
echo -e "${gold}${bold}WARN:${default}${gold} $1${default}"
|
||||||
echo -e "${gold}${bold}WARN:${default}${gold} $1${default}" >> "$BENCHMARK_LOG_FILE"
|
echo -e "${gold}${bold}WARN:${default}${gold} $1${default}" >> "$BENCHMARK_LOG_FILE"
|
||||||
@@ -33,7 +33,7 @@ log-warn() {
|
|||||||
|
|
||||||
log-info() {
|
log-info() {
|
||||||
if [[ -z $2 ]]; then
|
if [[ -z $2 ]]; then
|
||||||
echo -e "${cyan}${bold}INFO:${default}${cyan} $1${default}"
|
echo -e "INFO: $1"
|
||||||
else
|
else
|
||||||
echo -e "${cyan}${bold}INFO:${default}${cyan} $1${default}"
|
echo -e "${cyan}${bold}INFO:${default}${cyan} $1${default}"
|
||||||
echo -e "${cyan}${bold}INFO:${default}${cyan} $1${default}" >> "$BENCHMARK_LOG_FILE"
|
echo -e "${cyan}${bold}INFO:${default}${cyan} $1${default}" >> "$BENCHMARK_LOG_FILE"
|
||||||
|
|||||||
@@ -105,10 +105,8 @@ parse-arguments() {
|
|||||||
show-properties() {
|
show-properties() {
|
||||||
log-info "Using the following settings to randomly populate the DynamoDB benchmarking table:"
|
log-info "Using the following settings to randomly populate the DynamoDB benchmarking table:"
|
||||||
cat <<-EOF
|
cat <<-EOF
|
||||||
${cyan}
|
|
||||||
ATTRIBUTES=$ATTRIBUTES
|
ATTRIBUTES=$ATTRIBUTES
|
||||||
TABLE_NAME=$TABLE_NAME
|
TABLE_NAME=$TABLE_NAME
|
||||||
${default}
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,3 +176,5 @@ while [[ $items_written -lt $ITEMS ]]; do
|
|||||||
log-info "Sleeping for 2 seconds to avoid the partition throughput limits..."
|
log-info "Sleeping for 2 seconds to avoid the partition throughput limits..."
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo -e "\n\n\nSuccessfully wrote $items_written randomly generated items to DynamoDB!"
|
||||||
|
|||||||
+5
-1
@@ -1,9 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
TERMINAL_HEIGHT=$(tput lines)
|
TERMINAL_HEIGHT=$(tput lines)
|
||||||
BOX_HEIGHT=$(printf "%.0f" "$(echo "scale=2; $TERMINAL_HEIGHT * .5" | bc)")
|
BOX_HEIGHT=$(printf "%.0f" "$(echo "scale=2; $TERMINAL_HEIGHT * .5" | bc)")
|
||||||
|
CHECKBOX_HEIGHT=$(printf "%.0f" "$(echo "scale=2; $TERMINAL_HEIGHT * .5" | bc)")
|
||||||
|
TAIL_BOX_HEIGHT=$(printf "%.0f" "$(echo "scale=2; $TERMINAL_HEIGHT * .8" | bc)")
|
||||||
|
|
||||||
TERMINAL_WIDTH=$(tput cols)
|
TERMINAL_WIDTH=$(tput cols)
|
||||||
BOX_WIDTH=$(printf "%.0f" "$(echo "scale=2; $TERMINAL_WIDTH * .75" | bc)")
|
BOX_WIDTH=$(printf "%.0f" "$(echo "scale=2; $TERMINAL_WIDTH * .75" | bc)")
|
||||||
|
CHECKBOX_WIDTH=$(printf "%.0f" "$(echo "scale=2; $TERMINAL_WIDTH * .5" | bc)")
|
||||||
|
TAIL_BOX_WIDTH=$(printf "%.0f" "$(echo "scale=2; $TERMINAL_WIDTH * .85" | bc)")
|
||||||
|
|
||||||
msg-box() {
|
msg-box() {
|
||||||
whiptail --fb --msgbox "$1" "$BOX_HEIGHT" "$BOX_WIDTH"
|
whiptail --fb --msgbox "$1" "$BOX_HEIGHT" "$BOX_WIDTH"
|
||||||
@@ -20,7 +24,7 @@ show-tail-box() {
|
|||||||
trap "kill $2 2> /dev/null" EXIT
|
trap "kill $2 2> /dev/null" EXIT
|
||||||
|
|
||||||
while kill -0 "$2" 2> /dev/null; do
|
while kill -0 "$2" 2> /dev/null; do
|
||||||
dialog --title "$1" --exit-label "Finished" --tailbox "$3" "$BOX_HEIGHT" "$BOX_WIDTH"
|
dialog --title "$1" --exit-label "Finished" --tailbox "$3" "$TAIL_BOX_HEIGHT" "$TAIL_BOX_WIDTH"
|
||||||
done
|
done
|
||||||
|
|
||||||
clear
|
clear
|
||||||
|
|||||||
Reference in New Issue
Block a user