This repository has been archived by the owner on Jun 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 196
/
stressng.sh
executable file
·59 lines (46 loc) · 1.95 KB
/
stressng.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
#
# Copyright (c) 2023 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
set -o pipefail
# General env
SCRIPT_PATH=$(dirname "$(readlink -f "$0")")
source "${SCRIPT_PATH}/../metrics/lib/common.bash"
PAYLOAD_ARGS="${PAYLOAD_ARGS:-tail -f /dev/null}"
DOCKERFILE="${SCRIPT_PATH}/stressng_dockerfile/Dockerfile"
IMAGE="docker.io/library/local-stressng:latest"
CONTAINER_NAME="${CONTAINER_NAME:-stressng_test}"
function main() {
local cmds=("docker")
init_env
check_cmds "${cmds[@]}"
check_ctr_images "${IMAGE}" "${DOCKERFILE}"
sudo -E ctr run -d --runtime "${CTR_RUNTIME}" "${IMAGE}" "${CONTAINER_NAME}" sh -c "${PAYLOAD_ARGS}"
# Run 1 iomix stressor (mix of I/O operations) for 20 seconds with verbose output
info "Running iomix stressor test"
IOMIX_CMD="stress-ng --iomix 1 -t 20 -v"
sudo -E ctr t exec --exec-id 1 "${CONTAINER_NAME}" sh -c "${IOMIX_CMD}"
# Run cpu stressors and virtual memory stressors for 5 minutes
info "Running memory stressors for 5 minutes"
MEMORY_CMD="stress-ng --cpu 2 --vm 4 -t 5m"
sudo -E ctr t exec --exec-id 2 "${CONTAINER_NAME}" sh -c "${MEMORY_CMD}"
# Run shared memory stressors
info "Running 8 shared memory stressors"
SHARED_CMD="stress-ng --shm 0"
sudo -E ctr t exec --exec-id 3 "${CONTAINER_NAME}" sh -c "${SHARED_CMD}"
# Run all stressors one by one on all CPUs
info "Running all stressors one by one"
STRESSORS_CMD="stress-ng --seq 0 -t 10 --tz -v"
sudo -E ctr t exec --exec-id 4 "${CONTAINER_NAME}" sh -c "${STRESSORS_CMD}"
# Test floating point on CPU for 60 seconds
info "Running floating tests on CPU"
FLOAT_CMD="stress-ng --matrix 1 -t 1m"
sudo -E ctr t exec --exec-id 5 "${CONTAINER_NAME}" sh -c "${FLOAT_CMD}"
# Runs two instances of the CPU stressors, one instance of the matrix
info "Running instances of the CPU stressors"
INSTANCE_CMD='stress-ng --cpu 2 --matrix 1 --mq 3 -t 5m'
sudo -E ctr t exec --exec-id 6 "${CONTAINER_NAME}" sh -c "${INSTANCE_CMD}"
clean_env_ctr
}
main "$@"