diff --git a/dockerfiles/Dockerfile b/dockerfiles/Dockerfile index 9e96c846991..7c4c5ce940a 100644 --- a/dockerfiles/Dockerfile +++ b/dockerfiles/Dockerfile @@ -49,6 +49,7 @@ RUN apt-get update && \ pkg-config \ libsystemd-dev \ zlib1g-dev \ + libzstd-dev \ libpq-dev \ postgresql-server-dev-all \ flex \ @@ -263,7 +264,7 @@ RUN apt-get update && \ openssl \ htop atop strace iotop sysstat ncdu logrotate hdparm pciutils psmisc tree pv \ make tar flex bison \ - libssl-dev libsasl2-dev libsystemd-dev zlib1g-dev libpq-dev libyaml-dev postgresql-server-dev-all \ + libssl-dev libsasl2-dev libsystemd-dev zlib1g-dev libzstd-dev libpq-dev libyaml-dev postgresql-server-dev-all \ && apt-get satisfy -y cmake "cmake (<< 4.0)" \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* diff --git a/tests/runtime/CMakeLists.txt b/tests/runtime/CMakeLists.txt index 104750b456e..1e5d4b7d571 100644 --- a/tests/runtime/CMakeLists.txt +++ b/tests/runtime/CMakeLists.txt @@ -345,6 +345,17 @@ foreach(source_file ${CHECK_PROGRAMS}) endif() endforeach() +# The out_kafka runtime test includes librdkafka's public header directly, so it +# needs the same include path the in_kafka/out_kafka plugins use. Cover both the +# system librdkafka (pkg-config) and the bundled librdkafka build. +if(TARGET flb-rt-out_kafka) + if(DEFINED KAFKA_INCLUDEDIR) + target_include_directories(flb-rt-out_kafka PRIVATE ${KAFKA_INCLUDEDIR}/librdkafka) + endif() + target_include_directories(flb-rt-out_kafka PRIVATE + ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_RDKAFKA}/src) +endif() + function(flb_runtime_lock_tests resource_name) foreach(test_name ${ARGN}) if (TEST ${test_name}) diff --git a/tests/runtime/out_kafka.c b/tests/runtime/out_kafka.c index 4c5c852bc44..d18ff7f5643 100644 --- a/tests/runtime/out_kafka.c +++ b/tests/runtime/out_kafka.c @@ -3,9 +3,34 @@ #include #include "flb_tests_runtime.h" +#include "rdkafka.h" + /* Test data */ #include "data/td/json_td.h" +/* + * Ensure librdkafka was compiled with zstd support so Kafka producers can + * negotiate zstd compression. Setting compression.codec to zstd only succeeds + * when WITH_ZSTD was enabled at build time, otherwise rd_kafka_conf_set + * reports the codec as not built in. + */ +void flb_test_zstd_compression_available() +{ + rd_kafka_conf_t *conf; + rd_kafka_conf_res_t res; + char errstr[512] = {0}; + + conf = rd_kafka_conf_new(); + TEST_CHECK(conf != NULL); + + res = rd_kafka_conf_set(conf, "compression.codec", "zstd", + errstr, sizeof(errstr)); + TEST_CHECK(res == RD_KAFKA_CONF_OK); + TEST_MSG("compression.codec=zstd rejected: %s", errstr); + + rd_kafka_conf_destroy(conf); +} + void flb_test_raw_format() { @@ -44,6 +69,7 @@ void flb_test_raw_format() } TEST_LIST = { + { "zstd_compression_available", flb_test_zstd_compression_available }, { "raw_format", flb_test_raw_format }, { NULL, NULL }, };