Repository navigation
Service Card
service.json is a small JSON file that says what a service did in a test run: which parties it talked to, every
operation between them, and why each call was made. A service catalogue, a dependency map or an indexer reads it
without opening the report. kronikol card writes it from a report that has already been written (5.21.0):
kronikol card ./Reports -o service.json
kronikol card TestRunReport.krkl > service.json| Argument / option | Meaning |
|---|---|
<report> |
A TestRunReport.krkl or TestRunReport.json, or the directory holding one, resolved as kronikol query resolves it |
-o, --out <file>
|
Write the card to a file instead of stdout; its folder is created |
-h, --help
|
Show usage |
It reads every report the tool reads, a 4.x TestRunReport.json as well as a 5.x TestRunReport.krkl, in one pass
that never holds the report whole: a report of 2,000 scenarios is carded in about 300 ms. Exit 0 when the card is
written; 1 when the file cannot be read, is no Kronikol report or is one this build cannot read, or the card cannot be
written; 2 for a command it cannot take (--json among them: the card is always JSON).
On BreakfastProvider's lanes a card is 96 to 175 KB, where the report it is made from runs to megabytes.
From 5.22.0 a run writes service.json beside its report, with GenerateServiceCard on, its default. It is the card
kronikol card writes from the data file the run has just written, byte for byte: written after the run's other
outputs, from that file, and before Run.json, which lists it and carries its hash as serviceCard.behaviourHash
(Generated Reports › Earlier runs). An indexer that keeps the last
hash it read tells from Run.json alone whether the card changed.
- A run whose data file is off (
GenerateTestRunReportData = false) or written as XML writes no card and says nothing of it: the card is made from the JSON data file. - A card that cannot be written (the file held open by a reader) is no card of the run's:
Run.jsonnames noserviceCard, and the run warns on the console. Its bytes go toservice2.json, as any output's do, andRun.jsonlists that file underfiles. The run itself does not fail. -
kronikol ingestwrites one, andkronikol mergewrites one beside a merged report, from the merged data file. - It costs one more pass over the data file at the run's end: about 150 ms on a run of 2,000 scenarios. Set
GenerateServiceCard = falseto go without it.
The file has three members, formatVersion, run and behaviour, in that order:
-
runholds what moves from one run to the next: the run's id and end (from theRun.jsonbeside the report, when that manifest lists the report and is not older than it, and null otherwise), the repository, commit and branch on CI, the suite, the report's file name, format version, the Kronikol that wrote it and its SHA-256, the environment, the scenario counts by result,behaviourHash, each party's hosts and the calls a test double answered, per operation the calls, errors, statuses and phases counted, one example address for each operation (sN/iM, whichkronikol queryopens), every operation each scenario reached, and the capture diagnostics the report recorded, counted by kind. -
behaviourholds what the service does: the rules the card was made under, the party under test, the parties with their kinds, the edges between them, each edge's operations with their statuses, origins, causes and effective phases, the operations the service exposes, the messages it publishes and consumes, each scenario's own operations, the names no party id resolves, and what the capture could not see. Every list is sorted by ordinal comparison, and nothing in it counts anything.
Two runs of the same commit whose scenarios behave the same write the same behaviour bytes. On BreakfastProvider's
lanes, ten pairs of runs of one commit gave byte-identical behaviour on all ten.
An operation is a caller, a callee, a protocol, a method and a target, with graphqlOperation for a GraphQL
request. The target and the GraphQL operation are the call's operation key, the one
Cross-Run History, the warm-up marks and the component diagram read (5.17.0), with the query string
left out:
- the target is the call's path, templated:
/orders/123and/orders/456are/orders/{n}. A Service Bus queue, an S3 bucket, an EventBridge bus and a Redis database, which their trackers write where a host would go, are kept as the first segment, so a send toservicebus://orders/is on/orders; - a statement's call adds the statement's first line, its values templated:
INSERT INTO orders (id, dish) VALUES (7, 'pancakes')on/ordersis/orders INSERT INTO orders (id, dish) VALUES ({n}, '{s}'). That holds for SQL, past theSETstatements EF Core sends first, and for a document whose top-levelquerymember is a string, as Cosmos DB's and BigQuery's queries are; -
graphqlOperationis the operation a GraphQL request names, read from a POST's body or a GET's query string (query Menu,mutation PlaceOrder), orbatchfor a batch of them.
A run's own templating rules, HistoryShapeTemplates, shape the target as they shape history's, read from the
report's shapeTemplates block (5.19.0). behaviour.rules.templateRules says which rules those were: their hash, the
one history records as shapeRules; none for a run that had none; null for a report that cannot say, written
before 5.19.0 or by Kronikol4J.
An operation's op is the first 16 hex characters of the SHA-256 of those parts, so one operation has one id in every
card, and a new one adds an id and moves no other.
Each operation lists:
| Member | Values |
|---|---|
statuses |
the status codes or labels its calls answered, none for a call with no answer |
origins |
test (the test's own client), subject (the service under test), other (any other party) |
causes |
test (the test made it), request (made while the service served a request: inside a call the service received, or marked by the request's headers), background (made with no request in progress: a hosted service, a timer, the report's background block), unknown (no attribution was recorded and no call encloses it) |
effectivePhases |
setup or action as the call recorded it, else its enclosing call's when it was made inside one, else unknown
|
Limits, stated so they are not mistaken for behaviour:
-
Seeding through the service's own client (the test resolves the service's repository and writes with it) reads
as origin
subjectand causebackground: the call is the service's client's, made with no request in progress. -
An in-process service with nothing declared reads as the test: with no
ServiceIdand no parties declared, the inference cannot tell the service's calls from the test's when both run in the test's process and context. Declare the service (ServiceId, orPartieswithunderTest) and its calls read assubject. -
A producer that records no attribution (an ingested capture, a proxy tap) gives
causeandeffectivePhasesfrom nesting alone, which is only as good as the order the producer recorded its calls in.
behaviour.exposes lists the operations the service under test received, deliveries and user actions apart, with
basis: "tested": the surface the run tested, not everything the service serves.
behaviour.messages lists each message call between the service and a broker: publishes for the service's send or
publish, consumes for its receive or for the broker's delivery into it, with the broker and the topic or queue. A
delivery into the service is never an operation it exposes. Settlement and management calls (completing a message,
committing an offset, creating a queue) are operations on their edge and no message, and so is the fault MassTransit
records when a consumer throws.
A label the card does not know, from a tracker newer than the card's writer, has no direction rather than a guessed
one. At Raw, the SQS, SNS, Storage Queues and EventBridge trackers record the HTTP request itself, whose verb and
endpoint name neither the direction nor the queue, so those rows have direction and topic null.
behaviour.capture.emptyTargets lists the message operations whose address names no destination where one belongs
(Kafka at Summarised writes kafka:///), or only a tracker's placeholder (servicebus://unknown/), so an indexer does
not read them as one queue.
behaviour.parties comes from the report's parties block when the run declared something (see
Report Configuration), else from the inference over the report's calls, with
kindSource: "inferred" on the rows it inferred and rules.inference naming the inference's version. A name with no
id is listed in behaviour.unresolved.
The card is a function of the report alone, so kronikol card on a kept report writes the card its run wrote.
What a run observed of its test clients and did not write reaches the card only through the parties block, which the
run writes when it declares something.
behaviour.subject is the party under test: the underTest party whose id is the run's ServiceId, else the one
that received the most calls, the first by name on a tie; a declared subject no call reaches is still the subject,
and listed. A run with no party under test has no subject, no exposed operations and no messages. The parties,
the subject and each call's origin and cause are the ones kronikol query parties and its origin and cause
read (5.20.0), so the card and the query never disagree about who a party is or why a call was made.
run.behaviourHash is the SHA-256 of the behaviour member's bytes exactly as the file holds them. The file is
written compact, on one line, with behaviour last, so those bytes run from the { after the last "behaviour": to
the byte before the file's closing }. Check it over that range, never over a copy written again by a JSON library
(jq -c and Python's json change the escapes):
python3 -c 'import hashlib,json,sys
data = open(sys.argv[1], "rb").read().rstrip(b"\n")
start = data.rindex(b"\"behaviour\":") + len(b"\"behaviour\":")
print(hashlib.sha256(data[start:-1]).hexdigest() == json.loads(data)["run"]["behaviourHash"])' service.jsonAn indexer compares two runs by the hash and reads the card only when it moved. These move it with no change of behaviour, and each is visible in the card:
- the card's own rules: the operation key, the templating rules or the inference, which
behaviour.rulesrecords; - a Kronikol upgrade that records more or names a party anew (5.13.0 named a call to an unmapped host by its host,
where it was
localhost:443; 5.16.0 marks the calls a stub handler answered as a test double; 5.27.14 keeps a method as the run wrote it, where a merge readDeleteasDELETEand a verb built by hand was written in capitals, which moves a call'soponce; 5.31.2 follows a call past a handler that hands it on, so a party reached through one can change kind once), whichrun.report.kronikolVersiontells; - the platform: an SDK that makes a call on one OS and not another (the Cosmos DB SDK asks the gateway for a query plan
on Linux only), which
run.environmenttells; - the titles Kronikol makes, when an upgrade writes a feature or scenario title differently (5.16.5 keeps the words a method's name writes in capitals).
The card's JSON Schema is
schemas/service-card.v1.schema.json,
draft 2020-12. A member a later version adds does not move formatVersion, which names the card's shape, and a reader
ignores members it does not know. The schema's objects are closed, so a newer card fails validation against an older
copy of it: validate against the copy on main.
Home · 🔍 Search this wiki Full-text search across every page. The “Pages” list above matches page and heading names, not page content.
Getting Started
- Quick Start (xUnit)
- Project Templates
- AI Integration Prompt
- Framework Integration Guides
- Migrating to v5
- Migrating to v4
Common Tasks
Integration Guides
- Integration xUnit3
- Integration xUnit2
- Integration NUnit
- Integration MSTest
- Integration TUnit
- Integration BDDfy xUnit3
- Integration LightBDD xUnit2
- Integration LightBDD xUnit3
- Integration LightBDD TUnit
- Integration ReqNRoll xUnit2
- Integration ReqNRoll xUnit3
- Integration ReqNRoll TUnit
- Integration Playwright
Uninstrumentable / polyglot backends
- Integration ProxyTap Extension
- Integration TcpTap Extension
- Integration Otlp Extension
- Exporting to OpenTelemetry
- Ingesting External Captures
- Ingesting from Jest
- Integration Cucumber Messages
- Capture-Time Redaction
Extensions
- Integration AtlasDataApi Extension
- Integration BigQuery Extension
- Integration Bigtable Extension
- Integration BlobStorage Extension
- Integration ClickHouse Extension
- Integration CloudStorage Extension
- Integration CosmosDB Extension
- Integration Dapper Extension
- Integration DynamoDB Extension
- Integration EF Core Relational Extension
- Integration Elasticsearch Extension
- Integration EventBridge Extension
- Integration EventHubs Extension
- Integration Grpc Extension
- Integration Kafka Extension
- Integration MassTransit Extension
- Integration MongoDB Extension
- Integration MySqlConnector Extension
- Integration Npgsql Extension
- Integration Oracle Extension
- Integration PubSub Extension
- Integration Redis Extension
- Integration S3 Extension
- Integration ServiceBus Extension
- Integration SNS Extension
- Integration Spanner Extension
- Integration SqlClient Extension
- Integration Sqlite Extension
- Integration SQS Extension
- Integration StorageQueues Extension
- Integration OpenTelemetry Extension
- Integration DispatchProxy Extension
- Integration MediatR Extension
- Integration PlantUML IKVM
Configuration
- Tracking Dependencies
- Tracking Custom Dependencies
- HTTP Tracking Setup
- Report Configuration
- Diagram Customisation
- Phase-Aware Tracking
- Content Formatting
- PlantUML Server Configuration
Features
- Generated Reports
- Report Themes
- Search and Filter Syntax
- Component Diagrams
- PlantUML Browser Rendering
- Inline SVG Rendering
- Internal Flow Tracking
- Tags and Attributes
- Excluding Requests
- Excluded Headers
- Multi-Host Test Architectures
- Event-Driven Architecture Testing
- Service Bus Tracking Patterns
- Background Thread Correlation
- Parallel-Safe Background Correlation
- Event & Message Tracking
- Assertion Tracking
- Step Tracking
- Tabular Attributes
- Large Response and Diagram Handling
- Querying Reports
- Service Card
- Cross-Run History
- Diagnostics and Debugging
- CI Summary Integration
- CI Artifact Upload
- Merging Parallel Reports
Reference