Skip to content

Test wait for database + SMTP in forbid pipelining mode support - #86

Open
AndrewSav wants to merge 2 commits into
mailserver2:masterfrom
AndrewSav:test-wait-for-database
Open

Test wait for database + SMTP in forbid pipelining mode support#86
AndrewSav wants to merge 2 commits into
mailserver2:masterfrom
AndrewSav:test-wait-for-database

Conversation

@AndrewSav

Copy link
Copy Markdown
Collaborator

Description

Two fixes to the integration test harness, in preparation to Debian 13 upgrade.

1. SMTP fixtures are sent fire-and-forget

  • Current behavior: the fixtures pipe a whole SMTP dialogue into nc or openssl s_client, which sends every command without reading the server's replies. Postfix treats that as unauthorised pipelining and rejects it with 554 5.5.0 Error: SMTP protocol synchronization. smtpd_forbid_unauth_pipelining defaults to yes from postfix 3.9 on, so on Debian 13 (postfix 3.10) not one fixture mail is accepted and every suite fails wholesale. The dialogues also use HELO, so postfix never advertises PIPELINING and no look-ahead is permitted at all.

    On Debian 12 (postfix 3.7) the submission fixtures pass only by timing luck — openssl happens to be slow enough that the server's replies have already arrived by the time the next command is written.

  • New behavior: adds test/share/tests/smtp-send.py, which replays a dialogue file one command at a time and reads each reply before sending the next. The port 25 and submission (587/465) fixtures and the SMTP-auth assertions are routed through it. Its exit status reports whether the dialogue completed, not whether the mail was accepted, because several fixtures test a rejection on purpose and postfix ends those dialogues by hanging up.

    The IMAP triggers on port 993 are left alone, as IMAP permits pipelining.

2. Container startup races its backing service

  • Current behavior: the suites start the mailserver container a fixed number of seconds after creating its backing service, which races against that service's startup. A service may need more time on a slow host, and the waits were inconsistent anyway - init_ecdsa waited 10s while init_sieve, init_ldap, init_ldap2 and the two traefik targets did not wait at all.

    When the race is lost, dovecot logs Connect failed to database to /var/log/mail.err and the "mail.err does not exist" assertion fails. Early delivery failures also shift the message UIDs that the sieve assertions depend on, so the failure surfaces far from its cause.

  • New behavior: every fixed sleep is replaced with a wait on the condition it stood in for.

    • redis, mariadb, postgres, openldap — each service is probed at the end of its own init_ target, so all dependent targets inherit the wait. The SQL probes query the seeded schema as the application user, which covers server startup, init-script import and user creation in one check; openldap is probed with an authenticated search of the bootstrapped tree.
    • the blanket sleep 30 in fixtures_reverse / fixtures_ldap2 becomes explicit waits for rspamd, imaps and submission to listen.
    • the sleep 2 / sleep 10 around mail delivery become waits for postfix to drain its incoming, active and maildrop queues. Deferred mail is ignored, so a bounce to an unreachable external domain cannot hang the wait.

    Each wait is bounded by WAIT_TIMEOUT (default 300s) and dumps the service's logs on timeout, so a genuine hang still fails the build with something to read.

    13 fixed sleeps are removed, totalling 196s of unconditional sleeping per full run. Every sleep that remains is a poll interval inside one of these bounded waits.

Dependencies: none. smtp-send.py is stdlib-only (socket, ssl, argparse) and python3 is already present in the image.

Type of change

  • Test (adding missing tests or correcting existing ones)

Status

  • Ready

Todo List

  • Implementation
  • Tests
  • Documentation — n/a, no user-facing behaviour changes; smtp-send.py carries a module docstring explaining why it exists, and the Makefile waits are commented at each site

How has this been tested ?

Full suite run against the current Debian 12 base (mailserver2/debian-mail-overlay:1.0.20, postfix 3.7) — the base master and CI use — to confirm the change is a no-op there:

Suite ok not ok
default 122 0
reverse 79 0
ldap 66 0
ldap2 29 0
sieve 2 0
ecdsa 4 0
traefik_acmev1 10 0
traefik_acmev2 11 0
Total 323 0

Counts are unchanged from master.

@AndrewSav AndrewSav changed the title Test wait for database Test wait for database + SMTP in forbid pipelining mode support Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant