Skip to content

Commit

Permalink
Add test for async, make it work on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Shadle committed Feb 7, 2024
1 parent 61fe0e3 commit 85439a1
Show file tree
Hide file tree
Showing 2 changed files with 228 additions and 189 deletions.
63 changes: 34 additions & 29 deletions tests/connect/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,31 +48,6 @@ fn main() {
ts = mt;
}

assert!(
std::process::Command::new("strace")
.args([
"-f",
"-e",
"trace=connect",
"-o",
"/tmp/tame-index-connection-trace"
])
.arg(latest)
.arg("reuses_connection")
.status()
.unwrap()
.success(),
"failed to strace test"
);

let trace = std::fs::read_to_string("/tmp/tame-index-connection-trace")
.expect("failed to read strace output");

let connection_counts = trace
.lines()
.filter(|line| line.contains("connect("))
.count();

// The connection count should be roughly the same as the processor count
let stdout = std::process::Command::new("nproc").output().unwrap().stdout;

Expand All @@ -81,9 +56,39 @@ fn main() {
.trim()
.parse()
.unwrap();

let max = proc_count + 5;
assert!(
connection_counts <= max,
"connection syscalls ({connection_counts}) should be lower than {max}"
);

for test in ["reuses_connection", "async_reuses_connection"] {
assert!(
std::process::Command::new("strace")
.args([
"-f",
"-e",
"trace=connect",
"-o",
"/tmp/tame-index-connection-trace"
])
.arg(&latest)
.arg("--exact")
.arg(format!("remote::{test}"))
.status()
.unwrap()
.success(),
"failed to strace test"
);

let trace = std::fs::read_to_string("/tmp/tame-index-connection-trace")
.expect("failed to read strace output");

let connection_counts = trace
.lines()
.filter(|line| line.contains("connect("))
.count();

assert!(
connection_counts <= max,
"connection syscalls ({connection_counts}) should be lower than {max}"
);
}
}
Loading

0 comments on commit 85439a1

Please sign in to comment.