From: Michael Tremer Date: Sat, 4 Oct 2025 16:02:09 +0000 (+0000) Subject: sources: Add a test that stalls the event loop X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d1d47f6b480d8b71c71ccd1e89475a750d07f9c;p=telemetry.git sources: Add a test that stalls the event loop Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 56204ac..9a63a10 100644 --- a/Makefile.am +++ b/Makefile.am @@ -146,6 +146,8 @@ dist_collectyd_SOURCES = \ src/daemon/sources/test-error.h \ src/daemon/sources/test-flapping.c \ src/daemon/sources/test-flapping.h \ + src/daemon/sources/test-stall.c \ + src/daemon/sources/test-stall.h \ src/daemon/util.c \ src/daemon/util.h diff --git a/src/daemon/sources.c b/src/daemon/sources.c index 25d91db..309bc68 100644 --- a/src/daemon/sources.c +++ b/src/daemon/sources.c @@ -38,6 +38,7 @@ #include "sources/processor.h" #include "sources/test-error.h" #include "sources/test-flapping.h" +#include "sources/test-stall.h" // Register all sources static const collecty_source_impl* source_impls[] = { @@ -53,6 +54,7 @@ static const collecty_source_impl* source_impls[] = { // Tests &test_error_source, &test_flapping_source, + &test_stall_source, NULL, }; diff --git a/src/daemon/sources/test-stall.c b/src/daemon/sources/test-stall.c new file mode 100644 index 0000000..8c5c9bb --- /dev/null +++ b/src/daemon/sources/test-stall.c @@ -0,0 +1,39 @@ +/*############################################################################# +# # +# collecty - A system statistics collection daemon for IPFire # +# Copyright (C) 2025 IPFire Development Team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +#############################################################################*/ + +#include "../ctx.h" +#include "../source.h" +#include "test-stall.h" + +/* + This is a test stalls the event loop. +*/ + +static int test_stall_collect(collecty_ctx* ctx, collecty_source* source) { + // Sleep for 500ms + return usleep(500000); +} + +const collecty_source_impl test_stall_source = { + .name = "test-stall", + + // Methods + .collect = test_stall_collect, +}; diff --git a/src/daemon/sources/test-stall.h b/src/daemon/sources/test-stall.h new file mode 100644 index 0000000..6f3f314 --- /dev/null +++ b/src/daemon/sources/test-stall.h @@ -0,0 +1,28 @@ +/*############################################################################# +# # +# collecty - A system statistics collection daemon for IPFire # +# Copyright (C) 2025 IPFire Development Team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +#############################################################################*/ + +#ifndef COLLECTY_SOURCE_TEST_STALL_H +#define COLLECTY_SOURCE_TEST_STALL_H + +#include "../source.h" + +extern const collecty_source_impl test_stall_source; + +#endif /* COLLECTY_SOURCE_TEST_STALL_H */