summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorthiagoftsm <thiagoftsm@gmail.com>2023-07-12 16:49:48 +0000
committerGitHub <noreply@github.com>2023-07-12 16:49:48 +0000
commit929b19f485b7100d8caa322abb0987afd01b3883 (patch)
tree578e1a52e1f09b109e5bf775c86fac9f84fc1e76 /tests
parent83272d4903522d4a10535e96f4e3b7f869653137 (diff)
eBPF Functions (enable/disable threads) (#15214)
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am3
-rw-r--r--tests/ebpf/ebpf.d.conf28
-rw-r--r--tests/ebpf/ebpf_thread_function.sh52
-rw-r--r--tests/ebpf/ebpf_thread_function.sh.in52
4 files changed, 135 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index eb19512df9..2a9b2105c6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -9,6 +9,7 @@ CLEANFILES = \
$(srcdir)/urls/request.sh \
$(srcdir)/alarm_repetition/alarm.sh \
$(srcdir)/template_dimension/template_dim.sh \
+ $(srcdir)/ebpf/ebpf_thread_function.sh \
$(NULL)
include $(top_srcdir)/build/subst.inc
@@ -20,6 +21,7 @@ dist_noinst_DATA = \
$(srcdir)/urls/request.sh.in \
$(srcdir)/alarm_repetition/alarm.sh.in \
$(srcdir)/template_dimension/template_dim.sh.in \
+ $(srcdir)/ebpf/ebpf_thread_function.sh.in \
$(NULL)
dist_plugins_SCRIPTS = \
@@ -28,6 +30,7 @@ dist_plugins_SCRIPTS = \
$(srcdir)/urls/request.sh \
$(srcdir)/alarm_repetition/alarm.sh \
$(srcdir)/template_dimension/template_dim.sh \
+ $(srcdir)/ebpf/ebpf_thread_function.sh \
$(NULL)
dist_noinst_SCRIPTS = \
diff --git a/tests/ebpf/ebpf.d.conf b/tests/ebpf/ebpf.d.conf
new file mode 100644
index 0000000000..4b781d53e3
--- /dev/null
+++ b/tests/ebpf/ebpf.d.conf
@@ -0,0 +1,28 @@
+[global]
+ ebpf load mode = entry
+ apps = yes
+ cgroups = no
+ update every = 5
+ pid table size = 32768
+ btf path = /sys/kernel/btf/
+ maps per core = yes
+ life time = 300
+
+[ebpf programs]
+ cachestat = no
+ dcstat = no
+ disk = no
+ fd = no
+ filesystem = no
+ hardirq = no
+ mdflush = no
+ mount = no
+ oomkill = no
+ process = no
+ shm = no
+ socket = no
+ softirq = no
+ sync = no
+ swap = no
+ vfs = no
+ network connections = no
diff --git a/tests/ebpf/ebpf_thread_function.sh b/tests/ebpf/ebpf_thread_function.sh
new file mode 100644
index 0000000000..dd1e7b6ee0
--- /dev/null
+++ b/tests/ebpf/ebpf_thread_function.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+netdata_ebpf_test_functions() {
+ echo "QUERYING: ${1}"
+ curl -k -o /tmp/ebpf_netdata_test_functions.txt "${1}"
+ TEST=$?
+ if [ $TEST -ne 0 ]; then
+ echo "Cannot request run a for ${1}. See '/tmp/ebpf_netdata_test_functions.txt' for more details."
+ exit 1
+ fi
+
+ grep "${2}" /tmp/ebpf_netdata_test_functions.txt >/dev/null
+ TEST=$?
+ if [ $TEST -ne 0 ]; then
+ echo "Cannot find ${2} in the output. See '/tmp/ebpf_netdata_test_functions.txt' for more details.."
+ exit 1
+ fi
+
+ rm /tmp/ebpf_netdata_test_functions.txt
+}
+
+MURL="http://127.0.0.1:19999"
+INTERVAL=60
+
+if [ -n "$1" ]; then
+ MURL="$1"
+fi
+
+# Check function loaded
+netdata_ebpf_test_functions "${MURL}/api/v1/functions" "ebpf_thread"
+
+# Check function help
+netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20help" "allows user to control eBPF threads"
+
+#Test default request
+netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread" "columns"
+
+#Test thread requests . The mdflush is not enabled, because it is not present in all distributions by default.
+#Socket is not in the list, because it will have a complete refactory with next PR
+for THREAD in "cachestat" "dc" "disk" "fd" "filesystem" "hardirq" "mount" "oomkill" "process" "shm" "softirq" "sync" "swap" "vfs" ;
+do
+ echo "TESTING ${THREAD}"
+ netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20enable:${THREAD}:${INTERVAL}%20thread:${THREAD}"
+ sleep 17
+ netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20thread:${THREAD}" "running"
+ sleep 17
+ netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20disable:${THREAD}"
+ sleep 6
+ netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20thread:${THREAD}" "stopped"
+ sleep 6
+done
+
diff --git a/tests/ebpf/ebpf_thread_function.sh.in b/tests/ebpf/ebpf_thread_function.sh.in
new file mode 100644
index 0000000000..dd1e7b6ee0
--- /dev/null
+++ b/tests/ebpf/ebpf_thread_function.sh.in
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+netdata_ebpf_test_functions() {
+ echo "QUERYING: ${1}"
+ curl -k -o /tmp/ebpf_netdata_test_functions.txt "${1}"
+ TEST=$?
+ if [ $TEST -ne 0 ]; then
+ echo "Cannot request run a for ${1}. See '/tmp/ebpf_netdata_test_functions.txt' for more details."
+ exit 1
+ fi
+
+ grep "${2}" /tmp/ebpf_netdata_test_functions.txt >/dev/null
+ TEST=$?
+ if [ $TEST -ne 0 ]; then
+ echo "Cannot find ${2} in the output. See '/tmp/ebpf_netdata_test_functions.txt' for more details.."
+ exit 1
+ fi
+
+ rm /tmp/ebpf_netdata_test_functions.txt
+}
+
+MURL="http://127.0.0.1:19999"
+INTERVAL=60
+
+if [ -n "$1" ]; then
+ MURL="$1"
+fi
+
+# Check function loaded
+netdata_ebpf_test_functions "${MURL}/api/v1/functions" "ebpf_thread"
+
+# Check function help
+netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20help" "allows user to control eBPF threads"
+
+#Test default request
+netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread" "columns"
+
+#Test thread requests . The mdflush is not enabled, because it is not present in all distributions by default.
+#Socket is not in the list, because it will have a complete refactory with next PR
+for THREAD in "cachestat" "dc" "disk" "fd" "filesystem" "hardirq" "mount" "oomkill" "process" "shm" "softirq" "sync" "swap" "vfs" ;
+do
+ echo "TESTING ${THREAD}"
+ netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20enable:${THREAD}:${INTERVAL}%20thread:${THREAD}"
+ sleep 17
+ netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20thread:${THREAD}" "running"
+ sleep 17
+ netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20disable:${THREAD}"
+ sleep 6
+ netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20thread:${THREAD}" "stopped"
+ sleep 6
+done
+