tests: replace set with vector
The alarm handling code in utils/ uses std::vector for handling multiple
values for severities and resources of alarms. The tests however, work
with sets. This commit unifies the code by using vectors.
Change-Id: I1adbb94450e7da4dd7cdf6a91f2fc485b97d241c
diff --git a/tests/health_systemd-units.cpp b/tests/health_systemd-units.cpp
index 5bf878b..5eaf354 100644
--- a/tests/health_systemd-units.cpp
+++ b/tests/health_systemd-units.cpp
@@ -22,7 +22,7 @@
using namespace std::chrono_literals;
#define REQUIRE_NEW_ALARM_INVENTORY_UNIT(UNIT) \
- REQUIRE_NEW_ALARM_INVENTORY_RESOURCES(alarmsWatcher, (std::set<std::string>{"velia-alarms:systemd-unit-failure"}), std::set<std::string>{UNIT})
+ REQUIRE_NEW_ALARM_INVENTORY_RESOURCES(alarmsWatcher, (std::vector<std::string>{"velia-alarms:systemd-unit-failure"}), std::vector<std::string>{UNIT})
#define REQUIRE_ALARM_RPC(UNIT, SEVERITY, TEXT) \
REQUIRE_NEW_ALARM(alarmsWatcher, "velia-alarms:systemd-unit-failure", UNIT, SEVERITY, TEXT)
@@ -48,8 +48,8 @@
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"}),
+ (std::vector<std::string>{"unit1.service", "unit2.service", "unit3.service"}),
+ (std::vector<std::string>{"critical"}),
true,
"The systemd service is considered in failed state.");
diff --git a/tests/sysrepo-helpers/alarms.cpp b/tests/sysrepo-helpers/alarms.cpp
index c7ad7e3..14fc323 100644
--- a/tests/sysrepo-helpers/alarms.cpp
+++ b/tests/sysrepo-helpers/alarms.cpp
@@ -13,7 +13,7 @@
{
}
-void AlarmWatcher::AlarmInventory::add(const std::set<std::string>& alarmTypeIds, const std::set<std::string>& resources, const std::set<std::string>& severities)
+void AlarmWatcher::AlarmInventory::add(const std::vector<std::string>& alarmTypeIds, const std::vector<std::string>& resources, const std::vector<std::string>& severities)
{
for (const auto& type : alarmTypeIds) {
auto& alarm = inventory[type];
diff --git a/tests/sysrepo-helpers/alarms.h b/tests/sysrepo-helpers/alarms.h
index 6863a8e..87c17db 100644
--- a/tests/sysrepo-helpers/alarms.h
+++ b/tests/sysrepo-helpers/alarms.h
@@ -16,8 +16,8 @@
#include "test_log_setup.h"
inline ValueChanges constructAlarmInventoryChange(const std::string& alarmType,
- const std::set<std::string>& resources,
- const std::set<std::string>& severities,
+ const std::vector<std::string>& resources,
+ const std::vector<std::string>& severities,
const std::optional<bool>& willClear,
const std::optional<std::string>& description)
{
@@ -48,7 +48,7 @@
return ret;
}
-inline ValueChanges constructAlarmInventoryResourceChange(const std::set<std::string>& alarmTypeIds, const std::set<std::string>& resources) {
+inline ValueChanges constructAlarmInventoryResourceChange(const std::vector<std::string>& alarmTypeIds, const std::vector<std::string>& resources) {
ValueChanges ret;
for (const auto& alarmType : alarmTypeIds) {
@@ -76,7 +76,7 @@
std::map<AlarmType, AllowedResourcesAndSeverities> inventory;
- void add(const std::set<std::string>& alarmTypeIds, const std::set<std::string>& resources, const std::set<std::string>& severities);
+ void add(const std::vector<std::string>& alarmTypeIds, const std::vector<std::string>& resources, const std::vector<std::string>& severities);
bool contains(const std::string& alarmTypeId, const std::optional<std::string>& resource, const std::optional<std::string>& severity) const;
};
@@ -97,11 +97,11 @@
#define REQUIRE_NEW_ALARM_INVENTORY_ENTRY(WATCHER, ALARM_TYPE, RESOURCES, SEVERITIES, WILL_CLEAR, DESCRIPTION) \
REQUIRE_DATASTORE_CHANGE(WATCHER.datastoreWatcher, constructAlarmInventoryChange(ALARM_TYPE, RESOURCES, SEVERITIES, WILL_CLEAR, DESCRIPTION)) \
- .INSERT_INTO_INVENTORY(WATCHER.alarmInventory, (std::set<std::string>{ALARM_TYPE}), RESOURCES, SEVERITIES)
+ .INSERT_INTO_INVENTORY(WATCHER.alarmInventory, (std::vector<std::string>{ALARM_TYPE}), RESOURCES, SEVERITIES)
#define REQUIRE_NEW_ALARM_INVENTORY_RESOURCES(WATCHER, ALARM_TYPES, RESOURCES) \
REQUIRE_DATASTORE_CHANGE(WATCHER.datastoreWatcher, constructAlarmInventoryResourceChange(ALARM_TYPES, RESOURCES)) \
- .INSERT_INTO_INVENTORY(WATCHER.alarmInventory, ALARM_TYPES, RESOURCES, (std::set<std::string>{}))
+ .INSERT_INTO_INVENTORY(WATCHER.alarmInventory, ALARM_TYPES, RESOURCES, (std::vector<std::string>{}))
#define REQUIRE_NEW_ALARM(WATCHER, ALARM_TYPE, RESOURCE, SEVERITY, TEXT) \
REQUIRE_RPC_CALL(WATCHER.rpcWatcher, (Values{ \
diff --git a/tests/sysrepo_ietf-hardware.cpp b/tests/sysrepo_ietf-hardware.cpp
index ed86055..cbdbfbb 100644
--- a/tests/sysrepo_ietf-hardware.cpp
+++ b/tests/sysrepo_ietf-hardware.cpp
@@ -16,11 +16,11 @@
#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>{}), \
- (std::set<std::string>{}), true, DESCRIPTION)
+ REQUIRE_NEW_ALARM_INVENTORY_ENTRY(alarmWatcher, ALARM_TYPE, (std::vector<std::string>{}), \
+ (std::vector<std::string>{}), true, DESCRIPTION)
#define REQUIRE_ALARM_INVENTORY_ADD_RESOURCES(ALARM_TYPE, ...) \
- REQUIRE_NEW_ALARM_INVENTORY_RESOURCES(alarmWatcher, (std::set<std::string>{ALARM_TYPE}), (std::set<std::string>{__VA_ARGS__}))
+ REQUIRE_NEW_ALARM_INVENTORY_RESOURCES(alarmWatcher, (std::vector<std::string>{ALARM_TYPE}), (std::vector<std::string>{__VA_ARGS__}))
#define REQUIRE_ALARM_RPC(ALARM_TYPE, RESOURCE, SEVERITY, TEXT) \
REQUIRE_NEW_ALARM(alarmWatcher, ALARM_TYPE, COMPONENT(RESOURCE), SEVERITY, TEXT)