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 2/6] task cache: tests: allow to provide an explicit end time in 'task' helper
Date: Fri, 29 May 2026 15:39:47 +0200	[thread overview]
Message-ID: <20260529133951.326103-3-l.wagner@proxmox.com> (raw)
In-Reply-To: <20260529133951.326103-1-l.wagner@proxmox.com>

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

diff --git a/server/src/remote_tasks/task_cache.rs b/server/src/remote_tasks/task_cache.rs
index b8122d6a..fb544c6a 100644
--- a/server/src/remote_tasks/task_cache.rs
+++ b/server/src/remote_tasks/task_cache.rs
@@ -1265,11 +1265,11 @@ mod tests {
         Ok(())
     }
 
-    fn task(starttime: i64, ended: bool) -> TaskCacheItem {
-        let (status, endtime) = if ended {
-            (Some("OK".into()), Some(starttime + 10))
+    fn task(starttime: i64, endtime: Option<i64>) -> TaskCacheItem {
+        let status = if endtime.is_some() {
+            Some("OK".into())
         } else {
-            (None, None)
+            None
         };
 
         TaskCacheItem {
@@ -1320,7 +1320,7 @@ mod tests {
         cache.new_file(1000, false)?;
         assert_eq!(cache.cache.archive_files(&cache.lock)?.len(), 1);
 
-        add_tasks(&cache, vec![task(1000, true), task(1001, true)])?;
+        add_tasks(&cache, vec![task(1000, Some(1010)), task(1001, Some(1011))])?;
 
         assert_eq!(
             cache.read_state().cutoff_timestamp("pve-remote", "pve"),
@@ -1331,8 +1331,8 @@ mod tests {
 
         assert_eq!(cache.cache.archive_files(&cache.lock)?.len(), 2);
 
-        add_tasks(&cache, vec![task(1500, true), task(1501, true)])?;
-        add_tasks(&cache, vec![task(1200, true), task(1300, true)])?;
+        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"),
@@ -1342,15 +1342,15 @@ mod tests {
         cache.rotate(2000)?;
         assert_eq!(cache.cache.archive_files(&cache.lock)?.len(), 3);
 
-        add_tasks(&cache, vec![task(2000, true)])?;
-        add_tasks(&cache, vec![task(1502, true)])?;
-        add_tasks(&cache, vec![task(1002, true)])?;
+        add_tasks(&cache, vec![task(2000, Some(2010))])?;
+        add_tasks(&cache, vec![task(1502, Some(1512))])?;
+        add_tasks(&cache, vec![task(1002, Some(1012))])?;
 
         // These are before the cut-off of 1000, so they will be discarded.
         // add_tasks(&cache, vec![task(800, true), task(900, true)])?;
 
         // This one should be deduped
-        add_tasks(&cache, vec![task(1000, true)])?;
+        add_tasks(&cache, vec![task(1000, Some(1010))])?;
 
         assert_starttimes(
             &cache,
@@ -1386,10 +1386,10 @@ mod tests {
         .write()?;
 
         cache.new_file(1000, false)?;
-        add_tasks(&cache, vec![task(1000, false), task(1001, false)])?;
+        add_tasks(&cache, vec![task(1000, None), task(1001, None)])?;
         assert_eq!(cache.get_tasks(GetTasks::Active)?.count(), 2);
 
-        add_tasks(&cache, vec![task(1000, true), task(1001, true)])?;
+        add_tasks(&cache, vec![task(1000, Some(1010)), task(1001, Some(1011))])?;
 
         assert_starttimes(&cache, &[1001, 1000]);
 
@@ -1417,7 +1417,11 @@ mod tests {
 
         add_tasks(
             &cache,
-            vec![task(1050, true), task(950, true), task(850, true)],
+            vec![
+                task(1050, Some(1060)),
+                task(950, Some(960)),
+                task(850, Some(860)),
+            ],
         )?;
 
         assert_eq!(cache.get_tasks(GetTasks::Archived)?.count(), 3);
@@ -1426,7 +1430,7 @@ mod tests {
     }
 
     fn add_finished_tracked(cache: &WritableTaskCache, starttime: i64) -> Result<(), Error> {
-        let t = task(starttime, true);
+        let t = task(starttime, Some(starttime + 10));
         let upid = t.upid.clone();
 
         let mut node_map = NodeFetchSuccessMap::default();
@@ -1451,10 +1455,10 @@ mod tests {
 
         cache.init(1000)?;
 
-        cache.add_tracked_task(task(1050, false))?;
+        cache.add_tracked_task(task(1050, Some(1060)))?;
 
         assert_eq!(cache.get_tasks(GetTasks::Active)?.count(), 1);
-        cache.add_tracked_task(task(1060, false))?;
+        cache.add_tracked_task(task(1060, Some(1070)))?;
         assert_eq!(cache.get_tasks(GetTasks::Active)?.count(), 2);
 
         assert_eq!(cache.read_state().tracked_tasks().count(), 2);
@@ -1495,10 +1499,10 @@ mod tests {
         .unwrap()
         .write()?;
 
-        add_tasks(&cache, vec![task(1000, true)])?;
+        add_tasks(&cache, vec![task(1000, Some(1010))])?;
         assert!(cache.journal_size()? > 0);
 
-        add_tasks(&cache, vec![task(1000, true)])?;
+        add_tasks(&cache, vec![task(1000, Some(1010))])?;
 
         assert_eq!(cache.journal_size()?, 0);
 
-- 
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 ` Lukas Wagner [this message]
2026-05-29 13:39 ` [PATCH datacenter-manager 3/6] task cache: tests: add get_cutoff helper Lukas Wagner
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-3-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