diff --git a/.gitignore b/.gitignore index eb5a316..46311a3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ target +benchmarks.db diff --git a/README.md b/README.md index aa1d371..48f8b83 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,2 @@ -** tremor-benchmark ** -This repository contains code for our continuous integration system that enables our project -benchmarks to be executed on a CNCF Cluster bare metal Equinix machine via github actions. - -This tool was conceived and developed by [Akshat Agarwal]([humancalico]) for the LFX Spring 2021 mentorship program. - -[humancalico]: https://github.com/humancalico +required packages (ubuntu): apt install build-essential pkg-config libssl-dev sqlite3 libpq-dev libmysqlclient-dev libsqlite3-dev diff --git a/docker/run.sh b/docker/run.sh index adb1796..983cc84 100755 --- a/docker/run.sh +++ b/docker/run.sh @@ -1,2 +1,2 @@ tremor test bench tremor-cli/tests/bench -o "${1}.json" > tremor.log -cat "${1}.json" \ No newline at end of file +cat "${1}.json" diff --git a/src/error.rs b/src/error.rs index de0867c..fba39f7 100644 --- a/src/error.rs +++ b/src/error.rs @@ -27,7 +27,7 @@ impl From<&str> for Error { } impl From for Error { fn from(_: InvalidKeyLength) -> Self { - Self::Other + Self::Other("invalid lenght") } } @@ -38,23 +38,23 @@ impl From for Error { } impl From for Error { fn from(_: std::io::Error) -> Self { - Self::Other + Self::Other("IO Error") } } impl From> for Error { fn from(_: async_std::channel::SendError) -> Self { - Self::Other + Self::Other("send error") } } impl From for Error { fn from(_: diesel::result::Error) -> Self { - Self::Other + Self::Other("diesel error") } } #[derive(Debug)] pub enum Error { - Other, + Other(&'static str), Text(String), Hyper(hyper::Error), BadRequest(String), diff --git a/src/main.rs b/src/main.rs index cd8a249..33aa07b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -104,7 +104,7 @@ async fn run( .header(header::CONTENT_TYPE, "application/json") .header(header::ACCESS_CONTROL_ALLOW_ORIGIN, "*") .body(Body::from(res)) - .map_err(|_| Error::Other) + .map_err(|_| Error::Other("response error")) } // Simply echo the body back to the client. (&Method::POST, "/bench") => { @@ -154,7 +154,7 @@ async fn run( .ok_or_else(|| Error::BadRequest("`ref` is missing".into()))? .to_string(); - if ghref != "main" { + if ghref != "refs/heads/main" { return Ok(Response::new(Body::from(format!( r#"{{"branch": "{}"}}"#, ghref @@ -215,7 +215,7 @@ async fn main() -> Result<(), Box> { }); let opts: Opts = Opts::parse(); - let addr = ([127, 0, 0, 1], 3001).into(); + let addr = ([0, 0, 0, 0], 8080).into(); let service = make_service_fn(move |_| { let o = Arc::new(opts.clone()); diff --git a/src/util.rs b/src/util.rs index 9cdb87b..42d53a9 100644 --- a/src/util.rs +++ b/src/util.rs @@ -24,14 +24,24 @@ pub struct WholeReport { metadata: Metadata, includes: Vec, excludes: Vec, - reports: Vec, + reports: Reports, stats: Stats, } +#[derive(Deserialize, Debug)] +struct Reports { + bench: Vec +} + #[derive(Deserialize, Debug)] struct SingleReport { description: String, - elements: Bench, + elements: Element, +} + +#[derive(Deserialize, Debug)] +struct Element { + bench: Bench } #[derive(Deserialize, Debug)] @@ -89,14 +99,25 @@ pub fn convert_into_relevant_data( whole_report .reports + .bench .into_iter() .map(|report| { // TODO add a check if benchmark has passed or failed - let bench_name = report.elements.name; - let r = report.elements.evidence.stdout; - let mbps = extract_throughput(&r).ok_or(Error::Other)?; - let eps = extract_events(&r).ok_or(Error::Other)?; - let hist = extract_hist(&r).ok_or(Error::Other)?.to_string(); + let r = &report.elements.bench.evidence.stdout; + let mbps = extract_throughput(r).ok_or(Error::Other("failed to get mbps")); + let eps = extract_events(r).ok_or(Error::Other("failed to get eps")); + let hist = extract_hist(r).ok_or(Error::Other("faild to get histogram")); + drop(r); + + if mbps.is_err() || eps.is_err() || hist.is_err() { + dbg!(&report); + } + + let mbps = mbps.unwrap_or_default(); + let eps = eps.unwrap_or_default(); + let hist = hist.unwrap_or_default().to_string(); + + let bench_name = report.elements.bench.name; Ok(crate::model::Benchmark { id: format!("{}-{}-{}", commit_hash, &bench_name, &created_at), created_at: created_at.clone(),