no warnings
parent
591a1df5d6
commit
ba395543e4
|
|
@ -1,6 +1,10 @@
|
|||
//
|
||||
// module needed to check host-agent health condition and to communicate with it
|
||||
//
|
||||
use tokio::{io::Interest, net::UnixStream};
|
||||
use anyhow::{Ok, Result, Error};
|
||||
// to kill lint bug
|
||||
#[allow(unused_imports)]
|
||||
use tokio::net::UnixListener;
|
||||
|
||||
/// # Fn `open_unix_socket`
|
||||
|
|
@ -16,6 +20,7 @@ use tokio::net::UnixListener;
|
|||
///
|
||||
/// *depends on* : -
|
||||
///
|
||||
#[allow(dead_code)]
|
||||
async fn open_unix_socket(sock_path: &str) -> Result<UnixStream, std::io::Error> {
|
||||
// "/var/run/enode/hostagent.sock"
|
||||
UnixStream::connect(sock_path).await
|
||||
|
|
@ -34,6 +39,7 @@ async fn open_unix_socket(sock_path: &str) -> Result<UnixStream, std::io::Error>
|
|||
///
|
||||
/// *depends on* : -
|
||||
///
|
||||
#[allow(dead_code)]
|
||||
async fn ha_healthcheck(socket: &UnixStream) -> Result<(), Error> {
|
||||
socket.ready(Interest::WRITABLE).await?;
|
||||
socket.writable().await?;
|
||||
|
|
@ -54,6 +60,7 @@ async fn ha_healthcheck(socket: &UnixStream) -> Result<(), Error> {
|
|||
///
|
||||
/// *depends on* : -
|
||||
///
|
||||
#[allow(dead_code)]
|
||||
async fn ha_send_data(socket: &UnixStream, data: &str) -> Result<(), Error > {
|
||||
socket.ready(Interest::WRITABLE).await?;
|
||||
socket.writable().await?;
|
||||
|
|
@ -74,10 +81,10 @@ mod hagent_unittets {
|
|||
// maybe bool : true -> alive, false -> dead
|
||||
// simple request on api
|
||||
async fn hagent_healthcheck() {
|
||||
let mut list = init_listener().await;
|
||||
let _ = init_listener().await;
|
||||
let sock = open_unix_socket(TEST_SOCKET).await;
|
||||
assert!(sock.is_ok());
|
||||
let mut sock = sock.unwrap();
|
||||
let sock = sock.unwrap();
|
||||
assert!(ha_healthcheck(&sock).await.is_ok());
|
||||
}
|
||||
#[tokio::test]
|
||||
|
|
@ -91,17 +98,17 @@ mod hagent_unittets {
|
|||
let metrics = Metrics::new(contm, vec![procm]);
|
||||
let metrics = &serde_json::to_string_pretty(&metrics).unwrap();
|
||||
|
||||
let mut list = init_listener().await;
|
||||
let _ = init_listener().await;
|
||||
let sock = open_unix_socket(TEST_SOCKET).await;
|
||||
assert!(sock.is_ok());
|
||||
let mut sock = sock.unwrap();
|
||||
let sock = sock.unwrap();
|
||||
assert!(ha_healthcheck(&sock).await.is_ok());
|
||||
assert!(ha_send_data(&sock, &metrics).await.is_ok());
|
||||
|
||||
}
|
||||
#[tokio::test]
|
||||
async fn open_unixsocket_test() {
|
||||
let mut list = init_listener().await;
|
||||
let _ = init_listener().await;
|
||||
assert!(open_unix_socket(TEST_SOCKET).await.is_ok());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue