From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id DEFDB69514 for ; Mon, 22 Mar 2021 16:28:16 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D7B2526B2A for ; Mon, 22 Mar 2021 16:28:16 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id BC33526C76 for ; Mon, 22 Mar 2021 16:28:15 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 887F546372 for ; Mon, 22 Mar 2021 16:28:15 +0100 (CET) Date: Mon, 22 Mar 2021 16:28:13 +0100 From: Stoiko Ivanov To: Mira Limbeck Cc: pmg-devel@lists.proxmox.com Message-ID: <20210322162813.4e5beb31@rosa.proxmox.com> In-Reply-To: <20210322130618.6246-1-m.limbeck@proxmox.com> References: <20210322130618.6246-1-m.limbeck@proxmox.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.061 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pmg-devel] applied: [PATCH log-tracker] change tests to use faketime X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Mar 2021 15:28:16 -0000 On Mon, 22 Mar 2021 14:06:18 +0100 Mira Limbeck wrote: > 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. applied the patch but fixed-up the updated debian/control file resulting from the change do debian/debcargo.toml If possible include the changes to debian/control in those cases in your patch huge thanks for the patch! > > Signed-off-by: Mira Limbeck > --- > 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")