summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
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.sh.in52
-rw-r--r--tests/profile/benchmark-procfile-parser.c32
-rw-r--r--tests/profile/test-eval.c2
5 files changed, 100 insertions, 17 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index eb19512df..2a9b2105c 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 000000000..4b781d53e
--- /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.in b/tests/ebpf/ebpf_thread_function.sh.in
new file mode 100644
index 000000000..dd1e7b6ee
--- /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
+
diff --git a/tests/profile/benchmark-procfile-parser.c b/tests/profile/benchmark-procfile-parser.c
index 214ca9417..7302da547 100644
--- a/tests/profile/benchmark-procfile-parser.c
+++ b/tests/profile/benchmark-procfile-parser.c
@@ -17,29 +17,29 @@ extern size_t procfile_max_allocation;
static inline void pflines_reset(pflines *fl) {
- // debug(D_PROCFILE, PF_PREFIX ": resetting lines");
+ // netdata_log_debug(D_PROCFILE, PF_PREFIX ": resetting lines");
fl->len = 0;
}
static inline void pflines_free(pflines *fl) {
- // debug(D_PROCFILE, PF_PREFIX ": freeing lines");
+ // netdata_log_debug(D_PROCFILE, PF_PREFIX ": freeing lines");
freez(fl);
}
static inline void pfwords_reset(pfwords *fw) {
- // debug(D_PROCFILE, PF_PREFIX ": resetting words");
+ // netdata_log_debug(D_PROCFILE, PF_PREFIX ": resetting words");
fw->len = 0;
}
static inline void pfwords_add(procfile *ff, char *str) {
- // debug(D_PROCFILE, PF_PREFIX ": adding word No %d: '%s'", fw->len, str);
+ // netdata_log_debug(D_PROCFILE, PF_PREFIX ": adding word No %d: '%s'", fw->len, str);
pfwords *fw = ff->words;
if(unlikely(fw->len == fw->size)) {
- // debug(D_PROCFILE, PF_PREFIX ": expanding words");
+ // netdata_log_debug(D_PROCFILE, PF_PREFIX ": expanding words");
ff->words = fw = reallocz(fw, sizeof(pfwords) + (fw->size + PFWORDS_INCREASE_STEP) * sizeof(char *));
fw->size += PFWORDS_INCREASE_STEP;
@@ -50,11 +50,11 @@ static inline void pfwords_add(procfile *ff, char *str) {
NEVERNULL
static inline size_t *pflines_add(procfile *ff) {
- // debug(D_PROCFILE, PF_PREFIX ": adding line %d at word %d", fl->len, first_word);
+ // netdata_log_debug(D_PROCFILE, PF_PREFIX ": adding line %d at word %d", fl->len, first_word);
pflines *fl = ff->lines;
if(unlikely(fl->len == fl->size)) {
- // debug(D_PROCFILE, PF_PREFIX ": expanding lines");
+ // netdata_log_debug(D_PROCFILE, PF_PREFIX ": expanding lines");
ff->lines = fl = reallocz(fl, sizeof(pflines) + (fl->size + PFLINES_INCREASE_STEP) * sizeof(ffline));
fl->size += PFLINES_INCREASE_STEP;
@@ -70,7 +70,7 @@ static inline size_t *pflines_add(procfile *ff) {
NOINLINE
static void procfile_parser(procfile *ff) {
- // debug(D_PROCFILE, PF_PREFIX ": Parsing file '%s'", ff->filename);
+ // netdata_log_debug(D_PROCFILE, PF_PREFIX ": Parsing file '%s'", ff->filename);
char *s = ff->data // our current position
, *e = &ff->data[ff->len] // the terminating null
@@ -115,7 +115,7 @@ static void procfile_parser(procfile *ff) {
(*line_words)++;
t = ++s;
- // debug(D_PROCFILE, PF_PREFIX ": ended line %d with %d words", l, ff->lines->lines[l].words);
+ // netdata_log_debug(D_PROCFILE, PF_PREFIX ": ended line %d with %d words", l, ff->lines->lines[l].words);
line_words = pflines_add(ff);
break;
@@ -190,7 +190,7 @@ static void procfile_parser(procfile *ff) {
procfile *procfile_readall1(procfile *ff) {
- // debug(D_PROCFILE, PF_PREFIX ": Reading file '%s'.", ff->filename);
+ // netdata_log_debug(D_PROCFILE, PF_PREFIX ": Reading file '%s'.", ff->filename);
ff->len = 0; // zero the used size
ssize_t r = 1; // read at least once
@@ -199,15 +199,15 @@ procfile *procfile_readall1(procfile *ff) {
ssize_t x = ff->size - s;
if(unlikely(!x)) {
- debug(D_PROCFILE, PF_PREFIX ": Expanding data buffer for file '%s'.", procfile_filename(ff));
+ netdata_log_debug(D_PROCFILE, PF_PREFIX ": Expanding data buffer for file '%s'.", procfile_filename(ff));
ff = reallocz(ff, sizeof(procfile) + ff->size + PROCFILE_INCREMENT_BUFFER);
ff->size += PROCFILE_INCREMENT_BUFFER;
}
- debug(D_PROCFILE, "Reading file '%s', from position %zd with length %zd", procfile_filename(ff), s, (ssize_t)(ff->size - s));
+ netdata_log_debug(D_PROCFILE, "Reading file '%s', from position %zd with length %zd", procfile_filename(ff), s, (ssize_t)(ff->size - s));
r = read(ff->fd, &ff->data[s], ff->size - s);
if(unlikely(r == -1)) {
- if(unlikely(!(ff->flags & PROCFILE_FLAG_NO_ERROR_ON_FILE_IO))) error(PF_PREFIX ": Cannot read from file '%s' on fd %d", procfile_filename(ff), ff->fd);
+ if(unlikely(!(ff->flags & PROCFILE_FLAG_NO_ERROR_ON_FILE_IO))) netdata_log_error(PF_PREFIX ": Cannot read from file '%s' on fd %d", procfile_filename(ff), ff->fd);
procfile_close(ff);
return NULL;
}
@@ -215,9 +215,9 @@ procfile *procfile_readall1(procfile *ff) {
ff->len += r;
}
- // debug(D_PROCFILE, "Rewinding file '%s'", ff->filename);
+ // netdata_log_debug(D_PROCFILE, "Rewinding file '%s'", ff->filename);
if(unlikely(lseek(ff->fd, 0, SEEK_SET) == -1)) {
- if(unlikely(!(ff->flags & PROCFILE_FLAG_NO_ERROR_ON_FILE_IO))) error(PF_PREFIX ": Cannot rewind on file '%s'.", procfile_filename(ff));
+ if(unlikely(!(ff->flags & PROCFILE_FLAG_NO_ERROR_ON_FILE_IO))) netdata_log_error(PF_PREFIX ": Cannot rewind on file '%s'.", procfile_filename(ff));
procfile_close(ff);
return NULL;
}
@@ -232,7 +232,7 @@ procfile *procfile_readall1(procfile *ff) {
if(unlikely(ff->words->len > procfile_max_words)) procfile_max_words = ff->words->len;
}
- // debug(D_PROCFILE, "File '%s' updated.", ff->filename);
+ // netdata_log_debug(D_PROCFILE, "File '%s' updated.", ff->filename);
return ff;
}
diff --git a/tests/profile/test-eval.c b/tests/profile/test-eval.c
index 3c463166d..17836f6e9 100644
--- a/tests/profile/test-eval.c
+++ b/tests/profile/test-eval.c
@@ -231,7 +231,7 @@ NETDATA_DOUBLE evaluate(EVAL_NODE *op, int depth) {
break;
default:
- error("I don't know how to handle operator '%c'", op->operator);
+ netdata_log_error("I don't know how to handle operator '%c'", op->operator);
r = 0;
break;
}