static linking tests

14-integration-tests
plazmoid 3 years ago
parent 5734145e8f
commit 8cccc82fc2
  1. 8
      .cargo/config.toml
  2. 2
      bin/u_agent/Cargo.toml
  3. 2
      bin/u_agent/src/lib.rs
  4. 2
      bin/u_panel/Cargo.toml
  5. 1
      bin/u_server/Cargo.toml
  6. 2
      bin/u_server/src/db.rs
  7. 4
      bin/u_server/src/main.rs
  8. 12
      integration/docker-compose.yml
  9. 4
      integration/utils.py
  10. 2
      lib/u_lib/Cargo.toml
  11. 4
      lib/u_lib/src/api.rs
  12. 5
      lib/u_lib/src/config.rs
  13. 1
      lib/u_lib/src/lib.rs
  14. 11
      scripts/cargo_musl.sh

@ -1,3 +1,9 @@
[build] [build]
target = "x86_64-unknown-linux-musl" target = "x86_64-unknown-linux-musl"
rustflags = ["-C", "target-feature=+crt-static"]
[target.x86_64-unknown-linux-musl]
rustflags = [
"-Ctarget-feature=+crt-static",
"-Clink-args=-Istatic/include",
"-L", "static/lib",
]

@ -13,7 +13,7 @@ log = "^0.4"
env_logger = "0.8.3" env_logger = "0.8.3"
uuid = "0.6.5" uuid = "0.6.5"
reqwest = { version = "0.11", features = ["json"] } reqwest = { version = "0.11", features = ["json"] }
openssl = { version = "0.10.32", features = ["vendored"] } openssl = "*"
u_lib = { version = "*", path = "../../lib/u_lib" } u_lib = { version = "*", path = "../../lib/u_lib" }
[[test]] [[test]]

