Skip to content

Commit 7770b48

Browse files
Fix CI concurrency test runs (#4271)
1 parent 8899a50 commit 7770b48

File tree

4 files changed

+17
-39
lines changed

4 files changed

+17
-39
lines changed

app/test/testlinks.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ void UrlTester::processFinished()
2828
}
2929
else
3030
{
31-
qDebug() << " URL " << mUrl << " ...ERROR";
31+
// for CI debugging
32+
qDebug() << " URL " << mUrl << " ...ERROR. " << r->error();
3233
mResult = 1;
3334
}
3435
r->deleteLater();

app/test/testmerginapi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2500,9 +2500,9 @@ void TestMerginApi::testCreateWorkspace()
25002500
QSKIP( "testCreateWorkspace requires USE_MM_SERVER_API_KEY" );
25012501
#endif
25022502
// we need to register new user for tests and assign its credentials to env vars
2503-
QString username = TestUtils::generateUsername();
25042503
QString password = TestUtils::generatePassword();
25052504
QString email = TestUtils::generateEmail();
2505+
QString username = email.left( email.lastIndexOf( '@' ) );
25062506

25072507
qDebug() << "REGISTERING NEW TEST USER WITH EMAIL:" << email;
25082508

app/test/testutils.cpp

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,19 @@ bool TestUtils::needsToAuthorizeAgain( MerginApi *api, const QString &username )
118118
return false;
119119
}
120120

121-
122-
QString TestUtils::generateUsername()
123-
{
124-
QDateTime time = QDateTime::currentDateTime();
125-
QString uniqename = time.toString( QStringLiteral( "ddMMyy-hhmmss-z" ) );
126-
return QStringLiteral( "mobile-%1" ).arg( uniqename );
127-
}
128-
129121
QString TestUtils::generateEmail()
130122
{
123+
#if defined(Q_OS_MACOS)
124+
QString prefix = QStringLiteral( "mac" );
125+
#elif defined(Q_OS_LINUX)
126+
QString prefix = QStringLiteral( "lin" );
127+
#else
128+
QString prefix = QStringLiteral( "mob" );
129+
#endif
131130
QDateTime time = QDateTime::currentDateTime();
132-
QString uniqename = time.toString( QStringLiteral( "ddMMyy-hhmmss-z" ) );
133-
return QStringLiteral( "mobile-autotest+%1@lutraconsulting.co.uk" ).arg( uniqename );
131+
QString uniqeName = time.toString( QStringLiteral( "ddMMyy-hhmmss" ) );
132+
// adding the prefix and the uniqueName
133+
return QStringLiteral( "%1-%2@lutraconsulting.co.uk" ).arg( prefix, uniqeName );
134134
}
135135

136136
QString TestUtils::generatePassword()
@@ -139,27 +139,12 @@ QString TestUtils::generatePassword()
139139
return QStringLiteral( "_Pass12%1" ).arg( pass );
140140
}
141141

142-
QString TestUtils::generateWorkspaceName( const QString &username )
143-
{
144-
static const QRegularExpression regex( R"(mobile-autotest(\d{6})-(\d{4})\d{2}-\d{3})" );
145-
const QRegularExpressionMatch match = regex.match( username );
146-
147-
if ( match.hasMatch() )
148-
{
149-
const QString date = match.captured( 1 ); // Day Month Year
150-
const QString time = match.captured( 2 ); // Hour Second
151-
return QString( "mmat-%1-%2" ).arg( date, time );
152-
}
153-
return {};
154-
}
155-
156142
void TestUtils::generateRandomUser( MerginApi *api, QString &username, QString &password )
157143
{
158144
// generate the test run-specific user details
159145
QString email = generateEmail();
160146
password = generatePassword();
161-
username = email.split( '@' ).first();
162-
username.remove( "+" );
147+
username = email.left( email.lastIndexOf( '@' ) );
163148

164149
// create the account for the test run user
165150
api->clearAuth();
@@ -182,11 +167,10 @@ void TestUtils::generateRandomUser( MerginApi *api, QString &username, QString &
182167
// create workspace
183168
QSignalSpy wsSpy( api, &MerginApi::workspaceCreated );
184169
// create the workspace name
185-
QString workspace = generateWorkspaceName( username );
186-
api->createWorkspace( workspace );
170+
api->createWorkspace( username );
187171
bool workspaceSuccess = wsSpy.wait( TestUtils::LONG_REPLY );
188172
QVERIFY( workspaceSuccess );
189-
qDebug() << "CREATED NEW WORKSPACE:" << workspace;
173+
qDebug() << "CREATED NEW WORKSPACE:" << username;
190174

191175
// call userInfo to set active workspace
192176
QSignalSpy infoSpy( api, &MerginApi::userInfoReplyFinished );
@@ -211,7 +195,7 @@ void TestUtils::generateRandomUser( MerginApi *api, QString &username, QString &
211195
bool workspaceStorageModified = wsStorageSpy.wait( TestUtils::LONG_REPLY );
212196
if ( workspaceStorageModified )
213197
{
214-
qDebug() << "Updated the storage limit" << workspace;
198+
qDebug() << "Updated the storage limit" << username;
215199
}
216200

217201
// this needs to be cleared, as the user will be authorized in the test cases.

app/test/testutils.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,8 @@ namespace TestUtils
4343
bool needsToAuthorizeAgain( MerginApi *api, const QString &username );
4444
void generateRandomUser( MerginApi *api, QString &username, QString &password );
4545

46-
QString generateUsername();
4746
QString generateEmail();
4847
QString generatePassword();
49-
/*
50-
* Create a workspace name from the generated username
51-
* Output: a workspace name: mmat-DayMonthYear-HourMinutes
52-
*/
53-
QString generateWorkspaceName( const QString &username );
54-
5548
QString testDataDir();
5649

5750
QgsProject *loadPlanesTestProject();

0 commit comments

Comments
 (0)