Files
jcoffey-dev ad65f0d10a Upgrade tests with the published images (K-L5)
rolling-upgrade-test.sh: release N-1 to N from ghcr.io, pinned by digest,
with mail flowing the whole way (mailflow.py, a message a second, retried
as an MTA would) and every accepted message checked to arrive exactly
once. 27.1-rc.33 to rc.34: rolled in 19s, 43 accepted, 43 arrived, one
connection refused while a pod went away and retried.

crossing-test.sh: a store made and filled by 2026.11.18.3 (layout 1),
upgraded by the chart to 27.1-rc.34: refused until the layout change is
acknowledged, then crossed in 194s (1 to 2 to 3), mailbox digests equal.

Fixes on the way: fresh-store.sh's pods and seed-job.yaml carry the
chart's labels, so its NetworkPolicies cover them as the Kyverno policy
requires; fresh-store.sh and seed-store.sh take PULL for published images;
mailtest.py and mailbox-digest.py send from a sender domain of their own
(the default throttle allows 25 an hour per sender domain and recipient),
and mailbox-digest.py one message per session, paced.
2026-11-19 21:07:40 -07:00

63 lines
2.4 KiB
Python
Executable File

#!/usr/bin/env python3
"""The chart smoke test's mail check: a message in over SMTP on port 25,
then found over IMAPS on 993, both through the mail Service's address.
ACCOUNT=user@domain PASSWORD_FILE=... mailtest.py LB_ADDRESS
The server's certificate is self-signed in the lab, so TLS isn't verified.
"""
import imaplib, os, smtplib, ssl, sys, time, uuid
from email.message import EmailMessage
from email.utils import formatdate, make_msgid
lb = sys.argv[1]
account = os.environ["ACCOUNT"]
password = open(os.environ["PASSWORD_FILE"]).read().strip()
token = uuid.uuid4().hex
tls = ssl.create_default_context()
tls.check_hostname = False
tls.verify_mode = ssl.CERT_NONE
msg = EmailMessage()
# A sender domain with no DNS at all: one that publishes DMARC (example.net
# does, p=reject) would send the message to Junk
# ...and one of its own each run: the server's default throttle allows 25
# messages an hour from one sender domain to one recipient
msg["From"] = f"lab-sender@{token[:12]}.sender.test"
msg["To"] = account
msg["Subject"] = f"chart smoke {token}"
msg["Date"] = formatdate()
msg["Message-ID"] = make_msgid(domain="sender.test")
msg.set_content("Sent by the inbuxa-k8s-lab chart smoke test.\n")
started = time.time()
with smtplib.SMTP(lb, 25, timeout=30) as smtp:
smtp.ehlo("lab-client.sender.test")
if smtp.has_extn("starttls"):
smtp.starttls(context=tls)
smtp.ehlo("lab-client.sender.test")
smtp.send_message(msg)
print(f"SMTP: accepted for {account}")
deadline = started + 90
while True:
with imaplib.IMAP4_SSL(lb, 993, ssl_context=tls, timeout=30) as imap:
imap.login(account, password)
# The lab has no public DNS, so the sender can't pass SPF, DKIM or
# reverse DNS and the spam filter files it in Junk, rightly. The test
# is the path through the chart, so either folder will do.
where = None
for folder in ("INBOX", "Junk Mail", "Junk"):
if imap.select(f'"{folder}"', readonly=True)[0] != "OK":
continue
_, found = imap.search(None, "SUBJECT", f'"{token}"')
if found[0].split():
where = folder
break
if where:
print(f"IMAPS: delivered to {where}, found after {time.time() - started:.1f}s")
break
if time.time() > deadline:
sys.exit("IMAPS: the message never arrived")
time.sleep(3)