Skip to content

Commit

Permalink
KAFKA-18162 Move LocalLogTest to storage module (#18057)
Browse files Browse the repository at this point in the history
Reviewers: Chia-Ping Tsai <[email protected]>
  • Loading branch information
mimaison authored Dec 7, 2024
1 parent 417bd22 commit e255433
Show file tree
Hide file tree
Showing 4 changed files with 774 additions and 722 deletions.
17 changes: 17 additions & 0 deletions clients/src/test/java/org/apache/kafka/test/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,23 @@ public static File tempDirectory(final Path parent, String prefix) {
return file;
}

/**
* Create a random log directory in the format <string>-<int> used for Kafka partition logs.
* It is the responsibility of the caller to set up a shutdown hook for deletion of the directory.
*/
public static File randomPartitionLogDir(File parentDir) {
int attempts = 1000;
while (attempts > 0) {
File f = new File(parentDir, "kafka-" + RANDOM.nextInt(1000000));
if (f.mkdir()) {
f.deleteOnExit();
return f;
}
attempts--;
}
throw new RuntimeException("Failed to create directory after 1000 attempts");
}

public static Properties producerConfig(final String bootstrapServers,
final Class<?> keySerializer,
final Class<?> valueSerializer,
Expand Down
Loading

0 comments on commit e255433

Please sign in to comment.