pve: test: resource scheduling: use dedicated functions for tests

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fiona Ebner 2023-03-21 13:33:44 +01:00 committed by Thomas Lamprecht
parent 0648876946
commit 24702d4472

View File

@ -7,6 +7,7 @@ use Test::More;
use PVE::RS::ResourceScheduling::Static;
sub test_basic {
my $static = PVE::RS::ResourceScheduling::Static->new();
is(scalar($static->list_nodes()->@*), 0, 'node list empty');
$static->add_node("A", 10, 100_000_000_000);
@ -20,6 +21,12 @@ is(scalar($static->list_nodes()->@*), 2, '3rd removed should be 2');
ok($static->contains_node("A"), 'should contain a node A');
ok($static->contains_node("B"), 'should contain a node B');
ok(!$static->contains_node("C"), 'should not contain a node C');
}
sub test_balance {
my $static = PVE::RS::ResourceScheduling::Static->new();
$static->add_node("A", 10, 100_000_000_000);
$static->add_node("B", 20, 200_000_000_000);
my $service = {
maxcpu => 4,
@ -45,5 +52,9 @@ for (my $i = 0; $i < 15; $i++) {
$static->add_service_usage_to_node($nodes[0], $service);
}
}
test_basic();
test_balance();
done_testing();