From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id A1F841FF0E7 for ; Fri, 10 Jul 2026 13:36:33 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 4C2F92143E; Fri, 10 Jul 2026 13:36:33 +0200 (CEST) Message-ID: Date: Fri, 10 Jul 2026 13:35:59 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: [PATCH datacenter-manager 05/15] task cache: add test case for task cache rotation To: Lukas Wagner , pdm-devel@lists.proxmox.com References: <20260702092258.174740-1-l.wagner@proxmox.com> <20260702092258.174740-6-l.wagner@proxmox.com> Content-Language: en-US From: Dominik Csapak In-Reply-To: <20260702092258.174740-6-l.wagner@proxmox.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1783683348516 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.060 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) 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: RHJNQRH5V5MZQA3VKYFF2S7X3LDD5JTH X-Message-ID-Hash: RHJNQRH5V5MZQA3VKYFF2S7X3LDD5JTH X-MailFrom: d.csapak@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: some nits inline On 7/2/26 11:23 AM, Lukas Wagner wrote: > This is to ensure that older files are indeed compressed and then later > removed. > > Signed-off-by: Lukas Wagner > --- > server/src/remote_tasks/task_cache.rs | 65 +++++++++++++++++++++++++++ > 1 file changed, 65 insertions(+) > > diff --git a/server/src/remote_tasks/task_cache.rs b/server/src/remote_tasks/task_cache.rs > index 55aa8b70..aa92fcc8 100644 > --- a/server/src/remote_tasks/task_cache.rs > +++ b/server/src/remote_tasks/task_cache.rs > @@ -1555,4 +1555,69 @@ mod tests { > assert_eq!(cache.get_tasks(GetTasks::Active).unwrap().count(), 0); > assert_eq!(cache.get_tasks(GetTasks::Archived).unwrap().count(), 3); > } > + > + #[test] > + fn archive_file_rotation() { > + let (_tmp_dir, mut cache) = make_cache().unwrap(); > + cache.rotate_after = 100; > + cache.uncompressed_files = 1; > + cache.max_files = 2; > + > + let cache = cache.write().unwrap(); > + cache.init(1000).unwrap(); > + > + add_tasks(&cache, vec![task(1010, Some(1011)), task(1020, Some(1021))]).unwrap(); > + cache.apply_journal().unwrap(); > + > + cache.rotate(1100).unwrap(); > + > + let files = cache.cache.archive_files(&cache.lock).unwrap(); > + assert_eq!(files.len(), 2); > + let first = files.get(0).unwrap(); > + let second = files.get(1).unwrap(); > + > + assert_eq!(first.compressed, false); nit: clippy complains about this line: used `assert_eq!` with a literal bool so using `assert!(!first.compressed)` and below with `assert!(second.compressed)` could be better? > + assert_eq!(first.starttime, 1100); > + assert_eq!(second.compressed, true); > + assert_eq!(second.starttime, 1000); > + > + assert_eq!(first.iter().unwrap().unwrap().count(), 0); > + assert_eq!(second.iter().unwrap().unwrap().count(), 2); > + > + add_tasks(&cache, vec![task(1110, Some(1111))]).unwrap(); > + cache.apply_journal().unwrap(); > + > + cache.rotate(1200).unwrap(); > + > + add_tasks(&cache, vec![task(1210, Some(1211))]).unwrap(); > + cache.apply_journal().unwrap(); > + > + let files = cache.cache.archive_files(&cache.lock).unwrap(); > + assert_eq!(files.len(), 2); > + let first = files.get(0).unwrap(); > + let second = files.get(1).unwrap(); > + > + assert_eq!(first.compressed, false); same here > + assert_eq!(first.starttime, 1200); > + assert_eq!(second.compressed, true); and here > + assert_eq!(second.starttime, 1100); > + > + assert_eq!(first.iter().unwrap().unwrap().count(), 1); > + assert_eq!(second.iter().unwrap().unwrap().count(), 1); > + > + cache.rotate(1300).unwrap(); > + > + let files = cache.cache.archive_files(&cache.lock).unwrap(); > + assert_eq!(files.len(), 2); > + let first = files.get(0).unwrap(); > + let second = files.get(1).unwrap(); > + > + assert_eq!(first.compressed, false); and here > + assert_eq!(first.starttime, 1300); > + assert_eq!(second.compressed, true); and here > + assert_eq!(second.starttime, 1200); > + > + assert_eq!(first.iter().unwrap().unwrap().count(), 0); > + assert_eq!(second.iter().unwrap().unwrap().count(), 1); > + } > }