From ba641620c5ec0b869b9fb8d2c7314645b57f5a8b Mon Sep 17 00:00:00 2001 From: thayson Date: Fri, 14 Jun 2024 21:15:15 -0300 Subject: [PATCH 1/8] add - stress --- rejuvenation/.gitignore | 2 +- rejuvenation/run | 228 ++++++++++++------ rejuvenation/setup/virtualbox/dependencies.sh | 4 + rejuvenation/setup/virtualbox/setupVm.sh | 2 +- rejuvenation/utils/time/sleeping.sh | 28 +++ .../virtualizer_functions/vbox_functions.sh | 7 +- 6 files changed, 196 insertions(+), 75 deletions(-) create mode 100644 rejuvenation/utils/time/sleeping.sh diff --git a/rejuvenation/.gitignore b/rejuvenation/.gitignore index 57ba096..d5e8f5d 100644 --- a/rejuvenation/.gitignore +++ b/rejuvenation/.gitignore @@ -3,6 +3,6 @@ /machine_resources_monitoring/response_times.csv /setup/virtualbox/disks /setup/virtualbox/vmDebian.ova -/setup/virtualbox/debian125.ova +/setup/virtualbox/debian*.ova /setup/kvm/disks_kvm .idea \ No newline at end of file diff --git a/rejuvenation/run b/rejuvenation/run index 3a02c81..9d77d4c 100755 --- a/rejuvenation/run +++ b/rejuvenation/run @@ -12,31 +12,40 @@ # STATIC USAGE: # vbox | kvm | xen | lxc -readonly VIRTUALIZER_TYPE="xen" +readonly VIRTUALIZER_TYPE="vbox" -# ############################## IMPORTS ############################# +# ####################################### IMPORTS ############################################# case "$VIRTUALIZER_TYPE" in "vbox") # shellcheck disable=SC1091 source ./virtualizer_functions/vbox_functions.sh + echo -e "\nusing virtualbox for testing\n" ;; "kvm") # shellcheck disable=SC1091 source ./virtualizer_functions/kvm_functions.sh + echo -e "\nusing kvm for testing\n" ;; "xen") # shellcheck disable=SC1091 source ./virtualizer_functions/xen_functions.sh + echo -e "\nusing xen for testing\n" ;; "lxc") echo "No information available for LXC at the moment" + echo -e "\nusing lxc for testing\n" exit 1 ;; *) echo "Unknown virtualizer type: $VIRTUALIZER_TYPE" + exit 1 ;; esac -# #################################################################### + +# UTILS +# shellcheck disable=SC1091 +source "utils/time/sleeping.sh" +# ############################################################################################ #Time method minutes=0 @@ -49,61 +58,41 @@ force=0 soft=0 ssh=0 +# enable workload lifecycle +enable=0 +work_cycle=0 + +# workload pid process +workload_process_pid=0 + # FUNCTION=PRINT_USAGE() # DESCRIPTION: # Displays the script's usage information, including available options and their descriptions (works as a helper menu) -function PRINT_USAGE() { - echo "script usage $(basename "$0") [-t minutes] [-m mb] [-f (forced reboot)] [-s (soft reboot)] [-ssh (ssh reboot)]" >&1 +PRINT_USAGE() { + echo -e "script usage example: + bash run.sh -t (time_for_reboot) -s (soft reboot) -e -w= (number workload cycles) + + parameters: + [-t -f -s -ssh -e -w] + + usages: + -t | --time [ minutes] + -f | --force [forced reboot] + -s | --soft [soft reboot] + -ssh | --ssh [ssh reboot] + -e | --enable [enable workload lifecycle] + -w= | --work_cycle= [ number workload cycles]" >&1 } -if [[ "$1" =~ ^((-{1,2})([Hh]$|[Hh][Ee][Ll][Pp])|)$ ]]; then - PRINT_USAGE - exit 0 -else - while [[ $# -gt 0 ]]; do - opt="$1" - shift - current_arg="$1" - if [[ "$current_arg" =~ ^-{1,2}.* ]]; then - echo "WARNING: You may have left an argument blank. Double-check your command." - exit 1 - fi - case "$opt" in - "-t" | "--time") - minutes=$1 - echo "Starting rejuvenation tests | The virtual machine will restart every $minutes minutes" - shift - ;; - "-f" | "--force") - force=1 - shift - ;; - "-s" | "--soft") - soft=1 - shift - ;; - "-ssh" | "--ssh") - ssh=1 - shift - ;; - "-h" | "--help") - PRINT_USAGE - exit 0 - ;; - *) - echo "ERROR: Invalid option: \"$opt\"" >&2 - PRINT_USAGE - exit 1 - ;; - esac - done -fi -function REBOOT_VM() { +REBOOT_VM() { ((reboot_count++)) + local current_time current_time=$(date "+%Y.%m.%d-%H.%M.%S") + echo "Rebooting VM $current_time - Reboot count: $reboot_count" + if [ "$soft" -eq 1 ]; then GRACEFUL_REBOOT fi @@ -117,32 +106,131 @@ function REBOOT_VM() { fi } -START_VM -case "$VIRTUALIZER_TYPE" in - "vbox") - bash workloads/vbox_workload.sh & - ;; - "kvm") - bash workloads/kvm_workload.sh & - ;; - "xen") - bash workloads/xen_workload.sh & - ;; - "lxc") - echo "No information available for LXC at the moment" - exit 1 - ;; - *) - echo "Unknown virtualizer type: $VIRTUALIZER_TYPE" - ;; -esac +WORKLOAD() { + local virtualizer=$1 + + case "$virtualizer" in + "vbox") + bash workloads/vbox_workload.sh & + workload_process_pid=$! + ;; + "kvm") + bash workloads/kvm_workload.sh & + workload_process_pid=$! + ;; + "xen") + bash workloads/xen_workload.sh & + workload_process_pid=$! + ;; + "lxc") + echo "No information available for LXC at the moment" + exit 1 + ;; + *) + echo "Unknown virtualizer type: $VIRTUALIZER_TYPE" + exit 1 + ;; + esac + + echo -e "workload pid is: $workload_process_pid\n" +} + +# FUNCTION=START_WORKLOAD() +# DESCRIPTION: +# start the workload lifecycle +# ATTENTION: +# Before starting a new load cycle, +# modify the two calls of the "SLEEPING" function +# to the desired stress waiting time +START_WORKLOAD() { + local i=0 + local qtt=$1 + + while [[ "$i" != "$qtt" ]]; do + echo "current load lifecycle: $(( i+1 ))" + WORKLOAD "$VIRTUALIZER_TYPE" + SLEEPING 1 h # 3 days + + echo "killing pid workload: $workload_process_pid" + + kill -9 "$workload_process_pid" + + SLEEPING 15 m # 12 hours + + (( i+=1 )) + done +} + + +if [[ "$1" =~ ^((-{1,2})([Hh]$|[Hh][Ee][Ll][Pp])|)$ ]]; then + PRINT_USAGE + exit 0 + +else + while [[ $# -gt 0 ]]; do + opt="$1" + shift + + case "$opt" in + "-t" | "--time") + minutes=$1 + echo "Starting rejuvenation tests | The virtual machine will restart every $minutes minutes" + shift + ;; + + "-f" | "--force") + force=1 + shift + ;; + + "-s" | "--soft") + soft=1 + shift + ;; + + "-ssh" | "--ssh") + ssh=1 + shift + ;; + + "-e" | "--enable") + enable=1 + shift + ;; + + -w=* | --work_cycle=*) + work_cycle="${opt#*=}" + shift + ;; + + "-h" | "--help") + PRINT_USAGE + exit 0 + ;; + + *) + echo "ERROR: Invalid option: \"$opt\"" >&2 + PRINT_USAGE + exit 1 + ;; + esac + done +fi -machine_resources_monitoring/run "$VIRTUALIZER_TYPE" & +START_VM + +bash machine_resources_monitoring/run "$VIRTUALIZER_TYPE" & while true; do - : - sleep "$minutes"m + if [[ "$enable" -eq 1 ]] && [[ "$work_cycle" != 0 ]]; then + echo -e "\nrunning test with workload lifecycle" + START_WORKLOAD "$work_cycle" # 4 cycles + + else + echo -e "\nrunning test without workload lifecycle" + SLEEPING "$minutes" m + fi REBOOT_VM done diff --git a/rejuvenation/setup/virtualbox/dependencies.sh b/rejuvenation/setup/virtualbox/dependencies.sh index 34cb981..71371da 100755 --- a/rejuvenation/setup/virtualbox/dependencies.sh +++ b/rejuvenation/setup/virtualbox/dependencies.sh @@ -48,3 +48,7 @@ INSTALL_DEPENDENCIES() { } INSTALL_DEPENDENCIES + +sudo rm /usr/bin/vboxmanage + +sudo ln -s /usr/lib/virtualbox/VBoxManage /usr/bin/vboxmanage diff --git a/rejuvenation/setup/virtualbox/setupVm.sh b/rejuvenation/setup/virtualbox/setupVm.sh index 51f15ae..b971ffa 100755 --- a/rejuvenation/setup/virtualbox/setupVm.sh +++ b/rejuvenation/setup/virtualbox/setupVm.sh @@ -60,7 +60,7 @@ DISKS_MANAGEMENT() { REMOVE_DISKS ERROR_HANDLING "ERROR REMOVING DISKS" 0 - CREATE_DISKS 50 10 + CREATE_DISKS 50 100 ERROR_HANDLING "ERROR CREATING DISKS" 0 } diff --git a/rejuvenation/utils/time/sleeping.sh b/rejuvenation/utils/time/sleeping.sh new file mode 100644 index 0000000..aa36b91 --- /dev/null +++ b/rejuvenation/utils/time/sleeping.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +SLEEPING() { + local dormir=$1 + local tipo_dormir=$2 + + case "$tipo_dormir" in + "s") + echo "dormindo por $dormir segundo(s)" + ;; + "m") + echo "dormindo por $dormir minuto(s)" + ;; + "h") + echo "dormindo por $dormir hora(s)" + ;; + "d") + echo "dormindo por $dormir dia(s)" + ;; + *) + echo -e "forneça unidade de tempo válida!\n" + echo -e "s - segundo\nm - minuto\nh - hora\nd - dia\n" + exit 1 + ;; + esac + + sleep "$dormir""$tipo_dormir" +} \ No newline at end of file diff --git a/rejuvenation/virtualizer_functions/vbox_functions.sh b/rejuvenation/virtualizer_functions/vbox_functions.sh index 201f5a4..615c67d 100755 --- a/rejuvenation/virtualizer_functions/vbox_functions.sh +++ b/rejuvenation/virtualizer_functions/vbox_functions.sh @@ -13,7 +13,8 @@ # GLOBAL VARIABLES: # VM_NAME="vmDebian" -VM_NAME="debian125" +#VM_NAME="debian125" +VM_NAME="debian125-pre-aloc" # FUNCTION=TURN_VM_OFF() # DESCRIPTION: @@ -76,7 +77,7 @@ CREATE_VM() { host_ip=$(hostname -I | awk '{print $1}') vboxmanage import "$VM_NAME".ova - vboxmanage modifyvm vmDebian --natpf1 "porta 8080,tcp,$host_ip,8080,,80" + vboxmanage modifyvm "$VM_NAME" --natpf1 "porta 8080,tcp,$host_ip,8080,,80" } # FUNCTION=CREATE_DISKS() @@ -188,4 +189,4 @@ ATTACH_DISK() { DETACH_DISK() { local port="$1" VBoxManage storageattach "$VM_NAME" --storagectl "SATA" --device 0 --port "$port" --type hdd --medium none -} \ No newline at end of file +} From 8d7ee0c10f7997f155c01aeb63da27f2ccc5618f Mon Sep 17 00:00:00 2001 From: ThaysonScript Date: Tue, 16 Jul 2024 15:49:36 -0300 Subject: [PATCH 2/8] fix - start workload lifecycle --- rejuvenation/run | 1 - 1 file changed, 1 deletion(-) diff --git a/rejuvenation/run b/rejuvenation/run index 9d77d4c..b530569 100755 --- a/rejuvenation/run +++ b/rejuvenation/run @@ -170,7 +170,6 @@ if [[ "$1" =~ ^((-{1,2})([Hh]$|[Hh][Ee][Ll][Pp])|)$ ]]; then else while [[ $# -gt 0 ]]; do opt="$1" - shift case "$opt" in "-t" | "--time") From df45688bb2048a70d65e03410c7a2fb7b9240881 Mon Sep 17 00:00:00 2001 From: ThaysonScript Date: Sat, 27 Jul 2024 12:02:21 -0300 Subject: [PATCH 3/8] time modified --- rejuvenation/run | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/rejuvenation/run b/rejuvenation/run index b530569..27fd118 100755 --- a/rejuvenation/run +++ b/rejuvenation/run @@ -149,20 +149,22 @@ START_WORKLOAD() { while [[ "$i" != "$qtt" ]]; do echo "current load lifecycle: $(( i+1 ))" + SLEEPING 12 h # 3 days - 12 h wait + WORKLOAD "$VIRTUALIZER_TYPE" - SLEEPING 1 h # 3 days + SLEEPING 3 d # 12 hours - 3 days estress echo "killing pid workload: $workload_process_pid" - kill -9 "$workload_process_pid" - SLEEPING 15 m # 12 hours - (( i+=1 )) done + + SLEEPING 12 h # 3 days - 12 h wait } + if [[ "$1" =~ ^((-{1,2})([Hh]$|[Hh][Ee][Ll][Pp])|)$ ]]; then PRINT_USAGE exit 0 From 41cb2b14b81f0815116ec43308fefcd9cfcbbcd9 Mon Sep 17 00:00:00 2001 From: ThaysonScript Date: Sat, 27 Jul 2024 12:03:28 -0300 Subject: [PATCH 4/8] add - experimental function for fixed disk vmdk --- .../virtualizer_functions/vbox_functions.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/rejuvenation/virtualizer_functions/vbox_functions.sh b/rejuvenation/virtualizer_functions/vbox_functions.sh index 615c67d..7ca6bf9 100755 --- a/rejuvenation/virtualizer_functions/vbox_functions.sh +++ b/rejuvenation/virtualizer_functions/vbox_functions.sh @@ -190,3 +190,18 @@ DETACH_DISK() { local port="$1" VBoxManage storageattach "$VM_NAME" --storagectl "SATA" --device 0 --port "$port" --type hdd --medium none } + +# EXPERIMENTALL FUNCTION +CLONE_DISK() { + rm -r /root/VirtualBox\ VMs/$VM_NAME/$VM_NAME-disk002* + + # - clonar disco vmdk: + VBoxManage clonemedium "/root/VirtualBox\ VMs/$VM_NAME/$VM_NAME-disk001.vmdk" "/root/VirtualBox\ VMs/$VM_NAME/$VM_NAME-disk002.vmdk" --format VMDK --variant Fixed + +# - remover disco dinâmico da vm e anexar o fixo: + VBoxManage storageattach "$VM_NAME" --storagectl "SATA" --port 0 --device 0 --medium none + VBoxManage storageattach "$VM_NAME" --storagectl "SATA" --port 0 --device 0 --type hdd --medium "/root/VirtualBox\ VMs/$VM_NAME/$VM_NAME-disk002.vmdk" + +# - apagar o disco dinâmico: + rm -r "/root/VirtualBox\ VMs/$VM_NAME/$VM_NAME-disk001.vmdk" +} \ No newline at end of file From e84e8a6ae820256b43b1d7de30087c5c697f73c7 Mon Sep 17 00:00:00 2001 From: ThaysonScript Date: Sat, 27 Jul 2024 15:14:12 -0300 Subject: [PATCH 5/8] update gitignore --- rejuvenation/.gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rejuvenation/.gitignore b/rejuvenation/.gitignore index d5e8f5d..0cbb097 100644 --- a/rejuvenation/.gitignore +++ b/rejuvenation/.gitignore @@ -2,7 +2,6 @@ /machine_resources_monitoring/reset_times.csv /machine_resources_monitoring/response_times.csv /setup/virtualbox/disks -/setup/virtualbox/vmDebian.ova -/setup/virtualbox/debian*.ova +/setup/virtualbox/*.ova /setup/kvm/disks_kvm .idea \ No newline at end of file From f56f876044d2f0dce901972d088de6a5c05cbadb Mon Sep 17 00:00:00 2001 From: ThaysonScript Date: Sat, 27 Jul 2024 15:15:41 -0300 Subject: [PATCH 6/8] fix - corrected stress load time --- rejuvenation/run | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/rejuvenation/run b/rejuvenation/run index 27fd118..c357ecd 100755 --- a/rejuvenation/run +++ b/rejuvenation/run @@ -149,22 +149,21 @@ START_WORKLOAD() { while [[ "$i" != "$qtt" ]]; do echo "current load lifecycle: $(( i+1 ))" - SLEEPING 12 h # 3 days - 12 h wait + SLEEPING 12 h # 12 h wait WORKLOAD "$VIRTUALIZER_TYPE" - SLEEPING 3 d # 12 hours - 3 days estress + SLEEPING 3 d # 3 days estress echo "killing pid workload: $workload_process_pid" kill -9 "$workload_process_pid" (( i+=1 )) done - SLEEPING 12 h # 3 days - 12 h wait + SLEEPING 12 h # 12 h wait } - if [[ "$1" =~ ^((-{1,2})([Hh]$|[Hh][Ee][Ll][Pp])|)$ ]]; then PRINT_USAGE exit 0 From bc3635e3608f9a9bc91385f70ed1ffe6793b9b4b Mon Sep 17 00:00:00 2001 From: ThaysonScript Date: Mon, 2 Sep 2024 00:12:17 -0300 Subject: [PATCH 7/8] fix - --time did not work; add - workload without running lifecycles --- rejuvenation/run | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rejuvenation/run b/rejuvenation/run index c357ecd..16a3a0c 100755 --- a/rejuvenation/run +++ b/rejuvenation/run @@ -174,6 +174,7 @@ else case "$opt" in "-t" | "--time") + shift minutes=$1 echo "Starting rejuvenation tests | The virtual machine will restart every $minutes minutes" shift @@ -229,7 +230,11 @@ while true; do else echo -e "\nrunning test without workload lifecycle" + WORKLOAD "$VIRTUALIZER_TYPE" SLEEPING "$minutes" m + + echo "killing pid workload: $workload_process_pid" + kill -9 "$workload_process_pid" fi REBOOT_VM From 5c13b7a59b458d5599ca1453bef051309846f752 Mon Sep 17 00:00:00 2001 From: ThaysonScript Date: Mon, 2 Sep 2024 00:14:23 -0300 Subject: [PATCH 8/8] replace m to h --- rejuvenation/run | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rejuvenation/run b/rejuvenation/run index 16a3a0c..e03eb2c 100755 --- a/rejuvenation/run +++ b/rejuvenation/run @@ -76,7 +76,7 @@ PRINT_USAGE() { [-t -f -s -ssh -e -w] usages: - -t | --time [ minutes] + -t | --time [ hours] -f | --force [forced reboot] -s | --soft [soft reboot] -ssh | --ssh [ssh reboot] @@ -231,7 +231,7 @@ while true; do else echo -e "\nrunning test without workload lifecycle" WORKLOAD "$VIRTUALIZER_TYPE" - SLEEPING "$minutes" m + SLEEPING "$minutes" h echo "killing pid workload: $workload_process_pid" kill -9 "$workload_process_pid"