Fix livestatus unit tests

refs #8791
This commit is contained in:
Gunnar Beutner 2015-03-18 12:11:42 +01:00
parent 6c96d5bc98
commit 50b1e1cf6b
3 changed files with 21 additions and 10 deletions

View File

@ -472,6 +472,7 @@ int Main(void)
return EXIT_FAILURE;
}
LogSeverity logLevel = Logger::GetConsoleLogSeverity();
Logger::SetConsoleLogSeverity(LogWarning);
if (vm.count("app"))

View File

@ -45,6 +45,7 @@ using namespace icinga;
boost::mutex ConfigItem::m_Mutex;
ConfigItem::TypeMap ConfigItem::m_Items;
ConfigItem::ItemList ConfigItem::m_UnnamedItems;
ConfigItem::ItemList ConfigItem::m_CommittedItems;
REGISTER_SCRIPTFUNCTION(commit_objects, &ConfigItem::ScriptCommit);
@ -199,6 +200,11 @@ DynamicObject::Ptr ConfigItem::Commit(bool discard)
dobj->SetName(name);
dobj->OnConfigLoaded();
{
boost::mutex::scoped_lock lock(m_Mutex);
m_CommittedItems.push_back(this);
}
Dictionary::Ptr persistentItem = new Dictionary();
persistentItem->Set("type", GetType());
@ -257,7 +263,6 @@ void ConfigItem::Register(void)
* @returns The configuration item.
*/
ConfigItem::Ptr ConfigItem::GetObject(const String& type, const String& name)
{
{
boost::mutex::scoped_lock lock(m_Mutex);
@ -273,7 +278,6 @@ ConfigItem::Ptr ConfigItem::GetObject(const String& type, const String& name)
return it2->second;
}
}
bool ConfigItem::CommitNewItems(WorkQueue& upq)
{
@ -313,6 +317,11 @@ bool ConfigItem::CommitNewItems(WorkQueue& upq)
std::vector<ConfigItem::Ptr> new_items;
{
boost::mutex::scoped_lock lock(m_Mutex);
new_items.swap(m_CommittedItems);
}
std::set<String> types;
BOOST_FOREACH(const ConfigItem::Ptr& item, new_items) {

View File

@ -92,6 +92,7 @@ private:
typedef std::vector<ConfigItem::Ptr> ItemList;
static ItemList m_UnnamedItems;
static ItemList m_CommittedItems;
static ConfigItem::Ptr GetObjectUnlocked(const String& type,
const String& name);