Skip to content

Play a run as a film in tomato ui, and stop the app when a run is interrupted - #238

Merged
alileza merged 2 commits into
mainfrom
feat/ui-run-movie
Oct 23, 2026
Merged

alileza merged 2 commits into
mainfrom
feat/ui-run-movie

Conversation

@alileza

@alileza alileza commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Two changes, both about what happens when you run the suite from tomato ui.

1. Stop the app when a run is interrupted, and a leftover one before the next

A run interrupted with Ctrl+C, or stopped from tomato ui, left the app it started running: tomato exited before its defers ran, and go run ./cmd/app sits in its own process group, so nothing reached the compiled app. It kept the app port, and every run after it failed with app port 8099 is already in use by another process until someone killed it by hand.

  • tomato run handles SIGINT/SIGTERM: it stops the app, then the resources, then the containers, and exits with 130. A second signal quits at once. Keep-alive waits through the same handler.
  • The UI's Stop button sends SIGTERM instead of SIGKILL, and only kills the run if it is still there after 45 seconds.
  • Each run records its app's process group in app.pid while the app is up. A run that finds its port busy stops an earlier run's app when that run's tomato is gone and the process still runs the configured app command (a reused pid, or a run in progress, is left alone), prints stopped the app left running by run <id>, and carries on.

2. Play a run as a film, from the dependencies to the report

Starting a run from the UI folds the tree, the inspector and the console away and plays the run on the whole window, in four acts:

  1. Dependencies: the topology, each container pulsing until its wait_for answers, then green with the time it took.
  2. App: the app box through starting → listening → ready, with its URL and time.
  3. Scenarios: a feature title card, then each scenario's traffic over the topology step by step, the steps ticked off with durations and the failing error, and the narration.
  4. Report: verdict, tiles (scenarios, steps, time, startup, app CPU and memory), where the time went, every feature's scenarios with the failed step, the slowest scenarios, and performance from the profile.

It follows the run a beat behind, can be paused, stepped (←/→, space) and replayed; m brings it back, esc leaves it and restores the panes. A past run can be watched again from the Runs tab, and ?watch=<run>&beat=<n> links to a moment of one.

Behind it, tomato run emits phase, container and app events in the tomato format (documented), tomato ui relays them through one wsMessagesFor function, and GET /api/runs/{run}/events reuses it to rebuild a run's feed from its tomato.log.

