Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions rejuvenation/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/debian125.ova
/setup/virtualbox/*.ova
/setup/kvm/disks_kvm
.idea
233 changes: 163 additions & 70 deletions rejuvenation/run
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 <integer> minutes] [-m <integer> 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=<value> (number workload cycles)

parameters:
[-t -f -s -ssh -e -w]

usages:
-t | --time [<integer> hours]
-f | --force [forced reboot]
-s | --soft [soft reboot]
-ssh | --ssh [ssh reboot]
-e | --enable [enable workload lifecycle]
-w=<value> | --work_cycle=<value> [<integer> 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
Expand All @@ -117,32 +106,136 @@ 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

machine_resources_monitoring/run "$VIRTUALIZER_TYPE" &
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 ))"
SLEEPING 12 h # 12 h wait

WORKLOAD "$VIRTUALIZER_TYPE"

SLEEPING 3 d # 3 days estress
echo "killing pid workload: $workload_process_pid"
kill -9 "$workload_process_pid"

(( i+=1 ))
done

SLEEPING 12 h # 12 h wait
}


if [[ "$1" =~ ^((-{1,2})([Hh]$|[Hh][Ee][Ll][Pp])|)$ ]]; then
PRINT_USAGE
exit 0

else
while [[ $# -gt 0 ]]; do
opt="$1"

case "$opt" in
"-t" | "--time")
shift
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

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"
WORKLOAD "$VIRTUALIZER_TYPE"
SLEEPING "$minutes" h

echo "killing pid workload: $workload_process_pid"
kill -9 "$workload_process_pid"
fi

REBOOT_VM
done
4 changes: 4 additions & 0 deletions rejuvenation/setup/virtualbox/dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ INSTALL_DEPENDENCIES() {
}

INSTALL_DEPENDENCIES

sudo rm /usr/bin/vboxmanage

sudo ln -s /usr/lib/virtualbox/VBoxManage /usr/bin/vboxmanage
2 changes: 1 addition & 1 deletion rejuvenation/setup/virtualbox/setupVm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
28 changes: 28 additions & 0 deletions rejuvenation/utils/time/sleeping.sh
Original file line number Diff line number Diff line change
@@ -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"
}
20 changes: 18 additions & 2 deletions rejuvenation/virtualizer_functions/vbox_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -188,4 +189,19 @@ ATTACH_DISK() {
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"
}