TYPO3

A smoke test baseline before you touch a TYPO3 upgrade

6 min read

Capture first, upgrade later

“Does the site still work?” Every upgrade ends with this question, and for a long time my answer was a feeling. I clicked through the main pages, the client clicked through some more, and we hoped that nobody visited the one page with a broken plugin before Monday.

When I moved my own site hoja.in from TYPO3 7.6 to 14.3 this year, I wanted a better answer: a list of URLs, what the old site returned for each of them, and a diff against the new site. Nothing fancy, but written down before the first composer require. This post shows the approach, a small script you can use, and an honest list of what it does not catch.

Problems I faced

The baseline has to come from the old site, and the old site must be running somewhere you can hit it many times. Production is a bad place for that: you do not want to hammer it, and it keeps changing while you work. So the first job was to boot the 7.6 site locally.

I created a second DDEV project with PHP 7.0 and MariaDB 10.5 and imported the live dump into it. Of course it did not start at the first try. The committed 7.6 core in my old repository had an empty index.php (do not ask me how that happened years ago), so I took the file from the original typo3_src-7.6.10 archive. After that the old site answered under its own DDEV host name, and I could capture as often as I liked.

Solution

Step 1: Decide which URLs matter

Start with the site base and the sitemap if there is one, then add by hand what a crawler does not find: forms, search results, a news detail page, login entry points, pages with plugins. One URL per line, comments with #. For hoja.in the list was short, because it is a one-page portfolio: the root and the six section pages. The old site had no speaking URLs that I trusted, so I used index.php?id=…. These keep working in v14, which made the before/after comparison direct:

# urls-legacy.txt: the TYPO3 7.6 copy
https://myport-legacy.ddev.site/
https://myport-legacy.ddev.site/index.php?id=6
https://myport-legacy.ddev.site/index.php?id=7
https://myport-legacy.ddev.site/index.php?id=10

# urls.txt: the v14 project, same paths plus new ones
https://myport.ddev.site/
https://myport.ddev.site/index.php?id=6
https://myport.ddev.site/index.php?id=7
https://myport.ddev.site/index.php?id=10
https://myport.ddev.site/about
https://hoja.in/blog/
https://myport.ddev.site/sitemap.xml

Step 2: Capture what each URL returns

For every URL I record five things: the path, the HTTP status after redirects, the size of the body, the <title> and whether the body contains a typical error marker such as “Oops, an error occurred” or “Fatal error”. That is cheap to collect and surprisingly good at catching the big breakages. Here is a small standalone version of the idea in plain bash, curl and awk:

#!/usr/bin/env bash
# smoke.sh capture <urls.txt> <out.tsv>
# smoke.sh compare <before.tsv> <after.tsv> [size-tolerance-percent]
set -euo pipefail

markers='Oops, an error occurred|Uncaught .*Exception|Fatal error|Parse error:'

capture() {
  local list="$1" out="$2" body url meta title err
  body="$(mktemp)"
  printf 'urltstatustbytesttitleterrorn' > "$out"
  grep -v '^#' "$list" | while read -r url; do
    [ -z "$url" ] && continue
    meta="$(curl -sk -L --max-time 30 -o "$body" -w '%{http_code}t%{size_download}' "$url" || printf '000t0')"
    title="$(tr 'n' ' ' < "$body" | sed -n 's:.*<title[^>]*>([^<]*)</title>.*:1:p' | cut -c1-120)"
    err=no; grep -Eq "$markers" "$body" && err=yes
    path="/${url#*://*/}"
    printf '%st%st%st%sn' "$path" "$meta" "$title" "$err" >> "$out"
  done
  rm -f "$body"
}

compare() {
  awk -F't' -v tol="${3:-30}" '
    NR == FNR { if (FNR > 1) { st[$1] = $2; by[$1] = $3; ti[$1] = $4 } next }
    FNR == 1 { next }
    !($1 in st) { print "NEW     " $1 " (" $2 ")"; next }
    {
      msg = ""
      if (st[$1] != $2) msg = msg " status " st[$1] "->" $2
      if ($5 == "yes") msg = msg " error-marker"
      if (ti[$1] != $4) msg = msg " title changed"
      if (by[$1] > 0 && (($3 - by[$1]) * 100 / by[$1] > tol || (by[$1] - $3) * 100 / by[$1] > tol))
        msg = msg " size " by[$1] "->" $3
      if (msg != "") { print "CHANGED " $1 ":" msg; bad++ } else ok++
    }
    END { printf "%d unchanged, %d changedn", ok, bad; exit bad > 0 }
  ' "$1" "$2"
}

cmd="$1"; shift
"$cmd" "$@"

The script stores the path instead of the full URL, so a capture from the old host and one from the new host can be compared directly. In the real project I solved the same problem by keeping the raw capture and writing a normalized copy with the host rewritten; both ways work, just do not compare two different host names and wonder why every line is “new”.

Run it once against the old site and once against the new one:

./smoke.sh capture urls-legacy.txt baseline.tsv
# ... upgrade, import, configure ...
./smoke.sh capture urls.txt after.tsv
./smoke.sh compare baseline.tsv after.tsv

The exit code is 1 when anything changed, so you can put the compare into a CI job or a deployment script and stop there.

Step 3: Also keep the HTML

A TSV line tells you that something changed, not what. I also saved the full HTML of each baseline page next to the capture. When a size changed a lot, a quick diff of the old and new markup showed if a whole content element was missing or only the theme was lighter.

Step 4: Read the result like a reviewer

For hoja.in, the first gate after the upgrade said: 7 baseline URLs unchanged, 5 new URLs with status 200. That was the moment I believed the import script, not before.

Then I rebuilt the design, and the next compare flagged all 7 baseline URLs. Status 200 everywhere, no error markers, but the root title changed and the pages shrank from about 55–65 KB to 19–24 KB, because the old theme shipped a lot of jQuery markup and inline stuff. That is a correct finding and not a bug. It needed a human decision: accept the change and capture a new baseline, or look deeper. The script must never decide that alone, and I wrote it into the ledger as an open decision instead of silently re-baselining.

One more useful rule: a page that is broken before and after proves nothing. If the old site already throws an exception on a URL, fix it or remove it from the list, otherwise it sits in every report and trains you to ignore red lines.

What the comparison can and cannot catch

It catches:

  • pages that are gone (404), redirect somewhere else or crash (5xx, error markers)
  • missing or changed page titles, which often means a wrong template or a lost page property
  • big size jumps, which often means missing content or a missing menu

It does not catch:

  • Layout and CSS. A page can be 200, same title, same size and still look broken. For the blog I had no visual baseline at all, because I never booted the old WordPress 5.6. I checked that part by eye and wrote the gap down.
  • Forms and anything after a POST. The contact form moved from powermail to EXT:form. I submitted it by hand and checked that the mail arrived in Mailpit.
  • The backend. Editor rights, the page module, file lists. That is a manual checklist.
  • URLs that you did not list. Old realurl links ending in .html and the 404 behaviour of the old site were not in my baseline, so the comparison says nothing about them. They are still open points in my notes.
  • Small text changes. A changed sentence inside a page moves the size by a few bytes and stays under the tolerance.

So it is a smoke test, not a test suite. But it turns “I clicked around and it looked fine” into a file you can show to someone else, and it runs again in seconds after every change. For the rollout I plan the same thing on production: capture the live site before switching, capture again after, compare.

If you have an upgrade coming, spend the first hour on this list before you touch any version number. You will thank yourself later. Cheers!

Further reading

Leave a comment

Your email address will not be published.