From 04c31b165c7e584cf532c25d28d185eaec5ca08c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Mon, 1 Dec 2025 10:58:03 +0100 Subject: [PATCH] Stabalize verify action exectued tests --- tests/auto/logging/testlogging.cpp | 33 ++++++++++++------------------ 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/tests/auto/logging/testlogging.cpp b/tests/auto/logging/testlogging.cpp index 92531690..d76a82a7 100644 --- a/tests/auto/logging/testlogging.cpp +++ b/tests/auto/logging/testlogging.cpp @@ -324,18 +324,12 @@ void TestLogging::actionLog() // EXECUTE with params QVariant response = injectAndWait("Integrations.ExecuteAction", params); - // wait for the outgoing data - // 3 packets: ExecuteAction reply, LogDatabaseUpdated signal and LogEntryAdded signal - while (clientSpy.count() < 3) { - bool success = clientSpy.wait(); - if (!success) { - break; - } - } - - QVariantList logEntryAddedVariants = checkNotifications(clientSpy, "Logging.LogEntryAdded"); + QVariantList logEntryAddedVariants; + QTRY_VERIFY_WITH_TIMEOUT([&]() { + logEntryAddedVariants = checkNotifications(clientSpy, "Logging.LogEntryAdded"); + return !logEntryAddedVariants.isEmpty(); + }(), 5000); qWarning() << QJsonDocument::fromVariant(logEntryAddedVariants).toJson(); - QVERIFY2(!logEntryAddedVariants.isEmpty(), "Did not get Logging.LogEntryAdded notification."); bool found = false; foreach (const QVariant &loggEntryAddedVariant, logEntryAddedVariants) { @@ -360,10 +354,10 @@ void TestLogging::actionLog() params.insert("thingId", m_mockThingId); response = injectAndWait("Integrations.ExecuteAction", params); - clientSpy.wait(); - - logEntryAddedVariants = checkNotifications(clientSpy, "Logging.LogEntryAdded"); - QVERIFY(!logEntryAddedVariants.isEmpty()); + QTRY_VERIFY_WITH_TIMEOUT([&]() { + logEntryAddedVariants = checkNotifications(clientSpy, "Logging.LogEntryAdded"); + return !logEntryAddedVariants.isEmpty(); + }(), 5000); // get this logentry with filter params.clear(); @@ -379,10 +373,10 @@ void TestLogging::actionLog() params.insert("thingId", m_mockThingId); response = injectAndWait("Integrations.ExecuteAction", params); - clientSpy.wait(); - - logEntryAddedVariants = checkNotifications(clientSpy, "Logging.LogEntryAdded"); - QVERIFY2(!logEntryAddedVariants.isEmpty(), "Did not get Logging.LogEntryAdded notification."); + QTRY_VERIFY_WITH_TIMEOUT([&]() { + logEntryAddedVariants = checkNotifications(clientSpy, "Logging.LogEntryAdded"); + return !logEntryAddedVariants.isEmpty(); + }(), 5000); found = false; foreach (const QVariant &loggEntryAddedVariant, logEntryAddedVariants) { @@ -479,4 +473,3 @@ void TestLogging::removeThing() #include "testlogging.moc" QTEST_MAIN(TestLogging) -