tests: remove alarm-qualifier form alarms expectations
We do not use alarm-qualifier anywhere.
Change-Id: I2101af3c70edb775ee3cbb0b543de7e95d153712
diff --git a/tests/health_systemd-units.cpp b/tests/health_systemd-units.cpp
index 48e0856..2a82e6e 100644
--- a/tests/health_systemd-units.cpp
+++ b/tests/health_systemd-units.cpp
@@ -22,10 +22,10 @@
using namespace std::chrono_literals;
#define REQUIRE_NEW_ALARM_INVENTORY_UNIT(UNIT) \
- REQUIRE_NEW_ALARM_INVENTORY_RESOURCE(alarmsWatcher, "velia-alarms:systemd-unit-failure", "", std::set<std::string>{UNIT})
+ REQUIRE_NEW_ALARM_INVENTORY_RESOURCE(alarmsWatcher, "velia-alarms:systemd-unit-failure", std::set<std::string>{UNIT})
#define REQUIRE_ALARM_RPC(UNIT, SEVERITY, TEXT) \
- REQUIRE_NEW_ALARM(alarmsWatcher, "velia-alarms:systemd-unit-failure", "", UNIT, SEVERITY, TEXT)
+ REQUIRE_NEW_ALARM(alarmsWatcher, "velia-alarms:systemd-unit-failure", UNIT, SEVERITY, TEXT)
TEST_CASE("systemd unit state monitoring (alarms)")
{
@@ -48,7 +48,6 @@
REQUIRE_NEW_ALARM_INVENTORY_ENTRY(alarmsWatcher,
"velia-alarms:systemd-unit-failure",
- "",
(std::set<std::string>{"unit1.service", "unit2.service", "unit3.service"}),
(std::set<std::string>{"critical"}),
true,
diff --git a/tests/sysrepo-helpers/alarms.cpp b/tests/sysrepo-helpers/alarms.cpp
index 9a8fc8f..3b95bb0 100644
--- a/tests/sysrepo-helpers/alarms.cpp
+++ b/tests/sysrepo-helpers/alarms.cpp
@@ -13,16 +13,16 @@
{
}
-void AlarmWatcher::AlarmInventory::add(const std::string& alarmTypeId, const std::string& alarmTypeQualifier, const std::set<std::string>& resources, const std::set<std::string>& severities)
+void AlarmWatcher::AlarmInventory::add(const std::string& alarmTypeId, const std::set<std::string>& resources, const std::set<std::string>& severities)
{
- auto& alarm = inventory[{alarmTypeId, alarmTypeQualifier}];
+ auto& alarm = inventory[alarmTypeId];
alarm.resources.insert(resources.begin(), resources.end());
alarm.severities.insert(severities.begin(), severities.end());
}
-bool AlarmWatcher::AlarmInventory::contains(const std::string& alarmTypeId, const std::string& alarmTypeQualifier, const std::optional<std::string>& resource, const std::optional<std::string>& severity) const
+bool AlarmWatcher::AlarmInventory::contains(const std::string& alarmTypeId, const std::optional<std::string>& resource, const std::optional<std::string>& severity) const
{
- if (auto it = inventory.find({alarmTypeId, alarmTypeQualifier}); it != inventory.end()) {
+ if (auto it = inventory.find(alarmTypeId); it != inventory.end()) {
const auto& alarm = it->second;
if (resource && !alarm.resources.empty() && !alarm.resources.contains(*resource)) {
diff --git a/tests/sysrepo-helpers/alarms.h b/tests/sysrepo-helpers/alarms.h
index 63e86fb..914c0e5 100644
--- a/tests/sysrepo-helpers/alarms.h
+++ b/tests/sysrepo-helpers/alarms.h
@@ -22,19 +22,18 @@
inline ValueChanges constructAlarmInventoryChange(EntryAction action,
const std::string& alarmType,
- const std::string& alarmQualifier,
const std::set<std::string>& resources,
const std::set<std::string>& severities,
const std::optional<bool>& willClear,
const std::optional<std::string>& description)
{
- const std::string prefix = "/ietf-alarms:alarms/alarm-inventory/alarm-type[alarm-type-id='" + alarmType + "'][alarm-type-qualifier='" + alarmQualifier + "']";
+ const std::string prefix = "/ietf-alarms:alarms/alarm-inventory/alarm-type[alarm-type-id='" + alarmType + "'][alarm-type-qualifier='']";
ValueChanges ret;
if (action == EntryAction::Create) {
ret.emplace(prefix + "/alarm-type-id", alarmType);
- ret.emplace(prefix + "/alarm-type-qualifier", alarmQualifier);
+ ret.emplace(prefix + "/alarm-type-qualifier", "");
}
if (willClear) {
@@ -62,19 +61,17 @@
struct AlarmWatcher {
/** @brief Poor man's /ietf-alarms:alarms/alarm-inventory implementation in C++. */
struct AlarmInventory {
- struct AlarmKey {
- std::string type;
- std::string qualifier;
- auto operator<=>(const AlarmKey&) const = default;
- };
+ using AlarmType = std::string;
+
struct AllowedResourcesAndSeverities {
std::set<std::string> resources;
std::set<std::string> severities;
};
- std::map<AlarmKey, AllowedResourcesAndSeverities> inventory;
- void add(const std::string& alarmTypeId, const std::string& alarmTypeQualifier, const std::set<std::string>& resources, const std::set<std::string>& severities);
- bool contains(const std::string& alarmTypeId, const std::string& alarmTypeQualifier, const std::optional<std::string>& resource, const std::optional<std::string>& severity) const;
+ std::map<AlarmType, AllowedResourcesAndSeverities> inventory;
+
+ void add(const std::string& alarmTypeId, const std::set<std::string>& resources, const std::set<std::string>& severities);
+ bool contains(const std::string& alarmTypeId, const std::optional<std::string>& resource, const std::optional<std::string>& severity) const;
};
AlarmInventory alarmInventory;
@@ -85,28 +82,28 @@
};
// checks if the alarm is contained in AlarmInventory
-#define WITH_ALARM_IN_INVENTORY(INV, ALARM_TYPE, ALARM_QUALIFIER, RESOURCE, SEVERITY) \
- LR_WITH(INV.contains(ALARM_TYPE, ALARM_QUALIFIER, RESOURCE, SEVERITY))
+#define WITH_ALARM_IN_INVENTORY(INV, ALARM_TYPE, RESOURCE, SEVERITY) \
+ LR_WITH(INV.contains(ALARM_TYPE, RESOURCE, SEVERITY))
// inserts the alarm in AlarmInventory as a side effect
-#define INSERT_INTO_INVENTORY(INV, ALARM_TYPE, ALARM_QUALIFIER, RESOURCE, SEVERITIES) \
- LR_SIDE_EFFECT(INV.add(ALARM_TYPE, ALARM_QUALIFIER, RESOURCE, SEVERITIES))
+#define INSERT_INTO_INVENTORY(INV, ALARM_TYPE, RESOURCE, SEVERITIES) \
+ LR_SIDE_EFFECT(INV.add(ALARM_TYPE, RESOURCE, SEVERITIES))
-#define REQUIRE_NEW_ALARM_INVENTORY_ENTRY(WATCHER, ALARM_TYPE, ALARM_QUALIFIER, RESOURCES, SEVERITIES, WILL_CLEAR, DESCRIPTION) \
- REQUIRE_DATASTORE_CHANGE(WATCHER.datastoreWatcher, constructAlarmInventoryChange(EntryAction::Create, ALARM_TYPE, ALARM_QUALIFIER, RESOURCES, SEVERITIES, WILL_CLEAR, DESCRIPTION)) \
- .INSERT_INTO_INVENTORY(WATCHER.alarmInventory, ALARM_TYPE, ALARM_QUALIFIER, RESOURCES, SEVERITIES)
+#define REQUIRE_NEW_ALARM_INVENTORY_ENTRY(WATCHER, ALARM_TYPE, RESOURCES, SEVERITIES, WILL_CLEAR, DESCRIPTION) \
+ REQUIRE_DATASTORE_CHANGE(WATCHER.datastoreWatcher, constructAlarmInventoryChange(EntryAction::Create, ALARM_TYPE, RESOURCES, SEVERITIES, WILL_CLEAR, DESCRIPTION)) \
+ .INSERT_INTO_INVENTORY(WATCHER.alarmInventory, ALARM_TYPE, RESOURCES, SEVERITIES)
-#define REQUIRE_NEW_ALARM_INVENTORY_RESOURCE(WATCHER, ALARM_TYPE, ALARM_QUALIFIER, RESOURCES) \
- REQUIRE_DATASTORE_CHANGE(WATCHER.datastoreWatcher, constructAlarmInventoryChange(EntryAction::Update, ALARM_TYPE, ALARM_QUALIFIER, RESOURCES, {}, std::nullopt, std::nullopt)) \
- .INSERT_INTO_INVENTORY(WATCHER.alarmInventory, ALARM_TYPE, ALARM_QUALIFIER, RESOURCES, (std::set<std::string>{}))
+#define REQUIRE_NEW_ALARM_INVENTORY_RESOURCE(WATCHER, ALARM_TYPE, RESOURCES) \
+ REQUIRE_DATASTORE_CHANGE(WATCHER.datastoreWatcher, constructAlarmInventoryChange(EntryAction::Update, ALARM_TYPE, RESOURCES, {}, std::nullopt, std::nullopt)) \
+ .INSERT_INTO_INVENTORY(WATCHER.alarmInventory, ALARM_TYPE, RESOURCES, (std::set<std::string>{}))
-#define REQUIRE_NEW_ALARM(WATCHER, ALARM_TYPE, ALARM_QUALIFIER, RESOURCE, SEVERITY, TEXT) \
+#define REQUIRE_NEW_ALARM(WATCHER, ALARM_TYPE, RESOURCE, SEVERITY, TEXT) \
REQUIRE_RPC_CALL(WATCHER.rpcWatcher, (Values{ \
{"/sysrepo-ietf-alarms:create-or-update-alarm", "(unprintable)"}, \
{"/sysrepo-ietf-alarms:create-or-update-alarm/alarm-text", TEXT}, \
{"/sysrepo-ietf-alarms:create-or-update-alarm/alarm-type-id", ALARM_TYPE}, \
- {"/sysrepo-ietf-alarms:create-or-update-alarm/alarm-type-qualifier", ALARM_QUALIFIER}, \
+ {"/sysrepo-ietf-alarms:create-or-update-alarm/alarm-type-qualifier", ""}, \
{"/sysrepo-ietf-alarms:create-or-update-alarm/resource", RESOURCE}, \
{"/sysrepo-ietf-alarms:create-or-update-alarm/severity", SEVERITY}, \
})) \
- .WITH_ALARM_IN_INVENTORY(WATCHER.alarmInventory, ALARM_TYPE, ALARM_QUALIFIER, RESOURCE, SEVERITY)
+ .WITH_ALARM_IN_INVENTORY(WATCHER.alarmInventory, ALARM_TYPE, RESOURCE, SEVERITY)
diff --git a/tests/sysrepo_ietf-hardware.cpp b/tests/sysrepo_ietf-hardware.cpp
index a859453..a9424a9 100644
--- a/tests/sysrepo_ietf-hardware.cpp
+++ b/tests/sysrepo_ietf-hardware.cpp
@@ -16,14 +16,14 @@
#define COMPONENT(RESOURCE) "/ietf-hardware:hardware/component[name='" RESOURCE "']"
#define REQUIRE_ALARM_INVENTORY_ADD_ALARM(ALARM_TYPE, DESCRIPTION) \
- REQUIRE_NEW_ALARM_INVENTORY_ENTRY(alarmWatcher, ALARM_TYPE, "", (std::set<std::string>{}), \
+ REQUIRE_NEW_ALARM_INVENTORY_ENTRY(alarmWatcher, ALARM_TYPE, (std::set<std::string>{}), \
(std::set<std::string>{}), true, DESCRIPTION)
#define REQUIRE_ALARM_INVENTORY_ADD_RESOURCES(ALARM_TYPE, ...) \
- REQUIRE_NEW_ALARM_INVENTORY_RESOURCE(alarmWatcher, ALARM_TYPE, "", (std::set<std::string>{__VA_ARGS__}))
+ REQUIRE_NEW_ALARM_INVENTORY_RESOURCE(alarmWatcher, ALARM_TYPE, (std::set<std::string>{__VA_ARGS__}))
#define REQUIRE_ALARM_RPC(ALARM_TYPE, RESOURCE, SEVERITY, TEXT) \
- REQUIRE_NEW_ALARM(alarmWatcher, ALARM_TYPE, "", COMPONENT(RESOURCE), SEVERITY, TEXT)
+ REQUIRE_NEW_ALARM(alarmWatcher, ALARM_TYPE, COMPONENT(RESOURCE), SEVERITY, TEXT)
TEST_CASE("IETF Hardware with sysrepo")
{