From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pdm-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 564ED1FF164 for <inbox@lore.proxmox.com>; Fri, 14 Mar 2025 15:13:49 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 192AE55CE; Fri, 14 Mar 2025 15:13:40 +0100 (CET) From: Lukas Wagner <l.wagner@proxmox.com> To: pdm-devel@lists.proxmox.com Date: Fri, 14 Mar 2025 15:12:25 +0100 Message-Id: <20250314141225.240768-9-l.wagner@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250314141225.240768-1-l.wagner@proxmox.com> References: <20250314141225.240768-1-l.wagner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.010 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 Subject: [pdm-devel] [PATCH proxmox-datacenter-manager 8/8] fake remote: generate fake task data X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion <pdm-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pdm-devel>, <mailto:pdm-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pdm-devel/> List-Post: <mailto:pdm-devel@lists.proxmox.com> List-Help: <mailto:pdm-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel>, <mailto:pdm-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox Datacenter Manager development discussion <pdm-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" <pdm-devel-bounces@lists.proxmox.com> This one helps us with the evaluation of the performance characteristics of huge setups. Signed-off-by: Lukas Wagner <l.wagner@proxmox.com> Reviewed-by: Max Carrara <m.carrara@proxmox.com> --- server/src/test_support/fake_remote.rs | 70 +++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 2 deletions(-) diff --git a/server/src/test_support/fake_remote.rs b/server/src/test_support/fake_remote.rs index 2419e690..40f68807 100644 --- a/server/src/test_support/fake_remote.rs +++ b/server/src/test_support/fake_remote.rs @@ -6,8 +6,9 @@ use pdm_config::remotes::RemoteConfig; use proxmox_product_config::ApiLockGuard; use proxmox_section_config::typed::SectionConfigData; use pve_api_types::{ - client::PveClient, ClusterMetrics, ClusterMetricsData, ClusterResource, ClusterResourceKind, - ClusterResourceType, StorageContent, + client::PveClient, ClusterMetrics, ClusterMetricsData, ClusterNodeIndexResponse, + ClusterNodeIndexResponseStatus, ClusterResource, ClusterResourceKind, ClusterResourceType, + ListTasks, ListTasksResponse, PveUpid, StorageContent, }; use serde::Deserialize; @@ -351,4 +352,69 @@ impl PveClient for FakePveClient { Ok(ClusterMetrics { data }) } + + async fn list_nodes(&self) -> Result<Vec<ClusterNodeIndexResponse>, proxmox_client::Error> { + tokio::time::sleep(Duration::from_millis(self.api_delay_ms as u64)).await; + Ok((0..self.nr_of_nodes) + .into_iter() + .map(|i| ClusterNodeIndexResponse { + node: format!("pve-{i}"), + cpu: None, + level: None, + maxcpu: None, + maxmem: None, + mem: None, + ssl_fingerprint: None, + status: ClusterNodeIndexResponseStatus::Online, + uptime: None, + }) + .collect()) + } + + async fn get_task_list( + &self, + node: &str, + params: ListTasks, + ) -> Result<Vec<ListTasksResponse>, proxmox_client::Error> { + tokio::time::sleep(Duration::from_millis(self.api_delay_ms as u64)).await; + let make_task = |starttime| { + let endtime = Some(starttime + 4); + + let upid_str = + format!("UPID:{node}:0000C530:001C9BEC:{starttime:08X}:stopall::root@pam:",); + let upid: PveUpid = upid_str.parse().unwrap(); + + ListTasksResponse { + node: node.to_string(), + endtime, + pid: upid.pid as i64, + pstart: upid.pstart as i64, + starttime, + status: Some("OK".to_string()), + ty: upid.worker_type, + user: upid.auth_id, + upid: upid_str, + id: upid.worker_id.unwrap_or_default(), + } + }; + + const DEFAULT_LIMIT: u64 = 1500; + const DEFAULT_SINCE: i64 = 0; + // Let's fake a new task every 5 minutes + const NEW_TASK_EVERY: i64 = 5; + + let limit = params.limit.unwrap_or(DEFAULT_LIMIT); + let since = params.since.unwrap_or(DEFAULT_SINCE); + + let now = proxmox_time::epoch_i64(); + + let number_of_tasks = (now - since) / (NEW_TASK_EVERY * 60); + + let number_of_tasks = limit.min(number_of_tasks as u64); + + Ok((0..number_of_tasks) + .into_iter() + .map(|i| make_task(now - i as i64 * NEW_TASK_EVERY * 60)) + .collect()) + } } -- 2.39.5 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel