master
in 52 lines 1.83 KB
Raw
1 #!/bin/bash
2
3 netdata_ebpf_test_functions() {
4 echo "QUERYING: ${1}"
5 curl -k -o /tmp/ebpf_netdata_test_functions.txt "${1}"
6 TEST=$?
7 if [ $TEST -ne 0 ]; then
8 echo "Cannot request run a for ${1}. See '/tmp/ebpf_netdata_test_functions.txt' for more details."
9 exit 1
10 fi
11
12 grep "${2}" /tmp/ebpf_netdata_test_functions.txt >/dev/null
13 TEST=$?
14 if [ $TEST -ne 0 ]; then
15 echo "Cannot find ${2} in the output. See '/tmp/ebpf_netdata_test_functions.txt' for more details.."
16 exit 1
17 fi
18
19 rm /tmp/ebpf_netdata_test_functions.txt
20 }
21
22 MURL="http://127.0.0.1:19999"
23 INTERVAL=60
24
25 if [ -n "$1" ]; then
26 MURL="$1"
27 fi
28
29 # Check function loaded
30 netdata_ebpf_test_functions "${MURL}/api/v1/functions" "ebpf_thread"
31
32 # Check function help
33 netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20help" "allows user to control eBPF threads"
34
35 #Test default request
36 netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread" "columns"
37
38 #Test thread requests . The mdflush is not enabled, because it is not present in all distributions by default.
39 #Socket is not in the list, because it will have a complete refactory with next PR
40 for THREAD in "cachestat" "dc" "disk" "fd" "filesystem" "hardirq" "mount" "oomkill" "process" "shm" "softirq" "sync" "swap" "vfs" ;
41 do
42 echo "TESTING ${THREAD}"
43 netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20enable:${THREAD}:${INTERVAL}%20thread:${THREAD}"
44 sleep 17
45 netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20thread:${THREAD}" "running"
46 sleep 17
47 netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20disable:${THREAD}"
48 sleep 6
49 netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20thread:${THREAD}" "stopped"
50 sleep 6
51 done
52