mirror of
https://github.com/clearlinux/cloud-native-setup.git
synced 2026-08-19 05:27:26 +00:00
metrics: enable cpu-load ability across tests
Rejig the framework a little to unify the init/shutdown calls and code, which allows us to add the cpu-load enable/disable ability to all the existing metrics. Signed-off-by: Graham Whaley <graham.whaley@intel.com>
This commit is contained in:
committed by
Obed N Munoz
parent
c846e9753d
commit
952e037420
@@ -25,8 +25,6 @@ init_stats() {
|
||||
}
|
||||
|
||||
cleanup_stats() {
|
||||
local delete_wait_time=$1
|
||||
|
||||
# attempting to provide buffer for collectd CPU collection to record adequate history
|
||||
sleep 6
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ RESULT_DIR="${LIB_DIR}/../results"
|
||||
|
||||
source ${LIB_DIR}/json.bash
|
||||
source ${LIB_DIR}/k8s-api.bash
|
||||
source ${LIB_DIR}/cpu-load.bash
|
||||
source /etc/os-release || source /usr/lib/os-release
|
||||
|
||||
die() {
|
||||
@@ -67,6 +68,46 @@ init_env()
|
||||
# been deliberately injected into the cluster under test.
|
||||
}
|
||||
|
||||
framework_init() {
|
||||
info "Initialising"
|
||||
|
||||
check_cmds "${cmds[@]}"
|
||||
|
||||
info "Checking k8s accessible"
|
||||
local worked=$( kubectl get nodes > /dev/null 2>&1 && echo $? || echo $? )
|
||||
if [ "$worked" != 0 ]; then
|
||||
die "kubectl failed to get nodes"
|
||||
fi
|
||||
|
||||
info $(get_num_nodes) "k8s nodes in 'Ready' state found"
|
||||
|
||||
k8s_api_init
|
||||
|
||||
# Launch our stats gathering pod
|
||||
if [ -n "$SMF_USE_COLLECTD" ]; then
|
||||
info "Setting up collectd"
|
||||
init_stats $wait_time
|
||||
fi
|
||||
|
||||
# Initialise the cpu load generators
|
||||
cpu_load_init
|
||||
|
||||
# And now we can set up our results storage then...
|
||||
metrics_json_init "k8s"
|
||||
save_config
|
||||
}
|
||||
|
||||
framework_shutdown() {
|
||||
metrics_json_save
|
||||
k8s_api_shutdown
|
||||
cpu_load_shutdown
|
||||
|
||||
if [ -n "$SMF_USE_COLLECTD" ]; then
|
||||
cleanup_stats
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
# finds elements in $1 that are not in $2
|
||||
find_unique_pods() {
|
||||
local list_a=$1
|
||||
|
||||
@@ -126,7 +126,7 @@ init() {
|
||||
# a nice way to do it (unless you want to parse 'descibe nodes')
|
||||
# Have a read of https://github.com/kubernetes/kubernetes/issues/25353
|
||||
|
||||
k8s_api_init
|
||||
framework_init
|
||||
|
||||
# Ensure we pre-cache the container image etc.
|
||||
warmup
|
||||
@@ -218,11 +218,8 @@ cleanup() {
|
||||
|
||||
# First try to save any results we got
|
||||
metrics_json_end_array "BootResults"
|
||||
metrics_json_save
|
||||
|
||||
kill_deployment "${deployment}" "${LABEL}" "${LABELVALUE}" ${delete_wait_time}
|
||||
|
||||
k8s_api_shutdown
|
||||
framework_shutdown
|
||||
}
|
||||
|
||||
show_vars()
|
||||
|
||||
@@ -209,7 +209,7 @@ init() {
|
||||
# FIXME - check the node(s) can run enough pods - check 'max-pods' in the
|
||||
# kubelet config - from 'kubectl describe node -o json' ?
|
||||
|
||||
k8s_api_init
|
||||
framework_init
|
||||
|
||||
# Launch our stats gathering pod
|
||||
kubectl apply -f ${SCRIPT_PATH}/${stats_pod}.yaml
|
||||
@@ -347,9 +347,7 @@ EOF
|
||||
)"
|
||||
|
||||
metrics_json_add_fragment "$json"
|
||||
metrics_json_save
|
||||
|
||||
k8s_api_shutdown
|
||||
framework_shutdown
|
||||
}
|
||||
|
||||
show_vars()
|
||||
|
||||
@@ -235,7 +235,7 @@ init() {
|
||||
# FIXME - check the node(s) can run enough pods - check 'max-pods' in the
|
||||
# kubelet config - from 'kubectl describe node -o json' ?
|
||||
|
||||
k8s_api_init
|
||||
framework_init
|
||||
|
||||
# Launch our stats gathering pod
|
||||
kubectl apply -f ${SCRIPT_PATH}/${stats_pod}.yaml
|
||||
@@ -410,9 +410,7 @@ EOF
|
||||
)"
|
||||
|
||||
metrics_json_add_fragment "$json"
|
||||
metrics_json_save
|
||||
|
||||
k8s_api_shutdown
|
||||
framework_shutdown
|
||||
}
|
||||
|
||||
show_vars()
|
||||
|
||||
@@ -15,6 +15,8 @@ source "${SCRIPT_PATH}/../collectd/collectd.bash"
|
||||
NUM_PODS=${NUM_PODS:-20}
|
||||
STEP=${STEP:-1}
|
||||
|
||||
SMF_USE_COLLECTD=true
|
||||
|
||||
LABELVALUE=${LABELVALUE:-gandalf}
|
||||
|
||||
pod_command="[\"tail\", \"-f\", \"/dev/null\"]"
|
||||
@@ -64,27 +66,7 @@ EOF
|
||||
}
|
||||
|
||||
init() {
|
||||
info "Initialising"
|
||||
|
||||
local cmds=("bc" "jq")
|
||||
check_cmds "${cmds[@]}"
|
||||
|
||||
info "Checking k8s accessible"
|
||||
local worked=$( kubectl get nodes > /dev/null 2>&1 && echo $? || echo $? )
|
||||
if [ "$worked" != 0 ]; then
|
||||
die "kubectl failed to get nodes"
|
||||
fi
|
||||
|
||||
info $(get_num_nodes) "k8s nodes in 'Ready' state found"
|
||||
|
||||
k8s_api_init
|
||||
|
||||
# Launch our stats gathering pod
|
||||
init_stats $wait_time
|
||||
|
||||
# And now we can set up our results storage then...
|
||||
metrics_json_init "k8s"
|
||||
save_config
|
||||
framework_init
|
||||
}
|
||||
|
||||
save_config(){
|
||||
@@ -198,11 +180,7 @@ EOF
|
||||
)"
|
||||
|
||||
metrics_json_add_fragment "$json"
|
||||
metrics_json_save
|
||||
|
||||
cleanup_stats $delete_wait_time
|
||||
|
||||
k8s_api_shutdown
|
||||
framework_shutdown
|
||||
}
|
||||
|
||||
show_vars()
|
||||
|
||||
Reference in New Issue
Block a user