Skip to content

Commit

Permalink
Updates to clean up errors in deployment
Browse files Browse the repository at this point in the history
Signed-off-by: Heinz N. Gies <[email protected]>
  • Loading branch information
Licenser committed Oct 25, 2021
1 parent fa63ae3 commit 6624797
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
target
benchmarks.db
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion docker/run.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
tremor test bench tremor-cli/tests/bench -o "${1}.json" > tremor.log
cat "${1}.json"
cat "${1}.json"
10 changes: 5 additions & 5 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl From<&str> for Error {
}
impl From<InvalidKeyLength> for Error {
fn from(_: InvalidKeyLength) -> Self {
Self::Other
Self::Other("invalid lenght")
}
}

Expand All @@ -38,23 +38,23 @@ impl From<serde_json::Error> for Error {
}
impl From<std::io::Error> for Error {
fn from(_: std::io::Error) -> Self {
Self::Other
Self::Other("IO Error")
}
}
impl<T> From<async_std::channel::SendError<T>> for Error {
fn from(_: async_std::channel::SendError<T>) -> Self {
Self::Other
Self::Other("send error")
}
}
impl From<diesel::result::Error> 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),
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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") => {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -215,7 +215,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
});
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());
Expand Down
35 changes: 28 additions & 7 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,24 @@ pub struct WholeReport {
metadata: Metadata,
includes: Vec<String>,
excludes: Vec<String>,
reports: Vec<SingleReport>,
reports: Reports,
stats: Stats,
}

#[derive(Deserialize, Debug)]
struct Reports {
bench: Vec<SingleReport>
}

#[derive(Deserialize, Debug)]
struct SingleReport {
description: String,
elements: Bench,
elements: Element,
}

#[derive(Deserialize, Debug)]
struct Element {
bench: Bench
}

#[derive(Deserialize, Debug)]
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit 6624797

Please sign in to comment.