fix: integration tests — sequential execution, IMAP timeouts, JMAP timeout

Root cause: flutter test ran all 3 integration test files in parallel
against the same Stalwart instance. Concurrent SMTP/IMAP from
email_repository_imap_test and concurrent_sync_test caused SMTP rate
limiting (4th send hung for ~27s) and flushPendingChanges race failures.

Fixes:
- stalwart-dev/test.sh: add --concurrency=1 so test files run serially
- concurrent_sync_test: reduce timeout 2 min → 30 s (tests now pass in ~2s)
- imap_client_factory + test helpers: set defaultResponseTimeout=20s on
  ImapClient so individual IMAP commands never block indefinitely
- jmap_client: reduce HTTP call timeout 30 s → 10 s (local server; keeps
  stacked-timeout total well below any reasonable per-test limit)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Thomas Güttler
2026-04-21 06:29:49 +02:00
co-authored by Claude Sonnet 4.6
parent be56232f00
commit 733da201ee
5 changed files with 13 additions and 8 deletions
+2 -1
View File
@@ -21,7 +21,8 @@ Future<ImapClient> connectImap(
'Unencrypted IMAP connections are not allowed. Enable SSL/TLS.',
);
}
final client = ImapClient();
final client =
ImapClient(defaultResponseTimeout: const Duration(seconds: 20));
await client.connectToServer(account.imapHost, account.imapPort);
await client.login(username, password);
return client;
+2 -2
View File
@@ -123,7 +123,7 @@ class JmapClient {
},
body: body,
)
.timeout(const Duration(seconds: 30));
.timeout(const Duration(seconds: 10));
if (resp.statusCode != 200) {
throw JmapException('API call failed (HTTP ${resp.statusCode})');
@@ -160,7 +160,7 @@ class JmapClient {
},
body: data,
)
.timeout(const Duration(seconds: 30));
.timeout(const Duration(seconds: 10));
if (resp.statusCode != 200 && resp.statusCode != 201) {
throw JmapException('Blob upload failed (HTTP ${resp.statusCode})');
}
+1 -1
View File
@@ -62,6 +62,6 @@ export STALWART_IMAP_HOST="127.0.0.1"
export STALWART_SMTP_HOST="127.0.0.1"
START=$(date +%s)
fvm flutter test test/integration/
fvm flutter test --concurrency=1 test/integration/
END=$(date +%s)
echo "integration: $((END - START))s"
+4 -2
View File
@@ -61,7 +61,9 @@ Future<enough_mail.ImapClient> _connectImapPlaintext(
String username,
String password,
) async {
final client = enough_mail.ImapClient();
final client = enough_mail.ImapClient(
defaultResponseTimeout: const Duration(seconds: 20),
);
await client.connectToServer(
account.imapHost,
account.imapPort,
@@ -125,7 +127,7 @@ void main() {
});
test('concurrent IMAP + JMAP sync caches all emails without errors',
timeout: const Timeout(Duration(minutes: 2)), () async {
timeout: const Timeout(Duration(seconds: 30)), () async {
final ts = DateTime.now().millisecondsSinceEpoch;
const msgCount = 2;
@@ -27,7 +27,8 @@ Future<ImapClient> _imapConnect({
required String user,
required String pass,
}) async {
final client = ImapClient();
final client =
ImapClient(defaultResponseTimeout: const Duration(seconds: 20));
await client.connectToServer(host, port, isSecure: false);
await client.login(user, pass);
return client;
@@ -109,7 +110,8 @@ void main() {
String username,
String password,
) async {
final client = ImapClient();
final client =
ImapClient(defaultResponseTimeout: const Duration(seconds: 20));
await client.connectToServer(a.imapHost, a.imapPort, isSecure: false);
await client.login(username, password);
return client;