mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-26 23:38:31 +00:00
Merge pull request #7527 from GabyCT/topic/latency
metrics: Add network latency test
This commit is contained in:
commit
7144acb2a5
@ -10,6 +10,7 @@ bandwidth, jitter, latency and parallel bandwidth.
|
|||||||
## Networking tests
|
## Networking tests
|
||||||
|
|
||||||
- `k8s-network-metrics-iperf3.sh` measures bandwidth which is the speed of the data transfer.
|
- `k8s-network-metrics-iperf3.sh` measures bandwidth which is the speed of the data transfer.
|
||||||
|
- `latency-network.sh` measures network latency.
|
||||||
|
|
||||||
## Running the tests
|
## Running the tests
|
||||||
|
|
||||||
|
17
tests/metrics/network/latency_kubernetes/latency-client.yaml
Normal file
17
tests/metrics/network/latency_kubernetes/latency-client.yaml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# Copyright (c) 2022-2023 Intel Corporation
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
name: latency-client
|
||||||
|
spec:
|
||||||
|
terminationGracePeriodSeconds: 0
|
||||||
|
runtimeClassName: kata
|
||||||
|
containers:
|
||||||
|
- name: client-container
|
||||||
|
image: quay.io/prometheus/busybox:latest
|
||||||
|
command:
|
||||||
|
- sleep
|
||||||
|
- "180"
|
85
tests/metrics/network/latency_kubernetes/latency-network.sh
Executable file
85
tests/metrics/network/latency_kubernetes/latency-network.sh
Executable file
@ -0,0 +1,85 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Copyright (c) 2022 Intel Corporation
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
SCRIPT_PATH=$(dirname "$(readlink -f "$0")")
|
||||||
|
|
||||||
|
source "${SCRIPT_PATH}/../../lib/common.bash"
|
||||||
|
latency_file=$(mktemp latencyresults.XXXXXXXXXX)
|
||||||
|
TEST_NAME="${TEST_NAME:-latency}"
|
||||||
|
|
||||||
|
function remove_tmp_file() {
|
||||||
|
rm -rf "${latency_file}"
|
||||||
|
}
|
||||||
|
|
||||||
|
trap remove_tmp_file EXIT
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
init_env
|
||||||
|
cmds=("bc" "jq")
|
||||||
|
check_cmds "${cmds[@]}"
|
||||||
|
|
||||||
|
# Check no processes are left behind
|
||||||
|
check_processes
|
||||||
|
|
||||||
|
wait_time=20
|
||||||
|
sleep_time=2
|
||||||
|
|
||||||
|
# Create server
|
||||||
|
kubectl create -f "${SCRIPT_PATH}/runtimeclass_workloads/latency-server.yaml"
|
||||||
|
|
||||||
|
# Get the names of the server pod
|
||||||
|
export server_pod_name="latency-server"
|
||||||
|
|
||||||
|
# Verify the server pod is working
|
||||||
|
local cmd="kubectl get pod $server_pod_name -o yaml | grep 'phase: Running'"
|
||||||
|
waitForProcess "$wait_time" "$sleep_time" "$cmd"
|
||||||
|
|
||||||
|
# Create client
|
||||||
|
kubectl create -f "${SCRIPT_PATH}/runtimeclass_workloads/latency-client.yaml"
|
||||||
|
|
||||||
|
# Get the names of the client pod
|
||||||
|
export client_pod_name="latency-client"
|
||||||
|
|
||||||
|
# Verify the client pod is working
|
||||||
|
local cmd="kubectl get pod $client_pod_name -o yaml | grep 'phase: Running'"
|
||||||
|
waitForProcess "$wait_time" "$sleep_time" "$cmd"
|
||||||
|
|
||||||
|
# Get the ip address of the server pod
|
||||||
|
export server_ip_add=$(kubectl get pod "$server_pod_name" -o jsonpath='{.status.podIP}')
|
||||||
|
|
||||||
|
# Number of packets (sent)
|
||||||
|
local number="${number:-30}"
|
||||||
|
|
||||||
|
local client_command="ping -c ${number} ${server_ip_add}"
|
||||||
|
|
||||||
|
kubectl exec "$client_pod_name" -- sh -c "$client_command" > "$latency_file"
|
||||||
|
|
||||||
|
metrics_json_init
|
||||||
|
|
||||||
|
local latency=$(cat $latency_file | grep avg | cut -f2 -d'=' | sed 's/[[:blank:]]//g' | cut -f2 -d'/')
|
||||||
|
|
||||||
|
metrics_json_start_array
|
||||||
|
|
||||||
|
local json="$(cat << EOF
|
||||||
|
{
|
||||||
|
"latency": {
|
||||||
|
"Result" : $latency,
|
||||||
|
"Units" : "ms"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
)"
|
||||||
|
|
||||||
|
metrics_json_add_array_element "$json"
|
||||||
|
metrics_json_end_array "Results"
|
||||||
|
metrics_json_save
|
||||||
|
|
||||||
|
kubectl delete pod "$client_pod_name" "$server_pod_name"
|
||||||
|
check_processes
|
||||||
|
}
|
||||||
|
main "$@"
|
18
tests/metrics/network/latency_kubernetes/latency-server.yaml
Normal file
18
tests/metrics/network/latency_kubernetes/latency-server.yaml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2022-2023 Intel Corporation
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
name: latency-server
|
||||||
|
spec:
|
||||||
|
terminationGracePeriodSeconds: 0
|
||||||
|
runtimeClassName: kata
|
||||||
|
containers:
|
||||||
|
- name: server-container
|
||||||
|
image: quay.io/prometheus/busybox:latest
|
||||||
|
command:
|
||||||
|
- sleep
|
||||||
|
- "180"
|
Loading…
Reference in New Issue
Block a user