-
Notifications
You must be signed in to change notification settings - Fork 118
AsyncAPI 3.x: the driver contract for publishing a message #1738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b29712e
AsyncAPI 3.x: the driver contract for publishing a message
LautaroPetaccio d7d3e9b
AsyncAPI 3.x: constants before fields in the action DTO
LautaroPetaccio 5f3a2c7
AsyncAPI 3.x: say what the header maps hold
LautaroPetaccio 2e1304d
AsyncAPI 3.x: withServicesToNotMock states its pre-condition
LautaroPetaccio 69860be
AsyncAPI 3.x: say when the two durations are null
LautaroPetaccio 0e2c12e
AsyncAPI 3.x: the reply's index cannot be null
LautaroPetaccio 94b1a36
AsyncAPI 3.x: no primitives in the reply DTO
LautaroPetaccio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...rc/main/java/org/evomaster/client/java/controller/api/dto/problem/AsyncApiProblemDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package org.evomaster.client.java.controller.api.dto.problem; | ||
|
|
||
| /** | ||
| * Info the driver gives about an AsyncAPI service, so that the core can learn what the service | ||
| * consumes and what shape those messages have. | ||
| * | ||
| * Note the transport client is not here, and never crosses: it is an open connection to a | ||
| * broker, held by the driver. Only the document travels. | ||
| */ | ||
| public class AsyncApiProblemDto extends ProblemInfoDto { | ||
|
|
||
| /** | ||
| * Where the AsyncAPI document can be fetched from: a URL, or a path on the machine running | ||
| * the driver. Null when the document is given inline instead. | ||
| */ | ||
| public String schemaLocation; | ||
|
|
||
| /** | ||
| * The AsyncAPI document itself. Null when a location is given instead. | ||
| * | ||
| * Useful when the document is packaged with the service rather than served by it, which is | ||
| * the common case: unlike OpenAPI, an AsyncAPI service rarely exposes its own contract over | ||
| * HTTP, since it may not speak HTTP at all. | ||
| */ | ||
| public String schemaText; | ||
| } |
99 changes: 99 additions & 0 deletions
99
...java/org/evomaster/client/java/controller/api/dto/problem/asyncapi/AsyncApiActionDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| package org.evomaster.client.java.controller.api.dto.problem.asyncapi; | ||
|
|
||
| import java.util.LinkedHashMap; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * One message for the driver to publish, and what to do about a reply. | ||
| * | ||
| * Everything here is decided by the core: which operation, where it goes, what it says. The | ||
| * driver's job is to put it on the wire and, when a reply is expected, wait for the one that | ||
| * answers it. | ||
| */ | ||
| public class AsyncApiActionDto { | ||
|
|
||
| /** | ||
| * The two places a correlation id can travel, as {@link #correlationLocation} names them. | ||
| */ | ||
| public static final String CORRELATION_IN_HEADER = "HEADER"; | ||
|
|
||
| public static final String CORRELATION_IN_PAYLOAD = "PAYLOAD"; | ||
|
|
||
| /** | ||
| * Key of the operation in the AsyncAPI document. Sent along so the driver can report and | ||
| * log in terms the user will recognise from their own contract. | ||
| */ | ||
| public String operationId; | ||
|
|
||
| /** | ||
| * Key of the channel the message is published on. | ||
| */ | ||
| public String channelName; | ||
|
|
||
| /** | ||
| * Where the message actually goes on the wire: a topic, a queue, a routing key. Already | ||
| * resolved by the core, including any binding that overrides the channel's address. | ||
| */ | ||
| public String address; | ||
|
|
||
| /** | ||
| * Id of the message being published, as the document names it. | ||
| */ | ||
| public String messageId; | ||
|
|
||
| /** | ||
| * The message body, serialised. Its content type is in {@link #contentType}. | ||
| */ | ||
| public String payload; | ||
|
|
||
| /** | ||
| * What the document declares the payload is encoded as, eg "application/json". | ||
| */ | ||
| public String contentType; | ||
|
|
||
| /** | ||
| * Headers to publish alongside the body, for a transport that has them. | ||
| * Key is the header name as the document declares it, value is what to send under it, as text. | ||
| */ | ||
| public Map<String, String> headers = new LinkedHashMap<>(); | ||
|
|
||
| /** | ||
| * The value stamped into this message so that a reply can be recognised as answering it. | ||
| * | ||
| * It is minted fresh by the core for every execution rather than being part of the message | ||
| * the search varies: pairing needs a value unique to the execution, and the service only | ||
| * echoes it back. | ||
| */ | ||
| public String correlationId; | ||
|
|
||
| /** | ||
| * Where the correlation id has to be written, as the document declares it. One of | ||
| * {@link #CORRELATION_IN_HEADER} or {@link #CORRELATION_IN_PAYLOAD}, or null when the | ||
| * document says nothing, in which case it is up to the driver to decide -- a transport with | ||
| * native correlation should use it. | ||
| */ | ||
| public String correlationLocation; | ||
|
|
||
| /** | ||
| * JSON Pointer to the field the correlation id goes in, within whatever | ||
| * {@link #correlationLocation} names. Null when there is no declared location. | ||
| */ | ||
| public String correlationPointer; | ||
|
|
||
| /** | ||
| * Where a reply is expected to arrive, when the operation declares one. Null for a | ||
| * fire-and-forget operation, in which case the driver publishes and returns. | ||
| */ | ||
| public String replyAddress; | ||
|
|
||
| /** | ||
| * How long to wait for a reply before giving up, in milliseconds. | ||
| * | ||
| * There is no right answer here: a slow service and a stuck one look the same from outside, | ||
| * so this is a tuning parameter with no equivalent in a synchronous protocol. It is set | ||
| * generously and reported with the result. | ||
| * | ||
| * Null when no reply is expected, as there is then nothing to wait for. | ||
| */ | ||
| public Long replyTimeoutMs; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can this value be null?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, when no reply is expected (replyAddress null), there is nothing to wait for. I've written it in the javadoc. |
||
| } | ||
89 changes: 89 additions & 0 deletions
89
.../java/org/evomaster/client/java/controller/api/dto/problem/asyncapi/AsyncApiReplyDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| package org.evomaster.client.java.controller.api.dto.problem.asyncapi; | ||
|
|
||
| import java.util.LinkedHashMap; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * What came of publishing one message. | ||
| * | ||
| * The four outcomes are deliberately distinguished, because they mean different things and only | ||
| * one of them is a fault: | ||
| * | ||
| * <ul> | ||
| * <li>published, with no reply expected -- a fire-and-forget operation did what it could;</li> | ||
| * <li>published, and a reply arrived -- the only case with something to classify;</li> | ||
| * <li>published, and nothing arrived within the window -- the contract promised a reply and | ||
| * did not deliver one, though a slow service and a stuck one look alike from outside;</li> | ||
| * <li>could not be published at all -- a broken setup rather than a finding about the | ||
| * service, which is why it is reported separately from silence.</li> | ||
| * </ul> | ||
| */ | ||
| public class AsyncApiReplyDto { | ||
|
|
||
| /** | ||
| * The index of the action this answers, echoing what was asked. | ||
| */ | ||
| public Integer index; | ||
|
|
||
| /** | ||
| * Whether the message reached the broker. False means the driver could not publish, and | ||
| * {@link #errorMessage} says why. | ||
| * | ||
| * Null means the driver did not say, which is read the same way as false: without an answer | ||
| * here there is no knowing whether the message went out, and the rest of the test would | ||
| * mean nothing. | ||
| */ | ||
| public Boolean published; | ||
|
|
||
| /** | ||
| * Whether a reply arrived and was recognised as answering this message. | ||
| * | ||
| * Null means the driver did not say, and is read as no reply having arrived. | ||
| */ | ||
| public Boolean replyReceived; | ||
|
|
||
| /** | ||
| * Whether the driver waited for a reply at all. False for a fire-and-forget operation, so | ||
| * that the absence of a reply is not mistaken for silence in answer to a promise. | ||
| * | ||
| * Null means the driver did not say, and is read as not having waited. | ||
| */ | ||
| public Boolean replyExpected; | ||
|
|
||
| /** | ||
| * The reply body, as it arrived. | ||
| */ | ||
| public String replyPayload; | ||
|
|
||
| /** | ||
| * The reply's headers, for a transport that has them. | ||
| * Key is the header name, value is what arrived under it, as text. | ||
| */ | ||
| public Map<String, String> replyHeaders = new LinkedHashMap<>(); | ||
|
jgaleotti marked this conversation as resolved.
|
||
|
|
||
| /** | ||
| * Whether the reply carried back the correlation id that was stamped on the request. | ||
| * | ||
| * This is the honest answer to "did correlation work", which cannot be read off a contract: | ||
| * echoing the id is the service's own behaviour. A reply that arrives without it is | ||
| * recorded rather than treated as a fault, since from outside there is no telling a defect | ||
| * from a service that correlates by some business key instead. | ||
| * | ||
| * Null means the driver does not track correlation at all, which is not the same as having | ||
| * checked and found the id missing, and is recorded as neither. | ||
| */ | ||
| public Boolean correlationMatched; | ||
|
|
||
| /** | ||
| * How long the driver waited, in milliseconds, whether or not anything arrived. Reported | ||
| * because the verdict on silence is only meaningful alongside how long it was waited for. | ||
| * | ||
| * Null when the driver did not wait at all: no reply was expected, or nothing was published. | ||
| */ | ||
| public Long waitedMs; | ||
|
jgaleotti marked this conversation as resolved.
|
||
|
|
||
| /** | ||
| * Why publishing failed, when it did. | ||
| */ | ||
| public String errorMessage; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a description of what the keys and values are in maps. This programming discipline is specified in docs/for_developers.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!