Stabalize verify action exectued tests

This commit is contained in:
Simon Stürz 2025-12-01 10:58:03 +01:00
parent 603ec80f7f
commit 04c31b165c

View File

@ -324,18 +324,12 @@ void TestLogging::actionLog()
// EXECUTE with params // EXECUTE with params
QVariant response = injectAndWait("Integrations.ExecuteAction", params); QVariant response = injectAndWait("Integrations.ExecuteAction", params);
// wait for the outgoing data QVariantList logEntryAddedVariants;
// 3 packets: ExecuteAction reply, LogDatabaseUpdated signal and LogEntryAdded signal QTRY_VERIFY_WITH_TIMEOUT([&]() {
while (clientSpy.count() < 3) { logEntryAddedVariants = checkNotifications(clientSpy, "Logging.LogEntryAdded");
bool success = clientSpy.wait(); return !logEntryAddedVariants.isEmpty();
if (!success) { }(), 5000);
break;
}
}
QVariantList logEntryAddedVariants = checkNotifications(clientSpy, "Logging.LogEntryAdded");
qWarning() << QJsonDocument::fromVariant(logEntryAddedVariants).toJson(); qWarning() << QJsonDocument::fromVariant(logEntryAddedVariants).toJson();
QVERIFY2(!logEntryAddedVariants.isEmpty(), "Did not get Logging.LogEntryAdded notification.");
bool found = false; bool found = false;
foreach (const QVariant &loggEntryAddedVariant, logEntryAddedVariants) { foreach (const QVariant &loggEntryAddedVariant, logEntryAddedVariants) {
@ -360,10 +354,10 @@ void TestLogging::actionLog()
params.insert("thingId", m_mockThingId); params.insert("thingId", m_mockThingId);
response = injectAndWait("Integrations.ExecuteAction", params); response = injectAndWait("Integrations.ExecuteAction", params);
clientSpy.wait(); QTRY_VERIFY_WITH_TIMEOUT([&]() {
logEntryAddedVariants = checkNotifications(clientSpy, "Logging.LogEntryAdded");
logEntryAddedVariants = checkNotifications(clientSpy, "Logging.LogEntryAdded"); return !logEntryAddedVariants.isEmpty();
QVERIFY(!logEntryAddedVariants.isEmpty()); }(), 5000);
// get this logentry with filter // get this logentry with filter
params.clear(); params.clear();
@ -379,10 +373,10 @@ void TestLogging::actionLog()
params.insert("thingId", m_mockThingId); params.insert("thingId", m_mockThingId);
response = injectAndWait("Integrations.ExecuteAction", params); response = injectAndWait("Integrations.ExecuteAction", params);
clientSpy.wait(); QTRY_VERIFY_WITH_TIMEOUT([&]() {
logEntryAddedVariants = checkNotifications(clientSpy, "Logging.LogEntryAdded");
logEntryAddedVariants = checkNotifications(clientSpy, "Logging.LogEntryAdded"); return !logEntryAddedVariants.isEmpty();
QVERIFY2(!logEntryAddedVariants.isEmpty(), "Did not get Logging.LogEntryAdded notification."); }(), 5000);
found = false; found = false;
foreach (const QVariant &loggEntryAddedVariant, logEntryAddedVariants) { foreach (const QVariant &loggEntryAddedVariant, logEntryAddedVariants) {
@ -479,4 +473,3 @@ void TestLogging::removeThing()
#include "testlogging.moc" #include "testlogging.moc"
QTEST_MAIN(TestLogging) QTEST_MAIN(TestLogging)