diff --git a/README.md b/README.md index 44c7c657..abe913ee 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,22 @@ $ TEST_INTEGRATION=1 TEST_DELETE_RECORDS=1 KAFKA_CONNECT=localhost:9094 cargo te in another session. Note that Apache Kafka supports a different set of features then redpanda, so we pass other environment variables. +### Using a SOCKS 5 Proxy + +To run the integration test via a SOCKS 5 proxy, you need to set the environment variable `SOCKS_PROXY`. The following command requires a running proxy on the local machine. +```console +$ KAFKA_CONNECT=0.0.0.0:9094 SOCKS_PROXY=localhost:1080 cargo test --features full +``` + +A SOCKS proxy can be installed with: +```console +cargo install rsocx +``` +Launch this proxy with: +```console +rsocx -l 0.0.0.0:1080 +``` + ### Java Interopt To test if RSKafka can produce/consume records to/from the official Java client, you need to have Java installed and the `TEST_JAVA_INTEROPT=1` environment variable set. diff --git a/docker-compose-kafka.yml b/docker-compose-kafka.yml index 9d0ed746..a4f747f1 100644 --- a/docker-compose-kafka.yml +++ b/docker-compose-kafka.yml @@ -1,4 +1,4 @@ -version: "2" +version: "3" services: zookeeper: diff --git a/tests/client.rs b/tests/client.rs index f710feac..8ede1a6f 100644 --- a/tests/client.rs +++ b/tests/client.rs @@ -116,15 +116,18 @@ async fn test_tls() { .unwrap(); } -// Disabled as currently no SOCKS5 integration tests #[cfg(feature = "transport-socks5")] -#[ignore] #[tokio::test] async fn test_socks5() { maybe_start_logging(); - let client = ClientBuilder::new(vec!["my-cluster-kafka-bootstrap:9092".to_owned()]) - .socks5_proxy("localhost:1080".to_owned()) + // e.g. "my-connection-kafka-bootstrap:9092" + let connection = maybe_skip_kafka_integration!(); + // e.g. "localhost:1080" + let proxy = maybe_skip_socks_proxy!(); + + let client = ClientBuilder::new(vec![connection]) + .socks5_proxy(proxy) .build() .await .unwrap(); diff --git a/tests/test_helpers.rs b/tests/test_helpers.rs index f0ce6b09..8a8b4668 100644 --- a/tests/test_helpers.rs +++ b/tests/test_helpers.rs @@ -68,6 +68,26 @@ macro_rules! maybe_skip_delete { }; } +/// Get the Socks Proxy environment variable. +/// +/// If `SOCKS_PROXY` is not set, fail the tests and provide +/// guidance for setting `SOCKS_PROXY`. +#[macro_export] +macro_rules! maybe_skip_socks_proxy { + () => {{ + use std::env; + dotenv::dotenv().ok(); + + match (env::var("SOCKS_PROXY").ok()) { + Some(proxy) => proxy, + _ => { + eprintln!("skipping integration tests with Proxy - set SOCKS_PROXY to run"); + return; + } + } + }}; +} + /// Generated random topic name for testing. pub fn random_topic_name() -> String { format!("test_topic_{}", uuid::Uuid::new_v4())