tests: Don't use D-Bus custom names when mocking systemd's Manager
Because org.freedesktop.systemd1 busname is often used even as session
busname we had to improvise in systemd tests and we used custom name
cz.cesnet.systemd1 along with custom object paths and interfaces
when mocking systemd's D-Bus behaviour.
This is not necessary.
There is no need to create custom paths and interfaces, we can use the
standard ones. We only have to use another bus name.
Change-Id: Ied5dbfe9ad2fec2bd30787d5d6916bf5a5924fd9
diff --git a/tests/dbus-helpers/dbus_systemd_server.cpp b/tests/dbus-helpers/dbus_systemd_server.cpp
index 2d461d3..dcb96c9 100644
--- a/tests/dbus-helpers/dbus_systemd_server.cpp
+++ b/tests/dbus-helpers/dbus_systemd_server.cpp
@@ -5,9 +5,9 @@
using namespace std::literals;
namespace {
-static const std::string interfaceUnit = "cz.cesnet.systemd1.Unit";
-static const std::string interfaceManager = "cz.cesnet.systemd1.Manager";
-static const std::string objectPathManager = "/cz/cesnet/systemd1";
+static const std::string interfaceUnit = "org.freedesktop.systemd1.Unit";
+static const std::string interfaceManager = "org.freedesktop.systemd1.Manager";
+static const std::string objectPathManager = "/org/freedesktop/systemd1";
}
/** @brief Create a dbus server on the connection */
diff --git a/tests/health_input-systemd.cpp b/tests/health_input-systemd.cpp
index a027853..1b994a2 100644
--- a/tests/health_input-systemd.cpp
+++ b/tests/health_input-systemd.cpp
@@ -20,7 +20,7 @@
// Create and setuo separate connections for both client and server. Could be done using a single connection but this way it is more generic
auto clientConnection = sdbus::createSessionBusConnection();
- auto serverConnection = sdbus::createSessionBusConnection("cz.cesnet.systemd1");
+ auto serverConnection = sdbus::createSessionBusConnection();
clientConnection->enterEventLoopAsync();
serverConnection->enterEventLoopAsync();
@@ -36,43 +36,43 @@
// create units. Unit2 and Unit3 are in states that we consider failed
// therefore the DbusSystemdInput will report ERROR after loading the second unit
// FailedUnits: {unit2, unit3} -> ERROR
- server.createUnit(*serverConnection, "unit1.service", "/cz/cesnet/systemd1/unit/unit1", "active", "running");
- server.createUnit(*serverConnection, "unit2.service", "/cz/cesnet/systemd1/unit/unit2", "activating", "auto-restart");
- server.createUnit(*serverConnection, "unit3.service", "/cz/cesnet/systemd1/unit/unit3", "failed", "failed");
- server.createUnit(*serverConnection, "unitIgnored.service", "/cz/cesnet/systemd1/unit/unitIgnored", "failed", "failed");
+ server.createUnit(*serverConnection, "unit1.service", "/org/freedesktop/systemd1/unit/unit1", "active", "running");
+ server.createUnit(*serverConnection, "unit2.service", "/org/freedesktop/systemd1/unit/unit2", "activating", "auto-restart");
+ server.createUnit(*serverConnection, "unit3.service", "/org/freedesktop/systemd1/unit/unit3", "failed", "failed");
+ server.createUnit(*serverConnection, "unitIgnored.service", "/org/freedesktop/systemd1/unit/unitIgnored", "failed", "failed");
REQUIRE_CALL(*mx, updateState(ANY(void*), velia::health::State::OK)).IN_SEQUENCE(seq1);
REQUIRE_CALL(*mx, updateState(ANY(void*), velia::health::State::ERROR)).IN_SEQUENCE(seq1);
REQUIRE_CALL(*mx, updateState(ANY(void*), velia::health::State::ERROR)).IN_SEQUENCE(seq1);
- auto i1 = std::make_shared<velia::health::DbusSystemdInput>(mx, std::set<std::string> {"unitIgnored.service"}, *clientConnection, "cz.cesnet.systemd1", "/cz/cesnet/systemd1", "cz.cesnet.systemd1.Manager", "cz.cesnet.systemd1.Unit");
+ auto i1 = std::make_shared<velia::health::DbusSystemdInput>(mx, std::set<std::string> {"unitIgnored.service"}, *clientConnection, serverConnection->getUniqueName(), "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", "org.freedesktop.systemd1.Unit");
// i1 now listens for dbus events, we can start the semaphore server
// FailedUnits: {unit3} -> ERROR
REQUIRE_CALL(*mx, updateState(i1.get(), velia::health::State::ERROR)).IN_SEQUENCE(seq1);
- server.changeUnitState("/cz/cesnet/systemd1/unit/unit2", "active", "running");
+ server.changeUnitState("/org/freedesktop/systemd1/unit/unit2", "active", "running");
// FailedUnits: {} -> OK
REQUIRE_CALL(*mx, updateState(i1.get(), velia::health::State::OK)).IN_SEQUENCE(seq1);
- server.changeUnitState("/cz/cesnet/systemd1/unit/unit3", "active", "running");
+ server.changeUnitState("/org/freedesktop/systemd1/unit/unit3", "active", "running");
// In case we obtain a notifications that unit changed state from (X,Y) to (X,Y), do not trigger any events.
- server.changeUnitState("/cz/cesnet/systemd1/unit/unit3", "active", "running");
+ server.changeUnitState("/org/freedesktop/systemd1/unit/unit3", "active", "running");
// add new unit with failed/failed, DbusSystemdInput should receive UnitNew signal and monitor this unit too
// FailedUnits: {unit4} -> OK
REQUIRE_CALL(*mx, updateState(i1.get(), velia::health::State::ERROR)).IN_SEQUENCE(seq1);
- server.createUnit(*serverConnection, "unit4.service", "/cz/cesnet/systemd1/unit/unit4", "failed", "failed");
+ server.createUnit(*serverConnection, "unit4.service", "/org/freedesktop/systemd1/unit/unit4", "failed", "failed");
// unitIgnored is ignored by us, so it can change in any way but since we don't obtain the notifications, nothing will happen
- server.changeUnitState("/cz/cesnet/systemd1/unit/unitIgnored", "failed", "failed");
- server.changeUnitState("/cz/cesnet/systemd1/unit/unitIgnored", "active", "auto-restarting");
- server.changeUnitState("/cz/cesnet/systemd1/unit/unitIgnored", "active", "running");
+ server.changeUnitState("/org/freedesktop/systemd1/unit/unitIgnored", "failed", "failed");
+ server.changeUnitState("/org/freedesktop/systemd1/unit/unitIgnored", "active", "auto-restarting");
+ server.changeUnitState("/org/freedesktop/systemd1/unit/unitIgnored", "active", "running");
waitForCompletionAndBitMore(seq1);
// FailedUnits: {} -> OK
REQUIRE_CALL(*mx, updateState(i1.get(), velia::health::State::OK)).IN_SEQUENCE(seq1);
- server.changeUnitState("/cz/cesnet/systemd1/unit/unit4", "active", "running");
+ server.changeUnitState("/org/freedesktop/systemd1/unit/unit4", "active", "running");
waitForCompletionAndBitMore(seq1);