summaryrefslogtreecommitdiffstats
path: root/src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests')
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/.gitignore2
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/Makefile25
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/README.md8
-rwxr-xr-xsrc/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/run-test.sh49
-rwxr-xr-xsrc/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/test-on-docker.sh56
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/test.c77
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/test.cpp34
7 files changed, 251 insertions, 0 deletions
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/.gitignore b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/.gitignore
new file mode 100644
index 000000000..333a2b7ac
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/.gitignore
@@ -0,0 +1,2 @@
+test
+testcpp
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/Makefile b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/Makefile
new file mode 100644
index 000000000..edd457997
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/Makefile
@@ -0,0 +1,25 @@
+
+PROGS?=test test-static testcpp testcpp-static
+
+all: $(PROGS)
+
+test: test.c
+ $(CC) -O2 -Werror -Wall $^ -o $@ $$(pkg-config --libs rdkafka)
+
+test-static: test.c
+ $(CC) -O2 -Werror -Wall $^ -o $@ $$(pkg-config --libs --static rdkafka-static)
+
+testcpp: test.cpp
+ $(CXX) -O2 -Werror -Wall $^ -o $@ $$(pkg-config --libs rdkafka++)
+
+testcpp-static: test.cpp
+ $(CXX) -O2 -Werror -Wall $^ -o $@ $$(pkg-config --libs rdkafka++-static)
+
+run:
+ @(for p in $(PROGS); do \
+ echo "# Running $$p" ; \
+ ./$$p || (echo $$p failed ; exit 1) ; \
+ done)
+
+clean:
+ rm -f $(PROGS)
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/README.md b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/README.md
new file mode 100644
index 000000000..8d1107b66
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/README.md
@@ -0,0 +1,8 @@
+# Test librdkafka RPMs using docker
+
+After building the RPMs (see README.md in parent directory) test
+the RPMs on the supported CentOS/RHEL versions using:
+
+ $ packaging/rpm/tests/test-on-docker.sh
+
+
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/run-test.sh b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/run-test.sh
new file mode 100755
index 000000000..c1234a945
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/run-test.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+#
+# This script runs in the docker container, performing:
+# * install build toolchain
+# * install librdkafka rpms
+# * builds test apps
+# * runs test apps
+#
+# Usage: $0 <docker-image-name>
+
+set -ex
+
+pushd /v
+
+_IMG=$1
+
+echo "Testing on $_IMG"
+
+if [[ $_IMG == "centos:6" ]]; then
+ _EL=6
+ _INST="yum install -y -q"
+elif [[ $_IMG == "centos:7" ]]; then
+ _EL=7
+ _INST="yum install -y -q"
+ # centos:7 ships with openssl-libs 1.0.1 which is outdated and not
+ # ABI-compatible with 1.0.2 (which we build with).
+ # Upgrade openssl-libs, as users would, to prevent missing symbols.
+ _UPG="yum upgrade -y openssl-libs"
+else
+ _EL=8
+ _INST="dnf install -y -q"
+fi
+
+$_INST gcc gcc-c++ make pkg-config
+
+if [[ -n $_UPG ]]; then
+ $_UPG
+fi
+
+$_INST /rpms/librdkafka1-*el${_EL}.x86_64.rpm /rpms/librdkafka-devel-*el${_EL}.x86_64.rpm
+
+make clean all
+
+make run
+
+make clean
+
+echo "$_IMG is all good!"
+
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/test-on-docker.sh b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/test-on-docker.sh
new file mode 100755
index 000000000..2c12ff792
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/test-on-docker.sh
@@ -0,0 +1,56 @@
+#!/bin/bash
+#
+#
+# Test librdkafka packages in <rpmdirectory> using docker.
+# Must be executed from the librdkafka top-level directory.
+#
+# Usage:
+# packaging/rpm/test-on-docker.sh [<rpm-dir>]
+
+set -ex
+
+if [[ ! -f configure.self ]]; then
+ echo "Must be executed from the librdkafka top-level directory"
+ exit 1
+fi
+
+_DOCKER_IMAGES="centos:7 redhat/ubi8:8.5-226"
+_RPMDIR=artifacts
+
+if [[ -n $1 ]]; then
+ _RPMDIR="$1"
+fi
+
+_RPMDIR=$(readlink -f $_RPMDIR)
+
+if [[ ! -d $_RPMDIR ]]; then
+ echo "$_RPMDIR does not exist"
+ exit 1
+fi
+
+
+fails=""
+for _IMG in $_DOCKER_IMAGES ; do
+ if ! docker run \
+ -t \
+ -v $_RPMDIR:/rpms \
+ -v $(readlink -f packaging/rpm/tests):/v \
+ $_IMG \
+ /v/run-test.sh $_IMG ; then
+ echo "ERROR: $_IMG FAILED"
+ fails="${fails}$_IMG "
+ fi
+done
+
+if [[ -n $fails ]]; then
+ echo "##################################################"
+ echo "# Package verification failed for:"
+ echo "# $fails"
+ echo "# See previous errors"
+ echo "##################################################"
+ exit 1
+fi
+
+exit 0
+
+
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/test.c b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/test.c
new file mode 100644
index 000000000..cf39b6bcd
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/test.c
@@ -0,0 +1,77 @@
+#include <stdio.h>
+#include <string.h>
+#include <librdkafka/rdkafka.h>
+
+int main(int argc, char **argv) {
+ rd_kafka_conf_t *conf;
+ rd_kafka_t *rk;
+ char features[256];
+ size_t fsize = sizeof(features);
+ char errstr[512];
+ const char *exp_features[] = {
+ "gzip", "snappy", "ssl", "sasl", "regex",
+ "lz4", "sasl_gssapi", "sasl_plain", "sasl_scram", "plugins",
+ "zstd", "sasl_oauthbearer", NULL,
+ };
+ const char **exp;
+ int missing = 0;
+
+
+ printf("librdkafka %s\n", rd_kafka_version_str());
+
+ conf = rd_kafka_conf_new();
+ if (rd_kafka_conf_get(conf, "builtin.features", features, &fsize) !=
+ RD_KAFKA_CONF_OK) {
+ fprintf(stderr, "conf_get failed\n");
+ return 1;
+ }
+
+ printf("builtin.features %s\n", features);
+
+ /* Verify that expected features are enabled. */
+ for (exp = exp_features; *exp; exp++) {
+ const char *t = features;
+ size_t elen = strlen(*exp);
+ int match = 0;
+
+ while ((t = strstr(t, *exp))) {
+ if (t[elen] == ',' || t[elen] == '\0') {
+ match = 1;
+ break;
+ }
+ t += elen;
+ }
+
+ if (match)
+ continue;
+
+ fprintf(stderr, "ERROR: feature %s not found\n", *exp);
+ missing++;
+ }
+
+ if (rd_kafka_conf_set(conf, "security.protocol", "SASL_SSL", errstr,
+ sizeof(errstr)) ||
+ rd_kafka_conf_set(conf, "sasl.mechanism", "PLAIN", errstr,
+ sizeof(errstr)) ||
+ rd_kafka_conf_set(conf, "sasl.username", "username", errstr,
+ sizeof(errstr)) ||
+ rd_kafka_conf_set(conf, "sasl.password", "password", errstr,
+ sizeof(errstr)) ||
+ rd_kafka_conf_set(conf, "debug", "security", errstr,
+ sizeof(errstr))) {
+ fprintf(stderr, "conf_set failed: %s\n", errstr);
+ return 1;
+ }
+
+ rk = rd_kafka_new(RD_KAFKA_PRODUCER, conf, errstr, sizeof(errstr));
+ if (!rk) {
+ fprintf(stderr, "rd_kafka_new failed: %s\n", errstr);
+ return 1;
+ }
+
+ printf("client name %s\n", rd_kafka_name(rk));
+
+ rd_kafka_destroy(rk);
+
+ return missing ? 1 : 0;
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/test.cpp b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/test.cpp
new file mode 100644
index 000000000..d78a76710
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/rpm/tests/test.cpp
@@ -0,0 +1,34 @@
+#include <iostream>
+#include <librdkafka/rdkafkacpp.h>
+
+
+int main() {
+ std::cout << "librdkafka++ " << RdKafka::version_str() << std::endl;
+
+ RdKafka::Conf *conf = RdKafka::Conf::create(RdKafka::Conf::CONF_GLOBAL);
+
+ std::string features;
+
+ if (conf->get("builtin.features", features) != RdKafka::Conf::CONF_OK) {
+ std::cerr << "conf_get failed" << std::endl;
+ return 1;
+ }
+
+ std::cout << "builtin.features " << features << std::endl;
+
+ std::string errstr;
+ RdKafka::Producer *producer = RdKafka::Producer::create(conf, errstr);
+ if (!producer) {
+ std::cerr << "Producer::create failed: " << errstr << std::endl;
+ return 1;
+ }
+
+ delete conf;
+
+ std::cout << "client name " << producer->name() << std::endl;
+
+
+ delete producer;
+
+ return 0;
+}