Fix progress display in parallel mode.

This commit is contained in:
jcamiel 2024-04-08 17:42:23 +02:00
parent 5123035fd9
commit fedc64c873
No known key found for this signature in database
GPG Key ID: 07FF11CFD55356CC
6 changed files with 46 additions and 2 deletions

View File

@ -0,0 +1,13 @@
tests_ok/parallel_a.hurl: Success (1 request(s) in ~~~ ms)
tests_ok/parallel_b.hurl: Success (1 request(s) in ~~~ ms)
tests_ok/parallel_c.hurl: Success (1 request(s) in ~~~ ms)
tests_ok/parallel_d.hurl: Success (1 request(s) in ~~~ ms)
tests_ok/parallel_e.hurl: Success (1 request(s) in ~~~ ms)
tests_ok/parallel_f.hurl: Success (1 request(s) in ~~~ ms)
tests_ok/parallel_g.hurl: Success (1 request(s) in ~~~ ms)
--------------------------------------------------------------------------------
Executed files: 7
Succeeded files: 7 (100.0%)
Failed files: 0 (0.0%)
Duration: ~~~ ms

View File

@ -0,0 +1,7 @@
{"cookies":[],"entries":[{"asserts":[{"line":2,"success":true},{"line":2,"success":true},{"line":3,"success":true}],"calls":[{"request":{"cookies":[],"headers":[{"name":"Host","value":"localhost:8000"},{"name":"Accept","value":"*/*"},{"name":"User-Agent","value":"hurl/~~~"}],"method":"GET","queryString":[{"name":"name","value":"A"}],"url":"http://localhost:8000/parallel/hello?name=A"},"response":{"cookies":[],"headers":[{"name":"Server","value":"Werkzeug/~~~ Python/~~~"},{"name":"Date","value":"~~~"},{"name":"Content-Type","value":"text/html; charset=utf-8"},{"name":"Content-Length","value":"31"},{"name":"Server","value":"Flask Server"},{"name":"Connection","value":"close"}],"httpVersion":"HTTP/1.1","status":200},"timings":{"app_connect":~~~,"begin_call":"~~~","connect":~~~,"end_call":"~~~","name_lookup":~~~,"pre_transfer":~~~,"start_transfer":~~~,"total":~~~}}],"captures":[],"index":1,"line":1,"time":~~~}],"filename":"tests_ok/parallel_a.hurl","success":true,"time":~~~}
{"cookies":[],"entries":[{"asserts":[{"line":2,"success":true},{"line":2,"success":true},{"line":3,"success":true}],"calls":[{"request":{"cookies":[],"headers":[{"name":"Host","value":"localhost:8000"},{"name":"Accept","value":"*/*"},{"name":"User-Agent","value":"hurl/~~~"}],"method":"GET","queryString":[{"name":"name","value":"B"}],"url":"http://localhost:8000/parallel/hello?name=B"},"response":{"cookies":[],"headers":[{"name":"Server","value":"Werkzeug/~~~ Python/~~~"},{"name":"Date","value":"~~~"},{"name":"Content-Type","value":"text/html; charset=utf-8"},{"name":"Content-Length","value":"31"},{"name":"Server","value":"Flask Server"},{"name":"Connection","value":"close"}],"httpVersion":"HTTP/1.1","status":200},"timings":{"app_connect":~~~,"begin_call":"~~~","connect":~~~,"end_call":"~~~","name_lookup":~~~,"pre_transfer":~~~,"start_transfer":~~~,"total":~~~}}],"captures":[],"index":1,"line":1,"time":~~~}],"filename":"tests_ok/parallel_b.hurl","success":true,"time":~~~}
{"cookies":[],"entries":[{"asserts":[{"line":2,"success":true},{"line":2,"success":true},{"line":3,"success":true}],"calls":[{"request":{"cookies":[],"headers":[{"name":"Host","value":"localhost:8000"},{"name":"Accept","value":"*/*"},{"name":"User-Agent","value":"hurl/~~~"}],"method":"GET","queryString":[{"name":"name","value":"C"}],"url":"http://localhost:8000/parallel/hello?name=C"},"response":{"cookies":[],"headers":[{"name":"Server","value":"Werkzeug/~~~ Python/~~~"},{"name":"Date","value":"~~~"},{"name":"Content-Type","value":"text/html; charset=utf-8"},{"name":"Content-Length","value":"31"},{"name":"Server","value":"Flask Server"},{"name":"Connection","value":"close"}],"httpVersion":"HTTP/1.1","status":200},"timings":{"app_connect":~~~,"begin_call":"~~~","connect":~~~,"end_call":"~~~","name_lookup":~~~,"pre_transfer":~~~,"start_transfer":~~~,"total":~~~}}],"captures":[],"index":1,"line":1,"time":~~~}],"filename":"tests_ok/parallel_c.hurl","success":true,"time":~~~}
{"cookies":[],"entries":[{"asserts":[{"line":2,"success":true},{"line":2,"success":true},{"line":3,"success":true}],"calls":[{"request":{"cookies":[],"headers":[{"name":"Host","value":"localhost:8000"},{"name":"Accept","value":"*/*"},{"name":"User-Agent","value":"hurl/~~~"}],"method":"GET","queryString":[{"name":"name","value":"D"}],"url":"http://localhost:8000/parallel/hello?name=D"},"response":{"cookies":[],"headers":[{"name":"Server","value":"Werkzeug/~~~ Python/~~~"},{"name":"Date","value":"~~~"},{"name":"Content-Type","value":"text/html; charset=utf-8"},{"name":"Content-Length","value":"31"},{"name":"Server","value":"Flask Server"},{"name":"Connection","value":"close"}],"httpVersion":"HTTP/1.1","status":200},"timings":{"app_connect":~~~,"begin_call":"~~~","connect":~~~,"end_call":"~~~","name_lookup":~~~,"pre_transfer":~~~,"start_transfer":~~~,"total":~~~}}],"captures":[],"index":1,"line":1,"time":~~~}],"filename":"tests_ok/parallel_d.hurl","success":true,"time":~~~}
{"cookies":[],"entries":[{"asserts":[{"line":2,"success":true},{"line":2,"success":true},{"line":3,"success":true}],"calls":[{"request":{"cookies":[],"headers":[{"name":"Host","value":"localhost:8000"},{"name":"Accept","value":"*/*"},{"name":"User-Agent","value":"hurl/~~~"}],"method":"GET","queryString":[{"name":"name","value":"E"}],"url":"http://localhost:8000/parallel/hello?name=E"},"response":{"cookies":[],"headers":[{"name":"Server","value":"Werkzeug/~~~ Python/~~~"},{"name":"Date","value":"~~~"},{"name":"Content-Type","value":"text/html; charset=utf-8"},{"name":"Content-Length","value":"31"},{"name":"Server","value":"Flask Server"},{"name":"Connection","value":"close"}],"httpVersion":"HTTP/1.1","status":200},"timings":{"app_connect":~~~,"begin_call":"~~~","connect":~~~,"end_call":"~~~","name_lookup":~~~,"pre_transfer":~~~,"start_transfer":~~~,"total":~~~}}],"captures":[],"index":1,"line":1,"time":~~~}],"filename":"tests_ok/parallel_e.hurl","success":true,"time":~~~}
{"cookies":[],"entries":[{"asserts":[{"line":2,"success":true},{"line":2,"success":true},{"line":3,"success":true}],"calls":[{"request":{"cookies":[],"headers":[{"name":"Host","value":"localhost:8000"},{"name":"Accept","value":"*/*"},{"name":"User-Agent","value":"hurl/~~~"}],"method":"GET","queryString":[{"name":"name","value":"F"}],"url":"http://localhost:8000/parallel/hello?name=F"},"response":{"cookies":[],"headers":[{"name":"Server","value":"Werkzeug/~~~ Python/~~~"},{"name":"Date","value":"~~~"},{"name":"Content-Type","value":"text/html; charset=utf-8"},{"name":"Content-Length","value":"31"},{"name":"Server","value":"Flask Server"},{"name":"Connection","value":"close"}],"httpVersion":"HTTP/1.1","status":200},"timings":{"app_connect":~~~,"begin_call":"~~~","connect":~~~,"end_call":"~~~","name_lookup":~~~,"pre_transfer":~~~,"start_transfer":~~~,"total":~~~}}],"captures":[],"index":1,"line":1,"time":~~~}],"filename":"tests_ok/parallel_f.hurl","success":true,"time":~~~}
{"cookies":[],"entries":[{"asserts":[{"line":2,"success":true},{"line":2,"success":true},{"line":3,"success":true}],"calls":[{"request":{"cookies":[],"headers":[{"name":"Host","value":"localhost:8000"},{"name":"Accept","value":"*/*"},{"name":"User-Agent","value":"hurl/~~~"}],"method":"GET","queryString":[{"name":"name","value":"G"}],"url":"http://localhost:8000/parallel/hello?name=G"},"response":{"cookies":[],"headers":[{"name":"Server","value":"Werkzeug/~~~ Python/~~~"},{"name":"Date","value":"~~~"},{"name":"Content-Type","value":"text/html; charset=utf-8"},{"name":"Content-Length","value":"31"},{"name":"Server","value":"Flask Server"},{"name":"Connection","value":"close"}],"httpVersion":"HTTP/1.1","status":200},"timings":{"app_connect":~~~,"begin_call":"~~~","connect":~~~,"end_call":"~~~","name_lookup":~~~,"pre_transfer":~~~,"start_transfer":~~~,"total":~~~}}],"captures":[],"index":1,"line":1,"time":~~~}],"filename":"tests_ok/parallel_g.hurl","success":true,"time":~~~}

