Skip to content

Commit 41858c3

Browse files
build(deps): update thiserror requirement from 1.0 to 2.0 (#7)
* build(deps): update thiserror requirement from 1.0 to 2.0 Updates the requirements on [thiserror](https://github.com/dtolnay/thiserror) to permit the latest version. - [Release notes](https://github.com/dtolnay/thiserror/releases) - [Commits](dtolnay/thiserror@1.0.0...2.0.18) --- updated-dependencies: - dependency-name: thiserror dependency-version: 2.0.18 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): update jsonpath-rust requirement from 0.3 to 1.0 (#8) * build(deps): update jsonpath-rust requirement from 0.3 to 1.0 Updates the requirements on [jsonpath-rust](https://github.com/besok/jsonpath-rust) to permit the latest version. - [Changelog](https://github.com/besok/jsonpath-rust/blob/main/CHANGELOG.md) - [Commits](https://github.com/besok/jsonpath-rust/commits) --- updated-dependencies: - dependency-name: jsonpath-rust dependency-version: 1.0.4 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): update colored requirement from 2.1 to 3.1 (#9) Updates the requirements on [colored](https://github.com/mackwic/colored) to permit the latest version. - [Release notes](https://github.com/mackwic/colored/releases) - [Changelog](https://github.com/colored-rs/colored/blob/master/CHANGELOG.md) - [Commits](colored-rs/colored@v2.1.0...v3.1.1) --- updated-dependencies: - dependency-name: colored dependency-version: 3.1.1 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * refactor(executor): improve async handling and error reporting in request execution --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: ragilhadi <ragilprasetyo310@gmail.com> * bump version to v1.0.3 * build: update Docker platforms to linux/amd64 only --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: ragilhadi <ragilprasetyo310@gmail.com>
1 parent e124636 commit 41858c3

4 files changed

Lines changed: 21 additions & 37 deletions

File tree

.github/workflows/docker-build-push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
with:
6767
context: .
6868
file: ./Dockerfile
69-
platforms: linux/amd64,linux/arm64
69+
platforms: linux/amd64
7070
push: ${{ github.event_name != 'pull_request' }}
7171
tags: ${{ steps.meta.outputs.tags }}
7272
labels: ${{ steps.meta.outputs.labels }}

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ serde_json = "1.0"
1616
serde_yaml = "0.9"
1717

1818
# JSON path extraction
19-
jsonpath-rust = "0.3"
19+
jsonpath-rust = "1.0"
2020

2121
# Logging and tracing
2222
tracing = "0.1"
@@ -25,14 +25,14 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
2525
# Terminal UI
2626
indicatif = "0.18"
2727
console = "0.16"
28-
colored = "2.1"
28+
colored = "3.1"
2929

3030
# Time handling
3131
chrono = { version = "0.4", features = ["serde"] }
3232

3333
# Error handling
3434
anyhow = "1.0"
35-
thiserror = "1.0"
35+
thiserror = "2.0"
3636

3737
# Statistics
3838
hdrhistogram = "7.5"

src/executor.rs

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::config::{Config, Scenario};
33
use crate::metrics::{MetricsCollector, RequestResult};
44
use anyhow::Result;
55
use chrono::Utc;
6-
use jsonpath_rust::JsonPathFinder;
6+
use jsonpath_rust::JsonPath;
77
use std::collections::{HashMap, HashSet};
88
use std::sync::Arc;
99
use std::time::Instant;
@@ -261,39 +261,23 @@ impl Executor {
261261
) {
262262
for (var_name, json_path) in &scenario.extract {
263263
match serde_json::from_str::<serde_json::Value>(body) {
264-
Ok(_json) => {
265-
match JsonPathFinder::from_str(body, json_path) {
266-
Ok(finder) => {
267-
let result = finder.find();
268-
if let serde_json::Value::Array(arr) = result {
269-
if let Some(value) = arr.first() {
270-
let extracted = match value {
271-
serde_json::Value::String(s) => s.clone(),
272-
serde_json::Value::Number(n) => n.to_string(),
273-
serde_json::Value::Bool(b) => b.to_string(),
274-
_ => value.to_string(),
275-
};
276-
277-
debug!("Extracted variable '{}' = '{}'", var_name, extracted);
278-
variables.insert(var_name.clone(), extracted);
279-
}
280-
} else if result != serde_json::Value::Null {
281-
// Single value result
282-
let extracted = match result {
283-
serde_json::Value::String(s) => s,
284-
serde_json::Value::Number(n) => n.to_string(),
285-
serde_json::Value::Bool(b) => b.to_string(),
286-
_ => result.to_string(),
287-
};
288-
debug!("Extracted variable '{}' = '{}'", var_name, extracted);
289-
variables.insert(var_name.clone(), extracted);
290-
}
291-
}
292-
Err(e) => {
293-
warn!("JSONPath error for '{}': {}", json_path, e);
264+
Ok(json) => match json.query(json_path) {
265+
Ok(results) => {
266+
if let Some(value) = results.first() {
267+
let extracted = match value {
268+
serde_json::Value::String(s) => s.clone(),
269+
serde_json::Value::Number(n) => n.to_string(),
270+
serde_json::Value::Bool(b) => b.to_string(),
271+
_ => value.to_string(),
272+
};
273+
debug!("Extracted variable '{}' = '{}'", var_name, extracted);
274+
variables.insert(var_name.clone(), extracted);
294275
}
295276
}
296-
}
277+
Err(e) => {
278+
warn!("JSONPath error for '{}': {}", json_path, e);
279+
}
280+
},
297281
Err(e) => {
298282
warn!("Failed to parse JSON response: {}", e);
299283
}

vars/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.0.2
1+
v1.0.3

0 commit comments

Comments
 (0)