Skip to content

Commit

Permalink
Merge pull request #235 from hatoo/rand-url
Browse files Browse the repository at this point in the history
Support dynamic URL
  • Loading branch information
hatoo authored Jun 24, 2023
2 parents 0421303 + c0b9b65 commit 4c821b9
Show file tree
Hide file tree
Showing 9 changed files with 216 additions and 50 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
rust: [stable, beta, nightly]
additional_args: ["", "--no-default-features --features rustls"]
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
Expand All @@ -20,6 +21,7 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: check
args: ${{ matrix.additional_args }}

test:
name: Test Suite
Expand All @@ -28,6 +30,7 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
rust: [stable, beta, nightly]
additional_args: ["", "--no-default-features --features rustls"]
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
Expand All @@ -38,6 +41,7 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: test
args: ${{ matrix.additional_args }}

fmt:
name: Rustfmt
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

- Support randomly generated URL using rand_regex crate

# 0.5.9 (2023-06-12)

- Fix -H Header parser
Expand Down
18 changes: 18 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ base64 = "0.21.0"
lazy_static = "1.4.0"
rand = "0.8"
trust-dns-resolver = "0.22.0"
rand_regex = "0.15.1"
regex-syntax = "0.6.22"

[target.'cfg(unix)'.dependencies]
rlimit = "0.9.0"
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ Options:
-z <DURATION> Duration of application to send requests. If duration is specified, n is ignored.
Examples: -z 10s -z 3m.
-q <QUERY_PER_SECOND> Rate limit for all, in queries per second (QPS)
--rand-regex-url Generate URL by rand_regex crate but dot is disabled for each query e.g. http://127.0.0.1/[a-z][a-z][0-9]. See https://docs.rs/rand_regex/latest/rand_regex/struct.Regex.html for details of syntax.
--max-repeat <MAX_REPEAT> A parameter for the '--rand-regex-url'. The max_repeat parameter gives the maximum extra repeat counts the x*, x+ and x{n,} operators will become. [default: 4]
--latency-correction Correct latency to avoid coordinated omission problem. It's ignored if -q is not set.
--no-tui No realtime tui
-j, --json Print results as JSON
Expand Down Expand Up @@ -107,6 +109,20 @@ oha <-z or -n> -c <number of concurrent connections> -q <query per seconds> --la

You can avoid `Coordinated Omission Problem` by using `--latency-correction`.

## Dynamic url feature

You can use `--rand-regex-url` option to generate random url for each connection.

```sh
oha --rand-regex-url http://127.0.0.1/[a-z][a-z][0-9]
```

Each Urls are generated by [rand_regex](https://github.com/kennytm/rand_regex) crate but regex's dot is disabled since it's not useful for this purpose and it's very incovenient if url's dots are interpreted as regex's dot.
Optionaly you can set `--max-repeat` option to limit max repeat count for each regex. e.g http://127.0.0.1/[a-z]* with `--max-repeat 4` will generate url like http://127.0.0.1/[a-z]{0,4}
If keep-alive is enabled, path and query are generated for each request but shceme, host and port are fixed during connection.
# Contribution
Feel free to help us!
Expand Down
Loading

0 comments on commit 4c821b9

Please sign in to comment.