Skip to content

Commit 4e7e645

Browse files
committed
add documentation on how to test the processor
1 parent e722252 commit 4e7e645

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,30 @@ In short, the steps to run your custom processor are the following:
2828
3. Prepare `processor.properties` with rdkafka (Kafka client) configuration - [see example](./processor.properties) (put this file in the same directory as your executable).
2929
4. Run your executable (to see logs set the following environment variable: `RUST_LOG=info`, e.g. in bash you can just run `RUST_LOG=info ./your_executable`).
3030

31+
## Test your processor
32+
33+
You may want to test if the generated processor is correct before deploying it.
34+
To test it, in the generated project, create a `simulations` directory.
35+
In this directory, create another directory (or directories, depending on the `template.yaml`) with the name `${input_topic}_${output_topic}`,
36+
where `${input_topic}` is the name of the input_topic from `template.yaml` and `${output_topic}` is the name of the output_topic from `template.yaml`.
37+
38+
For example, if you have the following stream in your `tempate.yaml`:
39+
```yaml
40+
streams:
41+
- input_topic: sometopic
42+
output_topic: target
43+
```
44+
45+
Then create the following directory structure:
46+
```text
47+
<project_directory>
48+
> simulations
49+
| > sometopic_target
50+
```
51+
52+
In the `${input_topic}_${output_topic}` directory (in this case - `sometopic_target`), create text files with the input message and expected output.
53+
For example, given the template [`all_processors.yaml`](template-examples/all_processors.yaml) (see template-examples), I have prepared some test data in [`simulations/in_out`](simulations/in_out).
54+
The test files always have two headers - `[Input]` (for input JSON) and `[Expected]` (for expected processed message).
55+
56+
To run the simulation, run `cargo test` in the generated project.
57+
See [`kjp-generator/tests/integration_test.rs`](kjp-generator/tests/integration_test.rs) for a complete example.

0 commit comments

Comments
 (0)