Test plan

  • Rebased on the latest main (after feat(profile): bring the per-scenario profile to main #236); no conflicts with it.
  • go test ./... passes; 83 UI tests pass; make ui-check says the committed bundle is up to date.
  • New tests: the interrupt handler, the pid file and leftover detection (under -race); wsMessagesFor, the replay endpoint and the new formatter events; 17 for the reel.
  • On the orderly demo: SIGKILL mid-run → the next run stopped the leftover app and ran; Ctrl+C → exit 130, port free; UI Stop → port free in 3s; a live run from the UI plays all four acts; past runs replay from the Runs tab and from ?watch=.

Supersedes #237.

🤖 Generated with Claude Code

@alileza alileza changed the title feat(ui): play a run as a film, from the dependencies to the report Play a run as a film in tomato ui, and stop the app when a run is interrupted Oct 23, 2026
@alileza
alileza changed the base branch from feat/profile-on-main to main October 23, 2026 04:51
Starting a run from tomato ui folds the panes away and plays the run on
the whole window: the containers pulsing on the topology until they are
ready, the app coming up, every scenario's traffic over the topology step
by step with the steps ticked off beside the narration, and a report at
the end with the verdict, where the time went, each feature's failures,
the slowest scenarios and what the app cost. The film follows the run a
beat behind, can be paused, stepped and replayed, and a past run can be
watched again from the Runs tab or with ?watch=<run>&beat=<n>.

Behind it, tomato run reports how it comes up in the tomato event format
(phase, container and app events, with how long each took) and prints
each container's check as it is ready; tomato ui relays them, with the
feature, run_error and summary events, through one function that a
replay endpoint (GET /api/runs/{run}/events) reuses to rebuild a run's
feed from its tomato.log.

Based on feat/profile-on-main: the report's performance section reads
the per-scenario profile.
…e the next

Ctrl+C, or the UI's Stop, ended tomato before its defers ran: Docker
reaped the containers, but the app runs in its own process group, so
nothing reached it, and it held the app port and failed the next run with
"app port 8099 is already in use by another process".

- `tomato run` catches SIGINT and SIGTERM, stops the app, then the
  resources, then the containers, and exits with 130; a second signal
  quits at once. Keep-alive waits through the same handler.
- The UI's Stop sends SIGTERM and only kills the run if it is still there
  45 seconds later.
- A run that finds its port busy looks for an app an earlier run left
  running — each run records its app's process group in app.pid while the
  app is up — and stops it, as long as that run's tomato is gone and the
  process still runs the app command, then carries on.
@github-actions

Copy link
Copy Markdown
Contributor

🍅 Coverage

Gate Result
✅ Integration suite passes exit code 0
✅ Every resource step used by a scenario 335 / 335 steps (100.0%)
✅ Resource code coverage (internal/resource) ≥ 84.4% 85.1%
✅ Total code coverage ≥ 77.6% 79.6%

Code coverage is unit tests and the integration suite (tests/tomato.yml) merged.

Step coverage by resource

Resource Steps Coverage
AWS aws 2 / 2 ✅ 100%
Browser browser 18 / 18 ✅ 100%
gRPC grpc 19 / 19 ✅ 100%
gRPC Server grpc-server 16 / 16 ✅ 100%
HTTP Client http 57 / 57 ✅ 100%
HTTP Server http-server 18 / 18 ✅ 100%
Kafka kafka 29 / 29 ✅ 100%
Lifecycle lifecycle 9 / 9 ✅ 100%
Network network 12 / 12 ✅ 100%
PDF pdf 13 / 13 ✅ 100%
PostgreSQL postgres 11 / 11 ✅ 100%
RabbitMQ rabbitmq 23 / 23 ✅ 100%
Redis redis 25 / 25 ✅ 100%
S3 s3 27 / 27 ✅ 100%
ScyllaDB scylladb 9 / 9 ✅ 100%
Shell shell 22 / 22 ✅ 100%
WebSocket Client websocket 17 / 17 ✅ 100%
WebSocket Server websocket-server 8 / 8 ✅ 100%
Code coverage by resource file (internal/resource)
File Statements Coverage
aws/aws.go 128 / 141 90.8%
browser/browser.go 174 / 196 88.8%
browser/steps.go 359 / 407 88.2%
cassandra/cassandra.go 228 / 306 74.5%
grpcclient/grpc.go 152 / 202 75.2%
grpcclient/grpc_reflect.go 101 / 148 68.2%
grpcserver/grpc_server.go 429 / 465 92.3%
httpclient/concurrent.go 90 / 90 100.0%
httpclient/http_client.go 246 / 321 76.6%
httpclient/sse.go 316 / 316 100.0%
httpserver/http_server.go 248 / 262 94.7%
kafka/glue.go 175 / 180 97.2%
kafka/kafka.go 363 / 458 79.3%
kafka/kafka_groups.go 74 / 101 73.3%
kafka/kafka_topics.go 18 / 19 94.7%
kafka/schema_registry.go 93 / 115 80.9%
lifecycle/lifecycle.go 106 / 110 96.4%
network/gate.go 32 / 33 97.0%
network/meter.go 56 / 58 96.6%
network/network.go 200 / 223 89.7%
network/steps.go 112 / 134 83.6%
network_events.go 30 / 30 100.0%
pdf/cmap.go 139 / 146 95.2%
pdf/document.go 122 / 131 93.1%
pdf/encodings.go 35 / 35 100.0%
pdf/fonts.go 218 / 232 94.0%
pdf/lexer.go 179 / 189 94.7%
pdf/pdf.go 231 / 245 94.3%
pdf/text.go 129 / 139 92.8%
pdf/verapdf.go 89 / 96 92.7%
poll.go 7 / 7 100.0%
postgres/postgres.go 222 / 269 82.5%
rabbitmq/rabbitmq.go 203 / 295 68.8%
redis/redis.go 143 / 221 64.7%
s3/s3.go 274 / 361 75.9%
screenshots.go 8 / 8 100.0%
shell/shell.go 98 / 119 82.4%
stepdef.go 22 / 25 88.0%
variables.go 55 / 58 94.8%
websocket/client.go 165 / 252 65.5%
websocket/server.go 128 / 136 94.1%
Code coverage by package
Package Statements Coverage
. 6 / 6 100.0%
command 1250 / 2355 53.1%
internal/apprunner 451 / 534 84.5%
internal/awsid 6 / 6 100.0%
internal/config 407 / 432 94.2%
internal/container 369 / 475 77.7%
internal/feature 37 / 47 78.7%
internal/formatter 88 / 115 76.5%
internal/grpcfixture 30 / 31 96.8%
internal/grpcschema 101 / 108 93.5%
internal/jsonmatch 207 / 220 94.1%
internal/pdffixture 140 / 147 95.2%
internal/profile 181 / 193 93.8%
internal/registry 152 / 164 92.7%
internal/resource/aws 128 / 141 90.8%
internal/resource/browser 533 / 603 88.4%
internal/resource/cassandra 228 / 306 74.5%
internal/resource/grpcclient 253 / 350 72.3%
internal/resource/grpcserver 429 / 465 92.3%
internal/resource/httpclient 652 / 727 89.7%
internal/resource/httpserver 248 / 262 94.7%
internal/resource/kafka 723 / 873 82.8%
internal/resource/lifecycle 106 / 110 96.4%
internal/resource/network 400 / 448 89.3%
internal/resource/pdf 1142 / 1213 94.1%
internal/resource/postgres 222 / 269 82.5%
internal/resource/rabbitmq 203 / 295 68.8%
internal/resource/redis 143 / 221 64.7%
internal/resource/s3 274 / 361 75.9%
internal/resource/shell 98 / 119 82.4%
internal/resource/websocket 293 / 388 75.5%
internal/resource 122 / 128 95.3%
internal/runlog 37 / 58 63.8%
internal/runner 177 / 186 95.2%

From make coverage at d065447 · run

@alileza
alileza merged commit 3bd8ae4 into main Oct 23, 2026
4 checks passed
@alileza
alileza deleted the feat/ui-run-movie branch October 23, 2026 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant