mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 13:37:55 +00:00
[2205] added a test case using a real thread
This commit is contained in:
@@ -268,3 +268,9 @@ This is a debug message output during the processing of a NOTIFY
|
|||||||
request. The zone manager component has been informed of the request,
|
request. The zone manager component has been informed of the request,
|
||||||
but has returned an error response (which is included in the message). The
|
but has returned an error response (which is included in the message). The
|
||||||
NOTIFY request will not be honored.
|
NOTIFY request will not be honored.
|
||||||
|
|
||||||
|
% AUTH_DATASRC_CLIENT_BUILDER_STARTED data source builder thread started
|
||||||
|
|
||||||
|
% AUTH_DATASRC_CLIENT_BUILDER_STOPPED data source builder thread stopped
|
||||||
|
|
||||||
|
% AUTH_DATASRC_CLIENT_BUILDER_COMMAND data source builder received command, ID: %1
|
||||||
|
@@ -15,10 +15,16 @@
|
|||||||
#ifndef DATASRC_CLIENTS_MGR_H
|
#ifndef DATASRC_CLIENTS_MGR_H
|
||||||
#define DATASRC_CLIENTS_MGR_H 1
|
#define DATASRC_CLIENTS_MGR_H 1
|
||||||
|
|
||||||
|
#include <util/threads/thread.h>
|
||||||
#include <util/threads/lock.h>
|
#include <util/threads/lock.h>
|
||||||
|
|
||||||
|
#include <log/logger_support.h>
|
||||||
|
#include <log/log_dbglevels.h>
|
||||||
|
|
||||||
#include <cc/data.h>
|
#include <cc/data.h>
|
||||||
|
|
||||||
|
#include <auth/auth_log.h>
|
||||||
|
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
@@ -67,6 +73,10 @@ private:
|
|||||||
//boost::shared_ptr<DataSrcClientListMap>* map;
|
//boost::shared_ptr<DataSrcClientListMap>* map;
|
||||||
//MutexType* data_mutex_;
|
//MutexType* data_mutex_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Shortcut typedef for normal use
|
||||||
|
typedef DataSrcClientsBuilderBase<util::thread::Mutex, util::thread::CondVar>
|
||||||
|
DataSrcClientsBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename ThreadType, typename BuilderType, typename MutexType,
|
template <typename ThreadType, typename BuilderType, typename MutexType,
|
||||||
@@ -101,6 +111,8 @@ namespace internal {
|
|||||||
template <typename MutexType, typename CondVarType>
|
template <typename MutexType, typename CondVarType>
|
||||||
void
|
void
|
||||||
DataSrcClientsBuilderBase<MutexType, CondVarType>::run() {
|
DataSrcClientsBuilderBase<MutexType, CondVarType>::run() {
|
||||||
|
LOG_INFO(auth_logger, AUTH_DATASRC_CLIENT_BUILDER_STARTED);
|
||||||
|
|
||||||
bool keep_running = true;
|
bool keep_running = true;
|
||||||
while (keep_running) {
|
while (keep_running) {
|
||||||
std::list<Command> current_commands;
|
std::list<Command> current_commands;
|
||||||
@@ -119,6 +131,8 @@ DataSrcClientsBuilderBase<MutexType, CondVarType>::run() {
|
|||||||
current_commands.pop_front();
|
current_commands.pop_front();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG_INFO(auth_logger, AUTH_DATASRC_CLIENT_BUILDER_STOPPED);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename MutexType, typename CondVarType>
|
template <typename MutexType, typename CondVarType>
|
||||||
@@ -126,6 +140,9 @@ bool
|
|||||||
DataSrcClientsBuilderBase<MutexType, CondVarType>::handleCommand(
|
DataSrcClientsBuilderBase<MutexType, CondVarType>::handleCommand(
|
||||||
const Command& command)
|
const Command& command)
|
||||||
{
|
{
|
||||||
|
LOG_DEBUG(auth_logger, DBGLVL_TRACE_BASIC,
|
||||||
|
AUTH_DATASRC_CLIENT_BUILDER_COMMAND).arg(command.first);
|
||||||
|
|
||||||
switch (command.first) {
|
switch (command.first) {
|
||||||
case SHUTDOWN:
|
case SHUTDOWN:
|
||||||
return (false);
|
return (false);
|
||||||
@@ -134,8 +151,16 @@ DataSrcClientsBuilderBase<MutexType, CondVarType>::handleCommand(
|
|||||||
}
|
}
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
}
|
} // namespace internal
|
||||||
|
|
||||||
|
/// \brief Shortcut type for normal data source clients manager.
|
||||||
|
///
|
||||||
|
/// In fact, for non test applications this is the only type of this kind
|
||||||
|
/// to be considered.
|
||||||
|
typedef DataSrcClientsMgrBase<util::thread::Thread,
|
||||||
|
internal::DataSrcClientsBuilder,
|
||||||
|
util::thread::Mutex, util::thread::CondVar>
|
||||||
|
DataSrcClientsMgr;
|
||||||
} // namespace auth
|
} // namespace auth
|
||||||
} // namespace isc
|
} // namespace isc
|
||||||
|
|
||||||
|
@@ -25,10 +25,7 @@ using namespace isc::auth;
|
|||||||
using namespace isc::auth::internal;
|
using namespace isc::auth::internal;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
class DataSrcClientsMgrTest : public ::testing::Test {
|
TEST(DataSrcClientsMgrTest, start) {
|
||||||
};
|
|
||||||
|
|
||||||
TEST_F(DataSrcClientsMgrTest, start) {
|
|
||||||
// When we create a manager, builder's run() method should be called.
|
// When we create a manager, builder's run() method should be called.
|
||||||
FakeDataSrcClientsBuilder::started = false;
|
FakeDataSrcClientsBuilder::started = false;
|
||||||
TestDataSrcClientsMgr mgr;
|
TestDataSrcClientsMgr mgr;
|
||||||
@@ -36,7 +33,7 @@ TEST_F(DataSrcClientsMgrTest, start) {
|
|||||||
EXPECT_TRUE(FakeDataSrcClientsBuilder::command_queue->empty());
|
EXPECT_TRUE(FakeDataSrcClientsBuilder::command_queue->empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DataSrcClientsMgrTest, shutdown) {
|
TEST(DataSrcClientsMgrTest, shutdown) {
|
||||||
// Invoke shutdown on the manager.
|
// Invoke shutdown on the manager.
|
||||||
TestDataSrcClientsMgr mgr;
|
TestDataSrcClientsMgr mgr;
|
||||||
EXPECT_TRUE(FakeDataSrcClientsBuilder::started);
|
EXPECT_TRUE(FakeDataSrcClientsBuilder::started);
|
||||||
@@ -58,4 +55,11 @@ TEST_F(DataSrcClientsMgrTest, shutdown) {
|
|||||||
EXPECT_TRUE(FakeDataSrcClientsBuilder::thread_waited);
|
EXPECT_TRUE(FakeDataSrcClientsBuilder::thread_waited);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(DataSrcClientsMgrTest, realThread) {
|
||||||
|
// Using the non-test definition with a real thread. Just checking
|
||||||
|
// no disruption happens.
|
||||||
|
DataSrcClientsMgr mgr;
|
||||||
|
mgr.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
} // unnamed namespace
|
} // unnamed namespace
|
||||||
|
Reference in New Issue
Block a user