From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH proxmox-perl-rs 1/2] pve: test: resource scheduling: add test where memory is secondary to CPU
Date: Tue, 21 Mar 2023 17:44:51 +0100 [thread overview]
Message-ID: <20230321164452.268358-2-f.ebner@proxmox.com> (raw)
In-Reply-To: <20230321164452.268358-1-f.ebner@proxmox.com>
because memory usage differences are small.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
pve-rs/test/resource_scheduling.pl | 46 ++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/pve-rs/test/resource_scheduling.pl b/pve-rs/test/resource_scheduling.pl
index fbedfe1..c6724a4 100755
--- a/pve-rs/test/resource_scheduling.pl
+++ b/pve-rs/test/resource_scheduling.pl
@@ -86,8 +86,54 @@ sub test_overcommitted {
is($nodes[3], "A", 'fourth should be A');
}
+sub test_balance_small_memory_difference_with_start_load {
+ my $static = PVE::RS::ResourceScheduling::Static->new();
+ # Memory is different to avoid flaky results with what would otherwise be ties.
+ $static->add_node("A", 8, 10_000_000_000);
+ $static->add_node("B", 4, 9_000_000_000);
+ $static->add_node("C", 4, 8_000_000_000);
+
+ $static->add_service_usage_to_node("A", { maxcpu => 4, maxmem => 1_000_000_000 });
+ $static->add_service_usage_to_node("B", { maxcpu => 2, maxmem => 1_000_000_000 });
+ $static->add_service_usage_to_node("C", { maxcpu => 2, maxmem => 1_000_000_000 });
+
+ my $service = {
+ maxcpu => 3,
+ maxmem => 16_000_000,
+ };
+
+ for (my $i = 0; $i < 20; $i++) {
+ my $score_list = $static->score_nodes_to_start_service($service);
+
+ # imitate HA manager
+ my $scores = { map { $_->[0] => -$_->[1] } $score_list->@* };
+ my @nodes = sort {
+ $scores->{$a} <=> $scores->{$b} || $a cmp $b
+ } keys $scores->%*;
+
+ if ($i % 4 <= 1) {
+ is($nodes[0], "A", 'first should be A');
+ is($nodes[1], "B", 'second should be B');
+ is($nodes[2], "C", 'third should be C');
+ } elsif ($i % 4 == 2) {
+ is($nodes[0], "B", 'first should be B');
+ is($nodes[1], "C", 'second should be C');
+ is($nodes[2], "A", 'third should be A');
+ } elsif ($i % 4 == 3) {
+ is($nodes[0], "C", 'first should be C');
+ is($nodes[1], "A", 'second should be A');
+ is($nodes[2], "B", 'third should be B');
+ } else {
+ die "internal error, got $i % 4 == " . ($i % 4) . "\n";
+ }
+
+ $static->add_service_usage_to_node($nodes[0], $service);
+ }
+}
+
test_basic();
test_balance();
test_overcommitted();
+test_balance_small_memory_difference_with_start_load();
done_testing();
--
2.30.2
next prev parent reply other threads:[~2023-03-21 16:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-21 16:44 [pve-devel] [PATCH proxmox-resource-scheduling] pve static: add one to avoid boosting tiny relative differences Fiona Ebner
2023-03-21 16:44 ` Fiona Ebner [this message]
2023-03-21 16:44 ` [pve-devel] [PATCH proxmox-perl-rs 2/2] pve: test: resource scheduling: add another test where memory is secondary to CPU Fiona Ebner
2023-03-22 8:32 ` [pve-devel] applied: [PATCH proxmox-resource-scheduling] pve static: add one to avoid boosting tiny relative differences Thomas Lamprecht
2023-10-05 9:50 ` Fiona Ebner
2023-11-06 17:21 ` [pve-devel] applied: " Thomas Lamprecht
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=20230321164452.268358-2-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-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.