* [pmg-devel] [PATCH pmg-api 0/3] enable building with sbuild, by refactoring tests
@ 2026-01-02 20:31 Stoiko Ivanov
2026-01-02 20:31 ` [pmg-devel] [PATCH pmg-api 1/3] tests: test_utils: do not rely on system timezone Stoiko Ivanov
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Stoiko Ivanov @ 2026-01-02 20:31 UTC (permalink / raw)
To: pmg-devel
Building pmg-api in sbuild is currently not possible, due to 2 issues:
* the format_date_header tests in test_util.pl implicitly assume a
CET/CEST timezone (patch 1/3)
* most other tests in pmg-api are integration-tests - they create postgres
databases, dump them, start services, and expect syslog to work.
this is changed by skipping the tests conditionally (with the condition
evaluating to true in an sbuild environment)
I considered reworking the tests on the database to output a stable text file
for comparison (the output of `pmgdb dump` would work), but the RuleDB
code is tightly coupled to writing to the database - changing that would
amount to a far larger refactoring of pmg-api. So instead leave the
default build calls most of us working with pmg-api as they are and skip
the tests in sbuild (or by setting an environment variable).
checking out autopkgtests for the other tests is probably a good idea -
but should not prevent us from having a working sbuild target for pmg-api.
Stoiko Ivanov (3):
tests: test_utils: do not rely on system timezone
tests: make test nature explicit
tests: conditionally skip integration tests
src/tests/Makefile | 32 +++++++++++++++++++-------------
src/tests/test_utils.pl | 5 ++++-
2 files changed, 23 insertions(+), 14 deletions(-)
--
2.47.3
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pmg-devel] [PATCH pmg-api 1/3] tests: test_utils: do not rely on system timezone
2026-01-02 20:31 [pmg-devel] [PATCH pmg-api 0/3] enable building with sbuild, by refactoring tests Stoiko Ivanov
@ 2026-01-02 20:31 ` Stoiko Ivanov
2026-01-02 20:32 ` [pmg-devel] [PATCH pmg-api 2/3] tests: make test nature explicit Stoiko Ivanov
2026-01-02 20:32 ` [pmg-devel] [PATCH pmg-api 3/3] tests: conditionally skip integration tests Stoiko Ivanov
2 siblings, 0 replies; 4+ messages in thread
From: Stoiko Ivanov @ 2026-01-02 20:31 UTC (permalink / raw)
To: pmg-devel
the tests for format_date_header inherently rely on a timezone being
set (as the date-format in mail-headers expects one).
running the test in a build-environment like sbuild, which has the
timezone set to UTC fails.
fix this by explicitly setting the timezone to 'Europe/Vienna'.
Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
src/tests/test_utils.pl | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/tests/test_utils.pl b/src/tests/test_utils.pl
index 8abcc8b7..ff856ebe 100755
--- a/src/tests/test_utils.pl
+++ b/src/tests/test_utils.pl
@@ -4,10 +4,13 @@ use strict;
use warnings;
use Test::More;
-use POSIX qw(setlocale strftime);
+use POSIX qw(setlocale strftime tzset);
use PMG::Utils;
+$ENV{TZ} = 'Europe/Vienna';
+tzset();
+
subtest 'format_date_header works' => sub {
cmp_ok(length(PMG::Utils::format_date_header(localtime())), '>=', 30);
is(
--
2.47.3
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pmg-devel] [PATCH pmg-api 2/3] tests: make test nature explicit
2026-01-02 20:31 [pmg-devel] [PATCH pmg-api 0/3] enable building with sbuild, by refactoring tests Stoiko Ivanov
2026-01-02 20:31 ` [pmg-devel] [PATCH pmg-api 1/3] tests: test_utils: do not rely on system timezone Stoiko Ivanov
@ 2026-01-02 20:32 ` Stoiko Ivanov
2026-01-02 20:32 ` [pmg-devel] [PATCH pmg-api 3/3] tests: conditionally skip integration tests Stoiko Ivanov
2 siblings, 0 replies; 4+ messages in thread
From: Stoiko Ivanov @ 2026-01-02 20:32 UTC (permalink / raw)
To: pmg-devel
Most of the tests in PMG's test-suite are integration tests in nature
- they create a database, set the default ruleset and compare it, or
run tests against a running pmgpolicy daemon.
The two test-suites that are closer to unit-tests are test_utils.pl
and ./test_sa_channel_parser.pl.
This patch refactors the Makefile (and drops a few commented out
lines) to make this distinction explicit, in preparation for only
running unit-tests in restricted build-environments (e.g. sbuild).
No functional change intended.
Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
src/tests/Makefile | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/src/tests/Makefile b/src/tests/Makefile
index 68f77e4d..3d5b0179 100644
--- a/src/tests/Makefile
+++ b/src/tests/Makefile
@@ -1,26 +1,25 @@
-#export TESTDB = "Proxmox_testdb"
-
export PERLLIB = ..
all:
.PHONY: check
-check: test-utils
+check: test-utils test-sa-channel integration-tests
+
+.PHONY: test-utils
+test-utils:
+ ./test_utils.pl
+
+.PHONY: test-sa-channel
+test-sa-channel:
+ ./test_sa_channel_parser.pl
+
+.PHONY: integration-tests
+integration-tests:
./create_testdb.pl
./init_testdb.pl
./print_testdb.pl > testdb.txt.new
diff -u testdb.txt testdb.txt.new
./test_greylist.pl
- ./test_sa_channel_parser.pl
-
-# test_config.pl \
-# test_mimetype.pl \
-# test_proxy.pl \
-# test_unpack.pl
-
-.PHONY: test-utils
-test-utils:
- ./test_utils.pl
clean:
rm -rf *~ proxytest_report.out test.cfg testdb.txt.new
--
2.47.3
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pmg-devel] [PATCH pmg-api 3/3] tests: conditionally skip integration tests
2026-01-02 20:31 [pmg-devel] [PATCH pmg-api 0/3] enable building with sbuild, by refactoring tests Stoiko Ivanov
2026-01-02 20:31 ` [pmg-devel] [PATCH pmg-api 1/3] tests: test_utils: do not rely on system timezone Stoiko Ivanov
2026-01-02 20:32 ` [pmg-devel] [PATCH pmg-api 2/3] tests: make test nature explicit Stoiko Ivanov
@ 2026-01-02 20:32 ` Stoiko Ivanov
2 siblings, 0 replies; 4+ messages in thread
From: Stoiko Ivanov @ 2026-01-02 20:32 UTC (permalink / raw)
To: pmg-devel
By setting the SKIP_INTEGRATION_TESTS (environment or Makefile
variable) to a non-empty value the integration-tests are skipped.
To skip them in sbuild - check for the existance of /run/lock/sbuild
(inspired by pve-container's `src/test/Makefile`) with realpath[0],
which returns an empty string for a non-existing file.
tested by running `make sbuild`, `make deb` and
`SKIP_INTEGRATION_TESTS=y make deb`.
[0] https://www.gnu.org/software/make/manual/html_node/File-Name-Functions.html#index-realpath-1
Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
src/tests/Makefile | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/tests/Makefile b/src/tests/Makefile
index 3d5b0179..20833b4d 100644
--- a/src/tests/Makefile
+++ b/src/tests/Makefile
@@ -1,9 +1,16 @@
export PERLLIB = ..
+# realpath returns an empty string for non-existing files
+SKIP_INTEGRATION_TESTS ?= $(realpath /run/lock/sbuild)
+
all:
.PHONY: check
+ifeq ($(strip $(SKIP_INTEGRATION_TESTS)),)
check: test-utils test-sa-channel integration-tests
+else
+check: test-utils test-sa-channel
+endif
.PHONY: test-utils
test-utils:
--
2.47.3
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-01-02 20:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-02 20:31 [pmg-devel] [PATCH pmg-api 0/3] enable building with sbuild, by refactoring tests Stoiko Ivanov
2026-01-02 20:31 ` [pmg-devel] [PATCH pmg-api 1/3] tests: test_utils: do not rely on system timezone Stoiko Ivanov
2026-01-02 20:32 ` [pmg-devel] [PATCH pmg-api 2/3] tests: make test nature explicit Stoiko Ivanov
2026-01-02 20:32 ` [pmg-devel] [PATCH pmg-api 3/3] tests: conditionally skip integration tests Stoiko Ivanov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.