Skip to content

[TODO]: Tests - test_helper.bats refactor mailqueue test cases #3768

@polarathene

Description

@polarathene

Description

This was identified during recent review feedback, that the test cases could probably be refactored:

  • "wait_for_empty_mail_queue_in_container fails when timeout reached"
  • "wait_for_empty_mail_queue_in_container succeeds within timeout"

Presently it's skipped for being unreliable like some other tests have been (Dovecot Quota). The test file also needs to be adapted to our newer test format.

We can configure Postfix to defer mail to a transport, keeping it stuck in the queue until we decide to flush it. This is the main focus of the test-case which relied on unreliable means to try fill the queue up momentarily.


SECONDS=0
# no mails -> should return immediately
TEST_TIMEOUT_IN_SECONDS=5 wait_for_empty_mail_queue_in_container "${CONTAINER_NAME}"
[[ ${SECONDS} -lt 5 ]]
# fill the queue with a message
docker exec "${CONTAINER_NAME}" /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/emails/amavis-virus.txt"
# that should still be stuck in the queue
! TEST_TIMEOUT_IN_SECONDS=0 wait_for_empty_mail_queue_in_container "${CONTAINER_NAME}"

# fill the queue with a message
docker exec "${CONTAINER_NAME}" /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/emails/amavis-virus.txt"
# give it some time to clear the queue
SECONDS=0
wait_for_empty_mail_queue_in_container "${CONTAINER_NAME}"
[[ ${SECONDS} -gt 0 ]]

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/testskind/improvementImprove an existing feature, configuration file or the documentationmeta/help wantedThe OP requests help from others - chime in! :Dservice/postfixstale-bot/ignoreIndicates that this issue / PR shall not be closed by our stale-checking CI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions