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; return EXIT_FAILURE;
} }
LogSeverity logLevel = Logger::GetConsoleLogSeverity();
Logger::SetConsoleLogSeverity(LogWarning); Logger::SetConsoleLogSeverity(LogWarning);
if (vm.count("app")) if (vm.count("app"))

View File

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

View File

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