Skip to content

Commit

Permalink
Add reboot test.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvalinrh committed Jul 13, 2022
0 parents commit dde3502
Show file tree
Hide file tree
Showing 3 changed files with 285 additions and 0 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# reboot_measurement

reboot the system, get how long it took for the reboot to happen, as well as pull the
systemd information


Several files required to run
ansible_vars.yml
ansible_test_group
ignore.yml

Files content/format
ansible_vars.yml

---
config_info:
test_user: <user logging in as>
ssh_key: <full path to the ssh key to use>
user_parent: <parent directory of the users home directory>


ansible_test_group

---
test_group_list:
- <host name>

ignore.yml (dummy file to keep ansible happy)

---
ignore:
ignore: 0


114 changes: 114 additions & 0 deletions reboot_measurement/reboot_measure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
---
#
# Several files required to run
# ansible_vars.yml
# ansible_test_group
# ignore.yml
#
# Files content/format
# ansible_vars.yml
#
# ---
# config_info:
# test_user: <user logging in as>
# ssh_key: <full path to the ssh key to use>
# user_parent: <parent directory of the users home directory>
#
# ansible_test_group
#
# ---
# test_group_list:
# - <host name>
#
# ignore.yml (dummy file to keep ansible happy)
#
# ---
# ignore:
# ignore: 0


- hosts: local
vars_files:
- "{{ working_dir }}/ansible_vars.yml"
- [ "{{ working_dir }}/ansible_test_group", "{{ working_dir }}/ignore.yml" ]

tasks:
- name: include dynamic variables
include_vars:
file: "{{ working_dir }}/ansible_run_vars.yml"
name: dyn_data

#
# From the ansible_test_group file read in the hosts, ssh_key and user and
# build the list of hosts. Note, that the ssh_key needs to be set in the config
# file..
# zathras will default to the users ssh key value if none is provided.
# Format of the file:
#
# Once the list is built, we need to do a login to avoid ansible runnning into a
# login prompt.
#
- name: assign test hosts
add_host:
name: "{{ test_hostname }}"
groups: test_group
ansible_user: "{{ config_info.test_user }}"
ansible_ssh_private_key_file: "{{ config_info.ssh_key }}"
loop: "{{ test_group_list }}"
loop_control:
loop_var: test_hostname
- name: initial login to test hosts
command: "ssh -oStrictHostKeyChecking=no {{ dyn_data.ssh_i_option }} {{ config_info.test_user }}@{{ test_hostname }} \"cat /etc/passwd > /dev/null\""
loop: "{{ test_group_list }}"
loop_control:
loop_var: test_hostname
- name: make the results dir.
file:
path: "{{ working_dir }}/reboot_boot_info"
state: directory

#
# Perform the reboot measurement test.
#
- hosts: test_group
user: root
become: true
vars_files: "{{ working_dir }}/ansible_vars.yml"
gather_facts: no
tasks:

- name: grab reboot start time
command: "date -u +%s"
register: reboot_start

- name: Simply reboot the system
reboot:
reboot_timeout: 1800

- name: grab reboot end time
command: "date -u +%s"
register: reboot_end

- name: Report creation time
lineinfile:
path: "/tmp/reboot_boot_info/reboot_timings"
line: "reboot time: {{ (reboot_end.stdout) | int - (reboot_start.stdout) | int }}"
create: yes

- name: obtain reboot timings
shell: "{{ config_info.user_parent_home_dir }}/{{ config_info.test_user }}/tools_bin/gather_boot_info reboot"

- name: Move directory for iteration purpose.
shell: mv /tmp/reboot_boot_info /tmp/reboot_boot_info_{{ iteration }}

- name: Compress directory for retrival
archive:
path: /tmp/reboot_boot_info_{{ iteration }}
dest: /tmp/reboot_boot_info_{{ iteration }}.tgz

- name: archive data
fetch:
src: "/tmp/reboot_boot_info_{{ iteration }}.tgz"
dest: "{{ working_dir }}/reboot_boot_info/"
flat: yes

137 changes: 137 additions & 0 deletions reboot_measurement/run_reboot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
#!/bin/bash
#
# Define options
#
working_dir=`pwd`
iterations=1

usage()
{
echo "Usage: $0"
echo " --host_config: host configuration information"
echo " --home_parent: parent directory of the home directory"
echo " --iterations: number of iterations to run reboot test"
echo " --run_user: user running the test"
echo " --sysname: name of the system using"
echo " --sys_type: aws/azure/local...."
echo " --tuned_setting: system tuned using."
echo " --usage: this is usage message"
echo " --working_dir: Directory to run ansible from, default is current working directory"
echo " Three files are required by ansible, user has to create/provide."
echo " These files must be in the designated working directory"
echo " ansible_vars.yml"
echo " ansible_test_group"
echo " ignore.yml"
echo ""
echo " Files content/format"
echo " ansible_vars.yml"
echo ""
echo " ---"
echo " config_info:"
echo " test_user: <user logging in as>"
echo " ssh_key: <full path to the ssh key to use>"
echo " user_parent: <parent directory of the users home directory>"
echo ""
echo " ansible_test_group"
echo ""
echo " ---"
echo " test_group_list:"
echo " - <host name>"
echo " "
echo " ignore.yml (dummy file to keep ansible happy)"
echo ""
echo " ---"
echo " ignore:"
echo " ignore: 0"

exit
}

ARGUMENT_LIST=(
"host_config"
"home_parent"
"iterations"
"run_user"
"sysname"
"sys_type"
"tuned_setting"
"working_dir"
)

NO_ARGUMENTS=(
"usage"
)

# read arguments
opts=$(getopt \
--longoptions "$(printf "%s:," "${ARGUMENT_LIST[@]}")" \
--longoptions "$(printf "%s," "${NO_ARGUMENTS[@]}")" \
--name "$(basename "$0")" \
--options "h" \
-- "$@"
)

if [ $? -ne 0 ]; then
exit
fi

eval set --$opts

while [[ $# -gt 0 ]]; do
case "$1" in
--host_config)
config=`echo ${2} | cut -d'"' -f 2`
shift 2
;;
--home_parent)
home_root=${2}
shift 2
;;
--iterations)
iterations=${2}
shift 2
;;
--run_user)
user=${2}
shift 2
;;
--sys_type)
sys_type=${2}
shift 2
;;
--sysname)
sysname=${2}
shift 2
;;
--tuned_setting)
tuned_setting=${2}
shift 2
;;
--usage)
usage
;;
--working_dir)
working_dir=${2}
shift 2
;;
-h)
usage
;;
--)
break;
;;
*)
echo option not found $1
usage
;;
esac
done

#
# Execute the playbook for the reboot test.
#
cd $working_dir
for iteration in `seq 1 1 $iterations`
do
ansible-playbook -i ./inventory --extra-vars "working_dir=${working_dir} iteration=${iteration} ansible_python_interpreter=auto" ${working_dir}/workloads/reboot_me*/reboot_measurement/reboot_measure.yml
done

0 comments on commit dde3502

Please sign in to comment.