@ -73,7 +73,7 @@ pub async fn run_forever() {
//daemonize(); //daemonize();
env_logger::init(); env_logger::init();
let arg_ip = env::args().nth(1); let arg_ip = env::args().nth(1);
let instance = ClientHandler::new(arg_ip); let instance = ClientHandler::new(arg_ip.as_deref());
info!("Connecting to the server"); info!("Connecting to the server");
loop { loop {
let job_requests: Vec<AssignedJob> = let job_requests: Vec<AssignedJob> =

@ -13,5 +13,5 @@ log = "^0.4"
env_logger = "0.7.1" env_logger = "0.7.1"
uuid = "0.6.5" uuid = "0.6.5"
reqwest = { version = "0.11", features = ["json"] } reqwest = { version = "0.11", features = ["json"] }
openssl = { version = "0.10.32", features = ["vendored"] } openssl = "*"
u_lib = { version = "*", path = "../../lib/u_lib" } u_lib = { version = "*", path = "../../lib/u_lib" }

@ -15,6 +15,7 @@ once_cell = "1.7.2"
hyper = "0.13.10" hyper = "0.13.10"
mockall = "0.9.1" mockall = "0.9.1"
mockall_double = "0.2" mockall_double = "0.2"
openssl = "*"
[dependencies.diesel] [dependencies.diesel]
features = ["postgres", "uuid"] features = ["postgres", "uuid"]

@ -21,7 +21,7 @@ static DB: OnceCell<Arc<Mutex<UDB>>> = OnceCell::new();
impl UDB { impl UDB {
pub fn lock_db() -> MutexGuard<'static, UDB> { pub fn lock_db() -> MutexGuard<'static, UDB> {
DB.get_or_init(|| { DB.get_or_init(|| {
dotenv().unwrap(); dotenv().ok();
let db_path = env::var("DATABASE_URL").unwrap(); let db_path = env::var("DATABASE_URL").unwrap();
let conn = PgConnection::establish(&db_path).unwrap(); let conn = PgConnection::establish(&db_path).unwrap();
let instance = UDB { conn }; let instance = UDB { conn };

@ -1,3 +1,7 @@
extern crate openssl;
#[macro_use]
extern crate diesel;
use u_server::serve; use u_server::serve;
#[tokio::main] #[tokio::main]

@ -2,17 +2,13 @@ version: "2.1"
networks: networks:
u_net: u_net:
ipam:
config:
- subnet: 10.16.0.0/24
services: services:
u_server: u_server:
image: unki/u_server image: unki/u_server
networks: networks:
u_net: - u_net
ipv4_address: 10.16.0.200
volumes: volumes:
- ../target/x86_64-unknown-linux-musl/release/u_server:/u_server - ../target/x86_64-unknown-linux-musl/release/u_server:/u_server
- ./.env:/.env - ./.env:/.env
@ -29,6 +25,8 @@ services:
image: postgres:13.3 image: postgres:13.3
networks: networks:
- u_net - u_net
volumes:
- ../data:/var/lib/postgresql/data
expose: expose:
- '5432' - '5432'
environment: environment:
@ -40,7 +38,7 @@ services:
- u_net - u_net
volumes: volumes:
- ../target/x86_64-unknown-linux-musl/release/u_agent:/u_agent - ../target/x86_64-unknown-linux-musl/release/u_agent:/u_agent
command: /u_agent 10.16.0.200 command: /u_agent u_server
depends_on: depends_on:
u_server: u_server:
condition: service_started condition: service_started
@ -51,7 +49,7 @@ services:
- u_net - u_net
volumes: volumes:
- ../target/x86_64-unknown-linux-musl/release/u_agent:/u_agent - ../target/x86_64-unknown-linux-musl/release/u_agent:/u_agent
command: /u_agent 10.16.0.200 command: /u_agent u_server
depends_on: depends_on:
u_server: u_server:
condition: service_started condition: service_started

@ -8,9 +8,9 @@ class TestsError(Exception):
COLORS = { COLORS = {
'question': colored('[?]', 'yellow'), 'question': colored('[?]', 'magenta'),
'info': colored('[~]', 'green'), 'info': colored('[~]', 'green'),
'warning': colored('[!]', 'magenta'), 'warning': colored('[!]', 'yellow'),
'error': colored('[X]', 'red'), 'error': colored('[X]', 'red'),
} }

@ -14,7 +14,7 @@ libc = "^0.2"
lazy_static = "1.4.0" lazy_static = "1.4.0"
tokio = { version = "1.2.0", features = ["rt-multi-thread", "sync", "macros", "process", "time"] } tokio = { version = "1.2.0", features = ["rt-multi-thread", "sync", "macros", "process", "time"] }
reqwest = { version = "0.11", features = ["json"] } reqwest = { version = "0.11", features = ["json"] }
openssl = { version = "0.10.32", features = ["vendored"] } openssl = "*"
futures = "0.3.5" futures = "0.3.5"
guess_host_triple = "0.1.2" guess_host_triple = "0.1.2"
thiserror = "*" thiserror = "*"

@ -18,9 +18,9 @@ pub struct ClientHandler {
} }
impl ClientHandler { impl ClientHandler {
pub fn new(server: Option<String>) -> Self { pub fn new(server: Option<&str>) -> Self {
let master_server = server let master_server = server
.map(|s| Ipv4Addr::from_str(&s).unwrap()) //.map(|s| Ipv4Addr::from_str(&s).unwrap())
.unwrap_or(MASTER_SERVER); .unwrap_or(MASTER_SERVER);
Self { Self {
client: Client::new(), client: Client::new(),

@ -1,9 +1,8 @@
use std::net::Ipv4Addr;
use uuid::Uuid; use uuid::Uuid;
pub const MASTER_SERVER: Ipv4Addr = Ipv4Addr::LOCALHOST; //Ipv4Addr::new(3,9,16,40) pub const MASTER_SERVER: &str = "127.0.0.1"; //Ipv4Addr::new(3,9,16,40)
pub const MASTER_PORT: u16 = 63714; pub const MASTER_PORT: u16 = 63714;
lazy_static! { lazy_static! {
pub static ref UID: Uuid = Uuid::new_v4(); pub static ref UID: Uuid = Uuid::new_v4();
} }

@ -20,6 +20,7 @@ pub mod schema_exports {
#[macro_use] #[macro_use]
extern crate lazy_static; extern crate lazy_static;
extern crate openssl;
#[macro_use] #[macro_use]
extern crate diesel; extern crate diesel;

@ -0,0 +1,11 @@
#!/bin/bash
set -e
source $(dirname $0)/rootdir.sh #set ROOTDIR
docker run \
-v $ROOTDIR:/volume \
-v cargo-cache:/root/.cargo/registry \
-w /volume \
-it \
test/musllibs \
cargo $@
Loading…
Cancel
Save