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 806D01FF09B for ; Mon, 31 Aug 2026 12:30:03 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 19FB820985; Mon, 31 Aug 2026 12:30:03 +0200 (CEST) Message-ID: <43cb8031-164e-432e-b939-8018486060f2@proxmox.com> Date: Mon, 31 Aug 2026 12:29:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH datacenter-manager 11/20] parallel fetcher: pass arguments to closure in a single type To: Lukas Wagner References: <20260817125727.454039-1-l.wagner@proxmox.com> <20260817125727.454039-12-l.wagner@proxmox.com> <178732083104.243770.17090706260253141150.b4-review@b4> Content-Language: en-US, de-AT From: Robert Obkircher In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1788172181713 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.646 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) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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: 5PI3ZJFJYEOJC4F5TVPLOUDHDV3AQOZI X-Message-ID-Hash: 5PI3ZJFJYEOJC4F5TVPLOUDHDV3AQOZI X-MailFrom: r.obkircher@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 CC: pdm-devel@lists.proxmox.com 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: On 24.08.26 15:13, Lukas Wagner wrote: > On Fri Aug 21, 2026 at 4:00 PM CEST, Robert Obkircher wrote: >>> + >>> +extern "C" fn cleanup() { >>> + if let Some(dir) = STATIC_TEMP_DIR.get() { >>> + let _ = std::fs::remove_dir_all(dir); >>> + } >>> +} >>> + >>> +pub fn test_setup() { >>> + static INIT: Once = Once::new(); >>> + >>> + INIT.call_once(|| { >>> + let file_opts = CreateOptions::new(); >>> + >>> + let dir = proxmox_sys::fs::make_tmp_dir("/tmp", None).unwrap(); >> A while ago I had a brief discussion with Fabian about how file I/O >> should be tested. He argued that tests should not make any assumptions >> about the file system outside of CARGO_TARGET_TMPDIR, not even about >> /tmp. >> >> But that is only available for real integration tests, not for >> unittests. > Yeah, might make it sense to use it for the tests here, I guess. > > Right now, we have quite a few unit tests in PDM which use /tmp anyways, > for exactly the reason you mentioned. Wondering if there is any sensible > approach for these. > >>> + STATIC_TEMP_DIR.set(dir.clone()).unwrap(); >>> + >>> + proxmox_rest_server::init_worker_tasks(dir.clone(), file_opts).unwrap(); >>> + proxmox_access_control::init::init(&pdm_api_types::AccessControlConfig, dir) >>> + .expect("failed to setup access control config"); >>> + >>> + unsafe { >>> + libc::atexit(cleanup); >> Doesn't this potentially delete files while other threads are stil >> accessing them? > Its a bit of a crutch admittedly, but I think in the context of integration tests > this should not be a huge issue? If exit() is called, any remaining > thread is stopped anyway; it should not be a big deal if any file IO in > the temporary directory fails then? > > Admittedly, I haven't examined the exact behavior of rust's test runner, > so maybe I'm missing something here. I was worried that a panic in one test could trigger confusing false positives in others, because threads are stopped after the exit handler runs. But now that I think about it, cargo test --fail-fast probably catches the panic and waits for running tests before exiting, so this shouldn't be an issue. >