Skip to content

Commit

Permalink
Add TCP buffer sizes config tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oteffahi committed Dec 5, 2024
1 parent dfb110b commit 0e863e2
Showing 1 changed file with 89 additions and 0 deletions.
89 changes: 89 additions & 0 deletions zenoh/tests/tcp_buffers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
//
// Copyright (c) 2024 ZettaScale Technology
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
//
// Contributors:
// ZettaScale Zenoh Team, <[email protected]>
//

use zenoh::{Config, Wait};

#[test]
fn buffer_size_config() {
let mut config = Config::default();
config
.insert_json5(
"transport/link",
r#"
{
tcp_tx_buffer: 65000,
tcp_rx_buffer: 65000,
}
"#,
)
.unwrap();

config
.insert_json5("listen/endpoints", r#"["tcp/[::]:0"]"#)
.unwrap();

zenoh::open(config).wait().unwrap();
}

#[test]
fn buffer_size_endpoint() {
let mut config = Config::default();
config
.insert_json5(
"listen/endpoints",
r#"["tcp/[::]:0#tcp_tx_buffer=65000;tcp_rx_buffer=65000"]"#,
)
.unwrap();

zenoh::open(config).wait().unwrap();
}

#[test]
#[should_panic(expected = "Can not create a new TCP listener")]
fn buffer_size_config_override() {
let mut config = Config::default();
config
.insert_json5(
"transport/link",
r#"
{
tcp_tx_buffer: 0,
tcp_rx_buffer: 0,
}
"#,
)
.unwrap();

config
.insert_json5(
"listen/endpoints",
r#"["tcp/[::]:0#tcp_tx_buffer=65000;tcp_rx_buffer=65000"]"#,
)
.unwrap();

zenoh::open(config).wait().unwrap();
}

#[test]
#[should_panic(expected = "Can not create a new TCP listener")]
fn listen_zero_buffers() {
let mut config = Config::default();
config
.insert_json5(
"listen/endpoints",
r#"["tcp/[::]:0#tcp_tx_buffer=0;tcp_rx_buffer=0"]"#,
)
.unwrap();
zenoh::open(config).wait().unwrap();
}

0 comments on commit 0e863e2

Please sign in to comment.