Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tests for custom policy interfaces
Browse files Browse the repository at this point in the history
Problem: the expansion of fluxion's dfu_match_policy_factory to
include custom policies opens the door for more creative policy
options, but doesn't test them.

Add a shell test, starting from a previous test of node-exclusivity
but substituting the short policy keys (i.e. "hinodex") for longer,
"custom" policy strings.
wihobbs committed Dec 23, 2024
1 parent 98ba331 commit 3484d1c
Showing 3 changed files with 90 additions and 5 deletions.
15 changes: 10 additions & 5 deletions resource/policies/base/test/matcher_policy_factory_test02.cpp
Original file line number Diff line number Diff line change
@@ -31,15 +31,20 @@ using namespace Flux::resource_model;
int test_parsers ()
{
std::map<std::string, bool> container;
bool first = Flux::resource_model::parse_custom_match_policy("high=true node_centric=true node_exclusive=true stop_on_1_matches=false blah=4", container);
bool first = Flux::resource_model::parse_custom_match_policy (
"high=true node_centric=true node_exclusive=true stop_on_1_matches=false blah=4",
container);
ok (first == false, "blah is an unrecognized policy option");

std::map<std::string, bool> container2;
bool second = Flux::resource_model::parse_custom_match_policy("high=1 node_centric=true node_exclusive=true stop_on_1_matches=false", container2);
bool second = Flux::resource_model::parse_custom_match_policy (
"high=1 node_centric=true node_exclusive=true stop_on_1_matches=false", container2);
ok (second == false, "1 is an invalid option, must be true or false");

std::map<std::string, bool> container3;
bool third = Flux::resource_model::parse_custom_match_policy("high=true node_centric=true stop_on_1_matches=true", container3);
bool third = Flux::resource_model::
parse_custom_match_policy ("high=true node_centric=true stop_on_1_matches=true",
container3);
ok (third == true, "first is a valid policy");

// little debugging helper for printing the container
@@ -52,13 +57,13 @@ int test_parsers ()

bool fifth = Flux::resource_model::parse_bool_match_options ("node_centric", container3);
ok (fifth == true, "policy first uses option node_centric");

bool sixth = Flux::resource_model::parse_bool_match_options ("stop_on_1_matches", container3);
ok (sixth == true, "policy first uses option stop_on_1_matches");

bool seventh = Flux::resource_model::parse_bool_match_options ("low", container3);
ok (seventh == false, "policy first does not use option low");

return 0;
}

1 change: 1 addition & 0 deletions t/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -67,6 +67,7 @@ set(ALL_TESTS
t3034-resource-pconstraints.t
t3035-resource-remove.t
t3036-rq2.t
t3037-resource-custom-policy.t
t3300-system-dontblock.t
t3301-system-latestart.t
t4000-match-params.t
79 changes: 79 additions & 0 deletions t/t3037-resource-custom-policy.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/sh

test_description='Test node-locality-aware scheduling'

. $(dirname $0)/sharness.sh

cmd_dir="${SHARNESS_TEST_SRCDIR}/data/resource/commands/nodex"
exp_dir="${SHARNESS_TEST_SRCDIR}/data/resource/expected/nodex"
grugs="${SHARNESS_TEST_SRCDIR}/data/resource/grugs/small.graphml"
query="../../resource/utilities/resource-query"

# Takes policy and cmd outfile prefix
run_tests_with_policy() {
pol=$1
prefix=$2

cmds001="${cmd_dir}/cmds01.in"
test001_desc="allocate 7 jobs with node-level constraint (pol=$pol)"
test_expect_success "${test001_desc}" '
sed "s~@TEST_SRCDIR@~${SHARNESS_TEST_SRCDIR}~g" ${cmds001} > cmds001 &&
${query} -L ${grugs} -S CA -P $pol -t ${prefix}1.R.out < cmds001 &&
test_cmp ${prefix}1.R.out ${exp_dir}/${prefix}1.R.out
'

cmds002="${cmd_dir}/cmds02.in"
test002_desc="allocate 7 jobs with no node-level constraint (pol=$pol)"
test_expect_success "${test002_desc}" '
sed "s~@TEST_SRCDIR@~${SHARNESS_TEST_SRCDIR}~g" ${cmds002} > cmds002 &&
${query} -L ${grugs} -S CA -P $pol -t ${prefix}2.R.out < cmds002 &&
test_cmp ${prefix}2.R.out ${exp_dir}/${prefix}2.R.out
'

cmds003="${cmd_dir}/cmds03.in"
test003_desc="match allocate 7 jobs -- last fails (pol=$pol)"
test_expect_success "${test003_desc}" '
sed "s~@TEST_SRCDIR@~${SHARNESS_TEST_SRCDIR}~g" ${cmds003} > cmds003 &&
${query} -L ${grugs} -S CA -P $pol -t ${prefix}3.R.out < cmds003 &&
test_cmp ${prefix}3.R.out ${exp_dir}/${prefix}3.R.out
'
}

# Selection Policy -- High node first with node exclusivity (-P hinodex)
# Selection behavior is identical to hinode except that
# it marks each selected node as exclusive even if the
# jobspec does not require node exclusivity and
# that it selects and emits all of the node-local resources
# for each node where at least one node-local resource is selected.
#
# For a jobspec with node[1]->slot[1]->core[1], it selects
# 36 cores from the selected node if there is a total of
# 36 cores in that node.
#
# For a jobspec with slot[18]->core[1], it selects
# again all 36 cores from the current available highest node.
#

run_tests_with_policy "high=true node_centric=true node_exclusive=true" 00

#
# Selection Policy -- Low node first with node exclusivity (-P lonodex)
# Selection behavior is identical to lonode except that
# it marks each selected node as exclusive even if the
# jobspec does not require node exclusivity and
# that it selects and emits all of the node-local resources
# for each node where at least one node-local resource is selected.
#
# For a jobspec with node[1]->slot[1]->core[1], it selects
# 36 cores from the selected node if there is a total of
# 36 cores in that node.
#
# For a jobspec with slot[18]->core[1], it selects
# again all 36 cores from the current available lowest node.
#

run_tests_with_policy "low=true node_centric=true node_exclusive=true" 01

run_tests_with_policy "high=true node_centric=true node_exclusive=true stop_on_1_matches=true" 00

test_done

0 comments on commit 3484d1c

Please sign in to comment.