From: Lukas Wagner <l.wagner@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH proxmox-datacenter-manager 8/8] fake remote: generate fake task data
Date: Fri, 14 Mar 2025 15:12:25 +0100 [thread overview]
Message-ID: <20250314141225.240768-9-l.wagner@proxmox.com> (raw)
In-Reply-To: <20250314141225.240768-1-l.wagner@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
next prev parent reply other threads:[~2025-03-14 14:13 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-14 14:12 [pdm-devel] [PATCH proxmox-datacenter-manager 0/8] remote task cache fetching task / better cache backend Lukas Wagner
2025-03-14 14:12 ` [pdm-devel] [PATCH proxmox-datacenter-manager 1/8] test support: add NamedTempFile helper Lukas Wagner
2025-04-09 12:50 ` [pdm-devel] applied: " Thomas Lamprecht
2025-03-14 14:12 ` [pdm-devel] [PATCH proxmox-datacenter-manager 2/8] test support: add NamedTempDir helper Lukas Wagner
2025-04-09 12:50 ` [pdm-devel] applied: " Thomas Lamprecht
2025-03-14 14:12 ` [pdm-devel] [PATCH proxmox-datacenter-manager 3/8] move task_cache.rs to remote_tasks/mod.rs Lukas Wagner
2025-04-09 12:50 ` [pdm-devel] applied: " Thomas Lamprecht
2025-03-14 14:12 ` [pdm-devel] [PATCH proxmox-datacenter-manager 4/8] remote tasks: implement improved cache for remote tasks Lukas Wagner
2025-03-14 14:12 ` [pdm-devel] [PATCH proxmox-datacenter-manager 5/8] remote tasks: add background task for task polling, use new task cache Lukas Wagner
2025-03-20 17:39 ` Thomas Lamprecht
2025-03-21 13:33 ` Lukas Wagner
2025-03-21 13:39 ` Max Carrara
2025-04-11 8:03 ` Lukas Wagner
2025-03-14 14:12 ` [pdm-devel] [PATCH proxmox-datacenter-manager 6/8] pdm-api-types: remote tasks: implement From<&str> for TaskStateType Lukas Wagner
2025-03-14 14:12 ` [pdm-devel] [PATCH proxmox-datacenter-manager 7/8] fake remote: add missing fields to make the debug feature compile again Lukas Wagner
2025-04-09 12:52 ` [pdm-devel] applied: " Thomas Lamprecht
2025-03-14 14:12 ` Lukas Wagner [this message]
2025-04-09 12:52 ` [pdm-devel] applied: [PATCH proxmox-datacenter-manager 8/8] fake remote: generate fake task data Thomas Lamprecht
2025-04-11 11:02 ` [pdm-devel] superseded: [PATCH proxmox-datacenter-manager 0/8] remote task cache fetching task / better cache backend Lukas Wagner
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=20250314141225.240768-9-l.wagner@proxmox.com \
--to=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal