Skip to content

Commit

Permalink
fixed dind test
Browse files Browse the repository at this point in the history
  • Loading branch information
christopher-besch committed Jan 19, 2024
1 parent d9c9666 commit 4ded5b3
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 30 deletions.
36 changes: 16 additions & 20 deletions dind_test_driver/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
use futures::future::join_all;
use gethostname::gethostname;
use logdna_mock::{make_panic_exit, mock_server, TestCfg, TestType};
use std::net::TcpStream;
use std::{net::SocketAddr, time::Duration};
use tokio::process::Command;
use tokio::time::sleep;

const CONTAINER_AMOUNT: usize = 1;
const LINES_PER_SEC: f64 = 2.0;
const LINES_AMOUNT: usize = 20;
const CONTAINER_AMOUNT: usize = 10;
const LINES_PER_SEC: f64 = 500.0;
const LINES_AMOUNT: usize = 10000;
const MAX_SLOW_STREAK: u64 = 0;
const CHAR_MIN: u8 = ' ' as u8;
const CHAR_MAX: u8 = '~' as u8 + 1;
Expand Down Expand Up @@ -51,7 +48,6 @@ async fn start_client_server_pair(i: usize) {

let return_status = tokio::join!(
mock_server(cfg),
test(),
Command::new(match in_dind {
true => "docker-entrypoint.sh",
false => "docker",
Expand Down Expand Up @@ -107,22 +103,22 @@ async fn start_client_server_pair(i: usize) {
.unwrap()
.wait_with_output()
)
.2
.1
.unwrap()
.status;

assert_eq!(return_status.code(), Some(0));
}

async fn test() {
Command::new("journalctl")
.arg("--user")
.arg("-fu")
.arg("docker.service")
.arg("--no-pager")
.spawn()
.unwrap()
.wait_with_output()
.await
.unwrap();
}
// async fn test() {
// Command::new("journalctl")
// .arg("--user")
// .arg("-fu")
// .arg("docker.service")
// .arg("--no-pager")
// .spawn()
// .unwrap()
// .wait_with_output()
// .await
// .unwrap();
// }
44 changes: 34 additions & 10 deletions mock/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,29 @@ pub fn rng_check_lines(
lines: &Vec<Line>,
) {
for line in lines {
rng_check_line(&cfg, rng, &line);
if *count == 0 {
assert_eq!(
match &line.line {
Some(v) => Some(v.replace("\r", "")),
None => None,
},
Some("Critical: docker_logdna starting to log".to_string())
);
} else {
rng_check_line(&cfg, rng, &line);
}
*count += 1;
if *count % 1000 == 0 {
println!("{}", count);
}
if *count >= cfg.lines_amount {
// don't forget first critical line
if *count > cfg.lines_amount {
inner_notify_stop.notify_one();
}
}
}

// don't check for first critical line here
pub fn vec_check_lines(
cfg: &TestCfg,
count: &mut usize,
Expand Down Expand Up @@ -138,20 +150,31 @@ pub fn check_line_lengths(
lines: &Vec<Line>,
) {
for line in lines {
match &line.line {
Some(l) => {
assert!(
l.replace("\r", "").len() >= cfg.string_len_range.start
&& l.replace("\r", "").len() < cfg.string_len_range.end
)
if *count == 0 {
assert_eq!(
match &line.line {
Some(v) => Some(v.replace("\r", "")),
None => None,
},
Some("Critical: docker_logdna starting to log".to_string())
);
} else {
match &line.line {
Some(l) => {
assert!(
l.replace("\r", "").len() >= cfg.string_len_range.start
&& l.replace("\r", "").len() < cfg.string_len_range.end
)
}
None => (),
}
None => (),
}
*count += 1;
if *count % 1000 == 0 {
println!("{}", count);
}
if *count >= cfg.lines_amount {
// don't forget first critical line
if *count > cfg.lines_amount {
inner_notify_stop.notify_one();
}
}
Expand Down Expand Up @@ -211,6 +234,7 @@ pub async fn mock_server(cfg: TestCfg) {
inner_notify_stop.clone(),
&body.lines,
),
// TODO: add first critical line check
TestType::Retry => {
println!("{}", *proc_count.lock().unwrap());
assert_eq!(
Expand Down

0 comments on commit 4ded5b3

Please sign in to comment.