From f923a4fc399a3c8f10813634f39e20b853e07911 Mon Sep 17 00:00:00 2001 From: Sayan Nandan Date: Thu, 16 Nov 2023 22:37:38 +0530 Subject: [PATCH] Fix test harness Don't try to initiate an actual connection (right now). Instead, try to see if the TCP port is live and can be connected to. Also added some misc `rustfmt` fixes. --- Cargo.lock | 1 - harness/Cargo.toml | 1 - harness/src/test/svc.rs | 14 +++++--------- server/src/engine/fractal/mgr.rs | 2 +- server/src/engine/net/mod.rs | 10 +++++----- server/src/engine/ql/tests/lexer_tests.rs | 2 +- server/src/engine/storage/v1/tests/tx.rs | 6 ++++-- server/src/engine/sync/smart.rs | 1 - 8 files changed, 16 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c084f43a..046992a4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -520,7 +520,6 @@ dependencies = [ "log", "openssl", "powershell_script", - "skytable", "zip", ] diff --git a/harness/Cargo.toml b/harness/Cargo.toml index 605e03c9..1bd479a9 100644 --- a/harness/Cargo.toml +++ b/harness/Cargo.toml @@ -7,7 +7,6 @@ edition = "2021" [dependencies] # internal deps -skytable = { git = "https://github.com/skytable/client-rust.git", branch = "octave" } libsky = { path = "../libsky" } # external deps env_logger = "0.10.0" diff --git a/harness/src/test/svc.rs b/harness/src/test/svc.rs index 433e0fcd..1203f81a 100644 --- a/harness/src/test/svc.rs +++ b/harness/src/test/svc.rs @@ -32,10 +32,6 @@ use { util::{self}, HarnessError, HarnessResult, ROOT_DIR, }, - skytable::{ - error::{ClientResult, Error}, - Config, Connection, - }, std::{ io::ErrorKind, path::Path, @@ -55,9 +51,9 @@ const TESTSUITE_SERVER_HOST: &str = "127.0.0.1"; /// The workspace root const WORKSPACE_ROOT: &str = env!("ROOT_DIR"); -fn connect_db(host: &str, port: u16) -> ClientResult { - let cfg = Config::new(host, port, "root", "password12345678"); - cfg.connect() +fn connect_db(host: &str, port: u16) -> std::io::Result { + let tcp_stream = std::net::TcpStream::connect((host, port))?; + Ok(tcp_stream) } /// Get the command to start the provided server1 @@ -99,10 +95,10 @@ pub(super) fn wait_for_server_exit() -> HarnessResult<()> { Ok(()) } -fn connection_refused(input: ClientResult) -> HarnessResult { +fn connection_refused(input: std::io::Result) -> HarnessResult { match input { Ok(_) => Ok(false), - Err(Error::IoError(e)) + Err(e) if matches!( e.kind(), ErrorKind::ConnectionRefused | ErrorKind::ConnectionReset diff --git a/server/src/engine/fractal/mgr.rs b/server/src/engine/fractal/mgr.rs index 63906601..2abc9b2d 100644 --- a/server/src/engine/fractal/mgr.rs +++ b/server/src/engine/fractal/mgr.rs @@ -307,7 +307,7 @@ impl FractalMgr { } } Err(_) => { - log::error!( + error!( "fhp: error writing data batch for model {}. retrying ...", model_id.uuid() ); diff --git a/server/src/engine/net/mod.rs b/server/src/engine/net/mod.rs index 2e1977c2..4467fd8e 100644 --- a/server/src/engine/net/mod.rs +++ b/server/src/engine/net/mod.rs @@ -40,7 +40,7 @@ use { }, std::{cell::Cell, net::SocketAddr, pin::Pin, time::Duration}, tokio::{ - io::{AsyncRead, AsyncWrite, BufWriter, AsyncWriteExt}, + io::{AsyncRead, AsyncWrite, AsyncWriteExt, BufWriter}, net::{TcpListener, TcpStream}, sync::{broadcast, mpsc, Semaphore}, }, @@ -220,7 +220,7 @@ impl Listener { /* SECURITY: IGNORE THIS ERROR */ - log::error!("failed to accept connection on TCP socket: `{e}`"); + warn!("failed to accept connection on TCP socket: `{e}`"); continue; } }; @@ -232,7 +232,7 @@ impl Listener { ); tokio::spawn(async move { if let Err(e) = handler.run().await { - log::error!("error handling client connection: `{e}`"); + warn!("error handling client connection: `{e}`"); } }); // return the permit @@ -274,7 +274,7 @@ impl Listener { /* SECURITY: Once again, ignore this error */ - log::error!("failed to accept connection on TLS socket: `{e:#?}`"); + warn!("failed to accept connection on TLS socket: `{e}`"); continue; } }; @@ -286,7 +286,7 @@ impl Listener { ); tokio::spawn(async move { if let Err(e) = handler.run().await { - log::error!("error handling client TLS connection: `{e}`"); + warn!("error handling client TLS connection: `{e}`"); } }); } diff --git a/server/src/engine/ql/tests/lexer_tests.rs b/server/src/engine/ql/tests/lexer_tests.rs index 0985e101..558bfc5c 100644 --- a/server/src/engine/ql/tests/lexer_tests.rs +++ b/server/src/engine/ql/tests/lexer_tests.rs @@ -217,7 +217,7 @@ const SFQ_BOOL_FALSE: &[u8] = b"\x01\0"; const SFQ_BOOL_TRUE: &[u8] = b"\x01\x01"; const SFQ_UINT: &[u8] = b"\x0218446744073709551615\n"; const SFQ_SINT: &[u8] = b"\x03-9223372036854775808\n"; -const SFQ_FLOAT: &[u8] = b"\x0411\n3.141592654"; +const SFQ_FLOAT: &[u8] = b"\x043.141592654\n"; const SFQ_BINARY: &[u8] = "\x0546\ncringeπŸ˜ƒπŸ˜„πŸ˜πŸ˜†πŸ˜…πŸ˜‚πŸ€£πŸ˜ŠπŸ˜ΈπŸ˜Ί".as_bytes(); const SFQ_STRING: &[u8] = "\x0646\ncringeπŸ˜ƒπŸ˜„πŸ˜πŸ˜†πŸ˜…πŸ˜‚πŸ€£πŸ˜ŠπŸ˜ΈπŸ˜Ί".as_bytes(); diff --git a/server/src/engine/storage/v1/tests/tx.rs b/server/src/engine/storage/v1/tests/tx.rs index ba814378..6258b40c 100644 --- a/server/src/engine/storage/v1/tests/tx.rs +++ b/server/src/engine/storage/v1/tests/tx.rs @@ -130,8 +130,10 @@ fn open_log( log_name: &str, db: &Database, ) -> RuntimeResult> { - journal::open_or_create_journal::(log_name, db) - .map(|v| v.into_inner()) + journal::open_or_create_journal::( + log_name, db, + ) + .map(|v| v.into_inner()) } #[test] diff --git a/server/src/engine/sync/smart.rs b/server/src/engine/sync/smart.rs index 3d2b79cc..59c710fb 100644 --- a/server/src/engine/sync/smart.rs +++ b/server/src/engine/sync/smart.rs @@ -24,7 +24,6 @@ * */ - use { super::atm::{ORD_ACQ, ORD_REL, ORD_RLX}, std::{