diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 96708961d..8d388f2e2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,14 +7,14 @@ on: branches: [master] env: - rust_version: 1.61.0 + rust_version: 1.70.0 jobs: lint: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@b44cb146d03e8d870c57ab64b80f04586349ca5d + - uses: dtolnay/rust-toolchain@stable with: toolchain: ${{ env.rust_version }} components: rustfmt, clippy @@ -38,7 +38,8 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@b44cb146d03e8d870c57ab64b80f04586349ca5d + - uses: lukka/get-cmake@latest + - uses: dtolnay/rust-toolchain@stable with: toolchain: ${{ env.rust_version }} - run: cargo build --all-targets --verbose --features "${{ matrix.features }}" @@ -50,43 +51,44 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@b44cb146d03e8d870c57ab64b80f04586349ca5d + - uses: dtolnay/rust-toolchain@stable with: # The version of this toolchain doesn't matter much. It's only used to # generate the minimal-versions lockfile, not to actually run `cargo # check`. toolchain: nightly components: rustfmt, clippy - - uses: dtolnay/rust-toolchain@b44cb146d03e8d870c57ab64b80f04586349ca5d + - uses: dtolnay/rust-toolchain@stable with: toolchain: ${{ env.rust_version }} - run: rustup default ${{ env.rust_version }} - run: cargo +nightly -Z minimal-versions generate-lockfile - - run: cargo check + # Default features and features that require optional dependencies should be + # explicitly checked. + - run: cargo check --features libz,tokio,tracing test: strategy: fail-fast: false + # The test suite doesn't support concurrent runs. + max-parallel: 1 matrix: include: + - confluent-version: 7.7.0 + kafka-version: 3.7 - confluent-version: 7.5.1 kafka-version: 3.6 - confluent-version: 7.5.1 kafka-version: 3.5 - - confluent-version: 5.3.1 - kafka-version: 2.3 - - confluent-version: 5.0.3 - kafka-version: 2.0 - - confluent-version: 4.1.3 - kafka-version: 1.1 runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@b44cb146d03e8d870c57ab64b80f04586349ca5d + - uses: lukka/get-cmake@latest + - uses: dtolnay/rust-toolchain@stable with: toolchain: ${{ env.rust_version }} - - run: sudo apt-get update - - run: sudo apt-get install -qy valgrind + # - run: sudo apt-get update + # - run: sudo apt-get install -qy valgrind # Valgrind currently disabled in testing - run: ./test_suite.sh env: CONFLUENT_VERSION: ${{ matrix.confluent-version }} diff --git a/Cargo.toml b/Cargo.toml index e190bd18e..b9045ce58 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ keywords = ["kafka", "rdkafka"] categories = ["api-bindings"] edition = "2018" exclude = ["Cargo.lock"] -rust-version = "1.61" +rust-version = "1.70" [workspace] members = ["rdkafka-sys"] diff --git a/changelog.md b/changelog.md index 1806d5807..c87f5afc4 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,10 @@ See also the [rdkafka-sys changelog](rdkafka-sys/changelog.md). ## Unreleased +* Update MSRV to 1.70 +* Remove testign for old Kafka versions (before 3.0). Add tests for 3.7. +* Fix test dependency on docker compose. + ## 0.36.2 (2024-01-16) * Update `BaseConsumer::poll` to return `None` when handling rebalance diff --git a/docker-compose.yaml b/docker-compose.yaml index a194b25f4..a20430ac6 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,5 +1,3 @@ -version: '3' - services: kafka: image: confluentinc/cp-kafka:${CONFLUENT_VERSION:-7.5.1} diff --git a/rdkafka-sys/Cargo.toml b/rdkafka-sys/Cargo.toml index 4870e15b3..7ea379ef8 100644 --- a/rdkafka-sys/Cargo.toml +++ b/rdkafka-sys/Cargo.toml @@ -10,7 +10,7 @@ description = "Native bindings to the librdkafka library" keywords = ["kafka", "rdkafka"] categories = ["external-ffi-bindings"] edition = "2018" -rust-version = "1.61" +rust-version = "1.70" [dependencies] num_enum = "0.5.0" diff --git a/rdkafka-sys/src/lib.rs b/rdkafka-sys/src/lib.rs index 8679ad407..565f00bce 100644 --- a/rdkafka-sys/src/lib.rs +++ b/rdkafka-sys/src/lib.rs @@ -100,7 +100,7 @@ extern crate sasl2_sys; #[cfg(feature = "libz-sys")] extern crate libz_sys; -#[cfg(any(feature = "curl-sys", feature = "curl-sys/static-curl"))] +#[cfg(any(feature = "curl-sys", feature = "curl-static"))] extern crate curl_sys; #[cfg(feature = "zstd-sys")] diff --git a/src/config.rs b/src/config.rs index 58e062a5b..fc116d2a7 100644 --- a/src/config.rs +++ b/src/config.rs @@ -23,7 +23,7 @@ //! [librdkafka-config]: https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md use std::collections::HashMap; -use std::ffi::{CStr, CString}; +use std::ffi::CString; use std::iter::FromIterator; use std::os::raw::c_char; use std::ptr; @@ -150,7 +150,9 @@ impl NativeClientConfig { } // Convert the C string to a Rust string. - Ok(String::from_utf8_lossy(&buf).trim_matches(char::from(0)).to_string()) + Ok(String::from_utf8_lossy(&buf) + .trim_matches(char::from(0)) + .to_string()) } } diff --git a/src/groups.rs b/src/groups.rs index 2c805dc79..29bcbf297 100644 --- a/src/groups.rs +++ b/src/groups.rs @@ -84,6 +84,9 @@ impl GroupInfo { /// Returns the members of the group. pub fn members(&self) -> &[GroupMemberInfo] { + if self.0.members.is_null() { + return &[]; + } unsafe { slice::from_raw_parts( self.0.members as *const GroupMemberInfo, diff --git a/src/lib.rs b/src/lib.rs index 79a8d113f..46709c5a7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -176,7 +176,7 @@ //! //! ### Minimum supported Rust version (MSRV) //! -//! The current minimum supported Rust version (MSRV) is 1.61.0. Note that +//! The current minimum supported Rust version (MSRV) is 1.70.0. Note that //! bumping the MSRV is not considered a breaking change. Any release of //! rust-rdkafka may bump the MSRV. //! diff --git a/src/mocking.rs b/src/mocking.rs index b07b05230..5117b532f 100644 --- a/src/mocking.rs +++ b/src/mocking.rs @@ -39,7 +39,9 @@ use crate::ClientContext; /// In this case, we **must neither** destroy the mock cluster in `MockCluster`'s `drop()`, /// **nor** outlive the `Client` from which the reference is obtained, hence the lifetime. enum MockClusterClient<'c, C: ClientContext> { + #[allow(dead_code)] Owned(Client), + #[allow(dead_code)] Borrowed(&'c Client), } diff --git a/src/util.rs b/src/util.rs index 543481d3f..dd4862825 100644 --- a/src/util.rs +++ b/src/util.rs @@ -251,24 +251,13 @@ impl fmt::Display for ErrBuf { } } -pub(crate) trait WrappedCPointer { - type Target; - - fn ptr(&self) -> *mut Self::Target; - - fn is_null(&self) -> bool { - self.ptr().is_null() - } +pub(crate) trait AsCArray { + fn as_c_array(&self) -> *mut *mut T; } -/// Converts a container into a C array. -pub(crate) trait AsCArray { - fn as_c_array(&self) -> *mut *mut T::Target; -} - -impl AsCArray for Vec { - fn as_c_array(&self) -> *mut *mut T::Target { - self.as_ptr() as *mut *mut T::Target +impl AsCArray for Vec> { + fn as_c_array(&self) -> *mut *mut T { + self.as_ptr() as *mut *mut T } } @@ -297,17 +286,6 @@ pub(crate) unsafe trait KafkaDrop { const DROP: unsafe extern "C" fn(*mut Self); } -impl WrappedCPointer for NativePtr -where - T: KafkaDrop, -{ - type Target = T; - - fn ptr(&self) -> *mut T { - self.ptr.as_ptr() - } -} - impl Deref for NativePtr where T: KafkaDrop, @@ -340,6 +318,7 @@ where } } +#[allow(dead_code)] pub(crate) struct OnDrop(pub F) where F: Fn(); diff --git a/test_suite.sh b/test_suite.sh index 900abd507..396638cb9 100755 --- a/test_suite.sh +++ b/test_suite.sh @@ -29,8 +29,12 @@ run_with_valgrind() { # Initialize. git submodule update --init -docker-compose up -d -cargo test +docker compose up -d --wait + +# Run integration tests + +RUST_LOG=1 RUST_BACKTRACE=1 cargo test + # Run unit tests. diff --git a/tests/test_admin.rs b/tests/test_admin.rs index 846a96c2a..dc7177708 100644 --- a/tests/test_admin.rs +++ b/tests/test_admin.rs @@ -119,7 +119,7 @@ fn verify_delete(topic: &str) { #[tokio::test] async fn test_topics() { let admin_client = create_admin_client(); - let opts = AdminOptions::new().operation_timeout(Some(Duration::from_secs(1))); + let opts = AdminOptions::new().operation_timeout(Some(Duration::from_secs(30))); // Verify that topics are created as specified, and that they can later // be deleted.