-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1268 from wihobbs/new-policy-refactor
policy: expose internals of resource module policy factory to allow custom policies
- Loading branch information
Showing
13 changed files
with
410 additions
and
69 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
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
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
93 changes: 93 additions & 0 deletions
93
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,93 @@ | ||
/*****************************************************************************\ | ||
* 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 <iostream> | ||
#include <string> | ||
#include <boost/lexical_cast.hpp> | ||
#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::map<std::string, bool> container; | ||
std::string e = ""; | ||
bool first = Flux::resource_model::parse_custom_match_policy ( | ||
"policy=high node_centric=true node_exclusive=true stop_on_1_matches=false blah=4", | ||
container, | ||
e); | ||
ok (first == false, "blah is an unrecognized policy option"); | ||
ok (e == "invalid policy option: blah\n", "correct error message for invalid option"); | ||
|
||
std::map<std::string, bool> container2; | ||
std::string e2 = ""; | ||
bool second = Flux::resource_model::parse_custom_match_policy ( | ||
"policy=1 node_centric=true node_exclusive=true stop_on_1_matches=false", container2, e2); | ||
ok (second == false, "1 is an invalid option, must be high or low"); | ||
ok (e2 == "policy key within custom policy accepts only low or high\n", | ||
"correct error message for high/low"); | ||
|
||
std::map<std::string, bool> container3; | ||
std::string e3 = ""; | ||
bool third = Flux::resource_model:: | ||
parse_custom_match_policy ("policy=high node_centric=true stop_on_1_matches=true", | ||
container3, | ||
e3); | ||
ok (third == true, "first is a valid policy"); | ||
|
||
bool fourth = Flux::resource_model::parse_bool_match_options ("high", container3); | ||
ok (fourth == true, "policy first uses option high"); | ||
|
||
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"); | ||
|
||
std::map<std::string, bool> container4; | ||
std::string e4 = ""; | ||
bool eighth = Flux::resource_model:: | ||
parse_custom_match_policy ("policy=high node_centric=true node_exclusive=4", | ||
container4, | ||
e4); | ||
ok (eighth == false, "node_exclusive accepts only true or false"); | ||
ok (e4 == "Policy option node_exclusive requires true or false, got 4\n", | ||
"correct error msg for options"); | ||
|
||
return 0; | ||
} | ||
|
||
int main (int argc, char *argv[]) | ||
{ | ||
plan (11); | ||
test_parsers (); | ||
done_testing (); | ||
return 0; | ||
} | ||
|
||
/* | ||
* vi: ts=4 sw=4 expandtab | ||
*/ |
Oops, something went wrong.