public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: Lukas Wagner <l.wagner@proxmox.com>, pdm-devel@lists.proxmox.com
Subject: Re: [PATCH datacenter-manager 05/15] task cache: add test case for task cache rotation
Date: Fri, 10 Jul 2026 13:35:59 +0200	[thread overview]
Message-ID: <ff2ef927-0fe3-4a0d-8481-f33093cb65de@proxmox.com> (raw)
In-Reply-To: <20260702092258.174740-6-l.wagner@proxmox.com>

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 <l.wagner@proxmox.com>
> ---
>   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);
> +    }
>   }





  reply	other threads:[~2026-07-10 11:36 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02  9:22 [PATCH datacenter-manager/proxmox 00/15] task cache improvements (archive corruption handling, error handling) Lukas Wagner
2026-07-02  9:22 ` [PATCH proxmox 01/15] sys: fs: don't replace file extension make_tmp_file Lukas Wagner
2026-07-02  9:29   ` Lukas Wagner
2026-07-02  9:22 ` [PATCH datacenter-manager 02/15] task cache: fix missing cutoff state for PBS remotes Lukas Wagner
2026-07-02  9:22 ` [PATCH datacenter-manager 03/15] task cache: refresh task: don't apply journal if the archive was rotated Lukas Wagner
2026-07-02  9:22 ` [PATCH datacenter-manager 04/15] task cache: rotate: align timestamp for new files to UTC midnight Lukas Wagner
2026-07-10 11:36   ` Dominik Csapak
2026-07-10 12:02     ` Lukas Wagner
2026-07-02  9:22 ` [PATCH datacenter-manager 05/15] task cache: add test case for task cache rotation Lukas Wagner
2026-07-10 11:35   ` Dominik Csapak [this message]
2026-07-10 12:13     ` Lukas Wagner
2026-07-02  9:22 ` [PATCH datacenter-manager 06/15] task cache: pre-compute static paths during initialization Lukas Wagner
2026-07-02  9:22 ` [PATCH datacenter-manager 07/15] task cache: only initialize `TaskCache` struct once Lukas Wagner
2026-07-02  9:22 ` [PATCH datacenter-manager 08/15] task cache: archive iterator: don't yield more items if reading from file failed Lukas Wagner
2026-07-10 11:36   ` Dominik Csapak
2026-07-10 12:36     ` Lukas Wagner
2026-07-02  9:22 ` [PATCH datacenter-manager 09/15] task cache: include archive file path in error log messages Lukas Wagner
2026-07-10 11:36   ` Dominik Csapak
2026-07-10 12:53     ` Lukas Wagner
2026-07-02  9:22 ` [PATCH datacenter-manager 10/15] task cache: introduce ArchiveFileWriter Lukas Wagner
2026-07-10 11:36   ` Dominik Csapak
2026-07-02  9:22 ` [PATCH datacenter-manager 11/15] task cache: use ArchiveFileWriter when creating new archive files Lukas Wagner
2026-07-02  9:22 ` [PATCH datacenter-manager 12/15] task cache: trigger repair of corruption when applying journal Lukas Wagner
2026-07-02  9:22 ` [PATCH datacenter-manager 13/15] task cache: trigger repair of corruption when compressing archive files Lukas Wagner
2026-07-10 11:36   ` Dominik Csapak
2026-07-02  9:22 ` [PATCH datacenter-manager 14/15] task cache: trigger repair of corruption after read-accesses Lukas Wagner
2026-07-10 11:36   ` Dominik Csapak
2026-07-02  9:22 ` [PATCH datacenter-manager 15/15] task cache: handle potentially duplicated archive files after 'compress_archive_file' Lukas Wagner
2026-07-10 11:36   ` Dominik Csapak
2026-07-10 11:36 ` [PATCH datacenter-manager/proxmox 00/15] task cache improvements (archive corruption handling, error handling) Dominik Csapak

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=ff2ef927-0fe3-4a0d-8481-f33093cb65de@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=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