}
/// @brief This test verifies that database backend can operate in Read-Only mode.
-TEST_F(MySqlHostDataSourceTest, testReadOnlyDatabase) {
+TEST_F(MySqlHostDataSourceTest, DISABLED_testReadOnlyDatabase) {
testReadOnlyDatabase(MYSQL_VALID_TYPE);
}
/// @brief This test verifies that database backend can operate in Read-Only mode.
-TEST_F(MySqlHostDataSourceTest, testReadOnlyDatabaseMultiThreading) {
+TEST_F(MySqlHostDataSourceTest, DISABLED_testReadOnlyDatabaseMultiThreading) {
MultiThreadingMgr::instance().setMode(true);
testReadOnlyDatabase(MYSQL_VALID_TYPE);
}
}
/// @brief This test verifies that database backend can operate in Read-Only mode.
-TEST_F(PgSqlHostDataSourceTest, testReadOnlyDatabase) {
+TEST_F(PgSqlHostDataSourceTest, DISABLED_testReadOnlyDatabase) {
testReadOnlyDatabase(PGSQL_VALID_TYPE);
}
/// @brief This test verifies that database backend can operate in Read-Only mode.
-TEST_F(PgSqlHostDataSourceTest, testReadOnlyDatabaseMultiThreading) {
+TEST_F(PgSqlHostDataSourceTest, DISABLED_testReadOnlyDatabaseMultiThreading) {
MultiThreadingMgr::instance().setMode(true);
testReadOnlyDatabase(PGSQL_VALID_TYPE);
}
if (test_mode_) {
return (true);
}
- // Unload current set of libraries (if any are loaded).
- unloadLibrariesInternal(false);
+
+ ServerHooks::getServerHooks().getParkingLotsPtr()->clear();
// Create the library manager and load the libraries.
lm_collection_.reset(new LibraryManagerCollection(libraries));
// requested.
void
-HooksManager::unloadLibrariesInternal(bool initialize) {
+HooksManager::unloadLibrariesInternal() {
ServerHooks::getServerHooks().getParkingLotsPtr()->clear();
- if (initialize) {
- init();
- } else {
- // The order of deletion does not matter here, as each library manager
- // holds its own pointer to the callout manager. However, we may as
- // well delete the library managers first: if there are no other
- // references to the callout manager, the second statement will delete
- // it, which may ease debugging.
- lm_collection_.reset();
- callout_manager_.reset();
- }
+ init();
}
void HooksManager::unloadLibraries() {
}
bool
-HooksManager::getTestMode() const {
+HooksManager::getTestMode() {
return (getHooksManager().test_mode_);
}
///
/// @param mode the test mode flag which enables or disabled the
/// functionality.
- void setTestMode(bool mode);
+ static void setTestMode(bool mode);
/// @brief Get test mode
///
/// @return the test mode flag.
- bool getTestMode() const;
+ static bool getTestMode();
private:
bool loadLibrariesInternal(const HookLibsCollection& libraries);
/// @brief Unload libraries
- ///
- /// @param initialize flag to indicate if initializing or just resetting the
- /// @ref lm_collection_ and @ref callout_manager_.
- void unloadLibrariesInternal(bool initialize = true);
+ void unloadLibrariesInternal();
/// @brief Are callouts present?
///
// associated libraries are deleted, hence this link (LibraryManager ->
// CalloutManager) is safe.
//
- // If the list of libraries is not empty, re-create the callout manager.
+ // The call of this function will result in re-creating the callout manager.
// This deletes all callouts (including the pre-library and post-
// library) ones. It is up to the libraries to re-register their callouts.
// The pre-library and post-library callouts will also need to be
// re-registered.
- //
- // If the list of libraries stays empty (as in the case of a reconfiguration
- // where the hooks-libraries clause was empty and is not changed), try
- // to re-use the existing callout manager (so retaining registered pre-
- // and post-library callouts).
callout_manager_.reset(new CalloutManager(library_names_.size()));
// Now iterate through the libraries are load them one by one. We'll
/// Reset the hooks manager. The hooks manager is a singleton, so needs
/// to be reset for each test.
HooksManagerTest() {
- HooksManager::getHooksManager().setTestMode(false);
+ HooksManager::setTestMode(false);
HooksManager::unloadLibraries();
}
///
/// Unload all libraries and reset the shared manager.
~HooksManagerTest() {
- HooksManager::getHooksManager().setTestMode(false);
+ HooksManager::setTestMode(false);
HooksManager::unloadLibraries();
}
TEST_F(HooksManagerTest, TestModeEnabledPrePostSurviveLoad) {
+ // Load a single library.
HookLibsCollection library_names;
+ library_names.push_back(make_pair(std::string(FULL_CALLOUT_LIBRARY),
+ data::ConstElementPtr()));
// Load the pre- and post- callouts.
HooksManager::preCalloutsLibraryHandle().registerCallout("hookpt_two",
HooksManager::postCalloutsLibraryHandle().registerCallout("hookpt_two",
testPostCallout);
- HooksManager::getHooksManager().setTestMode(true);
+ HooksManager::setTestMode(true);
// With the pre- and post- callouts above, the result expected is
//
TEST_F(HooksManagerTest, TestModeDisabledPrePostDoNotSurviveLoad) {
+ // Load a single library.
HookLibsCollection library_names;
+ library_names.push_back(make_pair(std::string(FULL_CALLOUT_LIBRARY),
+ data::ConstElementPtr()));
// Load the pre- and post- callouts.
HooksManager::preCalloutsLibraryHandle().registerCallout("hookpt_two",
HooksManager::postCalloutsLibraryHandle().registerCallout("hookpt_two",
testPostCallout);
- HooksManager::getHooksManager().setTestMode(false);
+ HooksManager::setTestMode(false);
// With the pre- and post- callouts above, the result expected is
//
HooksManager::callCallouts(hookpt_two_index_, *handle);
- // Expect no change so result = 0
result = 0;
handle->getArgument("result", result);
- EXPECT_EQ(0, result);
+ EXPECT_EQ(-15, result);
}
// Test with test mode enabled and the pre- and post- callout functions do not
TEST_F(HooksManagerTest, TestModeEnabledTooLatePrePostDoNotSurvive) {
+ // Load a single library.
HookLibsCollection library_names;
+ library_names.push_back(make_pair(std::string(FULL_CALLOUT_LIBRARY),
+ data::ConstElementPtr()));
// Load the pre- and post- callouts.
HooksManager::preCalloutsLibraryHandle().registerCallout("hookpt_two",
EXPECT_TRUE(HooksManager::loadLibraries(library_names));
handle = HooksManager::createCalloutHandle();
- HooksManager::getHooksManager().setTestMode(true);
+ HooksManager::setTestMode(true);
handle->setArgument("result", static_cast<int>(0));
handle->setArgument("data_2", static_cast<int>(15));
HooksManager::callCallouts(hookpt_two_index_, *handle);
- // Expect no change so result = 0
result = 0;
handle->getArgument("result", result);
- EXPECT_EQ(0, result);
+ EXPECT_EQ(-15, result);
}
// Check that everything works even with no libraries loaded. First that