From 147eebf52e2a6dfd1cd4cd8f117828e98f8568d8 Mon Sep 17 00:00:00 2001 From: Hobbs Date: Fri, 20 Dec 2024 18:36:11 -0800 Subject: [PATCH] test: add tests for custom policy interfaces 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. --- t/CMakeLists.txt | 1 + t/t3037-resource-custom-policy.t | 79 ++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100755 t/t3037-resource-custom-policy.t diff --git a/t/CMakeLists.txt b/t/CMakeLists.txt index 82368ac13..14661dc32 100644 --- a/t/CMakeLists.txt +++ b/t/CMakeLists.txt @@ -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 diff --git a/t/t3037-resource-custom-policy.t b/t/t3037-resource-custom-policy.t new file mode 100755 index 000000000..7c957a1d8 --- /dev/null +++ b/t/t3037-resource-custom-policy.t @@ -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