fix(clients): repair Python & Rust tests, add container test orchestration
CI / test (push) Has been cancelled
CI / verify (push) Has been cancelled
Clients CI / build-server (push) Has been cancelled
Clients CI / test-python (push) Has been cancelled
Clients CI / test-javascript (push) Has been cancelled
Clients CI / test-nim (push) Has been cancelled
Clients CI / test-rust (push) Has been cancelled
CI / test (push) Has been cancelled
CI / verify (push) Has been cancelled
Clients CI / build-server (push) Has been cancelled
Clients CI / test-python (push) Has been cancelled
Clients CI / test-javascript (push) Has been cancelled
Clients CI / test-nim (push) Has been cancelled
Clients CI / test-rust (push) Has been cancelled
- Python: fix wire protocol test method names (bool_val -> bool, etc.) - Python: make integration tests and example fully async with pytest-asyncio - Rust: add tokio dev-dependency and convert integration tests to async/await - Rust: update ping_test example to async - Nim: remove committed ELF build artifact - Docker: add BARADB_HOST/BARADB_PORT env vars to test containers - Docker: fix docker-compose.test.yml usage (remove --abort-on-container-exit) - Add scripts/test-clients.sh for sequential client test runs - Remove docker-compose.test.yml from .gitignore so it is tracked - Fix repository URLs in Python and Rust READMEs
This commit is contained in:
@@ -1,104 +1,118 @@
|
||||
// BaraDB Rust Client — Integration Tests
|
||||
// Requires a running BaraDB server on localhost:9472.
|
||||
// Requires a running BaraDB server.
|
||||
// Set BARADB_HOST / BARADB_PORT env vars to override defaults.
|
||||
|
||||
use std::net::TcpStream;
|
||||
use std::time::Duration;
|
||||
|
||||
use baradb::{Client, QueryBuilder, WireValue};
|
||||
|
||||
const HOST: &str = "127.0.0.1";
|
||||
const PORT: u16 = 9472;
|
||||
|
||||
fn server_available() -> bool {
|
||||
TcpStream::connect((HOST, PORT)).is_ok()
|
||||
fn host() -> String {
|
||||
std::env::var("BARADB_HOST").unwrap_or_else(|_| "127.0.0.1".to_string())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_connect_and_close() {
|
||||
fn port() -> u16 {
|
||||
std::env::var("BARADB_PORT")
|
||||
.ok()
|
||||
.and_then(|s| s.parse().ok())
|
||||
.unwrap_or(9472)
|
||||
}
|
||||
|
||||
fn server_available() -> bool {
|
||||
TcpStream::connect((host().as_str(), port())).is_ok()
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_connect_and_close() {
|
||||
if !server_available() {
|
||||
return;
|
||||
}
|
||||
let mut client = Client::connect(HOST, PORT).unwrap();
|
||||
let mut client = Client::connect(&host(), port()).await.unwrap();
|
||||
assert!(client.is_connected());
|
||||
client.close();
|
||||
client.close().await;
|
||||
assert!(!client.is_connected());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ping() {
|
||||
#[tokio::test]
|
||||
async fn test_ping() {
|
||||
if !server_available() {
|
||||
return;
|
||||
}
|
||||
let mut client = Client::connect(HOST, PORT).unwrap();
|
||||
assert!(client.ping().unwrap());
|
||||
client.close();
|
||||
let mut client = Client::connect(&host(), port()).await.unwrap();
|
||||
assert!(client.ping().await.unwrap());
|
||||
client.close().await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_simple_select() {
|
||||
#[tokio::test]
|
||||
async fn test_simple_select() {
|
||||
if !server_available() {
|
||||
return;
|
||||
}
|
||||
let mut client = Client::connect(HOST, PORT).unwrap();
|
||||
let result = client.query("SELECT 1 as one").unwrap();
|
||||
let mut client = Client::connect(&host(), port()).await.unwrap();
|
||||
let result = client.query("SELECT 1 as one").await.unwrap();
|
||||
assert!(result.row_count() >= 0);
|
||||
client.close();
|
||||
client.close().await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parameterized_query() {
|
||||
#[tokio::test]
|
||||
async fn test_parameterized_query() {
|
||||
if !server_available() {
|
||||
return;
|
||||
}
|
||||
let mut client = Client::connect(HOST, PORT).unwrap();
|
||||
let mut client = Client::connect(&host(), port()).await.unwrap();
|
||||
let result = client
|
||||
.query_params(
|
||||
"SELECT $1 as num, $2 as txt",
|
||||
&[WireValue::Int64(42), WireValue::String("hello".to_string())],
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(result.row_count() >= 0);
|
||||
client.close();
|
||||
client.close().await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_create_table_insert_select_drop() {
|
||||
#[tokio::test]
|
||||
async fn test_create_table_insert_select_drop() {
|
||||
if !server_available() {
|
||||
return;
|
||||
}
|
||||
let mut client = Client::connect(HOST, PORT).unwrap();
|
||||
let mut client = Client::connect(&host(), port()).await.unwrap();
|
||||
|
||||
let _ = client.execute("DROP TABLE IF EXISTS rust_test_users");
|
||||
let _ = client.execute("DROP TABLE IF EXISTS rust_test_users").await;
|
||||
client
|
||||
.execute("CREATE TABLE rust_test_users (id INT PRIMARY KEY, name STRING, age INT)")
|
||||
.await
|
||||
.unwrap();
|
||||
let affected = client
|
||||
.execute("INSERT INTO rust_test_users (id, name, age) VALUES (1, 'Alice', 30)")
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(affected >= 0);
|
||||
|
||||
let result = client
|
||||
.query("SELECT name, age FROM rust_test_users WHERE id = 1")
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(result.row_count(), 1);
|
||||
|
||||
client.execute("DROP TABLE rust_test_users").unwrap();
|
||||
client.close();
|
||||
client.execute("DROP TABLE rust_test_users").await.unwrap();
|
||||
client.close().await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_query_builder_exec() {
|
||||
#[tokio::test]
|
||||
async fn test_query_builder_exec() {
|
||||
if !server_available() {
|
||||
return;
|
||||
}
|
||||
let mut client = Client::connect(HOST, PORT).unwrap();
|
||||
let mut client = Client::connect(&host(), port()).await.unwrap();
|
||||
|
||||
let _ = client.execute("DROP TABLE IF EXISTS rust_test_products");
|
||||
let _ = client.execute("DROP TABLE IF EXISTS rust_test_products").await;
|
||||
client
|
||||
.execute("CREATE TABLE rust_test_products (id INT PRIMARY KEY, name STRING, price FLOAT)")
|
||||
.await
|
||||
.unwrap();
|
||||
client
|
||||
.execute("INSERT INTO rust_test_products (id, name, price) VALUES (1, 'Widget', 9.99)")
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let result = QueryBuilder::new(&mut client)
|
||||
@@ -106,21 +120,22 @@ fn test_query_builder_exec() {
|
||||
.from("rust_test_products")
|
||||
.where_clause("id = 1")
|
||||
.exec()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(result.row_count(), 1);
|
||||
|
||||
client.execute("DROP TABLE rust_test_products").unwrap();
|
||||
client.close();
|
||||
client.execute("DROP TABLE rust_test_products").await.unwrap();
|
||||
client.close().await;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_auth_dummy_token() {
|
||||
#[tokio::test]
|
||||
async fn test_auth_dummy_token() {
|
||||
if !server_available() {
|
||||
return;
|
||||
}
|
||||
let mut client = Client::connect(HOST, PORT).unwrap();
|
||||
let res = client.auth("dummy-token-for-testing");
|
||||
let mut client = Client::connect(&host(), port()).await.unwrap();
|
||||
let res = client.auth("dummy-token-for-testing").await;
|
||||
// Dev server may accept or reject — both are fine
|
||||
match res {
|
||||
Ok(()) => {}
|
||||
@@ -129,5 +144,5 @@ fn test_auth_dummy_token() {
|
||||
assert!(msg.contains("Auth") || msg.to_lowercase().contains("error"));
|
||||
}
|
||||
}
|
||||
client.close();
|
||||
client.close().await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user