Skip to content

tests(refactor): mail_lmtp_ip.bats#3004

Merged
polarathene merged 6 commits intodocker-mailserver:masterfrom
polarathene:tests/migrate-lmtp
Jan 15, 2023
Merged

tests(refactor): mail_lmtp_ip.bats#3004
polarathene merged 6 commits intodocker-mailserver:masterfrom
polarathene:tests/migrate-lmtp

Conversation

@polarathene
Copy link
Copy Markdown
Member

@polarathene polarathene commented Jan 13, 2023

Description

This refactoring required a bit of extra investigation into the feature under test. That revealed some redundant content to drop, detailed below.

Refactor summary

  • Converted to new testing conventions and common container helpers.
  • ENABLE_POSTFIX_VIRTUAL_TRANSPORT was not relevant, dropped. Only POSTFIX_DAGENT matters for the feature.
  • Revised test cases, logic remains the same.
  • Large custom config used was not documented and doesn't appear to serve any purpose. Simplified by replacing with a single modification with user-patches.sh.
  • Added some additional comments for context of test and improvements that could be made.

NOTE: The ENV removal here is not a breaking change. So long as the actual ENV with LMTP URI is present, it continues to work (unless someone weirdly relied on keeping that URI var and toggling the enable var instead). It is part of v12 and changelog will still highlight it regardless if some third-party integrations were relying upon it.

The feature itself seems rather niche. You'd still need to manually configure DMS like the user-patches.sh is doing to leverage it with another DMS instance. The value of this ENV is for services with LMTP that aren't DMS based AFAIK? It might be relevant to deprecate the ENV and drop it in the future (deferring to postfix-main.cf or similar) if rarely used?

Additional info

Background (History)

Removing entire config dir for this test in favor of user-patches.sh

I've identified none of it was relevant to the test except a few files. Only one of those actually had an effect.

Only relevant changes in test config regarding LMTP:

  • /etc/dovecot/dovecot.conf (protocols = imap lmtp) and /etc/dovecot/protocols.d/ (protocols = $protocols lmtp).
  • conf.d/10-master.conf only changed the LMTP service listener from a unix socket to TCP on port 24 (This was the only change required for the test to pass).

None of those configs are required as:

  • protocols = imap pop3 lmtp is the upstream default, no need to add lmtp.
  • The LMTP service listener is now configured for the test with user-patches.sh.

Misc changes

Removed comment from mail_hostname.bats

In an old PR I was not familiar with LMTP or the relevance of the comment in this test file. I lacked time back then to investigate to know if it was ok to remove it 😅

There was a comment 'postfix virtual transport lmtp' followed by two lines sending mail. This came from this commit
(from a PR in Oct 2020).

There's no value from that comment, as the email sent is for generic testing, nothing to do with LMTP (Likely transferred over from test.bats at the time by accident).

smtp-delivery.bats

Similar logic to match delivery logs. Figured I'd keep that in sync, and reduced the horizontal scroll for the command by extracting out the matching and formatting parts into vars. Added an example comment if helpful.

Type of change

  • Improvement (non-breaking change that does improve existing functionality)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (README.md or the documentation under docs/)
  • If necessary I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

None of this is needed. Only relevant change is changing the LMTP service listener for Dovecot and that can be delegated to `user-patches.sh`.
Only relevant changes in test config regarding LMTP:
- `/etc/dovecot/dovecot.conf` (`protocols = imap lmtp`) and `/etc/dovecot/protocols.d/` (`protocols = $protocols lmtp`).
- `conf.d/10-master.conf` only changed the LMTP service listener from a unix socket to TCP on port 24 (_This was the only change required for the test to pass_).

None of those configs are required as:
- `protocols = imap pop3 lmtp` [is the upstream default](https://doc.dovecot.org/settings/core/#core_setting-protocols), no need to add `lmtp`.
- The LMTP service listener is now configured for the test with `user-patches.sh`.
- Converted to new testing conventions and common container helpers.
- `ENABLE_POSTFIX_VIRTUAL_TRANSPORT` was not relevant, dropped.
- Revised test cases, logic remains the same.
- Large custom config used was not documented and doesn't appear to serve any purpose. Simplified by replacing with a single modification with `user-patches.sh`.
- Added some additional comments for context of test and improvements that could be made.
@polarathene polarathene added service/dovecot service/postfix area/tests kind/improvement Improve an existing feature, configuration file or the documentation labels Jan 13, 2023
@polarathene polarathene added this to the v12.0.0 milestone Jan 13, 2023
@polarathene polarathene self-assigned this Jan 13, 2023
The comment from `mail_hostname` provides no valid context, it was likely copied over from `tests.bats` in Oct 2020 by accident.

The email sent is just for testing, nothing relevant to LMTP.

---

Added additional comment for test to reference extra information from.
Extracts out the match pattern and formatting commands into separate vars (reduces horizontal scrolling), and includes extra docs about what the matched line should be expected to look like.
@github-actions
Copy link
Copy Markdown
Contributor

Documentation preview for this PR is ready! 🎉

Built with commit: b02f759

Copy link
Copy Markdown
Member

@georglauterbach georglauterbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@polarathene polarathene merged commit 133eb9b into docker-mailserver:master Jan 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/tests kind/improvement Improve an existing feature, configuration file or the documentation service/dovecot service/postfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants