-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1 +1,44 @@ | ||
# k3a-embedded | ||
|
||
Embedded Kafka server for running simple integration tests. Embedded | ||
in the sense that the Kafka server is running in the same VM as the | ||
tests. No container runtime required. | ||
|
||
## Limitations | ||
|
||
* Not at all configurable. Starts a single-node server with no | ||
security at all. | ||
* No Zookeeper. The server runs in KRaft mode. | ||
|
||
## What it does | ||
|
||
* Creates a temporary directory that will hold all runtime files of | ||
Kafka. This directory is deleted when the server is stopped. | ||
* Finds a random available port that the broker will listen to. | ||
|
||
## Usage | ||
|
||
For JUnit tests, do something like this for starting, stopping, and | ||
getting the correct Kafka bootstrap servers (the latter will be | ||
`localhost` in combination with the random port): | ||
|
||
```java | ||
private static K3aEmbedded kafka; | ||
|
||
@BeforeClass | ||
public static void beforeClass() { | ||
kafka = new K3aEmbedded(); | ||
kafka.start(); | ||
} | ||
|
||
@AfterClass | ||
public static void afterClass() { | ||
kafka.stop(); | ||
} | ||
|
||
private Map<String, Object> getCommonConfig() { | ||
final Map<String, Object> map = new HashMap<>(); | ||
map.put(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, kafka.getBootstrapServers()); | ||
return map; | ||
} | ||
``` |