Skip to content

Commit

Permalink
feat: fix test bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jincheng.zhang committed Mar 29, 2024
1 parent faebe8e commit a5ad443
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 25 deletions.
40 changes: 40 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ eframe = { version = "0.27.0", default-features = false, features = [
"default_fonts", # Embed the default egui fonts.
"glow", # Use the glow rendering backend. Alternative: "wgpu".
] }
futures-util = "0.3.29"
futures-util = "0.3.29"
rayon = "1.10.0"
1 change: 1 addition & 0 deletions crates/netpurr_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ chrono.workspace = true
url.workspace = true
poll-promise.workspace = true
tokio.workspace = true
rayon.workspace = true
deno_core = { version = "0.245.0" }
# http
reqwest = { version = "0.11.23", features = ["default-tls", "trust-dns", "blocking", "cookies", "json", "multipart", "gzip", "brotli", "deflate", "stream"] }
Expand Down
48 changes: 24 additions & 24 deletions crates/netpurr_core/src/runner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use deno_core::futures::future::join_all;
use deno_core::futures::FutureExt;
use log::info;
use poll_promise::Promise;
use rayon::{ThreadPool, ThreadPoolBuilder};
use reqwest::Client;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -363,30 +364,29 @@ impl Runner {
test_group_run_result.write().unwrap().add_results(results);
}
pub fn run_test_group_jobs(client: Client,run_request_infos:Vec<RunRequestInfo>, test_group_run_result: Arc<RwLock<TestGroupRunResults>>){
let mut handles = Vec::new();
for run_request_info in run_request_infos {
let _client = client.clone();
let _run_request_info = run_request_info.clone();
let _shared_map = run_request_info.shared_map.clone();
let _test_group_run_result = test_group_run_result.clone();
handles.push(thread::spawn(move || {
let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap();
runtime.block_on(async {
let result = Self::send_rest_with_script_async(
_run_request_info,
_client,
_shared_map,
).await;
_test_group_run_result.write().unwrap().add_result(result);
});
}));
}
for handle in handles {
handle.join().unwrap();
}
let pool = ThreadPoolBuilder::new().num_threads(20).build().unwrap();
pool.scope(|scope| {
for run_request_info in run_request_infos {
let _client = client.clone();
let _run_request_info = run_request_info.clone();
let _shared_map = run_request_info.shared_map.clone();
let _test_group_run_result = test_group_run_result.clone();
scope.spawn(move |_| {
let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap();
runtime.block_on(async {
let result = Self::send_rest_with_script_async(
_run_request_info,
_client,
_shared_map,
).await;
_test_group_run_result.write().unwrap().add_result(result);
});
})
}
});
}
pub fn get_test_group_jobs(
envs: BTreeMap<String, EnvironmentItemValue>,
Expand Down

0 comments on commit a5ad443

Please sign in to comment.