View File

@ -0,0 +1,11 @@
Set-StrictMode -Version latest
$ErrorActionPreference = 'Stop'
hurl --test --json --parallel --jobs 1 `
tests_ok/parallel_a.hurl `
tests_ok/parallel_b.hurl `
tests_ok/parallel_c.hurl `
tests_ok/parallel_d.hurl `
tests_ok/parallel_e.hurl `
tests_ok/parallel_f.hurl `
tests_ok/parallel_g.hurl

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -Eeuo pipefail
hurl --test --json --parallel --jobs 1 \
tests_ok/parallel_a.hurl \
tests_ok/parallel_b.hurl \
tests_ok/parallel_c.hurl \
tests_ok/parallel_d.hurl \
tests_ok/parallel_e.hurl \
tests_ok/parallel_f.hurl \
tests_ok/parallel_g.hurl

View File

@ -81,7 +81,6 @@ impl ParProgress {
.filter(|(_, state)| matches!(state, WorkerState::Running { .. }))
.collect::<Vec<_>>();
if workers.is_empty() {
stderr.clear_progress_bar();
return;
}
@ -146,7 +145,6 @@ impl ParProgress {
));
}
stderr.clear_progress_bar();
stderr.set_progress_bar(&all_progress);
}

View File

@ -179,6 +179,8 @@ impl ParallelRunner {
}
// Everything is OK, we report the progress
WorkerMessage::Running(msg) => {
self.progress.clear_progress_bar(&mut stderr);
self.workers[msg.worker_id.0].1 = WorkerState::Running {
job: msg.job,
entry_index: msg.entry_index,
@ -194,6 +196,8 @@ impl ParallelRunner {
}
// A new job has been completed, we take a new job if the queue is not empty.
WorkerMessage::Completed(msg) => {
self.progress.clear_progress_bar(&mut stderr);
// The worker is becoming idle.
self.workers[msg.worker_id.0].1 = WorkerState::Idle;