Skip to content

Commit a7d9785

Browse files
committed
BUILD-KIP932: Commit to build branch with kip-932 librdkafka branch
1 parent 51ec85d commit a7d9785

File tree

4 files changed

+97
-9
lines changed

4 files changed

+97
-9
lines changed

.semaphore/semaphore.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ global_job_config:
99
env_vars:
1010
- name: LIBRDKAFKA_VERSION
1111
value: v2.13.2
12+
- name: LIBRDKAFKA_BRANCH
13+
value: dev_kip-932_queues-for-kafka
1214
prologue:
1315
commands:
1416
- checkout
@@ -332,7 +334,13 @@ blocks:
332334

333335
# Build and install confluent-kafka from source
334336
- lib_dir=dest/runtimes/$OS_NAME-$ARCH/native
335-
- tools/wheels/install-librdkafka.sh "${LIBRDKAFKA_VERSION#v}" dest
337+
- |
338+
if [[ -n $LIBRDKAFKA_BRANCH ]]; then
339+
sudo apt-get install -y -qq libssl-dev libsasl2-dev liblz4-dev libzstd-dev
340+
tools/wheels/build-librdkafka-branch.sh "$LIBRDKAFKA_BRANCH" dest
341+
else
342+
tools/wheels/install-librdkafka.sh "${LIBRDKAFKA_VERSION#v}" dest
343+
fi
336344
- export CFLAGS="$CFLAGS -I${PWD}/dest/build/native/include"
337345
- export LDFLAGS="$LDFLAGS -L${PWD}/${lib_dir}"
338346
- export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD/$lib_dir"

tests/test_ShareConsumer.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_constructor_with_valid_config():
3131
sc = ShareConsumer({
3232
'group.id': 'test-share-group',
3333
'bootstrap.servers': 'localhost:9092',
34-
'session.timeout.ms': 100,
34+
'socket.timeout.ms': 100,
3535
})
3636
assert sc is not None
3737
sc.close()
@@ -42,7 +42,7 @@ def test_subscribe():
4242
sc = ShareConsumer({
4343
'group.id': 'test-share-group',
4444
'bootstrap.servers': 'localhost:9092',
45-
'session.timeout.ms': 100,
45+
'socket.timeout.ms': 100,
4646
})
4747

4848
sc.subscribe(['test-topic'])
@@ -59,7 +59,7 @@ def test_unsubscribe():
5959
sc = ShareConsumer({
6060
'group.id': 'test-share-group',
6161
'bootstrap.servers': 'localhost:9092',
62-
'session.timeout.ms': 100,
62+
'socket.timeout.ms': 100,
6363
})
6464

6565
sc.subscribe(['test-topic'])
@@ -77,7 +77,7 @@ def test_consume_batch_no_broker():
7777
'group.id': 'test-share-group',
7878
'bootstrap.servers': 'localhost:9092',
7979
'socket.timeout.ms': '100',
80-
'session.timeout.ms': 100,
80+
'socket.timeout.ms': 100,
8181
})
8282

8383
sc.subscribe(['test-topic'])
@@ -96,7 +96,7 @@ def test_close_idempotent():
9696
sc = ShareConsumer({
9797
'group.id': 'test-share-group',
9898
'bootstrap.servers': 'localhost:9092',
99-
'session.timeout.ms': 100,
99+
'socket.timeout.ms': 100,
100100
})
101101

102102
sc.close()
@@ -108,7 +108,7 @@ def test_any_method_after_close_throws_exception():
108108
sc = ShareConsumer({
109109
'group.id': 'test-share-group',
110110
'bootstrap.servers': 'localhost:9092',
111-
'session.timeout.ms': 100,
111+
'socket.timeout.ms': 100,
112112
})
113113

114114
sc.subscribe(['test-topic'])
@@ -148,7 +148,7 @@ def test_concurrent_consumers():
148148
kafka_config = {
149149
'group.id': 'test-share-group-integration',
150150
'bootstrap.servers': 'localhost:9092',
151-
'session.timeout.ms': 100,
151+
'socket.timeout.ms': 100,
152152
}
153153

154154
sc1 = ShareConsumer(kafka_config)

tools/source-package-verification.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ for version in 3.9.0 4.0.0; do
2323
done
2424

