From: Mira Limbeck <m.limbeck@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH log-tracker] change tests to use faketime
Date: Mon, 22 Mar 2021 14:06:18 +0100 [thread overview]
Message-ID: <20210322130618.6246-1-m.limbeck@proxmox.com> (raw)
We only have the month, day, hours, minutes and seconds available to us,
but not the year. Because of this we assume the logs are always relative
to the current year. This means when running the log tracker the CTIME
is calculated based on the current year and once a new year starts, all
old tests have to be updated to match the new year.
To work around this issue, use 'faketime' to set the time to 2020-12-31
23:59:59 as all tests assume 2020 as the year.
Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
---
debian/debcargo.toml | 1 +
tests/tests_after_queue.rs | 24 ++++++++++++-----
tests/tests_before_queue.rs | 52 +++++++++++++++++++++++++++----------
3 files changed, 58 insertions(+), 19 deletions(-)
diff --git a/debian/debcargo.toml b/debian/debcargo.toml
index 5ee9490..3a5c8a0 100644
--- a/debian/debcargo.toml
+++ b/debian/debcargo.toml
@@ -7,6 +7,7 @@ section = "admin"
homepage = "http://www.proxmox.com"
vcs_git = "git://git.proxmox.com/git/pmg-log-tracker.git"
vcs_browser = "https://git.proxmox.com/?p=pmg-log-tracker.git;a=summary"
+build_depends = ["faketime"]
[package]
summary = "Proxmox Mailgateway Log Tracker"
diff --git a/tests/tests_after_queue.rs b/tests/tests_after_queue.rs
index f479325..6918de7 100644
--- a/tests/tests_after_queue.rs
+++ b/tests/tests_after_queue.rs
@@ -6,7 +6,9 @@ mod utils;
#[test]
fn after_queue_start_end_time_string() {
- let output = Command::new(utils::log_tracker_path())
+ let output = Command::new("faketime")
+ .arg("2020-12-31 23:59:59")
+ .arg(utils::log_tracker_path())
.arg("-vv")
.arg("-s")
.arg("2020-12-18 15:40:00")
@@ -27,7 +29,9 @@ fn after_queue_start_end_time_string() {
#[test]
fn after_queue_start_end_timestamp() {
- let output = Command::new(utils::log_tracker_path())
+ let output = Command::new("faketime")
+ .arg("2020-12-31 23:59:59")
+ .arg(utils::log_tracker_path())
.arg("-vv")
.arg("-s")
.arg("1608302400")
@@ -48,7 +52,9 @@ fn after_queue_start_end_timestamp() {
#[test]
fn after_queue_qid() {
- let output = Command::new(utils::log_tracker_path())
+ let output = Command::new("faketime")
+ .arg("2020-12-31 23:59:59")
+ .arg(utils::log_tracker_path())
.arg("-vv")
.arg("-s")
.arg("1608302400")
@@ -71,7 +77,9 @@ fn after_queue_qid() {
#[test]
fn after_queue_host() {
- let output = Command::new(utils::log_tracker_path())
+ let output = Command::new("faketime")
+ .arg("2020-12-31 23:59:59")
+ .arg(utils::log_tracker_path())
.arg("-vv")
.arg("-s")
.arg("1608302400")
@@ -94,7 +102,9 @@ fn after_queue_host() {
#[test]
fn after_queue_search_string() {
- let output = Command::new(utils::log_tracker_path())
+ let output = Command::new("faketime")
+ .arg("2020-12-31 23:59:59")
+ .arg(utils::log_tracker_path())
.arg("-vv")
.arg("-s")
.arg("1608302400")
@@ -117,7 +127,9 @@ fn after_queue_search_string() {
#[test]
fn after_queue_search_string_case_insensitive() {
- let output = Command::new(utils::log_tracker_path())
+ let output = Command::new("faketime")
+ .arg("2020-12-31 23:59:59")
+ .arg(utils::log_tracker_path())
.arg("-vv")
.arg("-s")
.arg("1608302400")
diff --git a/tests/tests_before_queue.rs b/tests/tests_before_queue.rs
index 5f36ec2..6089b92 100644
--- a/tests/tests_before_queue.rs
+++ b/tests/tests_before_queue.rs
@@ -5,7 +5,9 @@ mod utils;
#[test]
fn before_queue_start_end_time_string() {
- let output = Command::new(utils::log_tracker_path())
+ let output = Command::new("faketime")
+ .arg("2020-12-31 23:59:59")
+ .arg(utils::log_tracker_path())
.arg("-vv")
.arg("-s")
.arg("2020-12-18 15:00:00")
@@ -26,7 +28,9 @@ fn before_queue_start_end_time_string() {
#[test]
fn before_queue_start_end_timestamp() {
- let output = Command::new(utils::log_tracker_path())
+ let output = Command::new("faketime")
+ .arg("2020-12-31 23:59:59")
+ .arg(utils::log_tracker_path())
.arg("-vv")
.arg("-s")
.arg("1608300000")
@@ -47,7 +51,9 @@ fn before_queue_start_end_timestamp() {
#[test]
fn before_queue_qid() {
- let output = Command::new(utils::log_tracker_path())
+ let output = Command::new("faketime")
+ .arg("2020-12-31 23:59:59")
+ .arg(utils::log_tracker_path())
.arg("-vv")
.arg("-s")
.arg("1608300000")
@@ -70,7 +76,9 @@ fn before_queue_qid() {
#[test]
fn before_queue_host() {
- let output = Command::new(utils::log_tracker_path())
+ let output = Command::new("faketime")
+ .arg("2020-12-31 23:59:59")
+ .arg(utils::log_tracker_path())
.arg("-vv")
.arg("-s")
.arg("1608300000")
@@ -93,7 +101,9 @@ fn before_queue_host() {
#[test]
fn before_queue_search_string() {
- let output = Command::new(utils::log_tracker_path())
+ let output = Command::new("faketime")
+ .arg("2020-12-31 23:59:59")
+ .arg(utils::log_tracker_path())
.arg("-vv")
.arg("-s")
.arg("1608300000")
@@ -116,7 +126,9 @@ fn before_queue_search_string() {
#[test]
fn before_queue_search_string_case_insensitive() {
- let output = Command::new(utils::log_tracker_path())
+ let output = Command::new("faketime")
+ .arg("2020-12-31 23:59:59")
+ .arg(utils::log_tracker_path())
.arg("-vv")
.arg("-s")
.arg("1608300000")
@@ -139,7 +151,9 @@ fn before_queue_search_string_case_insensitive() {
#[test]
fn before_queue_exclude_greylist_ndr() {
- let output = Command::new(utils::log_tracker_path())
+ let output = Command::new("faketime")
+ .arg("2020-12-31 23:59:59")
+ .arg(utils::log_tracker_path())
.arg("-vv")
.arg("-s")
.arg("1608300000")
@@ -162,7 +176,9 @@ fn before_queue_exclude_greylist_ndr() {
#[test]
fn before_queue_to() {
- let output = Command::new(utils::log_tracker_path())
+ let output = Command::new("faketime")
+ .arg("2020-12-31 23:59:59")
+ .arg(utils::log_tracker_path())
.arg("-vv")
.arg("-s")
.arg("1608300000")
@@ -185,7 +201,9 @@ fn before_queue_to() {
#[test]
fn before_queue_mixed_downstream() {
- let output = Command::new(utils::log_tracker_path())
+ let output = Command::new("faketime")
+ .arg("2020-12-31 23:59:59")
+ .arg(utils::log_tracker_path())
.arg("-v")
.arg("-s")
.arg("1608303600")
@@ -206,7 +224,9 @@ fn before_queue_mixed_downstream() {
#[test]
fn before_queue_from_to() {
- let output = Command::new(utils::log_tracker_path())
+ let output = Command::new("faketime")
+ .arg("2020-12-31 23:59:59")
+ .arg(utils::log_tracker_path())
.arg("-vv")
.arg("-s")
.arg("1608300000")
@@ -231,7 +251,9 @@ fn before_queue_from_to() {
#[test]
fn before_queue_mixed_accept_block_quarantine() {
- let output = Command::new(utils::log_tracker_path())
+ let output = Command::new("faketime")
+ .arg("2020-12-31 23:59:59")
+ .arg(utils::log_tracker_path())
.arg("-vv")
.arg("-s")
.arg("1588254000")
@@ -253,7 +275,9 @@ fn before_queue_mixed_accept_block_quarantine() {
#[test]
fn before_queue_to_search_string() {
- let output = Command::new(utils::log_tracker_path())
+ let output = Command::new("faketime")
+ .arg("2020-12-31 23:59:59")
+ .arg(utils::log_tracker_path())
.arg("-vv")
.arg("-s")
.arg("1589810100")
@@ -278,7 +302,9 @@ fn before_queue_to_search_string() {
#[test]
fn before_queue_syntax_reject() {
- let output = Command::new(utils::log_tracker_path())
+ let output = Command::new("faketime")
+ .arg("2020-12-31 23:59:59")
+ .arg(utils::log_tracker_path())
.arg("-vv")
.arg("-s")
.arg("2020-08-27 14:00:00")
--
2.20.1
next reply other threads:[~2021-03-22 13:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-22 13:06 Mira Limbeck [this message]
2021-03-22 15:28 ` [pmg-devel] applied: " Stoiko Ivanov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210322130618.6246-1-m.limbeck@proxmox.com \
--to=m.limbeck@proxmox.com \
--cc=pmg-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox