From 1f9ac99bc63da3eadd1322645266664b7052efa7 Mon Sep 17 00:00:00 2001 From: Christopher Moussa Date: Thu, 3 Nov 2022 11:41:57 -0700 Subject: [PATCH] t: add tests for plugin config update Problem: There exist no tests for updating the plugin via conf-update. Add some tests. --- t/Makefile.am | 1 + t/t1034-mf-priority-config.t | 87 ++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100755 t/t1034-mf-priority-config.t diff --git a/t/Makefile.am b/t/Makefile.am index 13ec66be..54df882a 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -35,6 +35,7 @@ TESTSCRIPTS = \ t1031-mf-priority-issue406.t \ t1032-mf-priority-update-bank.t \ t1033-mf-priority-update-job.t \ + t1034-mf-priority-config.t \ t5000-valgrind.t \ python/t1000-example.py diff --git a/t/t1034-mf-priority-config.t b/t/t1034-mf-priority-config.t new file mode 100755 index 00000000..54414893 --- /dev/null +++ b/t/t1034-mf-priority-config.t @@ -0,0 +1,87 @@ +#!/bin/bash + +test_description='Test configuring weights of multi-factor priority factors' + +. `dirname $0`/sharness.sh +MULTI_FACTOR_PRIORITY=${FLUX_BUILD_DIR}/src/plugins/.libs/mf_priority.so +SUBMIT_AS=${SHARNESS_TEST_SRCDIR}/scripts/submit_as.py +SEND_PAYLOAD=${SHARNESS_TEST_SRCDIR}/scripts/send_payload.py +DB_PATH=$(pwd)/FluxAccountingTest.db + +mkdir -p config + +export TEST_UNDER_FLUX_NO_JOB_EXEC=y +export TEST_UNDER_FLUX_SCHED_SIMPLE_MODE="limited=1" +test_under_flux 1 job -o,--config-path=$(pwd)/config + +flux setattr log-stderr-level 1 + +test_expect_success 'load plugin successfully without configuration' ' + flux jobtap load ${MULTI_FACTOR_PRIORITY} +' + +test_expect_success 'create a flux-accounting DB' ' + flux account -p ${DB_PATH} create-db +' + +test_expect_success 'start flux-accounting service' ' + flux account-service -p ${DB_PATH} -t +' + +test_expect_success 'add some banks to the DB' ' + flux account -p ${DB_PATH} add-bank root 1 && + flux account -p ${DB_PATH} add-bank --parent-bank=root bankA 1 +' + +test_expect_success 'add a user to the DB' ' + flux account -p ${DB_PATH} add-user --username=user1001 --userid=1001 --bank=bankA +' + +test_expect_success 'send flux-accounting DB information to the plugin' ' + flux account-priority-update -p $(pwd)/FluxAccountingTest.db +' + +test_expect_success 'no configured priority factors will use default weights' ' + job1=$(flux python ${SUBMIT_AS} 1001 -n1 hostname) && + flux job wait-event -f json $job1 priority | jq '.context.priority' > job1.test && + grep "50000" job1.test && + flux job cancel $job1 +' + +test_expect_success 'set up new configuration for multi-factor priority plugin' ' + cat >config/test.toml <<-EOT && + [priority_factors] + fshare_weight = 1000 + queue_weight = 100 + EOT + flux config reload +' + +test_expect_success 'successfully submit a job with loaded configuration' ' + job2=$(flux python ${SUBMIT_AS} 1001 -n1 hostname) && + flux job wait-event -f json $job2 priority | jq '.context.priority' > job2.test && + grep "500" job2.test && + flux job cancel $job2 +' + +test_expect_success 'change the configuration for the priority factors' ' + cat >config/test.toml <<-EOT && + [priority_factors] + fshare_weight = 500 + queue_weight = 100 + EOT + flux config reload +' + +test_expect_success 'successfully submit a job with the new configuration' ' + job3=$(flux python ${SUBMIT_AS} 1001 -n1 hostname) && + flux job wait-event -f json $job3 priority | jq '.context.priority' > job3.test && + grep "250" job3.test && + flux job cancel $job3 +' + +test_expect_success 'shut down flux-accounting service' ' + flux python -c "import flux; flux.Flux().rpc(\"accounting.shutdown_service\").get()" +' + +test_done