From 58cde48a9e272d773c0db1f117f8f1a915d92d04 Mon Sep 17 00:00:00 2001 From: John Coffey Date: Thu, 19 Nov 2026 23:22:04 -0700 Subject: [PATCH 1/2] The mail test client: every client check in one command (K-L2) lab/chart/mailcheck.py checks, as alice: SMTP in on 25, submission on 465 with AUTH, IMAPS, JMAP (OAuth, Email/query), SMTP out to an outside server, CalDAV and CardDAV round trips; one table, exit 1 on any failure. The outside server is lab/chart/mail-sink.yaml, a small SMTP sink in its own namespace, in the CloudNativePG image the cluster already has; mail for sink.test reaches it by a Relay route the check sets up as admin. The outgoing message has to arrive from alice and DKIM-signed for lab.test. lab/chart/mailcheck.sh runs it with the webmail (across both replicas) and console sign-ins against an installed chart; e2e.sh now runs that after the install. --- README.md | 7 + lab/chart/mail-sink.yaml | 121 +++++++++++++++++ lab/chart/mailcheck.py | 278 +++++++++++++++++++++++++++++++++++++++ lab/chart/mailcheck.sh | 72 ++++++++++ lab/e2e.sh | 50 +------ 5 files changed, 484 insertions(+), 44 deletions(-) create mode 100644 lab/chart/mail-sink.yaml create mode 100755 lab/chart/mailcheck.py create mode 100755 lab/chart/mailcheck.sh diff --git a/README.md b/README.md index 5476cda..dd05e62 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,13 @@ and arm64 runners on each Kubernetes minor in `lab/kubernetes.json`, nightly and on every push (`.github/workflows/e2e.yml`), and each chart branch in inbuxa-charts calls the same workflow for its own commit. +`lab/chart/mailcheck.sh` is every client check against an installed chart, +in one command: SMTP in, submission, IMAP, JMAP, SMTP out to an outside +server (an SMTP sink in the cluster, `lab/chart/mail-sink.yaml`), CalDAV, +CardDAV, the webmail signing in across both replicas and the console. It's +what `e2e.sh` runs after the install, and what to run after changing the +lab by hand. + `lab/up.sh` is just the cluster: kind, Kyverno and the policies, MetalLB, and the data layer (CloudNativePG, NATS, Garage). It adds the Helm repositories it needs; the versions are pinned in `lab/versions.env`. diff --git a/lab/chart/mail-sink.yaml b/lab/chart/mail-sink.yaml new file mode 100644 index 0000000..84dd83b --- /dev/null +++ b/lab/chart/mail-sink.yaml @@ -0,0 +1,121 @@ +# SPDX-FileCopyrightText: 2026 Coffey Labs LLC +# SPDX-License-Identifier: Apache-2.0 +# +# The outside world's mail server, for mail going out (K-L2): an SMTP +# server that takes anything and prints each message as one JSON line in +# its log, for mailcheck.py to find. mailcheck.sh routes the domain +# sink.test here (a Relay route), so nothing leaves the cluster. +# +# Plain Python 3.9 in the CloudNativePG PostgreSQL image (IMAGE, from +# versions.env), which the cluster already has, so no new image. Own +# namespace, outside the inbuxa policies, but restricted-shaped anyway. +apiVersion: v1 +kind: Namespace +metadata: + name: lab-sink + labels: + pod-security.kubernetes.io/enforce: restricted +--- +apiVersion: v1 +kind: ConfigMap +metadata: {name: sink, namespace: lab-sink} +data: + sink.py: | + import asyncio, email, email.policy, json, sys, time + + def log(rec): + print(json.dumps(rec), flush=True) + + async def session(reader, writer): + peer = writer.get_extra_info("peername") + def send(line): + writer.write((line + "\r\n").encode()) + send("220 lab-sink ESMTP") + mail_from, rcpts = None, [] + try: + while True: + raw = await asyncio.wait_for(reader.readline(), 120) + if not raw: + break + line = raw.decode("utf-8", "replace").rstrip("\r\n") + verb = line[:4].upper() + if verb in ("EHLO", "HELO"): + send("250-lab-sink" if verb == "EHLO" else "250 lab-sink") + if verb == "EHLO": + send("250-8BITMIME") + send("250 SMTPUTF8") + ehlo = line[5:].strip() + elif verb == "MAIL": + mail_from, rcpts = line.split(":", 1)[1].strip().split(" ")[0].strip("<>"), [] + send("250 ok") + elif verb == "RCPT": + rcpts.append(line.split(":", 1)[1].strip().split(" ")[0].strip("<>")) + send("250 ok") + elif verb == "DATA": + send("354 go ahead") + await writer.drain() + data = bytearray() + while True: + l = await asyncio.wait_for(reader.readline(), 120) + if l in (b".\r\n", b".\n") or not l: + break + data += l[1:] if l.startswith(b"..") else l + msg = email.message_from_bytes(bytes(data), policy=email.policy.default) + log({"at": time.time(), "peer": peer[0], "ehlo": ehlo, "from": mail_from, "rcpts": rcpts, + "subject": str(msg.get("Subject", "")), + "dkim": [str(h) for h in msg.get_all("DKIM-Signature", [])]}) + send("250 queued") + elif verb == "RSET": + mail_from, rcpts = None, [] + send("250 ok") + elif verb == "NOOP": + send("250 ok") + elif verb == "QUIT": + send("221 bye") + break + else: + send("502 not here") + await writer.drain() + except (asyncio.TimeoutError, ConnectionError): + pass + finally: + writer.close() + + async def main(): + server = await asyncio.start_server(session, "0.0.0.0", 2525) + print("lab-sink listening on 2525", flush=True) + async with server: + await server.serve_forever() + + asyncio.run(main()) +--- +apiVersion: apps/v1 +kind: Deployment +metadata: {name: sink, namespace: lab-sink} +spec: + replicas: 1 + selector: {matchLabels: {app: lab-sink}} + template: + metadata: {labels: {app: lab-sink}} + spec: + automountServiceAccountToken: false + enableServiceLinks: false + securityContext: {runAsNonRoot: true, runAsUser: 2000, runAsGroup: 2000, seccompProfile: {type: RuntimeDefault}} + containers: + - name: sink + image: IMAGE + imagePullPolicy: IfNotPresent + command: [python3, -u, /sink/sink.py] + ports: [{name: smtp, containerPort: 2525}] + readinessProbe: {tcpSocket: {port: smtp}, periodSeconds: 2} + resources: {requests: {cpu: 10m, memory: 32Mi}, limits: {memory: 128Mi}} + securityContext: {allowPrivilegeEscalation: false, readOnlyRootFilesystem: true, capabilities: {drop: [ALL]}} + volumeMounts: [{name: sink, mountPath: /sink}] + volumes: [{name: sink, configMap: {name: sink}}] +--- +apiVersion: v1 +kind: Service +metadata: {name: sink, namespace: lab-sink} +spec: + selector: {app: lab-sink} + ports: [{name: smtp, port: 25, targetPort: smtp}] diff --git a/lab/chart/mailcheck.py b/lab/chart/mailcheck.py new file mode 100755 index 0000000..801b908 --- /dev/null +++ b/lab/chart/mailcheck.py @@ -0,0 +1,278 @@ +#!/usr/bin/env python3 +# SPDX-FileCopyrightText: 2026 Coffey Labs LLC +# SPDX-License-Identifier: Apache-2.0 +"""The mail test client (K-L2): what a mail client and the internet do with +an installed chart, each check named, one table at the end. + + KCTX=kind-inbuxa-lab mailcheck.py LB HTTP ALICE_PASSWORD_FILE ADMIN_PASSWORD_FILE + +LB is the mail Service's address (25, 465, 993), HTTP the server's http +port (http://127.0.0.1:N through a port-forward). Checks, as alice@lab.test: + + smtp in a message from another domain on 25 + submission alice sends on 465 (implicit TLS, AUTH): to herself, and out + imap both arrive, found over IMAPS on 993 + jmap both found with Email/query, signed in with OAuth + smtp out the outgoing one reaches the outside server (mail-sink.yaml) + from alice, DKIM-signed for lab.test + caldav an event put, read back and deleted + carddav a contact the same + +Mail for sink.test goes to the sink by a Relay route this sets up, as +admin@lab.test, if it isn't there (route "lab-sink" and one line in the +outbound strategy). Exits 1 if any check failed. The lab's certificate is +self-signed, so TLS isn't verified. +""" +import base64, hashlib, http.client as httpc, imaplib, json, os, secrets, smtplib, ssl +import subprocess, sys, time, urllib.parse, uuid +from email.message import EmailMessage +from email.utils import formatdate, make_msgid + +lb, http_base, alice_pw_file, admin_pw_file = sys.argv[1:5] +KCTX = os.environ.get("KCTX", "kind-inbuxa-lab") +ALICE = "alice@lab.test" +alice_pw = open(alice_pw_file).read().strip() +admin_pw = open(admin_pw_file).read().strip() +run = uuid.uuid4().hex[:10] +SINK = "sink.lab-sink.svc.cluster.local" +tls = ssl.create_default_context() +tls.check_hostname = False +tls.verify_mode = ssl.CERT_NONE +results = [] + + +def check(name): + def wrap(fn): + t = time.time() + try: + detail = fn() or "" + results.append((name, True, detail, time.time() - t)) + except Exception as e: # each check reports, the rest still run + results.append((name, False, f"{type(e).__name__}: {e}"[:200], time.time() - t)) + return fn + return wrap + + +def web(method, path, body=None, headers=None): + u = urllib.parse.urlsplit(http_base) + c = httpc.HTTPConnection(u.hostname, u.port, timeout=60) + h = {"Host": "mail.lab.test"} + h.update(headers or {}) + c.request(method, path, body=body, headers=h) + r = c.getresponse() + d = r.read() + c.close() + return r.status, d + + +def oauth(account, password): + """A bearer token, signed in as the console does (its OAuth client).""" + v = secrets.token_urlsafe(48) + ch = base64.urlsafe_b64encode(hashlib.sha256(v.encode()).digest()).rstrip(b"=").decode() + red = "https://admin.lab.test/oauth/callback" + s, d = web("POST", "/api/auth", json.dumps({ + "type": "authCode", "accountName": account, "accountSecret": password, "clientId": "inbuxa-admin", + "redirectUri": red, "codeChallenge": ch, "codeChallengeMethod": "S256", "state": "x"}), + {"content-type": "application/json"}) + if s != 200: + raise RuntimeError(f"/api/auth for {account}: HTTP {s} {d[:120]!r}") + code = json.loads(d)["client_code"] + s, d = web("POST", "/auth/token", urllib.parse.urlencode({ + "grant_type": "authorization_code", "code": code, "redirect_uri": red, + "client_id": "inbuxa-admin", "code_verifier": v}), + {"content-type": "application/x-www-form-urlencoded"}) + if s != 200: + raise RuntimeError(f"/auth/token for {account}: HTTP {s}") + return json.loads(d)["access_token"] + + +def jmap(token, using, calls): + s, d = web("POST", "/jmap", json.dumps({"using": using, "methodCalls": calls}), + {"content-type": "application/json", "authorization": "Bearer " + token}) + if s != 200: + raise RuntimeError(f"jmap: HTTP {s} {d[:160]!r}") + out = json.loads(d)["methodResponses"] + for name, args, tag in out: + if name == "error": + raise RuntimeError(f"jmap {tag}: {args}") + return out + + +def ensure_sink_route(): + """Mail for sink.test to the sink: a Relay route and its strategy line.""" + reg = ["urn:ietf:params:jmap:core", "urn:inbuxa:jmap:registry"] + tok = oauth("admin@lab.test", admin_pw) + routes, strategy = jmap(tok, reg, [["x:MtaRoute/get", {}, "r"], + ["x:MtaOutboundStrategy/get", {"ids": ["singleton"]}, "s"]]) + if not any(r.get("name") == "lab-sink" for r in routes[1]["list"]): + jmap(tok, reg, [["x:MtaRoute/set", {"create": {"sink": { + "@type": "Relay", "name": "lab-sink", "description": "The lab's outside mail server (mail-sink.yaml)", + "address": SINK, "port": 25, "protocol": "smtp", "implicitTls": False, + "allowInvalidCerts": True}}}, "c"]]) + route = strategy[1]["list"][0]["route"] + rule = {"if": "rcpt_domain == 'sink.test'", "then": "'lab-sink'"} + if rule not in route["match"].values(): + match = {str(i): m for i, m in enumerate([rule] + list(route["match"].values()))} + jmap(tok, reg, [["x:MtaOutboundStrategy/set", {"update": {"singleton": { + "route": {"match": match, "else": route["else"]}}}}, "u"]]) + # The strategy reaches every node by the cluster's config reload + time.sleep(5) + + +def message(frm, to, subject): + m = EmailMessage() + m["From"], m["To"], m["Subject"] = frm, to, subject + m["Date"] = formatdate() + m["Message-ID"] = make_msgid(domain=frm.split("@")[1]) + m.set_content(f"{subject}\n") + return m + + +SUBJECT = f"mailcheck {run}" +sent = {} + + +@check("smtp in") +def smtp_in(): + # A sender domain of its own: the default throttle allows 25 an hour + # from one sender domain to one recipient + with smtplib.SMTP(lb, 25, timeout=30) as s: + s.send_message(message(f"lab-sender@{run}.sender.test", ALICE, f"{SUBJECT} in")) + sent["in"] = f"{SUBJECT} in" + return "accepted on 25" + + +@check("submission") +def submission(): + ensure_sink_route() + with smtplib.SMTP_SSL(lb, 465, timeout=30, context=tls) as s: + s.login(ALICE, alice_pw) + s.send_message(message(ALICE, ALICE, f"{SUBJECT} self")) + s.send_message(message(ALICE, "probe@sink.test", f"{SUBJECT} out")) + sent["self"], sent["out"] = f"{SUBJECT} self", f"{SUBJECT} out" + return "accepted on 465 with AUTH: to alice and to probe@sink.test" + + +def imap_find(): + found = {} + m = imaplib.IMAP4_SSL(lb, 993, ssl_context=tls, timeout=30) + try: + m.login(ALICE, alice_pw) + _, boxes = m.list() + for line in boxes: + name = line.decode().rsplit(' "/" ', 1)[-1].strip() + if m.select(name, readonly=True)[0] != "OK": + continue + for key in ("in", "self"): + if key in sent: + _, data = m.search(None, "SUBJECT", f'"{sent[key]}"') + if data[0].split(): + found[key] = name.strip('"') + finally: + m.logout() + return found + + +@check("imap") +def imap(): + want = {k for k in ("in", "self") if k in sent} + if not want: + raise RuntimeError("nothing was sent") + deadline, found = time.time() + 90, {} + while time.time() < deadline: + found = imap_find() + if want <= found.keys(): + return ", ".join(f"{k} in {v}" for k, v in sorted(found.items())) + time.sleep(2) + raise RuntimeError(f"not found over IMAPS: {sorted(want - found.keys())}") + + +@check("jmap") +def jmap_check(): + tok = oauth(ALICE, alice_pw) + s, d = web("GET", "/jmap/session", None, {"authorization": "Bearer " + tok}) + if s != 200: + raise RuntimeError(f"session: HTTP {s}") + acct = json.loads(d)["primaryAccounts"]["urn:ietf:params:jmap:mail"] + using = ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"] + deadline = time.time() + 90 + while True: + out = jmap(tok, using, [ + ["Email/query", {"accountId": acct, "filter": {"subject": SUBJECT}}, "q"], + ["Email/get", {"accountId": acct, "#ids": {"resultOf": "q", "name": "Email/query", "path": "/ids"}, + "properties": ["subject"]}, "g"]]) + subjects = sorted(e["subject"] for e in out[1][1]["list"]) + want = sorted(sent[k] for k in ("in", "self") if k in sent) + if want and all(w in subjects for w in want): + return f"Email/query found {len(subjects)}" + if time.time() > deadline: + raise RuntimeError(f"Email/query found {subjects}, wanted {want}") + time.sleep(3) + + +@check("smtp out") +def smtp_out(): + if "out" not in sent: + raise RuntimeError("nothing was sent") + deadline = time.time() + 90 + while True: + logs = subprocess.run(["kubectl", "--context", KCTX, "-n", "lab-sink", "logs", "deploy/sink"], + capture_output=True, text=True, timeout=30).stdout + for line in logs.splitlines(): + if not line.startswith("{"): + continue + rec = json.loads(line) + if rec["subject"] == sent["out"]: + if rec["from"] != ALICE or rec["rcpts"] != ["probe@sink.test"]: + raise RuntimeError(f"arrived wrong: from {rec['from']} to {rec['rcpts']}") + if not any("d=lab.test" in h.replace(" ", "") for h in rec["dkim"]): + raise RuntimeError("arrived without a DKIM signature for lab.test") + return f"reached the sink from {rec['ehlo'] or '?'}, DKIM d=lab.test" + if time.time() > deadline: + raise RuntimeError("never reached the sink") + time.sleep(3) + + +BASIC = {"authorization": "Basic " + base64.b64encode(f"{ALICE}:{alice_pw}".encode()).decode()} + + +def dav_roundtrip(collection, name, ctype, body, marker): + path = f"/dav/{collection}/alice%40lab.test/default/{name}" + s, _ = web("PUT", path, body.encode(), dict(BASIC, **{"content-type": ctype})) + if s not in (201, 204): + raise RuntimeError(f"PUT: HTTP {s}") + s, d = web("GET", path, None, BASIC) + if s != 200 or marker not in d.decode(): + raise RuntimeError(f"GET: HTTP {s}, {'with' if marker in d.decode() else 'without'} it") + s, _ = web("DELETE", path, None, BASIC) + if s not in (200, 204): + raise RuntimeError(f"DELETE: HTTP {s}") + s, _ = web("GET", path, None, BASIC) + if s != 404: + raise RuntimeError(f"still there after DELETE: HTTP {s}") + return "put, read back, deleted" + + +@check("caldav") +def caldav(): + uid = f"mailcheck-{run}@lab.test" + stamp = time.strftime("%Y%m%dT%H%M%SZ", time.gmtime()) + ics = ("BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//inbuxa lab//mailcheck//EN\r\nBEGIN:VEVENT\r\n" + f"UID:{uid}\r\nDTSTAMP:{stamp}\r\nDTSTART:{stamp}\r\nDURATION:PT30M\r\n" + f"SUMMARY:mailcheck {run}\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n") + return dav_roundtrip("cal", f"{run}.ics", "text/calendar; charset=utf-8", ics, uid) + + +@check("carddav") +def carddav(): + uid = f"mailcheck-{run}" + vcf = (f"BEGIN:VCARD\r\nVERSION:3.0\r\nUID:{uid}\r\nFN:Mailcheck {run}\r\n" + f"EMAIL:probe@{run}.sender.test\r\nEND:VCARD\r\n") + return dav_roundtrip("card", f"{run}.vcf", "text/vcard; charset=utf-8", vcf, uid) + + +width = max(len(n) for n, *_ in results) +print(f"mailcheck {run}:") +for name, ok, detail, took in results: + print(f" {'ok ' if ok else 'FAIL'} {name:<{width}} {took:5.1f}s {detail}") +sys.exit(0 if all(ok for _, ok, *_ in results) else 1) diff --git a/lab/chart/mailcheck.sh b/lab/chart/mailcheck.sh new file mode 100755 index 0000000..ca6ac05 --- /dev/null +++ b/lab/chart/mailcheck.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +# SPDX-FileCopyrightText: 2026 Coffey Labs LLC +# SPDX-License-Identifier: Apache-2.0 +# +# Every client check against an installed chart, in one command (K-L2): +# +# mailcheck.py SMTP in on 25, submission on 465, IMAPS, JMAP, SMTP out +# to an outside server (mail-sink.yaml), CalDAV, CardDAV +# signin.py the webmail: signing in starting on one replica and +# finishing on the other +# console-signin.py the console: signing in as its browser would +# +# lab/chart/mailcheck.sh +# +# Wants the lab's seeded install with the webmail and the console +# (values-frontends.yaml), and the passwords seed-store.sh or e2e.sh left +# under $STATE. Sets up the sink (namespace lab-sink) if it isn't there. +# PORTS picks four free local ports in a row (default from 18080). +set -euo pipefail + +here=$(cd "$(dirname "$0")" && pwd) +. "$here/../versions.env" +KCTX="kind-$KIND_CLUSTER" +K=(kubectl --context "$KCTX" -n inbuxa) +STATE="${STATE:-$HOME/.cache/inbuxa-lab}" +P="${PORTS:-18080}" +PIDS=() +trap 'for p in "${PIDS[@]}"; do kill "$p" 2>/dev/null || true; done' EXIT +fail() { echo "!! $*" >&2; exit 1; } + +echo "== the outside mail server" +sed "s|image: IMAGE|image: $PG_IMAGE|" "$here/mail-sink.yaml" | kubectl --context "$KCTX" apply -f - >/dev/null +kubectl --context "$KCTX" -n lab-sink rollout status deploy/sink --timeout=180s >/dev/null + +lb="" +for _ in $(seq 1 30); do + lb="$("${K[@]}" get svc inbuxa-mail -o jsonpath='{.status.loadBalancer.ingress[0].ip}')" + [ -n "$lb" ] && break + sleep 2 +done +[ -n "$lb" ] || fail "the mail Service has no address" + +forward() { # + # Something else on the port would answer in the forward's place + if ss -ltn "sport = :$1" | grep -q LISTEN; then + fail "port $1 is in use: PORTS= $0" + fi + "${K[@]}" port-forward "$2" "$1:8080" >/dev/null 2>&1 & + PIDS+=($!) +} +mapfile -t webmail < <("${K[@]}" get pods -l app.kubernetes.io/component=webmail \ + --field-selector status.phase=Running -o name | sort) +[ "${#webmail[@]}" -ge 2 ] || fail "fewer than two webmail pods (values-frontends.yaml?)" +forward "$P" svc/inbuxa-http +forward $((P + 1)) "${webmail[0]}" +forward $((P + 2)) "${webmail[1]}" +forward $((P + 3)) svc/inbuxa-console +sleep 3 + +echo "== mail, calendars and contacts, as alice@lab.test" +KCTX="$KCTX" python3 "$here/mailcheck.py" "$lb" "http://127.0.0.1:$P" \ + "$STATE/alice.password" "$STATE/admin.password" + +echo "== webmail: start on ${webmail[0]#pod/}, finish on ${webmail[1]#pod/}" +python3 "$here/signin.py" "http://127.0.0.1:$((P + 1))" "http://127.0.0.1:$((P + 2))" \ + "http://127.0.0.1:$P" alice@lab.test "$STATE/alice.password" + +echo "== console" +python3 "$here/console-signin.py" "http://127.0.0.1:$((P + 3))" "http://127.0.0.1:$P" \ + https://admin.lab.test https://mail.lab.test admin@lab.test "$STATE/admin.password" + +echo "== every check passed" diff --git a/lab/e2e.sh b/lab/e2e.sh index 4a17c30..0c2c47e 100755 --- a/lab/e2e.sh +++ b/lab/e2e.sh @@ -6,9 +6,9 @@ # layer (up.sh), then the chart with the released images the next chart # release names (inbuxa-charts release/suite.yaml), seeded, then # -# 1. mail: in over SMTP, found over IMAPS, through the mail Service -# 2. the webmail: signing in across both replicas -# 3. the console: signing in as its browser would +# every client check, chart/mailcheck.sh: SMTP in, submission, IMAP, +# JMAP, SMTP out to an outside server, CalDAV, CardDAV, the webmail across +# both replicas and the console # # and how long each part took. CI runs this on a fresh runner; on the bench # it builds the lab from scratch too, so take the lab down first @@ -30,7 +30,6 @@ SUITE="$CHART_REPO/release/suite.yaml" STATE="${STATE:-$HOME/.cache/inbuxa-lab}" K=(kubectl --context "kind-$KIND_CLUSTER" -n inbuxa) P="${PORTS:-18080}" -PIDS=() t0=$SECONDS SUMMARY=() lap() { SUMMARY+=("| $1 | $(( SECONDS - ${2:-$t0} ))s |"); } @@ -42,7 +41,6 @@ report() { } on_exit() { rc=$? - for p in "${PIDS[@]}"; do kill "$p" 2>/dev/null || true; done if [ "$rc" != 0 ]; then SUMMARY+=("| **failed** | after $(( SECONDS - t0 ))s |") echo "== failed: pods and events" @@ -94,46 +92,10 @@ helm --kube-context "kind-$KIND_CLUSTER" -n inbuxa upgrade --install inbuxa "$CH "${K[@]}" get pods --no-headers -o wide | awk '{print " " $1, $3, $7}' lap "chart install (seed, server, webmail, console)" "$s" -echo "== 1. mail" +echo "== the client checks (chart/mailcheck.sh)" s=$SECONDS -lb="" -for _ in $(seq 1 30); do - lb="$("${K[@]}" get svc inbuxa-mail -o jsonpath='{.status.loadBalancer.ingress[0].ip}')" - [ -n "$lb" ] && break - sleep 2 -done -[ -n "$lb" ] || { echo "!! the mail Service has no address" >&2; exit 1; } -ACCOUNT=alice@lab.test PASSWORD_FILE="$STATE/alice.password" timeout 150 python3 "$here/chart/mailtest.py" "$lb" -lap "mail: SMTP in, IMAPS found" "$s" - -forward() { # - if ss -ltn "sport = :$1" | grep -q LISTEN; then - echo "!! port $1 is in use: PORTS= $0" >&2 - exit 1 - fi - "${K[@]}" port-forward "$2" "$1:8080" >/dev/null 2>&1 & - PIDS+=($!) -} -mapfile -t webmail < <("${K[@]}" get pods -l app.kubernetes.io/component=webmail \ - --field-selector status.phase=Running -o name | sort) -[ "${#webmail[@]}" -ge 2 ] || { echo "!! fewer than two webmail pods" >&2; exit 1; } -forward $((P + 1)) "${webmail[0]}" -forward $((P + 2)) "${webmail[1]}" -forward "$P" svc/inbuxa-http -forward $((P + 3)) svc/inbuxa-console -sleep 3 - -echo "== 2. webmail: start on ${webmail[0]#pod/}, finish on ${webmail[1]#pod/}" -s=$SECONDS -python3 "$here/chart/signin.py" "http://127.0.0.1:$((P + 1))" "http://127.0.0.1:$((P + 2))" \ - "http://127.0.0.1:$P" alice@lab.test "$STATE/alice.password" -lap "webmail sign-in across replicas" "$s" - -echo "== 3. console" -s=$SECONDS -python3 "$here/chart/console-signin.py" "http://127.0.0.1:$((P + 3))" "http://127.0.0.1:$P" \ - https://admin.lab.test https://mail.lab.test admin@lab.test "$STATE/admin.password" -lap "console sign-in" "$s" +PORTS="$P" STATE="$STATE" "$here/chart/mailcheck.sh" +lap "mail (SMTP in, submission, IMAP, JMAP, SMTP out), CalDAV, CardDAV, webmail, console" "$s" lap "**total**" echo "== passed in $(( SECONDS - t0 ))s" -- 2.54.0 From 89eca8a399924a7b5ba8371a8d9032a888370c30 Mon Sep 17 00:00:00 2001 From: John Coffey Date: Thu, 19 Nov 2026 23:27:55 -0700 Subject: [PATCH 2/2] tools.sh: no SIGPIPE from kubectl's version line head -1 closed the pipe while kubectl was still writing; under pipefail that failed the step (exit 141), once in six CI jobs. --- lab/tools.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lab/tools.sh b/lab/tools.sh index 43ac582..49377d0 100755 --- a/lab/tools.sh +++ b/lab/tools.sh @@ -47,5 +47,7 @@ tar -xzf "$WORK/helm.tgz" -C "$WORK" "linux-$ARCH/helm" install -m 0755 "$WORK/linux-$ARCH/helm" "$DIR/helm" "$DIR/kind" version -"$DIR/kubectl" version --client | head -1 +# sed reads everything: head would leave kubectl writing to a closed pipe +# (SIGPIPE, 141 under pipefail) +"$DIR/kubectl" version --client | sed -n 1p "$DIR/helm" version --short -- 2.54.0