public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Lukas Wagner <l.wagner@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [PATCH datacenter-manager 3/6] task cache: tests: add get_cutoff helper
Date: Fri, 29 May 2026 15:39:48 +0200	[thread overview]
Message-ID: <20260529133951.326103-4-l.wagner@proxmox.com> (raw)
In-Reply-To: <20260529133951.326103-1-l.wagner@proxmox.com>

This avoids a little bit of code duplication of the hard-coded remote
and node names.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
 server/src/remote_tasks/task_cache.rs | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/server/src/remote_tasks/task_cache.rs b/server/src/remote_tasks/task_cache.rs
index fb544c6a..7da92e31 100644
--- a/server/src/remote_tasks/task_cache.rs
+++ b/server/src/remote_tasks/task_cache.rs
@@ -1301,6 +1301,13 @@ mod tests {
         cache.update(tasks, &node_map, HashSet::new())
     }
 
+    fn get_cutoff(cache: &WritableTaskCache) -> i64 {
+        cache
+            .read_state()
+            .cutoff_timestamp("pve-remote", "pve")
+            .unwrap_or(0)
+    }
+
     const DEFAULT_MAX_SIZE: u64 = 10000;
 
     #[test]
@@ -1322,10 +1329,7 @@ mod tests {
 
         add_tasks(&cache, vec![task(1000, Some(1010)), task(1001, Some(1011))])?;
 
-        assert_eq!(
-            cache.read_state().cutoff_timestamp("pve-remote", "pve"),
-            Some(1001)
-        );
+        assert_eq!(get_cutoff(&cache), 1001);
 
         cache.rotate(1500)?;
 
@@ -1334,10 +1338,7 @@ mod tests {
         add_tasks(&cache, vec![task(1500, Some(1510)), task(1501, Some(1511))])?;
         add_tasks(&cache, vec![task(1200, Some(1210)), task(1300, Some(1310))])?;
 
-        assert_eq!(
-            cache.read_state().cutoff_timestamp("pve-remote", "pve"),
-            Some(1501),
-        );
+        assert_eq!(get_cutoff(&cache), 1501);
 
         cache.rotate(2000)?;
         assert_eq!(cache.cache.archive_files(&cache.lock)?.len(), 3);
-- 
2.47.3





  parent reply	other threads:[~2026-05-29 13:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-29 13:39 [PATCH datacenter-manager 0/6] fix #7639: task cache: consider running tasks when updating the cutoff timestamp Lukas Wagner
2026-05-29 13:39 ` [PATCH datacenter-manager 1/6] pdm-api-types: add NativeUpid::node() convenience getter Lukas Wagner
2026-05-29 13:39 ` [PATCH datacenter-manager 2/6] task cache: tests: allow to provide an explicit end time in 'task' helper Lukas Wagner
2026-05-29 13:39 ` Lukas Wagner [this message]
2026-05-29 13:39 ` [PATCH datacenter-manager 4/6] task cache: tests: add 'make_cache' convenience helper Lukas Wagner
2026-05-29 13:39 ` [PATCH datacenter-manager 5/6] fix #7639: task cache: consider running tasks when updating the cutoff timestamp Lukas Wagner
2026-05-29 13:39 ` [PATCH datacenter-manager 6/6] task cache: poll known active tasks every 30 seconds Lukas Wagner

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=20260529133951.326103-4-l.wagner@proxmox.com \
    --to=l.wagner@proxmox.com \
    --cc=pdm-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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal