From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 856321FF14C for ; Fri, 29 May 2026 15:40:04 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 93BFDC341; Fri, 29 May 2026 15:39:59 +0200 (CEST) From: Lukas Wagner 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 Message-ID: <20260529133951.326103-3-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260529133951.326103-1-l.wagner@proxmox.com> References: <20260529133951.326103-1-l.wagner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1780061964468 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.053 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: KGQSW652RZQOQKGYDXVWZ6XTUNHD6I2U X-Message-ID-Hash: KGQSW652RZQOQKGYDXVWZ6XTUNHD6I2U X-MailFrom: l.wagner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Lukas Wagner --- 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) -> 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