Skip to content

wip: socks 5 test #132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 18 commits into from
Closed
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-kafka.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "2"
version: "3"

services:
zookeeper:
Expand Down
11 changes: 7 additions & 4 deletions tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
20 changes: 20 additions & 0 deletions tests/test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down