Nikasa, home Request an invite
DocsCheck an upgrade

Check an upgrade

Upgrading a framework, a library or a database? Compare what your app does before and after, on the same requests, with no assertions to write.

On this page

An upgrade should change nothing you can see, and Nikasa shows what changed underneath. You compare what your app does before and after, on the same requests, with no assertions to write.

Pick the case that fits:

You are upgrading What differs between the builds How
Your app, or a framework or library inside it Your app's image Compare the two images
A database or another service under an unchanged app That one service Lay a compose file over the new side
Several services that must move together Several images Name each service's images

Your app, or a library inside it #

This is an ordinary compare. Build the old version and the upgraded one, then compare them:

shell
git checkout main
docker build -t myapp:old .
git checkout upgrade-framework
docker build -t myapp:new .
nk compare myapp:old myapp:new

What it can show #

This report is made up: myapp moves to a new major version of its web framework.

output
3 changes in responses and requests
learned from 8 runs: 304 values fixed, 9 varying, 0 sometimes present, 0 links
checked 4 runs of the new build
driver made 10 requests: 200 x8, 201 x1, 400 x1
requests exercised 7 of 24 endpoints the app declares (/openapi.json)
cost per request, calls the app made to other services while serving each request:
  0003 GET /api/orders: 7 calls to postgres:5432, was 4

VALUE  /response/status  422 -> 400
       1 scenario: 0002 POST /api/orders
VALUE  /response/headers/content-type  "application/json; charset=utf-8" -> "application/json"
       2 scenarios: 0000 GET /api/orders/7, 0003 GET /api/orders
COUNT  /calls/app -> postgres:5432/"SELECT sku, quantity FROM order_lines WHERE order_id = $1"  1 -> 4, added {"params":["7"],...}
       1 scenario: 0003 GET /api/orders

The three changes mean this:

Change What it could break
The status went from 422 to 400 A client that checks for a 422 would now break.
The content-type header lost its charset A strict client could trip on it.
The order query runs 4 times, where it ran once The list of orders has started loading its lines one order at a time.

Tests that check only the happy path would stay green through all three.

The version number is not a change #

Nikasa reads the build's version from the two image tags, such as myapp:1.4.0 and myapp:1.5.0. Values that say nothing but that version become one line marked (not counted).

An upgrade whose only change is its version reports no change.

A dependency under an unchanged app #

Say your app stays as it is and Postgres moves from 16 to 17. Write the upgraded service in a small compose file, and lay it over the new side only.

  1. Write the upgraded service in nk/postgres-17.yaml:

    yaml
    services:
      postgres:
        image: postgres:17-alpine
  2. Compare the same image of your app against itself, with the file laid over the new side:

    shell
    nk compare myapp:old myapp:old out/postgres-17 --new-with nk/postgres-17.yaml

--old-with does the same for the old side. Both sides run the same image of your app, so anything that changes comes from the dependency.

What the report shows #

Here is that compare, for real, on Nikasa's sample app, moving its Postgres from 16 to 17. The last two blocks of the report are left out:

output
no behaviour changes in what the requests exercised
learned from 3 runs: 317 values fixed, 5 varying, 0 sometimes present, 0 links
checked 2 runs of the new build

driver made 5 requests: 200 x3, 201 x2
requests lined up by what was sent: every run made 5 requests in 5 steps
requests exercised 4 endpoints; with no API description Nikasa cannot list what they missed (--openapi)
coverage: what this compare looked at and could not see is told at the end

the dependency itself changed (postgres), not counted:
4 changes, in logs; none in responses or requests

GONE   /postgres/selecting default max_connections .. <n>  true
       in the run's logs
GONE   /postgres/selecting default shared_buffers .. <n>MB  true
       in the run's logs
NEW    /postgres/selecting default "max_connections" .. <n>  true
       in the run's logs
NEW    /postgres/selecting default "shared_buffers" .. <n>MB  true
       in the run's logs

The app behaved the same on the requests it was sent. What the dependency did itself, here a few lines in its own log, is kept apart from the count, so --fail-on-change looks at your app.

Start from empty databases #

A database's data folder does not carry across engine versions, so --start-migrated is refused on such a compare:

output
--start-migrated: a database's data folder does not carry across engine versions, and the new build moves postgres: postgres:16-alpine in the old build, postgres:17-alpine in the new; compare from fresh installs

Each run then starts empty and your app migrates it, so have your requests create the data they read. Start from real data covers the other ways to start.

Several services together #

When a change spans services, --image gives another service images of its own, old then new:

shell
nk compare myapp:old myapp:new out --image worker=myworker:old,myworker:new

Make it a gate #

--fail-on-change turns a change into exit 1, for an upgrade check in CI. See Exit status.

An upgrade is expected to change some things. Once you have read a report and agree with a change, accept it, and the next compare leaves it out and says so.

Written for nk 0.3.14. Something wrong or unclear? Write to hello@nikasa.dev.