Compare commits

...

3 Commits

Author SHA1 Message Date
prplV 701de28cf8 small refactor in hagent 2024-10-31 10:39:30 +03:00
prplV cdcef60c18 hagent unittests 2024-10-31 10:39:16 +03:00
prplV 3c04acdc9f metrics unittests 2024-10-31 10:23:42 +03:00
4 changed files with 71 additions and 2 deletions

View File

@ -1,6 +1,8 @@
pub mod files;
pub mod prcs;
pub mod services;
pub mod hagent;
pub mod metrics;
use crate::options::structs::TrackingProcess;
use files::create_watcher;
@ -210,7 +212,7 @@ pub fn get_container_id() -> Option<String> {
}
Some(String::from_utf8_lossy(&output.stdout).to_string())
}
Err(er) => {
Err(_) => {
None
}
}

22
src/utils/hagent.rs Normal file
View File

@ -0,0 +1,22 @@
// module needed to check host-agent health condition and to communicate with it
//
// code will be here
//
#[cfg(test)]
mod hagent_unittets {
#[tokio::test]
// maybe bool : true -> alive, false -> dead
// simple request on api
async fn hagent_healthcheck() {
assert!(true);
}
#[tokio::test]
// Result<maybe Response>
// one-shot func
async fn send_metrics_to_hagent() {
assert!(true);
}
}

45
src/utils/metrics.rs Normal file
View File

@ -0,0 +1,45 @@
// module needed to get metrics such as
// cpu load, memmory load and net activity
//
// code will be here
//
#[cfg(test)]
mod metrics_unittets {
#[tokio::test]
// Option<String> output
// echo func
async fn get_cpu_load() {
assert!(true);
}
#[tokio::test]
// Option<String> output
// echo func
async fn get_ram_load() {
assert!(true);
}
#[tokio::test]
// Option<String> output
// echo func
async fn get_mem_load() {
assert!(true);
}
#[tokio::test]
// can't be tested this way because of 0-0 loop of checking buffer
// async func with loop inside
async fn get_net_stat(){
assert!(true);
}
#[tokio::test]
async fn init_sumodules() {
assert!(true);
}
// Option<Vec<TrackingProcess OR String>> output
// echo func
#[tokio::test]
async fn get_info_about_subsystems() {
assert!(true);
}
}

View File

@ -1,4 +1,4 @@
use runner_rs::*;
// use runner_rs::*;
#[test]
fn test() {