Skip to content

Commit

Permalink
test: Assert that a service call actually reaches the OPC UA server
Browse files Browse the repository at this point in the history
Previously it was only asserted that the ROS service call was registered
by the bridge but not if it was actually passed through to the OPC UA
server.
With this change, the assertion channel of the OPC UA test server is
levaraged in order to cover more of the code path under test.
  • Loading branch information
philipp-caspers committed Dec 16, 2024
1 parent 36ded93 commit 9377188
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions tests/test_bridge_methods.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::sync::{mpsc, Arc};
use std::{sync::{mpsc, Arc}, time::Duration};

use common::{wait_for_function_to_pass, ManagedRosBridge};

Expand All @@ -7,11 +7,11 @@ pub mod helpers;

#[test]
fn e2e_ros_service_to_opc_ua_call() {
let (assertion_tx, _assertion_rx) = mpsc::channel();
let (assertion_tx, assertion_rx) = mpsc::channel();
let (stop_opc_ua_server_tx, stop_opc_ua_server_rx) = mpsc::channel();
helpers::opc_ua_test_server::run_opc_ua_test_server(assertion_tx, stop_opc_ua_server_rx);

let mut bridge_process = ManagedRosBridge::new(None).expect("Failed to start subprocess");
let mut _bridge_process = ManagedRosBridge::new(None).expect("Failed to start subprocess");

let service_caller = Arc::new(
helpers::ros_service_caller::ServiceCaller::new(
Expand All @@ -30,10 +30,17 @@ fn e2e_ros_service_to_opc_ua_call() {
5000,
)
.unwrap();
bridge_process.terminate();
assert!(bridge_process
.get_std_err()
.unwrap()
.contains("ROS service called"));

wait_for_function_to_pass(
|| {
let received = assertion_rx
.recv_timeout(Duration::from_millis(10))
.unwrap();
received.contains("impedance_control/enable")
},
5000,
)
.unwrap();

stop_opc_ua_server_tx.send(()).unwrap();
}

0 comments on commit 9377188

Please sign in to comment.