Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ serde_json = "1.0"
serde_yaml = "0.9"

# JSON path extraction
jsonpath-rust = "0.3"
jsonpath-rust = "1.0"

# Logging and tracing
tracing = "0.1"
Expand All @@ -25,14 +25,14 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
# Terminal UI
indicatif = "0.18"
console = "0.16"
colored = "2.1"
colored = "3.1"

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

# Error handling
anyhow = "1.0"
thiserror = "1.0"
thiserror = "2.0"

# Statistics
hdrhistogram = "7.5"
Expand Down
48 changes: 16 additions & 32 deletions src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::config::{Config, Scenario};
use crate::metrics::{MetricsCollector, RequestResult};
use anyhow::Result;
use chrono::Utc;
use jsonpath_rust::JsonPathFinder;
use jsonpath_rust::JsonPath;
use std::collections::{HashMap, HashSet};
use std::sync::Arc;
use std::time::Instant;
Expand Down Expand Up @@ -261,39 +261,23 @@ impl Executor {
) {
for (var_name, json_path) in &scenario.extract {
match serde_json::from_str::<serde_json::Value>(body) {
Ok(_json) => {
match JsonPathFinder::from_str(body, json_path) {
Ok(finder) => {
let result = finder.find();
if let serde_json::Value::Array(arr) = result {
if let Some(value) = arr.first() {
let extracted = match value {
serde_json::Value::String(s) => s.clone(),
serde_json::Value::Number(n) => n.to_string(),
serde_json::Value::Bool(b) => b.to_string(),
_ => value.to_string(),
};

debug!("Extracted variable '{}' = '{}'", var_name, extracted);
variables.insert(var_name.clone(), extracted);
}
} else if result != serde_json::Value::Null {
// Single value result
let extracted = match result {
serde_json::Value::String(s) => s,
serde_json::Value::Number(n) => n.to_string(),
serde_json::Value::Bool(b) => b.to_string(),
_ => result.to_string(),
};
debug!("Extracted variable '{}' = '{}'", var_name, extracted);
variables.insert(var_name.clone(), extracted);
}
}
Err(e) => {
warn!("JSONPath error for '{}': {}", json_path, e);
Ok(json) => match json.query(json_path) {
Ok(results) => {
if let Some(value) = results.first() {
let extracted = match value {
serde_json::Value::String(s) => s.clone(),
serde_json::Value::Number(n) => n.to_string(),
serde_json::Value::Bool(b) => b.to_string(),
_ => value.to_string(),
};
debug!("Extracted variable '{}' = '{}'", var_name, extracted);
variables.insert(var_name.clone(), extracted);
}
}
}
Err(e) => {
warn!("JSONPath error for '{}': {}", json_path, e);
}
},
Err(e) => {
warn!("Failed to parse JSON response: {}", e);
}
Expand Down
2 changes: 1 addition & 1 deletion vars/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.0.2
v1.0.3