2525
lib_dir=dest/runtimes/$OS_NAME-$ARCH/native
26-
tools/wheels/install-librdkafka.sh "${LIBRDKAFKA_VERSION#v}" dest
26+
if [[ -n $LIBRDKAFKA_BRANCH ]]; then
27+
tools/wheels/build-librdkafka-branch.sh "$LIBRDKAFKA_BRANCH" dest
28+
else
29+
tools/wheels/install-librdkafka.sh "${LIBRDKAFKA_VERSION#v}" dest
30+
fi
2731
export CFLAGS="$CFLAGS -I${PWD}/dest/build/native/include"
2832
export LDFLAGS="$LDFLAGS -L${PWD}/${lib_dir}"
2933
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD/$lib_dir"
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
#
3+
# Build librdkafka from a git branch and install it into a NuGet-compatible
4+
# directory layout that matches what install-librdkafka.sh produces.
5+
#
6+
# Usage: build-librdkafka-branch.sh <branch> <destdir>
7+
#
8+
# branch - git branch name, e.g. dev_kip-932_queues-for-kafka
9+
# destdir - destination directory, e.g. dest
10+
#
11+
# Resulting layout (mirrors NuGet redist package):
12+
# <destdir>/build/native/include/librdkafka/rdkafka.h
13+
# <destdir>/runtimes/<os>-<arch>/native/librdkafka.{so.1,dylib}
14+
15+
set -ex
16+
17+
BRANCH="$1"
18+
DEST="$2"
19+
20+
if [[ -z $BRANCH || -z $DEST ]]; then
21+
echo "Usage: $0 <branch> <destdir>"
22+
exit 1
23+
fi
24+
25+
if [[ -f $DEST/build/native/include/librdkafka/rdkafka.h ]]; then
26+
echo "$0: librdkafka already built in $DEST"
27+
exit 0
28+
fi
29+
30+
echo "$0: Building librdkafka branch '$BRANCH' into '$DEST'"
31+
32+
ARCH=${ARCH:-x64}
33+
SRC=/tmp/librdkafka-branch-src
34+
INSTALL=$SRC/install
35+
36+
[[ -d "$DEST" ]] || mkdir -p "$DEST"
37+
rm -rf "$SRC"
38+
39+
git clone --depth 1 --branch "$BRANCH" \
40+
https://github.com/confluentinc/librdkafka.git "$SRC"
41+
42+
pushd "$SRC"
43+
./configure --prefix="$INSTALL" --disable-debug-symbols
44+
make -j"$(nproc 2>/dev/null || sysctl -n hw.ncpu)"
45+
make install
46+
popd
47+
48+
# --- Mirror NuGet layout ---
49+
50+
INC_DST="$DEST/build/native/include"
51+
mkdir -p "$INC_DST"
52+
cp -r "$INSTALL/include/librdkafka" "$INC_DST/"
53+
54+
if [[ $OSTYPE == linux* ]]; then
55+
OS_NAME=linux
56+
LIB_DST="$DEST/runtimes/$OS_NAME-$ARCH/native"
57+
mkdir -p "$LIB_DST"
58+
cp -v "$INSTALL"/lib/librdkafka.so* "$LIB_DST/" 2>/dev/null || true
59+
# Ensure librdkafka.so.1 exists (needed by the loader)
60+
if [[ ! -f "$LIB_DST/librdkafka.so.1" ]]; then
61+
cp -v "$LIB_DST/librdkafka.so" "$LIB_DST/librdkafka.so.1"
62+
fi
63+
ldd "$LIB_DST/librdkafka.so.1"
64+
65+
elif [[ $OSTYPE == darwin* ]]; then
66+
OS_NAME=osx
67+
LIB_DST="$DEST/runtimes/$OS_NAME-$ARCH/native"
68+
mkdir -p "$LIB_DST"
69+
cp -v "$INSTALL"/lib/librdkafka*.dylib "$LIB_DST/"
70+
# Fix the dylib self-referencing name to its installed path
71+
install_name_tool -id "$LIB_DST/librdkafka.dylib" "$LIB_DST/librdkafka.dylib"
72+
otool -L "$LIB_DST/librdkafka.dylib"
73+
fi
74+
75+
rm -rf "$SRC"
76+
echo "$0: Done. Headers at $INC_DST, library at $LIB_DST"

0 commit comments

Comments
 (0)