Spring Kafka integration test Error while writing to highwatermark file

Do you actually have permissions to write to /var/folders/s3 ...?

You can override the location with

@Bean
public EmbeddedKafkaBroker embeddedKafkaBroker() {
    return new EmbeddedKafkaBroker(1,false,2,"test-events")
        .brokerProperties(Collections.singletonMap(KafkaConfig.LogDirProp(), "/tmp/foo"));
}

I had similar issue and with help of Gary Russell answer I solved it by pointing log dir to gradle build output dir log.dir=out/embedded-kafka or in case of maven log.dir=target/embedded-kafka.

The following code snippet shows how to do it using @EmbeddedKafka.

@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = {Application.class})
@EmbeddedKafka(
        topics = "topic",
        partitions = 1,
        controlledShutdown = true,
        brokerProperties={
                "log.dir=out/embedded-kafka"
        })
@TestPropertySource(
        properties = {
                "spring.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}"
        })
public class OutboxEventsTest {
...
}