Skip to content

Commit

Permalink
Updating Pokeshop + Kafka docs
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbdias committed Sep 7, 2023
1 parent cc73901 commit 3fca868
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 10 deletions.
Binary file added docs/docs/img/choose-trigger-0.13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/docs/img/create-test-0.13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/docs/live-examples/pokeshop/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ We have three use cases that use each component of this structure and that can b
- [Add Pokemon](./use-cases/add-pokemon.md): Add a new Pokemon only relying on user input into the database.
- [Get Pokemon by ID](./use-cases/get-pokemon-by-id.md): Given a Pokemon ID, this endpoint returns the data of a Pokemon. If the same Pokemon was queried, the API will use its cache to return it.
- [List Pokemon](./use-cases/list-pokemon.md): Lists all Pokemons registered into Pokeshop.
- [Import Pokemon from Queue](./use-cases/import-pokemon.md): Given a Pokemon ID, this endpoint does an async process, going to PokeAPI to get Pokemon data and adding it to the database.
- [Import Pokemon](./use-cases/import-pokemon.md): Given a Pokemon ID, this endpoint does an async process, going to PokeAPI to get Pokemon data and adding it to the database.
- [Import Pokemon from Stream](./use-cases/import-pokemon-from-stream.md): Listening to a Stream, this usecase also does an async process, going to PokeAPI to get Pokemon data and adding it to the database.

## System Architecture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,23 @@ Using Tracetest, we can [create a test](../../../web-ui/creating-tests.md) that

Running these tests for the first time will create an Observability trace like the image below, where you can see spans for the stream messaging, the PokeAPI (external API) call and database calls.

<!-- ![](../images/import-pokemon-trace.png) -->
![](../images/import-pokemon-from-stream-trace.png)

### Assertions

With this trace, we can build [assertions](../../../concepts/assertions.md) on Tracetest and validate the API and Worker behaviors:

- **A message was received from Kafka stream:**
<!-- ![](../images/import-pokemon-message-dequeue-test-spec.png) -->
![](../images/import-pokemon-from-stream-message-received.png)

- **Import Pokemon use case was triggered**:
- ![](../images/import-pokemon-from-stream-use-case-executed.png)

- **PokeAPI should return a valid response:**
<!-- ![](../images/import-pokemon-pokeapi-call-test-spec.png) -->
![](../images/import-pokemon-from-stream-get-pokeapi.png)

- **The database should respond with low latency (< 200ms):**
<!-- ![](../images/import-pokemon-db-latency-test-spec.png) -->
![](../images/import-pokemon-from-stream-database-latency.png)

Now you can validate this entire use case.

Expand Down Expand Up @@ -88,7 +89,7 @@ spec:
name: Import Pokemon use case was triggered
assertions:
- attr:name = "import pokemon"
- selector: span[tracetest.span.type="http" name="HTTP GET pokeapi.pokemon" http.method="GET"]
- selector: span[tracetest.span.type="http" name="GET" http.method="GET"]
name: PokeAPI should return a valid response
assertions:
- attr:http.response.body = '{"name":"snorlax"}'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Pokeshop API - Import Pokemon from Queue
# Pokeshop API - Import Pokemon

This use case showcases a more complex scenario involving an async process. Usually, when working with microservices, there are use cases where some of the processing needs to happen asynchronously, for example, when triggering a user notification, generating reports or processing a payment order. With this endpoint, we provide an example of how users can implement trace-based testing for such scenarios.

Expand Down
7 changes: 4 additions & 3 deletions docs/docs/web-ui/creating-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ Click the **Create** button and select **Create New Test** in the drop down:

The "Create New Test" dialog appears:

![Create a Test](../img/create-test-0.11.png)
![Create a Test](../img/create-test-0.13.png)

The option to choose the kind of trigger to initiate the trace is presented:

- HTTP Request - Create a basic HTTP request.
- GRPC Request - Test and debug your GRPC request.
- cURL Command - Define your HTTP test via a cURL command.
- Postman Collection - Define your HTTP request via a Postman collection.
- TraceID - Define you test via a TraceID.
- TraceID - Define your test via a TraceID.
- Kafka - Test consumers with Kafka messages

Choose the trigger and click **Next**:

![Choose Trigger](../img/choose-trigger-0.11.png)
![Choose Trigger](../img/choose-trigger-0.13.png)

In this example, HTTP Request has been chosen.

Expand Down
5 changes: 5 additions & 0 deletions docs/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ const sidebars = {
id: "live-examples/pokeshop/use-cases/import-pokemon",
label: "Import Pokemon",
},
{
type: "doc",
id: "live-examples/pokeshop/use-cases/import-pokemon-from-stream",
label: "Import Pokemon from Stream",
},
],
},
],
Expand Down

0 comments on commit 3fca868

Please sign in to comment.