-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: bump to zenoh 1.0.0-alpha.6 Signed-off-by: Gabriele Baldoni <[email protected]> * chore: bump zenoh 1.0.0, updating macros Signed-off-by: Gabriele Baldoni <[email protected]> * style: cargo format Signed-off-by: Gabriele Baldoni <[email protected]> * ci: adding cleanup step Signed-off-by: Gabriele Baldoni <[email protected]> * deps: tracking zenoh main Signed-off-by: Gabriele Baldoni <[email protected]> * deps: zenoh Signed-off-by: Gabriele Baldoni <[email protected]> * deps: updated zenoh Signed-off-by: Gabriele Baldoni <[email protected]> * deps: sync zenoh Signed-off-by: Gabriele Baldoni <[email protected]> * chore: prepare beta release Signed-off-by: Gabriele Baldoni <[email protected]> * deps: zenoh 1.0.0 Signed-off-by: Gabriele Baldoni <[email protected]> * chore: release 0.8.0 Signed-off-by: Gabriele Baldoni <[email protected]> --------- Signed-off-by: Gabriele Baldoni <[email protected]>
- Loading branch information
Showing
9 changed files
with
96 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,12 +11,12 @@ | |
* ADLINK fog05 team, <[email protected]> | ||
*********************************************************************************/ | ||
|
||
use std::sync::Arc; | ||
use std::{str::FromStr, sync::Arc}; | ||
use tokio::sync::Mutex; | ||
|
||
use async_trait::async_trait; | ||
use zenoh::config::{EndPoint, ZenohId}; | ||
//importing the macros | ||
use zenoh::prelude::r#async::*; | ||
use zrpc::prelude::*; | ||
use zrpc_derive::service; | ||
|
||
|
@@ -55,34 +55,35 @@ impl Hello for MyServer { | |
fn configure_zenoh(id: ZenohId, listen: String, connect: String) -> zenoh::config::Config { | ||
let mut config = zenoh::config::Config::default(); | ||
config.set_id(id).unwrap(); | ||
config | ||
.set_mode(Some(zenoh::config::whatami::WhatAmI::Peer)) | ||
.unwrap(); | ||
config.set_mode(Some(zenoh::config::WhatAmI::Peer)).unwrap(); | ||
config.scouting.multicast.set_enabled(Some(false)).unwrap(); | ||
config.listen.endpoints.push(listen.parse().unwrap()); | ||
config.connect.endpoints.push(connect.parse().unwrap()); | ||
|
||
let listen: Vec<EndPoint> = vec![listen.parse().unwrap()]; | ||
let connect: Vec<EndPoint> = vec![connect.parse().unwrap()]; | ||
config.listen.endpoints.set(listen).unwrap(); | ||
config.connect.endpoints.set(connect).unwrap(); | ||
|
||
config | ||
} | ||
|
||
async fn wait_for_peer(session: &zenoh::Session, id: ZenohId) { | ||
while !session.info().peers_zid().res().await.any(|e| e == id) { | ||
while !session.info().peers_zid().await.any(|e| e == id) { | ||
tokio::time::sleep(std::time::Duration::from_secs(1)).await | ||
} | ||
} | ||
|
||
#[tokio::test(flavor = "multi_thread", worker_threads = 3)] | ||
async fn service_call() { | ||
let server_zid = ZenohId::rand(); | ||
let client_zid = ZenohId::rand(); | ||
let server_zid = ZenohId::from_str("a0").unwrap(); | ||
let client_zid = ZenohId::from_str("a1").unwrap(); | ||
|
||
let client_config = configure_zenoh( | ||
client_zid, | ||
"tcp/127.0.0.1:9003".to_string(), | ||
"tcp/127.0.0.1:9002".to_string(), | ||
); | ||
|
||
let client_session = Arc::new(zenoh::open(client_config).res().await.unwrap()); | ||
let client_session = zenoh::open(client_config).await.unwrap(); | ||
|
||
let c_zid_server = server_zid; | ||
tokio::task::spawn(async move { | ||
|
@@ -91,7 +92,7 @@ async fn service_call() { | |
"tcp/127.0.0.1:9002".to_string(), | ||
"tcp/127.0.0.1:9003".to_string(), | ||
); | ||
let server_session = Arc::new(zenoh::open(server_config).res().await.unwrap()); | ||
let server_session = zenoh::open(server_config).await.unwrap(); | ||
wait_for_peer(&server_session, client_zid).await; | ||
|
||
let service = MyServer { | ||
|
@@ -138,8 +139,8 @@ async fn service_call() { | |
|
||
#[tokio::test(flavor = "multi_thread", worker_threads = 3)] | ||
async fn service_unavailable() { | ||
let server_zid = ZenohId::rand(); | ||
let client_zid = ZenohId::rand(); | ||
let server_zid = ZenohId::from_str("a2").unwrap(); | ||
let client_zid = ZenohId::from_str("a3").unwrap(); | ||
|
||
let server_config = configure_zenoh( | ||
server_zid, | ||
|
@@ -153,8 +154,8 @@ async fn service_unavailable() { | |
"tcp/127.0.0.1:9004".to_string(), | ||
); | ||
|
||
let server_session = Arc::new(zenoh::open(server_config).res().await.unwrap()); | ||
let client_session = Arc::new(zenoh::open(client_config).res().await.unwrap()); | ||
let server_session = zenoh::open(server_config).await.unwrap(); | ||
let client_session = zenoh::open(client_config).await.unwrap(); | ||
|
||
// Check zenoh sessions are connected | ||
wait_for_peer(&server_session, client_zid).await; | ||
|
@@ -170,16 +171,16 @@ async fn service_unavailable() { | |
|
||
#[tokio::test(flavor = "multi_thread", worker_threads = 3)] | ||
async fn server_not_matching() { | ||
let server_zid = ZenohId::rand(); | ||
let client_zid = ZenohId::rand(); | ||
let server_zid = ZenohId::from_str("a4").unwrap(); | ||
let client_zid = ZenohId::from_str("a5").unwrap(); | ||
|
||
let client_config = configure_zenoh( | ||
client_zid, | ||
"tcp/127.0.0.1:9007".to_string(), | ||
"tcp/127.0.0.1:9006".to_string(), | ||
); | ||
|
||
let client_session = Arc::new(zenoh::open(client_config).res().await.unwrap()); | ||
let client_session = zenoh::open(client_config).await.unwrap(); | ||
|
||
let c_zid_server = server_zid; | ||
let st = tokio::task::spawn(async move { | ||
|
@@ -188,7 +189,7 @@ async fn server_not_matching() { | |
"tcp/127.0.0.1:9006".to_string(), | ||
"tcp/127.0.0.1:9007".to_string(), | ||
); | ||
let server_session = Arc::new(zenoh::open(server_config).res().await.unwrap()); | ||
let server_session = zenoh::open(server_config).await.unwrap(); | ||
wait_for_peer(&server_session, client_zid).await; | ||
|
||
let service = MyServer { | ||
|
@@ -220,16 +221,16 @@ async fn server_not_matching() { | |
|
||
#[tokio::test(flavor = "multi_thread", worker_threads = 3)] | ||
async fn server_matching() { | ||
let server_zid = ZenohId::rand(); | ||
let client_zid = ZenohId::rand(); | ||
let server_zid = ZenohId::from_str("a6").unwrap(); | ||
let client_zid = ZenohId::from_str("a7").unwrap(); | ||
|
||
let client_config = configure_zenoh( | ||
client_zid, | ||
"tcp/127.0.0.1:9009".to_string(), | ||
"tcp/127.0.0.1:9008".to_string(), | ||
); | ||
|
||
let client_session = Arc::new(zenoh::open(client_config).res().await.unwrap()); | ||
let client_session = zenoh::open(client_config).await.unwrap(); | ||
|
||
let c_zid_server = server_zid; | ||
tokio::task::spawn(async move { | ||
|
@@ -238,7 +239,7 @@ async fn server_matching() { | |
"tcp/127.0.0.1:9008".to_string(), | ||
"tcp/127.0.0.1:9009".to_string(), | ||
); | ||
let server_session = Arc::new(zenoh::open(server_config).res().await.unwrap()); | ||
let server_session = zenoh::open(server_config).await.unwrap(); | ||
wait_for_peer(&server_session, client_zid).await; | ||
|
||
let service = MyServer { | ||
|
Oops, something went wrong.