From 91dc35e48061a7639b93ef98a9222686df18d690 Mon Sep 17 00:00:00 2001 From: Oded Katz <88981719+katzoded@users.noreply.github.com> Date: Thu, 9 Dec 2021 18:15:34 -0800 Subject: [PATCH 1/2] Create CONTRIBUTING.md --- CONTRIBUTING.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..0b82a73 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,6 @@ +a nice feature would be running `exec` for every request. +I have tried this using the existing `exec` how ever if we run a `request` with-items (csv) the assign will store the last response only. + +So I have implemented an `exec` within the request, due to the modular object oriented logic this feature was pretty easy (even though this is the first time I write in rust) + +I'm willing to share the change with you and some example file From 9671dbd47f45c1ce9a51a30f8d8280afcf2abbdb Mon Sep 17 00:00:00 2001 From: Oded Katz <88981719+katzoded@users.noreply.github.com> Date: Thu, 9 Dec 2021 18:20:09 -0800 Subject: [PATCH 2/2] 1. code for exec within request 2. an example for the new feature --- example/exec-within-req.yaml | 26 ++++++++++++++++++++++++++ src/actions/request.rs | 14 ++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 example/exec-within-req.yaml diff --git a/example/exec-within-req.yaml b/example/exec-within-req.yaml new file mode 100644 index 0000000..1a78027 --- /dev/null +++ b/example/exec-within-req.yaml @@ -0,0 +1,26 @@ +# +# [iterations] - defines the number of times this will be invoked +# [concurrency] - defines the number of concurrent messages sent together +# [file_name:] - defines the csv file for getting the body content from. + +--- +base: "https://odedk.com" +iterations: 1 +concurrency: 1 +rampup: 2 + +plan: + + - name: ExecWithinRequest + request: + url: https://{{item.tenant}}/login?auth_token={{item.headless_auth}} + method: GET + headers: + Host: '{{item.tenant}}' + assign: memory + with_items_from_csv: + file_name: ./headless_node_login.csv + quote_char: "'" + exec: + command: "echo \"{{item.tenant}}\" \"{{ memory.body }}\" | tee -a ./next_script.csv" + diff --git a/src/actions/request.rs b/src/actions/request.rs index 8151fda..076677e 100644 --- a/src/actions/request.rs +++ b/src/actions/request.rs @@ -14,6 +14,7 @@ use yaml_rust::Yaml; use serde::{Deserialize, Serialize}; use serde_json::{json, Map, Value}; +use crate::actions; use crate::actions::{extract, extract_optional}; use crate::benchmark::{Context, Pool, Reports}; use crate::config::Config; @@ -30,6 +31,7 @@ pub struct Request { time: f64, method: String, headers: HashMap, + pub exec: Option, pub body: Option, pub with_item: Option, pub index: Option, @@ -51,6 +53,12 @@ impl Request { let name = extract(item, "name"); let url = extract(&item["request"], "url"); let assign = extract_optional(item, "assign"); + let mut exec: Option = None; + let exec_existance: bool = item["exec"].as_hash().is_some(); + + if exec_existance { + exec = Some(actions::Exec::new(item, None)); + } let method = if let Some(v) = extract_optional(&item["request"], "method") { v.to_string().to_uppercase() @@ -87,6 +95,7 @@ impl Request { with_item, index, assign: assign.map(str::to_string), + exec, } } @@ -316,6 +325,11 @@ impl Runnable for Request { }; log_message_response.map(|msg| log_response(msg, &data)); + + match &self.exec { + Some(p) => p.execute(context, reports, &pool, &config).await, + None => (), + } } } }