add basic test running
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
does not add actual test
This commit is contained in:
parent
ca6f0677ed
commit
edf212de7e
|
@ -27,6 +27,13 @@ steps:
|
||||||
- sleep 75
|
- sleep 75
|
||||||
- ./scripts/deploy_sandbox_client.sh server:4000
|
- ./scripts/deploy_sandbox_client.sh server:4000
|
||||||
|
|
||||||
|
- name: test_server
|
||||||
|
image: rust
|
||||||
|
commands:
|
||||||
|
- sleep 75
|
||||||
|
- ./scripts/deploy_sandbox_client.sh server:4000
|
||||||
|
- cargo test --no-default_features --features "client,tls_no_verify"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
- name: database
|
- name: database
|
||||||
image: postgres
|
image: postgres
|
||||||
|
|
|
@ -18,7 +18,7 @@ test = false
|
||||||
bench = false
|
bench = false
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["server", "client"]
|
default = ["server"]
|
||||||
server = []
|
server = []
|
||||||
client = []
|
client = []
|
||||||
tls_no_verify = ["tokio-rustls/dangerous_configuration"]
|
tls_no_verify = ["tokio-rustls/dangerous_configuration"]
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ./scripts/env.sh && cargo run --no-default-features --features "server" -- ${1:-0.0.0.0:4000} &
|
||||||
|
|
||||||
|
PID_server=$!
|
||||||
|
echo $PID_server
|
||||||
|
|
||||||
|
while kill -0 $PID_server > /dev/null 2>&1
|
||||||
|
do
|
||||||
|
[[ -f "/tmp/paper/running" ]] && break
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -f "/tmp/paper/running" ]]; then
|
||||||
|
cargo test --no-default-features --features "client,tls_no_verify"
|
||||||
|
rm /tmp/paper/running
|
||||||
|
kill $PID_server
|
||||||
|
pkill sandbox
|
||||||
|
fi
|
|
@ -1,9 +1,9 @@
|
||||||
extern crate log;
|
extern crate log;
|
||||||
|
|
||||||
#[cfg(feature = "client")]
|
|
||||||
use libtrader::client::initializer::libtrader_init_client;
|
|
||||||
#[cfg(feature = "server")]
|
#[cfg(feature = "server")]
|
||||||
use libtrader::server::initializer::{libtrader_init_server, IP};
|
use libtrader::server;
|
||||||
|
#[cfg(feature = "client")]
|
||||||
|
use libtrader::client;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
#[cfg(feature = "server")]
|
#[cfg(feature = "server")]
|
||||||
|
@ -18,9 +18,9 @@ fn main() {
|
||||||
|
|
||||||
// Spawn server
|
// Spawn server
|
||||||
rt.block_on(async move {
|
rt.block_on(async move {
|
||||||
IP.scope("0.0.0.0:0000".parse().unwrap(), async move {
|
server::IP.scope("0.0.0.0:0000".parse().unwrap(), async move {
|
||||||
// for main task logging
|
// for main task logging
|
||||||
libtrader_init_server()
|
server::initialize()
|
||||||
.await
|
.await
|
||||||
.expect("failed running server");
|
.expect("failed running server");
|
||||||
})
|
})
|
||||||
|
@ -31,5 +31,5 @@ fn main() {
|
||||||
/* this is a sandbox, we should try to atleast
|
/* this is a sandbox, we should try to atleast
|
||||||
* implement a testing method */
|
* implement a testing method */
|
||||||
#[cfg(feature = "client")]
|
#[cfg(feature = "client")]
|
||||||
libtrader_init_client().expect("failed running client");
|
client::initialize().expect("failed running client");
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,6 @@ pub mod authorization;
|
||||||
pub mod creation;
|
pub mod creation;
|
||||||
pub mod hash;
|
pub mod hash;
|
||||||
|
|
||||||
pub use crate::client::account::creation::create;
|
|
||||||
pub use crate::client::account::authorization::authorize;
|
pub use crate::client::account::authorization::authorize;
|
||||||
|
pub use crate::client::account::creation::create;
|
||||||
pub use crate::client::account::hash::hash;
|
pub use crate::client::account::hash::hash;
|
||||||
|
|
|
@ -37,7 +37,7 @@ struct Options {
|
||||||
/// libtrader_init_client().expect("failed running client");
|
/// libtrader_init_client().expect("failed running client");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
fn libtrader_init_log() -> io::Result<()> {
|
fn initialize_log() -> io::Result<()> {
|
||||||
use fern::colors::{Color, ColoredLevelConfig};
|
use fern::colors::{Color, ColoredLevelConfig};
|
||||||
|
|
||||||
let mut dispatch = fern::Dispatch::new().format(|out, message, record| {
|
let mut dispatch = fern::Dispatch::new().format(|out, message, record| {
|
||||||
|
@ -99,12 +99,12 @@ fn libtrader_init_log() -> io::Result<()> {
|
||||||
///
|
///
|
||||||
/// Example:
|
/// Example:
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// libtrader_init_client()?;
|
/// initialize()?;
|
||||||
/// ```
|
/// ```
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
pub async fn libtrader_init_client() -> std::io::Result<()> {
|
pub async fn initialize() -> std::io::Result<()> {
|
||||||
// Initialize log.
|
// Initialize log.
|
||||||
libtrader_init_log()?;
|
initialize_log()?;
|
||||||
|
|
||||||
// Initialize arguments
|
// Initialize arguments
|
||||||
let options: Options = argh::from_env();
|
let options: Options = argh::from_env();
|
||||||
|
|
|
@ -2,3 +2,5 @@ pub mod account;
|
||||||
pub mod ds;
|
pub mod ds;
|
||||||
pub mod initializer;
|
pub mod initializer;
|
||||||
pub mod network;
|
pub mod network;
|
||||||
|
|
||||||
|
pub use crate::client::initializer::initialize;
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
pub mod cmd;
|
pub mod cmd;
|
||||||
pub mod tls;
|
|
||||||
pub mod handle_data;
|
pub mod handle_data;
|
||||||
|
pub mod tls;
|
||||||
|
|
|
@ -7,10 +7,10 @@ use tokio::io::AsyncReadExt;
|
||||||
use tokio::io::AsyncWriteExt;
|
use tokio::io::AsyncWriteExt;
|
||||||
use tokio::net::TcpStream;
|
use tokio::net::TcpStream;
|
||||||
|
|
||||||
#[cfg(all(feature = "client", not(feature = "server")))]
|
|
||||||
use tokio_rustls::client::TlsStream;
|
|
||||||
#[cfg(all(feature = "server", not(feature = "client")))]
|
#[cfg(all(feature = "server", not(feature = "client")))]
|
||||||
use tokio_rustls::server::TlsStream;
|
use tokio_rustls::server::TlsStream;
|
||||||
|
#[cfg(all(feature = "client", not(feature = "server")))]
|
||||||
|
use tokio_rustls::client::TlsStream;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Default)]
|
#[derive(Serialize, Deserialize, PartialEq, Debug, Default)]
|
||||||
pub struct Message {
|
pub struct Message {
|
||||||
|
|
|
@ -42,7 +42,7 @@ tokio::task_local! {
|
||||||
/// libtrader_init_log()?;
|
/// libtrader_init_log()?;
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
fn libtrader_init_log() -> std::io::Result<()> {
|
fn initialize_log() -> std::io::Result<()> {
|
||||||
use fern::colors::{Color, ColoredLevelConfig};
|
use fern::colors::{Color, ColoredLevelConfig};
|
||||||
|
|
||||||
let mut dispatch = fern::Dispatch::new().format(|out, message, record| {
|
let mut dispatch = fern::Dispatch::new().format(|out, message, record| {
|
||||||
|
@ -124,9 +124,9 @@ fn libtrader_init_log() -> std::io::Result<()> {
|
||||||
/// .await;
|
/// .await;
|
||||||
/// });
|
/// });
|
||||||
/// ```
|
/// ```
|
||||||
pub async fn libtrader_init_server() -> std::io::Result<()> {
|
pub async fn initialize() -> std::io::Result<()> {
|
||||||
// Initialize log.
|
// Initialize log.
|
||||||
libtrader_init_log()?;
|
initialize_log()?;
|
||||||
|
|
||||||
// Initialize SQL connection
|
// Initialize SQL connection
|
||||||
let sql_shared_conn = Arc::new(
|
let sql_shared_conn = Arc::new(
|
||||||
|
@ -160,6 +160,12 @@ pub async fn libtrader_init_server() -> std::io::Result<()> {
|
||||||
|
|
||||||
let listener = TcpListener::bind(&addr).await?;
|
let listener = TcpListener::bind(&addr).await?;
|
||||||
|
|
||||||
|
// create temporary file to mark server is running
|
||||||
|
let marker_path = std::path::Path::new("/tmp/paper/running");
|
||||||
|
let marker_prefix = marker_path.parent().unwrap();
|
||||||
|
std::fs::create_dir_all(marker_prefix).unwrap();
|
||||||
|
std::fs::write(marker_path, "").unwrap();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let (socket, peer_addr) = listener.accept().await?; // socket, peer_addr
|
let (socket, peer_addr) = listener.accept().await?; // socket, peer_addr
|
||||||
let acceptor = acceptor.clone();
|
let acceptor = acceptor.clone();
|
||||||
|
|
|
@ -3,3 +3,6 @@ pub mod db;
|
||||||
pub mod ds;
|
pub mod ds;
|
||||||
pub mod initializer;
|
pub mod initializer;
|
||||||
pub mod network;
|
pub mod network;
|
||||||
|
|
||||||
|
pub use crate::server::initializer::initialize;
|
||||||
|
pub use crate::server::initializer::IP;
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
pub mod tls;
|
|
||||||
pub mod handle_data;
|
pub mod handle_data;
|
||||||
pub mod jwt;
|
pub mod jwt;
|
||||||
|
pub mod tls;
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
## To do
|
## To do
|
||||||
|
|
||||||
- add testing suite
|
|
||||||
* [ ] configure ci to run those tests
|
|
||||||
* [ ] add tests for all server functions
|
|
||||||
* [ ] add tests for all client functions
|
|
||||||
- create correct modules
|
- create correct modules
|
||||||
* [ ] fix weird file naming
|
* [ ] fix weird file naming
|
||||||
* [ ] fix namespace naming
|
* [ ] fix namespace naming
|
||||||
|
@ -19,6 +15,10 @@
|
||||||
|
|
||||||
## In progress
|
## In progress
|
||||||
|
|
||||||
|
- add testing suite
|
||||||
|
* [ ] configure ci to run those tests
|
||||||
|
* [ ] add tests for all server functions
|
||||||
|
* [ ] add tests for all client functions
|
||||||
|
|
||||||
## Done
|
## Done
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue