From 2e2ecb2295cd631d8a623118b51a813f9d13858f Mon Sep 17 00:00:00 2001 From: Gabriel Bolbotina Date: Fri, 12 Dec 2025 18:36:00 +0200 Subject: [PATCH 1/8] Added different names for generated usernames for tests --- .github/workflows/linux.yml | 1 + .github/workflows/macos.yml | 1 + app/test/testutils.cpp | 34 ++++++++++++---------------------- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 04c902cc9..c9fee8c84 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -24,6 +24,7 @@ env: VCPKG_BINARY_SOURCES: 'clear;nuget,GitHub,readwrite' VCPKG_ROOT: "${{ github.workspace }}/vcpkg" TRIPLET: x64-linux + CI_JOB_ID: linux concurrency: group: ci-${{github.ref}}-linux diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index e42b6598e..e0e98bc13 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -25,6 +25,7 @@ env: XC_VERSION: ${{ '16.4' }} DEPLOYMENT_TARGET: '11.0' TRIPLET: arm64-osx + CI_JOB_ID: macos concurrency: group: ci-${{github.ref}}-macos diff --git a/app/test/testutils.cpp b/app/test/testutils.cpp index 97abca5cd..483579d53 100644 --- a/app/test/testutils.cpp +++ b/app/test/testutils.cpp @@ -121,16 +121,22 @@ bool TestUtils::needsToAuthorizeAgain( MerginApi *api, const QString &username ) QString TestUtils::generateUsername() { + const char* ciId = getenv( "CI_JOB_ID" ); + QString prefix = ciId == nullptr ? QStringLiteral( "mobile" ) : QStringLiteral( "%1" ).arg( ciId); + QDateTime time = QDateTime::currentDateTime(); QString uniqename = time.toString( QStringLiteral( "ddMMyy-hhmmss-z" ) ); - return QStringLiteral( "mobile-%1" ).arg( uniqename ); + + return QStringLiteral( "%1-%2" ).arg( prefix, uniqename ); } QString TestUtils::generateEmail() { + QString ciId = getenv( "CI_JOB_ID" ); + QString prefix = ciId.isEmpty() ? QStringLiteral( "mobile" ) : QStringLiteral( "%1" ).arg( ciId); QDateTime time = QDateTime::currentDateTime(); QString uniqename = time.toString( QStringLiteral( "ddMMyy-hhmmss-z" ) ); - return QStringLiteral( "mobile-autotest+%1@lutraconsulting.co.uk" ).arg( uniqename ); + return QStringLiteral( "%1-autotest+%2@lutraconsulting.co.uk" ).arg( prefix, uniqename ); } QString TestUtils::generatePassword() @@ -139,27 +145,12 @@ QString TestUtils::generatePassword() return QStringLiteral( "_Pass12%1" ).arg( pass ); } -QString TestUtils::generateWorkspaceName( const QString &username ) -{ - static const QRegularExpression regex( R"(mobile-autotest(\d{6})-(\d{4})\d{2}-\d{3})" ); - const QRegularExpressionMatch match = regex.match( username ); - - if ( match.hasMatch() ) - { - const QString date = match.captured( 1 ); // Day Month Year - const QString time = match.captured( 2 ); // Hour Second - return QString( "mmat-%1-%2" ).arg( date, time ); - } - return {}; -} - void TestUtils::generateRandomUser( MerginApi *api, QString &username, QString &password ) { // generate the test run-specific user details QString email = generateEmail(); password = generatePassword(); - username = email.split( '@' ).first(); - username.remove( "+" ); + username = generateUsername(); // create the account for the test run user api->clearAuth(); @@ -182,11 +173,10 @@ void TestUtils::generateRandomUser( MerginApi *api, QString &username, QString & // create workspace QSignalSpy wsSpy( api, &MerginApi::workspaceCreated ); // create the workspace name - QString workspace = generateWorkspaceName( username ); - api->createWorkspace( workspace ); + api->createWorkspace( username ); bool workspaceSuccess = wsSpy.wait( TestUtils::LONG_REPLY ); QVERIFY( workspaceSuccess ); - qDebug() << "CREATED NEW WORKSPACE:" << workspace; + qDebug() << "CREATED NEW WORKSPACE:" << username; // call userInfo to set active workspace QSignalSpy infoSpy( api, &MerginApi::userInfoReplyFinished ); @@ -211,7 +201,7 @@ void TestUtils::generateRandomUser( MerginApi *api, QString &username, QString & bool workspaceStorageModified = wsStorageSpy.wait( TestUtils::LONG_REPLY ); if ( workspaceStorageModified ) { - qDebug() << "Updated the storage limit" << workspace; + qDebug() << "Updated the storage limit" << username; } // this needs to be cleared, as the user will be authorized in the test cases. From 937fd7d95aff914c778684e9ccd444fde1bf549a Mon Sep 17 00:00:00 2001 From: Gabriel Bolbotina Date: Fri, 12 Dec 2025 18:38:22 +0200 Subject: [PATCH 2/8] Formatted code --- app/test/testutils.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/test/testutils.cpp b/app/test/testutils.cpp index 483579d53..2855cd9fb 100644 --- a/app/test/testutils.cpp +++ b/app/test/testutils.cpp @@ -121,8 +121,8 @@ bool TestUtils::needsToAuthorizeAgain( MerginApi *api, const QString &username ) QString TestUtils::generateUsername() { - const char* ciId = getenv( "CI_JOB_ID" ); - QString prefix = ciId == nullptr ? QStringLiteral( "mobile" ) : QStringLiteral( "%1" ).arg( ciId); + const char *ciId = getenv( "CI_JOB_ID" ); + QString prefix = ciId == nullptr ? QStringLiteral( "mobile" ) : QStringLiteral( "%1" ).arg( ciId ); QDateTime time = QDateTime::currentDateTime(); QString uniqename = time.toString( QStringLiteral( "ddMMyy-hhmmss-z" ) ); @@ -133,7 +133,7 @@ QString TestUtils::generateUsername() QString TestUtils::generateEmail() { QString ciId = getenv( "CI_JOB_ID" ); - QString prefix = ciId.isEmpty() ? QStringLiteral( "mobile" ) : QStringLiteral( "%1" ).arg( ciId); + QString prefix = ciId.isEmpty() ? QStringLiteral( "mobile" ) : QStringLiteral( "%1" ).arg( ciId ); QDateTime time = QDateTime::currentDateTime(); QString uniqename = time.toString( QStringLiteral( "ddMMyy-hhmmss-z" ) ); return QStringLiteral( "%1-autotest+%2@lutraconsulting.co.uk" ).arg( prefix, uniqename ); From ae0c099211ff293c1bb452c5adc129d60b13ad13 Mon Sep 17 00:00:00 2001 From: Gabriel Bolbotina Date: Tue, 16 Dec 2025 19:43:23 +0200 Subject: [PATCH 3/8] Modified test username and email Added prefix according to the platform --- .github/workflows/linux.yml | 1 - .github/workflows/macos.yml | 1 - app/test/testmerginapi.cpp | 2 +- app/test/testutils.cpp | 26 ++++++++++---------------- app/test/testutils.h | 1 - 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index c9fee8c84..04c902cc9 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -24,7 +24,6 @@ env: VCPKG_BINARY_SOURCES: 'clear;nuget,GitHub,readwrite' VCPKG_ROOT: "${{ github.workspace }}/vcpkg" TRIPLET: x64-linux - CI_JOB_ID: linux concurrency: group: ci-${{github.ref}}-linux diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index e0e98bc13..e42b6598e 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -25,7 +25,6 @@ env: XC_VERSION: ${{ '16.4' }} DEPLOYMENT_TARGET: '11.0' TRIPLET: arm64-osx - CI_JOB_ID: macos concurrency: group: ci-${{github.ref}}-macos diff --git a/app/test/testmerginapi.cpp b/app/test/testmerginapi.cpp index b066163d5..6a3eef6af 100644 --- a/app/test/testmerginapi.cpp +++ b/app/test/testmerginapi.cpp @@ -2500,9 +2500,9 @@ void TestMerginApi::testCreateWorkspace() QSKIP( "testCreateWorkspace requires USE_MM_SERVER_API_KEY" ); #endif // we need to register new user for tests and assign its credentials to env vars - QString username = TestUtils::generateUsername(); QString password = TestUtils::generatePassword(); QString email = TestUtils::generateEmail(); + QString username = email.left(email.lastIndexOf('@')); qDebug() << "REGISTERING NEW TEST USER WITH EMAIL:" << email; diff --git a/app/test/testutils.cpp b/app/test/testutils.cpp index 2855cd9fb..18415de55 100644 --- a/app/test/testutils.cpp +++ b/app/test/testutils.cpp @@ -118,25 +118,19 @@ bool TestUtils::needsToAuthorizeAgain( MerginApi *api, const QString &username ) return false; } - -QString TestUtils::generateUsername() -{ - const char *ciId = getenv( "CI_JOB_ID" ); - QString prefix = ciId == nullptr ? QStringLiteral( "mobile" ) : QStringLiteral( "%1" ).arg( ciId ); - - QDateTime time = QDateTime::currentDateTime(); - QString uniqename = time.toString( QStringLiteral( "ddMMyy-hhmmss-z" ) ); - - return QStringLiteral( "%1-%2" ).arg( prefix, uniqename ); -} - QString TestUtils::generateEmail() { - QString ciId = getenv( "CI_JOB_ID" ); + #ifdef Q_OS_MACOS + QString ciId = "mc"; + #elif Q_OS_LINUX + QString ciId = "lx"; + #else + QString ciId = ""; + #endif QString prefix = ciId.isEmpty() ? QStringLiteral( "mobile" ) : QStringLiteral( "%1" ).arg( ciId ); QDateTime time = QDateTime::currentDateTime(); QString uniqename = time.toString( QStringLiteral( "ddMMyy-hhmmss-z" ) ); - return QStringLiteral( "%1-autotest+%2@lutraconsulting.co.uk" ).arg( prefix, uniqename ); + return QStringLiteral( "%1-%2@lutraconsulting.co.uk" ).arg( prefix, uniqename ); } QString TestUtils::generatePassword() @@ -150,7 +144,7 @@ void TestUtils::generateRandomUser( MerginApi *api, QString &username, QString & // generate the test run-specific user details QString email = generateEmail(); password = generatePassword(); - username = generateUsername(); + username = email.left(email.lastIndexOf('@')); // create the account for the test run user api->clearAuth(); @@ -198,7 +192,7 @@ void TestUtils::generateRandomUser( MerginApi *api, QString &username, QString & })" ).arg( TEST_WORKSPACE_STORAGE_SIZE ).arg( TEST_WORKSPACE_PROJECT_NUMBER ); api->updateWorkspaceService( workspaceId, payload ); - bool workspaceStorageModified = wsStorageSpy.wait( TestUtils::LONG_REPLY ); + bool workspaceStorageModified = wsStorageSpy. wait( TestUtils::LONG_REPLY ); if ( workspaceStorageModified ) { qDebug() << "Updated the storage limit" << username; diff --git a/app/test/testutils.h b/app/test/testutils.h index c24d8afeb..43f5f3001 100644 --- a/app/test/testutils.h +++ b/app/test/testutils.h @@ -43,7 +43,6 @@ namespace TestUtils bool needsToAuthorizeAgain( MerginApi *api, const QString &username ); void generateRandomUser( MerginApi *api, QString &username, QString &password ); - QString generateUsername(); QString generateEmail(); QString generatePassword(); /* From 27ee3fb5e9968a12f3efb77f222ee1eaf4e47da4 Mon Sep 17 00:00:00 2001 From: Gabriel Bolbotina Date: Tue, 16 Dec 2025 19:48:20 +0200 Subject: [PATCH 4/8] Formatting code --- app/test/testmerginapi.cpp | 2 +- app/test/testutils.cpp | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/test/testmerginapi.cpp b/app/test/testmerginapi.cpp index 6a3eef6af..cf480b655 100644 --- a/app/test/testmerginapi.cpp +++ b/app/test/testmerginapi.cpp @@ -2502,7 +2502,7 @@ void TestMerginApi::testCreateWorkspace() // we need to register new user for tests and assign its credentials to env vars QString password = TestUtils::generatePassword(); QString email = TestUtils::generateEmail(); - QString username = email.left(email.lastIndexOf('@')); + QString username = email.left( email.lastIndexOf( '@' ) ); qDebug() << "REGISTERING NEW TEST USER WITH EMAIL:" << email; diff --git a/app/test/testutils.cpp b/app/test/testutils.cpp index 18415de55..af8be4126 100644 --- a/app/test/testutils.cpp +++ b/app/test/testutils.cpp @@ -120,13 +120,13 @@ bool TestUtils::needsToAuthorizeAgain( MerginApi *api, const QString &username ) QString TestUtils::generateEmail() { - #ifdef Q_OS_MACOS - QString ciId = "mc"; - #elif Q_OS_LINUX - QString ciId = "lx"; - #else +#ifdef Q_OS_MACOS + QString ciId = "m"; +#elif Q_OS_LINUX + QString ciId = "l"; +#else QString ciId = ""; - #endif +#endif QString prefix = ciId.isEmpty() ? QStringLiteral( "mobile" ) : QStringLiteral( "%1" ).arg( ciId ); QDateTime time = QDateTime::currentDateTime(); QString uniqename = time.toString( QStringLiteral( "ddMMyy-hhmmss-z" ) ); @@ -144,7 +144,7 @@ void TestUtils::generateRandomUser( MerginApi *api, QString &username, QString & // generate the test run-specific user details QString email = generateEmail(); password = generatePassword(); - username = email.left(email.lastIndexOf('@')); + username = email.left( email.lastIndexOf( '@' ) ); // create the account for the test run user api->clearAuth(); From 2926df8b8f13125ad61d2f7c2bd89a1218ef2e9e Mon Sep 17 00:00:00 2001 From: Gabriel Bolbotina Date: Wed, 17 Dec 2025 12:27:05 +0200 Subject: [PATCH 5/8] Updated logic, and added debug info for CI --- app/test/testlinks.cpp | 3 ++- app/test/testutils.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/test/testlinks.cpp b/app/test/testlinks.cpp index 3e57c87f1..6cad9516d 100644 --- a/app/test/testlinks.cpp +++ b/app/test/testlinks.cpp @@ -28,7 +28,8 @@ void UrlTester::processFinished() } else { - qDebug() << " URL " << mUrl << " ...ERROR"; + // for CI debugging + qDebug() << " URL " << mUrl << " ...ERROR. " << r->error(); mResult = 1; } r->deleteLater(); diff --git a/app/test/testutils.cpp b/app/test/testutils.cpp index af8be4126..d2f2ac465 100644 --- a/app/test/testutils.cpp +++ b/app/test/testutils.cpp @@ -120,9 +120,9 @@ bool TestUtils::needsToAuthorizeAgain( MerginApi *api, const QString &username ) QString TestUtils::generateEmail() { -#ifdef Q_OS_MACOS +#if defined(Q_OS_MACOS) QString ciId = "m"; -#elif Q_OS_LINUX +#elif defined(Q_OS_LINUX) QString ciId = "l"; #else QString ciId = ""; From 034cf5b40c869a1688d9f32f3cf420e7542a10a5 Mon Sep 17 00:00:00 2001 From: Gabriel Bolbotina Date: Thu, 18 Dec 2025 17:46:50 +0200 Subject: [PATCH 6/8] Implemented code findings --- app/test/testutils.cpp | 16 ++++++++-------- app/test/testutils.h | 6 ------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/app/test/testutils.cpp b/app/test/testutils.cpp index d2f2ac465..db2897ff5 100644 --- a/app/test/testutils.cpp +++ b/app/test/testutils.cpp @@ -121,16 +121,16 @@ bool TestUtils::needsToAuthorizeAgain( MerginApi *api, const QString &username ) QString TestUtils::generateEmail() { #if defined(Q_OS_MACOS) - QString ciId = "m"; + QString prefix = QStringLiteral( "ac" ); #elif defined(Q_OS_LINUX) - QString ciId = "l"; + QString prefix = QStringLiteral( "lin" ); #else - QString ciId = ""; + QString prefix = QStringLiteral( "mob" ); #endif - QString prefix = ciId.isEmpty() ? QStringLiteral( "mobile" ) : QStringLiteral( "%1" ).arg( ciId ); QDateTime time = QDateTime::currentDateTime(); - QString uniqename = time.toString( QStringLiteral( "ddMMyy-hhmmss-z" ) ); - return QStringLiteral( "%1-%2@lutraconsulting.co.uk" ).arg( prefix, uniqename ); + QString uniqeName = time.toString( QStringLiteral( "ddMMyy-hhmmss" ) ); + // adding the prefix and the uniqueName + return QStringLiteral( "%1-%2@lutraconsulting.co.uk" ).arg( prefix, uniqeName ); } QString TestUtils::generatePassword() @@ -188,11 +188,11 @@ void TestUtils::generateRandomUser( MerginApi *api, QString &username, QString & "storage": %1, "projects" : %2, "api_allowed" : true - } + }ˆ })" ).arg( TEST_WORKSPACE_STORAGE_SIZE ).arg( TEST_WORKSPACE_PROJECT_NUMBER ); api->updateWorkspaceService( workspaceId, payload ); - bool workspaceStorageModified = wsStorageSpy. wait( TestUtils::LONG_REPLY ); + bool workspaceStorageModified = wsStorageSpy.wait( TestUtils::LONG_REPLY ); if ( workspaceStorageModified ) { qDebug() << "Updated the storage limit" << username; diff --git a/app/test/testutils.h b/app/test/testutils.h index 43f5f3001..8643248fa 100644 --- a/app/test/testutils.h +++ b/app/test/testutils.h @@ -45,12 +45,6 @@ namespace TestUtils QString generateEmail(); QString generatePassword(); - /* - * Create a workspace name from the generated username - * Output: a workspace name: mmat-DayMonthYear-HourMinutes - */ - QString generateWorkspaceName( const QString &username ); - QString testDataDir(); QgsProject *loadPlanesTestProject(); From eda1b0431cb29ce46bb376214bfa8d3a3da2266b Mon Sep 17 00:00:00 2001 From: Matej Bagar Date: Fri, 19 Dec 2025 09:36:06 +0000 Subject: [PATCH 7/8] Fix typo --- app/test/testutils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/test/testutils.cpp b/app/test/testutils.cpp index db2897ff5..565cec382 100644 --- a/app/test/testutils.cpp +++ b/app/test/testutils.cpp @@ -121,7 +121,7 @@ bool TestUtils::needsToAuthorizeAgain( MerginApi *api, const QString &username ) QString TestUtils::generateEmail() { #if defined(Q_OS_MACOS) - QString prefix = QStringLiteral( "ac" ); + QString prefix = QStringLiteral( "mac" ); #elif defined(Q_OS_LINUX) QString prefix = QStringLiteral( "lin" ); #else From b174b80a002f2825c177e39aac611dfcfd4942e9 Mon Sep 17 00:00:00 2001 From: Matej Bagar Date: Fri, 19 Dec 2025 09:36:23 +0000 Subject: [PATCH 8/8] Remove typo --- app/test/testutils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/test/testutils.cpp b/app/test/testutils.cpp index 565cec382..3c65c7ccb 100644 --- a/app/test/testutils.cpp +++ b/app/test/testutils.cpp @@ -188,7 +188,7 @@ void TestUtils::generateRandomUser( MerginApi *api, QString &username, QString & "storage": %1, "projects" : %2, "api_allowed" : true - }ˆ + } })" ).arg( TEST_WORKSPACE_STORAGE_SIZE ).arg( TEST_WORKSPACE_PROJECT_NUMBER ); api->updateWorkspaceService( workspaceId, payload );