forked from flux-framework/flux-sched
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
policy: refactor options to allow custom
Problem: the current fluxion policy matching factory doesn't allow for customizable policies. Add a custom option and refactor existing policies to behave similarly. Add unit testing for the string parsing convenience functions.
- Loading branch information
Showing
4 changed files
with
170 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
resource/policies/base/test/matcher_policy_factory_test02.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/*****************************************************************************\ | ||
* Copyright 2024 Lawrence Livermore National Security, LLC | ||
* (c.f. AUTHORS, NOTICE.LLNS, LICENSE) | ||
* | ||
* This file is part of the Flux resource manager framework. | ||
* For details, see https://github.com/flux-framework. | ||
* | ||
* SPDX-License-Identifier: LGPL-3.0 | ||
\*****************************************************************************/ | ||
|
||
/* | ||
* Test for the dfu_match_policy class(es). Compares shared pointers | ||
* expected values to string inputs to these classes. Strings can be | ||
* specified in config for custom policies, or some are provided. | ||
*/ | ||
|
||
extern "C" { | ||
#if HAVE_CONFIG_H | ||
#include <config.h> | ||
#endif | ||
} | ||
|
||
#include <string> | ||
#include "resource/policies/dfu_match_policy_factory.hpp" | ||
#include "src/common/libtap/tap.h" | ||
|
||
using namespace Flux; | ||
using namespace Flux::resource_model; | ||
|
||
int test_parsers () | ||
{ | ||
std::string policy_opts = policies.find ("first")->second; | ||
bool first = Flux::resource_model::parse_bool_match_options ("high", policy_opts); | ||
ok (first == true, "policy first uses option high"); | ||
|
||
policy_opts = policies.find ("high")->second; | ||
bool second = Flux::resource_model::option_exists ("stop_on_k_matches", policy_opts); | ||
ok (second == false, "policy high does not have stop_on_k_matches as substring"); | ||
|
||
policy_opts = policies.find ("firstnodex")->second; | ||
bool third = Flux::resource_model::parse_bool_match_options ("node_exclusive", policy_opts); | ||
ok (third == true, "policy first uses option node_centric"); | ||
|
||
bool fourth = Flux::resource_model::option_exists ("stop_on_k_matches", policy_opts); | ||
ok (fourth == true, "policy firstnodex has stop_on_k_matches as substring"); | ||
|
||
int fifth = Flux::resource_model::parse_int_match_options ("stop_on_k_matches", policy_opts); | ||
ok (fifth == 1, "policy firstnodex stops on first match"); | ||
|
||
return 0; | ||
} | ||
|
||
int main (int argc, char *argv[]) | ||
{ | ||
plan (5); | ||
test_parsers (); | ||
done_testing (); | ||
return 0; | ||
} | ||
|
||
/* | ||
* vi: ts=4 sw=4 expandtab | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters