Skip to content

Commit

Permalink
Dump out runtime components when integration test times out to help w…
Browse files Browse the repository at this point in the history
…ith diagnosing problem.
  • Loading branch information
locka99 committed Sep 1, 2019
1 parent 20b40f5 commit 1ab6149
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
1 change: 1 addition & 0 deletions integration/run-sanity.sh
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export RUST_OPCUA_LOG=debug
cargo test -- --exact --test-threads=1 --ignored tests::connect_none
24 changes: 15 additions & 9 deletions integration/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
use std::{
sync::{
Arc, Mutex, RwLock, mpsc, mpsc::channel,
atomic::{AtomicUsize, Ordering},
Arc, atomic::{AtomicUsize, Ordering}, mpsc, mpsc::channel, Mutex,
RwLock,
},
thread, time,
};

use log::{info, trace};
use chrono::Utc;
use log::*;

// Integration tests are asynchronous so futures will be used
use opcua_core;
use opcua_client::prelude::*;
use opcua_console_logging;
use opcua_core::{self, runtime_components};
use opcua_server::{
self,
config::ServerEndpoint,
builder::ServerBuilder,
config::ServerEndpoint,
prelude::*,
};
use opcua_client::prelude::*;
use opcua_console_logging;

const ENDPOINT_ID_NONE: &str = "sample_none";
const ENDPOINT_ID_BASIC128RSA15_SIGN_ENCRYPT: &str = "sample_basic128rsa15_signencrypt";
Expand Down Expand Up @@ -382,7 +381,14 @@ fn perform_test<CT, ST>(port_offset: u16, client_test: Option<CT>, server_test:
if elapsed.num_milliseconds() > timeout {
let _ = tx_client_command.send(ClientCommand::Quit);
let _ = tx_server_command.send(ServerCommand::Quit);
panic!("Test timed out after {} ms", elapsed.num_milliseconds());

error!("Test timed out after {} ms", elapsed.num_milliseconds());
error!("Running components:\n {}", {
let components = runtime_components!();
components.iter().cloned().collect::<Vec<String>>().join("\n ")
});

panic!();
}

// Check for a client response
Expand Down
4 changes: 2 additions & 2 deletions server/src/comms/tcp_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ impl TcpTransport {
/// Spawns the writing loop task. The writing loop takes messages to send off of a queue
/// and sends them to the stream.
fn spawn_writing_loop_task(writer: WriteHalf<TcpStream>, receiver: UnboundedReceiver<(u32, SupportedMessage)>, secure_channel: Arc<RwLock<SecureChannel>>, transport: Arc<RwLock<TcpTransport>>, send_buffer: Arc<Mutex<MessageWriter>>) {
let id = Self::make_session_id("writing_loop_task", transport.clone());
let id = Self::make_session_id("server_writing_loop_task", transport.clone());
let id_for_map = id.clone();
let id_for_map_err = id.clone();
register_runtime_component!(id);
Expand Down Expand Up @@ -460,7 +460,7 @@ impl TcpTransport {
}));
let framed_read_task = Self::framed_read_task(reader, finished_flag, connection.clone());

let id = Self::make_session_id("reading_loop_task", transport.clone());
let id = Self::make_session_id("server_reading_loop_task", transport.clone());
let id_for_map = id.clone();
let id_for_map_err = id.clone();
register_runtime_component!(id);
Expand Down

0 comments on commit 1ab6149

Please sign in to comment.