mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-09-11 05:35:53 +03:00
Fix parallel integration tests.
This commit is contained in:
parent
bf472937f9
commit
59f785974f
@ -44,6 +44,7 @@ _hurl() {
|
|||||||
'--interactive[Turn on interactive mode]' \
|
'--interactive[Turn on interactive mode]' \
|
||||||
'(-4 --ipv4)'{-4,--ipv4}'[Tell Hurl to use IPv4 addresses only when resolving host names, and not for example try IPv6]' \
|
'(-4 --ipv4)'{-4,--ipv4}'[Tell Hurl to use IPv4 addresses only when resolving host names, and not for example try IPv6]' \
|
||||||
'(-6 --ipv6)'{-6,--ipv6}'[Tell Hurl to use IPv6 addresses only when resolving host names, and not for example try IPv4]' \
|
'(-6 --ipv6)'{-6,--ipv6}'[Tell Hurl to use IPv6 addresses only when resolving host names, and not for example try IPv4]' \
|
||||||
|
'--jobs[(Experimental) Maximum number of parallel jobs]: :' \
|
||||||
'--json[Output each Hurl file result to JSON]' \
|
'--json[Output each Hurl file result to JSON]' \
|
||||||
'--max-redirs[Maximum number of redirects allowed, -1 for unlimited redirects]: :' \
|
'--max-redirs[Maximum number of redirects allowed, -1 for unlimited redirects]: :' \
|
||||||
'(-m --max-time)'{-m,--max-time}'[Maximum time allowed for the transfer]: :' \
|
'(-m --max-time)'{-m,--max-time}'[Maximum time allowed for the transfer]: :' \
|
||||||
@ -73,7 +74,6 @@ _hurl() {
|
|||||||
'*--variables-file[Define a properties file in which you define your variables]: :_files' \
|
'*--variables-file[Define a properties file in which you define your variables]: :_files' \
|
||||||
'(-v --verbose)'{-v,--verbose}'[Turn on verbose]' \
|
'(-v --verbose)'{-v,--verbose}'[Turn on verbose]' \
|
||||||
'--very-verbose[Turn on verbose output, including HTTP response and libcurl logs]' \
|
'--very-verbose[Turn on verbose output, including HTTP response and libcurl logs]' \
|
||||||
'--workers[(Experimental) Maximum number of parallel execution]: :' \
|
|
||||||
'--help[Print help]' \
|
'--help[Print help]' \
|
||||||
'--version[Print version]' \
|
'--version[Print version]' \
|
||||||
'*:file:_files' \
|
'*:file:_files' \
|
||||||
|
@ -49,6 +49,7 @@ Register-ArgumentCompleter -Native -CommandName 'hurl' -ScriptBlock {
|
|||||||
[CompletionResult]::new('--interactive', 'interactive', [CompletionResultType]::ParameterName, 'Turn on interactive mode')
|
[CompletionResult]::new('--interactive', 'interactive', [CompletionResultType]::ParameterName, 'Turn on interactive mode')
|
||||||
[CompletionResult]::new('--ipv4', 'ipv4', [CompletionResultType]::ParameterName, 'Tell Hurl to use IPv4 addresses only when resolving host names, and not for example try IPv6')
|
[CompletionResult]::new('--ipv4', 'ipv4', [CompletionResultType]::ParameterName, 'Tell Hurl to use IPv4 addresses only when resolving host names, and not for example try IPv6')
|
||||||
[CompletionResult]::new('--ipv6', 'ipv6', [CompletionResultType]::ParameterName, 'Tell Hurl to use IPv6 addresses only when resolving host names, and not for example try IPv4')
|
[CompletionResult]::new('--ipv6', 'ipv6', [CompletionResultType]::ParameterName, 'Tell Hurl to use IPv6 addresses only when resolving host names, and not for example try IPv4')
|
||||||
|
[CompletionResult]::new('--jobs', 'jobs', [CompletionResultType]::ParameterName, '(Experimental) Maximum number of parallel jobs')
|
||||||
[CompletionResult]::new('--json', 'json', [CompletionResultType]::ParameterName, 'Output each Hurl file result to JSON')
|
[CompletionResult]::new('--json', 'json', [CompletionResultType]::ParameterName, 'Output each Hurl file result to JSON')
|
||||||
[CompletionResult]::new('--max-redirs', 'max-redirs', [CompletionResultType]::ParameterName, 'Maximum number of redirects allowed, -1 for unlimited redirects')
|
[CompletionResult]::new('--max-redirs', 'max-redirs', [CompletionResultType]::ParameterName, 'Maximum number of redirects allowed, -1 for unlimited redirects')
|
||||||
[CompletionResult]::new('--max-time', 'max-time', [CompletionResultType]::ParameterName, 'Maximum time allowed for the transfer')
|
[CompletionResult]::new('--max-time', 'max-time', [CompletionResultType]::ParameterName, 'Maximum time allowed for the transfer')
|
||||||
@ -78,7 +79,6 @@ Register-ArgumentCompleter -Native -CommandName 'hurl' -ScriptBlock {
|
|||||||
[CompletionResult]::new('--variables-file', 'variables-file', [CompletionResultType]::ParameterName, 'Define a properties file in which you define your variables')
|
[CompletionResult]::new('--variables-file', 'variables-file', [CompletionResultType]::ParameterName, 'Define a properties file in which you define your variables')
|
||||||
[CompletionResult]::new('--verbose', 'verbose', [CompletionResultType]::ParameterName, 'Turn on verbose')
|
[CompletionResult]::new('--verbose', 'verbose', [CompletionResultType]::ParameterName, 'Turn on verbose')
|
||||||
[CompletionResult]::new('--very-verbose', 'very-verbose', [CompletionResultType]::ParameterName, 'Turn on verbose output, including HTTP response and libcurl logs')
|
[CompletionResult]::new('--very-verbose', 'very-verbose', [CompletionResultType]::ParameterName, 'Turn on verbose output, including HTTP response and libcurl logs')
|
||||||
[CompletionResult]::new('--workers', 'workers', [CompletionResultType]::ParameterName, '(Experimental) Maximum number of parallel execution')
|
|
||||||
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
|
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
|
||||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
|
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
|
||||||
break
|
break
|
||||||
|
@ -5,7 +5,7 @@ _hurl()
|
|||||||
_init_completion || return
|
_init_completion || return
|
||||||
|
|
||||||
if [[ $cur == -* ]]; then
|
if [[ $cur == -* ]]; then
|
||||||
COMPREPLY=($(compgen -W '--aws-sigv4 --cacert --cert --key --color --compressed --connect-timeout --connect-to --continue-on-error --cookie --cookie-jar --delay --error-format --fail-at-end --file-root --location --location-trusted --from-entry --glob --http1.0 --http1.1 --http2 --http3 --ignore-asserts --include --insecure --interactive --ipv4 --ipv6 --json --max-redirs --max-time --netrc --netrc-file --netrc-optional --no-color --no-output --noproxy --output --parallel --path-as-is --proxy --report-html --report-junit --report-tap --resolve --retry --retry-interval --ssl-no-revoke --test --to-entry --unix-socket --user --user-agent --variable --variables-file --verbose --very-verbose --workers --help --version' -- "$cur"))
|
COMPREPLY=($(compgen -W '--aws-sigv4 --cacert --cert --key --color --compressed --connect-timeout --connect-to --continue-on-error --cookie --cookie-jar --delay --error-format --fail-at-end --file-root --location --location-trusted --from-entry --glob --http1.0 --http1.1 --http2 --http3 --ignore-asserts --include --insecure --interactive --ipv4 --ipv6 --jobs --json --max-redirs --max-time --netrc --netrc-file --netrc-optional --no-color --no-output --noproxy --output --parallel --path-as-is --proxy --report-html --report-junit --report-tap --resolve --retry --retry-interval --ssl-no-revoke --test --to-entry --unix-socket --user --user-agent --variable --variables-file --verbose --very-verbose --help --version' -- "$cur"))
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ complete -c hurl -l insecure -d 'Allow insecure SSL connections'
|
|||||||
complete -c hurl -l interactive -d 'Turn on interactive mode'
|
complete -c hurl -l interactive -d 'Turn on interactive mode'
|
||||||
complete -c hurl -l ipv4 -d 'Tell Hurl to use IPv4 addresses only when resolving host names, and not for example try IPv6'
|
complete -c hurl -l ipv4 -d 'Tell Hurl to use IPv4 addresses only when resolving host names, and not for example try IPv6'
|
||||||
complete -c hurl -l ipv6 -d 'Tell Hurl to use IPv6 addresses only when resolving host names, and not for example try IPv4'
|
complete -c hurl -l ipv6 -d 'Tell Hurl to use IPv6 addresses only when resolving host names, and not for example try IPv4'
|
||||||
|
complete -c hurl -l jobs -d '(Experimental) Maximum number of parallel jobs'
|
||||||
complete -c hurl -l json -d 'Output each Hurl file result to JSON'
|
complete -c hurl -l json -d 'Output each Hurl file result to JSON'
|
||||||
complete -c hurl -l max-redirs -d 'Maximum number of redirects allowed, -1 for unlimited redirects'
|
complete -c hurl -l max-redirs -d 'Maximum number of redirects allowed, -1 for unlimited redirects'
|
||||||
complete -c hurl -l max-time -d 'Maximum time allowed for the transfer'
|
complete -c hurl -l max-time -d 'Maximum time allowed for the transfer'
|
||||||
@ -56,7 +57,6 @@ complete -c hurl -l variable -d 'Define a variable'
|
|||||||
complete -c hurl -l variables-file -d 'Define a properties file in which you define your variables'
|
complete -c hurl -l variables-file -d 'Define a properties file in which you define your variables'
|
||||||
complete -c hurl -l verbose -d 'Turn on verbose'
|
complete -c hurl -l verbose -d 'Turn on verbose'
|
||||||
complete -c hurl -l very-verbose -d 'Turn on verbose output, including HTTP response and libcurl logs'
|
complete -c hurl -l very-verbose -d 'Turn on verbose output, including HTTP response and libcurl logs'
|
||||||
complete -c hurl -l workers -d '(Experimental) Maximum number of parallel execution'
|
|
||||||
complete -c hurl -l help -d 'Print help'
|
complete -c hurl -l help -d 'Print help'
|
||||||
complete -c hurl -l version -d 'Print version'
|
complete -c hurl -l version -d 'Print version'
|
||||||
|
|
||||||
|
12
docs/spec/options/hurl/jobs.option
Normal file
12
docs/spec/options/hurl/jobs.option
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
name: jobs
|
||||||
|
long: jobs
|
||||||
|
value: NUM
|
||||||
|
value_parser: clap::value_parser!(u32).range(1..)
|
||||||
|
help: (Experimental) Maximum number of parallel jobs
|
||||||
|
cli_only: true
|
||||||
|
experimental: true
|
||||||
|
---
|
||||||
|
(Experimental) Maximum number of parallel jobs in parallel mode. Default value corresponds (in most cases) to the
|
||||||
|
current amount of CPUs.
|
||||||
|
|
||||||
|
See also [`--parallel`](#parallel).
|
@ -1,12 +0,0 @@
|
|||||||
name: workers
|
|
||||||
long: workers
|
|
||||||
value: NUM
|
|
||||||
value_parser: clap::value_parser!(u32).range(1..)
|
|
||||||
help: (Experimental) Maximum number of parallel execution
|
|
||||||
cli_only: true
|
|
||||||
experimental: true
|
|
||||||
---
|
|
||||||
(Experimental) Maximum number of parallel execution in parallel mode. Default value corresponds (in most cases) to the
|
|
||||||
current amount of CPUs.
|
|
||||||
|
|
||||||
See also [`--parallel`](#parallel).
|
|
@ -1,4 +1,4 @@
|
|||||||
* Parallel run using ~~~ workers
|
* Parallel run using 4 workers
|
||||||
* Variables:
|
* Variables:
|
||||||
* name: Bob
|
* name: Bob
|
||||||
* ------------------------------------------------------------------------------
|
* ------------------------------------------------------------------------------
|
||||||
|
@ -6,7 +6,7 @@ $ErrorActionPreference = 'Stop'
|
|||||||
|
|
||||||
$Start = [DateTimeOffset]::Now.ToUnixTimeSeconds()
|
$Start = [DateTimeOffset]::Now.ToUnixTimeSeconds()
|
||||||
|
|
||||||
hurl --parallel --verbose --variable name=Bob `
|
hurl --parallel --jobs 4 --verbose --variable name=Bob `
|
||||||
tests_ok/parallel.hurl `
|
tests_ok/parallel.hurl `
|
||||||
tests_ok/parallel.hurl `
|
tests_ok/parallel.hurl `
|
||||||
tests_ok/parallel.hurl `
|
tests_ok/parallel.hurl `
|
||||||
|
@ -7,7 +7,7 @@ rm -f build/parallel.tap
|
|||||||
|
|
||||||
start=$(date +%s)
|
start=$(date +%s)
|
||||||
|
|
||||||
hurl --parallel --verbose --variable name=Bob \
|
hurl --parallel --jobs 4 --verbose --variable name=Bob \
|
||||||
tests_ok/parallel.hurl \
|
tests_ok/parallel.hurl \
|
||||||
tests_ok/parallel.hurl \
|
tests_ok/parallel.hurl \
|
||||||
tests_ok/parallel.hurl \
|
tests_ok/parallel.hurl \
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
Set-StrictMode -Version latest
|
Set-StrictMode -Version latest
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
hurl --parallel --workers 1 `
|
hurl --parallel --jobs 1 `
|
||||||
tests_ok/parallel_a.hurl `
|
tests_ok/parallel_a.hurl `
|
||||||
tests_ok/parallel_b.hurl `
|
tests_ok/parallel_b.hurl `
|
||||||
tests_ok/parallel_c.hurl `
|
tests_ok/parallel_c.hurl `
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
|
||||||
hurl --parallel --workers 1 \
|
hurl --parallel --jobs 1 \
|
||||||
tests_ok/parallel_a.hurl \
|
tests_ok/parallel_a.hurl \
|
||||||
tests_ok/parallel_b.hurl \
|
tests_ok/parallel_b.hurl \
|
||||||
tests_ok/parallel_c.hurl \
|
tests_ok/parallel_c.hurl \
|
||||||
|
@ -264,6 +264,16 @@ pub fn ipv6() -> clap::Arg {
|
|||||||
.action(clap::ArgAction::SetTrue)
|
.action(clap::ArgAction::SetTrue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn jobs() -> clap::Arg {
|
||||||
|
clap::Arg::new("jobs")
|
||||||
|
.long("jobs")
|
||||||
|
.value_name("NUM")
|
||||||
|
.value_parser(clap::value_parser!(u32).range(1..))
|
||||||
|
.help("(Experimental) Maximum number of parallel jobs")
|
||||||
|
.num_args(1)
|
||||||
|
.hide(true)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn json() -> clap::Arg {
|
pub fn json() -> clap::Arg {
|
||||||
clap::Arg::new("json")
|
clap::Arg::new("json")
|
||||||
.long("json")
|
.long("json")
|
||||||
@ -514,13 +524,3 @@ pub fn very_verbose() -> clap::Arg {
|
|||||||
.help("Turn on verbose output, including HTTP response and libcurl logs")
|
.help("Turn on verbose output, including HTTP response and libcurl logs")
|
||||||
.action(clap::ArgAction::SetTrue)
|
.action(clap::ArgAction::SetTrue)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn workers() -> clap::Arg {
|
|
||||||
clap::Arg::new("workers")
|
|
||||||
.long("workers")
|
|
||||||
.value_name("NUM")
|
|
||||||
.value_parser(clap::value_parser!(u32).range(1..))
|
|
||||||
.help("(Experimental) Maximum number of parallel execution")
|
|
||||||
.num_args(1)
|
|
||||||
.hide(true)
|
|
||||||
}
|
|
||||||
|
@ -250,8 +250,8 @@ pub fn max_redirect(arg_matches: &ArgMatches) -> Option<usize> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn workers(arg_matches: &ArgMatches) -> Option<usize> {
|
pub fn jobs(arg_matches: &ArgMatches) -> Option<usize> {
|
||||||
get::<u32>(arg_matches, "workers").map(|m| m as usize)
|
get::<u32>(arg_matches, "jobs").map(|m| m as usize)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn netrc(arg_matches: &ArgMatches) -> bool {
|
pub fn netrc(arg_matches: &ArgMatches) -> bool {
|
||||||
|
@ -65,6 +65,7 @@ pub struct CliOptions {
|
|||||||
pub insecure: bool,
|
pub insecure: bool,
|
||||||
pub interactive: bool,
|
pub interactive: bool,
|
||||||
pub ip_resolve: Option<IpResolve>,
|
pub ip_resolve: Option<IpResolve>,
|
||||||
|
pub jobs: Option<usize>,
|
||||||
pub junit_file: Option<PathBuf>,
|
pub junit_file: Option<PathBuf>,
|
||||||
pub max_redirect: Option<usize>,
|
pub max_redirect: Option<usize>,
|
||||||
pub netrc: bool,
|
pub netrc: bool,
|
||||||
@ -91,7 +92,6 @@ pub struct CliOptions {
|
|||||||
pub variables: HashMap<String, Value>,
|
pub variables: HashMap<String, Value>,
|
||||||
pub verbose: bool,
|
pub verbose: bool,
|
||||||
pub very_verbose: bool,
|
pub very_verbose: bool,
|
||||||
pub workers: Option<usize>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
@ -189,6 +189,7 @@ pub fn parse() -> Result<CliOptions, CliOptionsError> {
|
|||||||
.arg(commands::interactive())
|
.arg(commands::interactive())
|
||||||
.arg(commands::ipv4())
|
.arg(commands::ipv4())
|
||||||
.arg(commands::ipv6())
|
.arg(commands::ipv6())
|
||||||
|
.arg(commands::jobs())
|
||||||
.arg(commands::json())
|
.arg(commands::json())
|
||||||
.arg(commands::max_redirects())
|
.arg(commands::max_redirects())
|
||||||
.arg(commands::max_time())
|
.arg(commands::max_time())
|
||||||
@ -217,8 +218,7 @@ pub fn parse() -> Result<CliOptions, CliOptionsError> {
|
|||||||
.arg(commands::variable())
|
.arg(commands::variable())
|
||||||
.arg(commands::variables_file())
|
.arg(commands::variables_file())
|
||||||
.arg(commands::verbose())
|
.arg(commands::verbose())
|
||||||
.arg(commands::very_verbose())
|
.arg(commands::very_verbose());
|
||||||
.arg(commands::workers());
|
|
||||||
|
|
||||||
let arg_matches = command.try_get_matches_from_mut(env::args_os())?;
|
let arg_matches = command.try_get_matches_from_mut(env::args_os())?;
|
||||||
let opts = parse_matches(&arg_matches)?;
|
let opts = parse_matches(&arg_matches)?;
|
||||||
@ -289,7 +289,7 @@ fn parse_matches(arg_matches: &ArgMatches) -> Result<CliOptions, CliOptionsError
|
|||||||
let variables = matches::variables(arg_matches)?;
|
let variables = matches::variables(arg_matches)?;
|
||||||
let verbose = matches::verbose(arg_matches);
|
let verbose = matches::verbose(arg_matches);
|
||||||
let very_verbose = matches::very_verbose(arg_matches);
|
let very_verbose = matches::very_verbose(arg_matches);
|
||||||
let workers = matches::workers(arg_matches);
|
let workers = matches::jobs(arg_matches);
|
||||||
Ok(CliOptions {
|
Ok(CliOptions {
|
||||||
aws_sigv4,
|
aws_sigv4,
|
||||||
cacert_file,
|
cacert_file,
|
||||||
@ -342,7 +342,7 @@ fn parse_matches(arg_matches: &ArgMatches) -> Result<CliOptions, CliOptionsError
|
|||||||
variables,
|
variables,
|
||||||
verbose,
|
verbose,
|
||||||
very_verbose,
|
very_verbose,
|
||||||
workers,
|
jobs: workers,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,10 +82,10 @@ fn main() {
|
|||||||
EXIT_ERROR_UNDEFINED,
|
EXIT_ERROR_UNDEFINED,
|
||||||
&base_logger,
|
&base_logger,
|
||||||
);
|
);
|
||||||
let workers = opts.workers.unwrap_or(available.get());
|
let workers_count = opts.jobs.unwrap_or(available.get());
|
||||||
base_logger.debug(&format!("Parallel run using {workers} workers"));
|
base_logger.debug(&format!("Parallel run using {workers_count} workers"));
|
||||||
|
|
||||||
run::run_par(&opts.input_files, current_dir, &opts, workers)
|
run::run_par(&opts.input_files, current_dir, &opts, workers_count)
|
||||||
} else {
|
} else {
|
||||||
run::run_seq(&opts.input_files, current_dir, &opts)
|
run::run_seq(&opts.input_files, current_dir, &opts)
|
||||||
};
|
};
|
||||||
|
@ -125,9 +125,9 @@ pub fn run_par(
|
|||||||
files: &[Input],
|
files: &[Input],
|
||||||
current_dir: &Path,
|
current_dir: &Path,
|
||||||
options: &CliOptions,
|
options: &CliOptions,
|
||||||
workers: usize,
|
workers_count: usize,
|
||||||
) -> Result<Vec<HurlRun>, CliError> {
|
) -> Result<Vec<HurlRun>, CliError> {
|
||||||
let workers_count = min(files.len(), workers);
|
let workers_count = min(files.len(), workers_count);
|
||||||
let variables = &options.variables;
|
let variables = &options.variables;
|
||||||
let output_type = options
|
let output_type = options
|
||||||
.output_type
|
.output_type
|
||||||
|
Loading…
Reference in New Issue
Block a user