Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
882eff53
Commit
882eff53
authored
Mar 13, 2017
by
Francis Dupont
Browse files
[5152] Introduced checkConfig()
parent
2f2ade19
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/bin/d2/tests/d2_controller_unittests.cc
View file @
882eff53
...
...
@@ -177,24 +177,24 @@ TEST_F(D2ControllerTest, configUpdateTests) {
isc
::
data
::
Element
::
fromJSON
(
valid_d2_config
);
// Verify that given a valid config we get a successful update result.
answer
=
updateConfig
(
config_set
,
false
);
answer
=
updateConfig
(
config_set
);
isc
::
config
::
parseAnswer
(
rcode
,
answer
);
EXPECT_EQ
(
0
,
rcode
);
// Verify that given a valid config we get a successful check result.
answer
=
update
Config
(
config_set
,
true
);
answer
=
check
Config
(
config_set
);
isc
::
config
::
parseAnswer
(
rcode
,
answer
);
EXPECT_EQ
(
0
,
rcode
);
// Use an invalid configuration to verify parsing error return.
std
::
string
config
=
"{
\"
bogus
\"
: 1000 } "
;
config_set
=
isc
::
data
::
Element
::
fromJSON
(
config
);
answer
=
updateConfig
(
config_set
,
false
);
answer
=
updateConfig
(
config_set
);
isc
::
config
::
parseAnswer
(
rcode
,
answer
);
EXPECT_EQ
(
1
,
rcode
);
// Use an invalid configuration to verify checking error return.
answer
=
update
Config
(
config_set
,
true
);
answer
=
check
Config
(
config_set
);
isc
::
config
::
parseAnswer
(
rcode
,
answer
);
EXPECT_EQ
(
1
,
rcode
);
}
...
...
src/lib/process/d_controller.cc
View file @
882eff53
...
...
@@ -112,7 +112,7 @@ DControllerBase::launch(int argc, char* argv[], const bool test_mode) {
initProcess
();
isc
::
data
::
ConstElementPtr
answer
;
answer
=
update
Config
(
module_config
,
true
);
answer
=
check
Config
(
module_config
);
int
rcode
=
0
;
answer
=
isc
::
config
::
parseAnswer
(
rcode
,
answer
);
if
(
rcode
!=
0
)
{
...
...
@@ -351,7 +351,7 @@ DControllerBase::configFromFile() {
getAppName
()
<<
"' entry."
);
}
answer
=
updateConfig
(
module_config
,
false
);
answer
=
updateConfig
(
module_config
);
int
rcode
=
0
;
isc
::
config
::
parseAnswer
(
rcode
,
answer
);
if
(
!
rcode
)
{
...
...
@@ -390,9 +390,14 @@ DControllerBase::runProcess() {
// Instance method for handling new config
isc
::
data
::
ConstElementPtr
DControllerBase
::
updateConfig
(
isc
::
data
::
ConstElementPtr
new_config
,
bool
check_only
)
{
return
(
process_
->
configure
(
new_config
,
check_only
));
DControllerBase
::
updateConfig
(
isc
::
data
::
ConstElementPtr
new_config
)
{
return
(
process_
->
configure
(
new_config
,
false
));
}
// Instance method for checking new config
isc
::
data
::
ConstElementPtr
DControllerBase
::
checkConfig
(
isc
::
data
::
ConstElementPtr
new_config
)
{
return
(
process_
->
configure
(
new_config
,
true
));
}
...
...
src/lib/process/d_controller.h
View file @
882eff53
...
...
@@ -155,14 +155,27 @@ public:
/// configuration and then invoke the application process' configure method.
///
/// @param new_config is the new configuration
/// @param check_only false for normal configuration, true when verifying only
///
/// @return returns an Element that contains the results of configuration
/// update composed of an integer status value (0 means successful,
/// non-zero means failure), and a string explanation of the outcome.
virtual
isc
::
data
::
ConstElementPtr
updateConfig
(
isc
::
data
::
ConstElementPtr
new_config
,
bool
check_only
=
false
);
virtual
isc
::
data
::
ConstElementPtr
updateConfig
(
isc
::
data
::
ConstElementPtr
new_config
);
/// @brief Instance method invoked by the configuration event handler and
/// which processes the actual configuration check. Provides behavioral
/// path for both integrated and stand-alone modes. The current
/// implementation will merge the configuration update into the existing
/// configuration and then invoke the application process' configure method
/// with a final rollback.
///
/// @param new_config is the new configuration
///
/// @return returns an Element that contains the results of configuration
/// update composed of an integer status value (0 means successful,
/// non-zero means failure), and a string explanation of the outcome.
virtual
isc
::
data
::
ConstElementPtr
checkConfig
(
isc
::
data
::
ConstElementPtr
new_config
);
/// @brief Reconfigures the process from a configuration file
///
...
...
@@ -194,7 +207,7 @@ public:
///
/// It then extracts the set of configuration elements for the
/// module-name that matches the controller's app_name_ and passes that
/// set into @c updateConfig().
/// set into @c updateConfig()
(or @c checkConfig())
.
///
/// The file may contain an arbitrary number of other modules.
///
...
...
src/lib/process/tests/d_controller_unittests.cc
View file @
882eff53
...
...
@@ -268,24 +268,24 @@ TEST_F(DStubControllerTest, configUpdateTests) {
isc
::
data
::
ElementPtr
config_set
=
isc
::
data
::
Element
::
fromJSON
(
config
);
// Verify that a valid config gets a successful update result.
answer
=
updateConfig
(
config_set
,
false
);
answer
=
updateConfig
(
config_set
);
isc
::
config
::
parseAnswer
(
rcode
,
answer
);
EXPECT_EQ
(
0
,
rcode
);
// Verify that a valid config gets a successful check result.
answer
=
update
Config
(
config_set
,
true
);
answer
=
check
Config
(
config_set
);
isc
::
config
::
parseAnswer
(
rcode
,
answer
);
EXPECT_EQ
(
0
,
rcode
);
// Verify that an error in process configure method is handled.
SimFailure
::
set
(
SimFailure
::
ftProcessConfigure
);
answer
=
updateConfig
(
config_set
,
false
);
answer
=
updateConfig
(
config_set
);
isc
::
config
::
parseAnswer
(
rcode
,
answer
);
EXPECT_EQ
(
1
,
rcode
);
// Verify that an error is handled too when the config is checked for.
SimFailure
::
set
(
SimFailure
::
ftProcessConfigure
);
answer
=
update
Config
(
config_set
,
true
);
answer
=
check
Config
(
config_set
);
isc
::
config
::
parseAnswer
(
rcode
,
answer
);
EXPECT_EQ
(
1
,
rcode
);
}
...
...
src/lib/process/testutils/d_test_stubs.h
View file @
882eff53
...
...
@@ -487,10 +487,16 @@ public:
/// @Wrapper to invoke the Controller's updateConfig method. Please
/// refer to DControllerBase::updateConfig for details.
isc
::
data
::
ConstElementPtr
updateConfig
(
isc
::
data
::
ConstElementPtr
new_config
,
bool
check_only
)
{
return
(
getController
()
->
updateConfig
(
new_config
,
check_only
));
isc
::
data
::
ConstElementPtr
updateConfig
(
isc
::
data
::
ConstElementPtr
new_config
)
{
return
(
getController
()
->
updateConfig
(
new_config
));
}
/// @Wrapper to invoke the Controller's checkConfig method. Please
/// refer to DControllerBase::checkConfig for details.
isc
::
data
::
ConstElementPtr
checkConfig
(
isc
::
data
::
ConstElementPtr
new_config
)
{
return
(
getController
()
->
checkConfig
(
new_config
));
}
/// @Wrapper to invoke the Controller's executeCommand method. Please
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment