-
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.
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
217 additions
and
43 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
75 changes: 75 additions & 0 deletions
75
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,75 @@ | ||
/*****************************************************************************\ | ||
* 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 <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; | ||
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); | ||
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); | ||
ok (third == true, "first is a valid policy"); | ||
|
||
// little debugging helper for printing the container | ||
// std::map<std::string, bool>::iterator it; | ||
// for (it=container.begin(); it != container.end(); it++) { | ||
// std::cout << it->first << ": " << it->second << std::endl; | ||
// } | ||
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"); | ||
|
||
return 0; | ||
} | ||
|
||
int main (int argc, char *argv[]) | ||
{ | ||
plan (7); | ||
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