Skip to content

Commit

Permalink
Add Hurl 4.3.0 announcement.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcamiel committed Apr 24, 2024
1 parent 7570c02 commit caa86d4
Show file tree
Hide file tree
Showing 16 changed files with 312 additions and 1 deletion.
1 change: 1 addition & 0 deletions sites/highlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def shell_to_html(snippet: str) -> str:
output = output.replace("\x1B[32m", '<span class="green">')
output = output.replace("\x1B[34m", '<span class="blue">')
output = output.replace("\x1B[35m", '<span class="magenta">')
output = output.replace("\x1B[90m", '<span class="gray">')
output = output.replace("\x1B[1;36m", '<span class="bright-cyan">')
output = output.replace("\x1B[1;31m", '<span class="bright-red">')
output = output.replace("\x1B[1;32m", '<span class="bright-green">')
Expand Down
303 changes: 303 additions & 0 deletions sites/hurl.dev/_posts/2024-04-24-announcing-hurl-4.3.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,303 @@
---
title: Announcing Hurl 4.3.0
layout: blog
section: Blog
permalink: /blog/:year/:month/:day/:title.html
---

# {{ page.title }}

<div class="blog-post-date">{{ page.date | date: "%b. %d, %Y" }}</div>

The Hurl team is thrilled to announce [Hurl 4.3.0] <picture><source srcset="{{ '/assets/img/emoji-surfer.avif' | prepend:site.baseurl }}" type="image/avif"><source srcset="{{ '/assets/img/emoji-surfer.webp' | prepend:site.baseurl }}" type="image/webp"><source srcset="{{ '/assets/img/emoji-surfer.png' | prepend:site.baseurl }}" type="image/png"><img class="emoji" src="{{ '/assets/img/emoji-surfer.png' | prepend:site.baseurl }}" width="20" height="20" alt="Surfer"></picture> !

[Hurl] is a command line tool powered by [curl], that runs HTTP requests defined in a simple plain text format:

```hurl
GET https://example.org/api/tests/4567
HTTP 200
[Asserts]
header "x-foo" contains "bar"
certificate "Expire-Date" daysAfterNow > 15
jsonpath "$.status" == "RUNNING" # Check the status code
jsonpath "$.tests" count == 25 # Check the number of items
jsonpath "$.id" matches /\d{4}/ # Check the format of the id
```

## What’s New in This Release

- [Quality of Life Improvements](#quality-of-life-improvements)
- [Shell Completion](#shell-completion)
- [One More Thing...](#one-more-thing)
- [Others](#others)

## Quality of Life Improvements

Hurl 4.3.0 is about bringing various __quality of life improvements__. Nothing fancy, but Hurl keeps iterating,
improving and increasing usefulness on each new release.


### Error display

{% comment %}
Speak of --error-format long
{% endcomment %}

Errors display have been slightly improved, with the request line displayed to give context without having to look in
the Hurl source file.

Before 4.3.0:

{% raw %}
```shell
error: Undefined variable
--> tests_ok/post_file.hurl:6:8
 |
 6 | file,{{filename}};
 | ^^^^^^^^ you must set the variable filename
 |
```
{% endraw %}
With 4.3.0:
{% raw %}
```shell
error: Undefined variable
--> tests_ok/post_file.hurl:6:8
 |
 | POST http://localhost:8000/post-file
 | ...
 6 | file,{{filename}};
 | ^^^^^^^^ you must set the variable filename
 |
```
{% endraw %}
### --netrc, --netrc-file, --netrc-optional
Like its HTTP engine [curl], Hurl supports now the classic `.netrc` file (typically stored in a user's home directory).
With [`--netrc`] option, you can tells Hurl to look for and use the `.netrc` file. [`--netrc-file`] is similar
to `--netrc`, except that you can provide the path to the actual file to use.
```shell
$ hurl --test --netrc-file /home/foo/.netrc *.hurl
```
### Per request --user
Let's keep talking about curl options. Like curl, one can use the command line options [`--user`] to add basic authentication
to all the request of an Hurl file:
```shell
$ hurl --user bob:secret login.hurl
```
`--user` option can now be set _per request_, in an [`[Options]` section]({% link _docs/request.md %}#options) section:
```hurl
# Login with Bob is OK
POST http://foo.com/login
[Options]
user: bob:secret
location: true
HTTP 200
# Login with Alice is KO
POST http://foo.com/login
[Options]
user: alice:secret
location: true
HTTP 401
```
This particular option is useful when using [AWS Signature Version 4]: Amazon S3 authenticated sessions can be set now per
request:
```hurl
GET https://foo.execute-api.us-east-1.amazonas.com/dev/bafe12
[Options]
aws-sigv4: aws:amz:eu-central-1:foo
user: someAccessKeyId:someSecretKey
HTTP 200
```
And, last but not least, `--user` option can use [variables]:
{% raw %}
```hurl
GET https://foo.execute-api.us-east-1.amazonas.com/dev/bafe12
[Options]
aws-sigv4: aws:amz:eu-central-1:foo
user: {{login}}:{{password}}
HTTP 200
```
{% endraw %}
Like many other Hurl option, `--user` option can be used in the command line (take effects for all requests of an Hurl
file), or per request, with an `[Options]` section:
```hurl
GET https://example.org
# An options section, each option is optional and applied only to this request...
[Options]
aws-sigv4: aws:amz:sts # generate AWS SigV4 Authorization header
cacert: /etc/cert.pem # custom certificate file
compressed: true # request a compressed response
delay: 3000 # delay in ms for this request
http3: true # use HTTP/3 protocol version
insecure: true # allow insecure SSL connections and transfers
ipv6: true # use IPv6 addresses
location: true # follow redirection for this request
max-redirs: 10 # maximum number of redirections
output: out.html # dump the response to this file
path-as-is: true # do not handle sequences of /../ or /./ in URL path
skip: false # skip this request
unix-socket: sock # use Unix socket for transfer
user: bob:secret # use basic authentication
variable: country=Italy # define variable country
variable: planet=Earth # define variable planet
verbose: true # allow verbose output
very-verbose: true # allow more verbose output
```
The [options documentation] and the Hurl man page have been improved to show which option can be only use in command line
and which option can be used in command line _and_ in an `[Options]` section. When option can only be used in command line
the option is tagged "cli-only option". For instance:
```
--color
Colorize debug output (the HTTP response output is not colorized).
This is a cli-only option.
```
When "cli-only option" is not specified, the option can be set per request within an [`Options`] section.
### --max-size
One last new option back ported from curl, [`--max-size`] allows to limit the size of HTTP response data:
```shell
$ hurl --max-size 100000 https://example.com/
```
### New Predicates: isNumber, isIsoDate
[Predicates] are used to add check on response:
```hurl
GET http://httpbin.org/json
HTTP 200
[Asserts]
jsonpath "$.slideshow.author" == "Yours Truly"
jsonpath "$.slideshow.slides[0].title" contains "Wonder"
jsonpath "$.slideshow.slides" count == 2
jsonpath "$.slideshow.date" != null
jsonpath "$.slideshow.slides[*].title" includes "Mind Blowing!"
```
Two new predicates are introduced with 4.3.0:
- `isNumber`: a companion to `isInteger` / `isFloat` existing predicates to test if a certain value is a number
- `isIsoDate`: check if a string value conforms to the [RFC-3339] date format `YYYY-MM-DDTHH:mm:sssZ`
```hurl
GET http://httpbin.org/json
HTTP 200
[Asserts]
jsonpath "$.slideshow.version" isNumber
jsonpath "$.slideshow.date" isIsoDate
jsonpath "$.slideshow.date" == "1937-01-01T12:00:27.87+00:20"
```
## Shell Completion
Hurl now offers shell completion scripts for various shell: [bash], [fish], [zsh] and [PowerShell]. Usually, packet
managers package the completion scripts, but you can still install it yourself from [Hurl's GitHub repository].
## One More Thing...
One last thing, and this is a pretty big thing (at least for us <picture><source srcset="{{ '/assets/img/emoji-smiling-face.avif' | prepend:site.baseurl }}" type="image/avif"><source srcset="{{ '/assets/img/emoji-smiling-face.webp' | prepend:site.baseurl }}" type="image/webp"><source srcset="{{ '/assets/img/emoji-smiling-face.png' | prepend:site.baseurl }}" type="image/png"><img class="emoji" src="{{ '/assets/img/emoji-smiling-face.png' | prepend:site.baseurl }}" width="20" height="20" alt="Surfer"></picture>) !
In Hurl 4.3.0, we've addressed [one of our oldest issue], proposed in Nomvember 2020: a `--parallel` option!
<div class="picture">
<picture>
<source srcset="{{ '/assets/img/pinto-light.avif' | prepend:site.baseurl }}" type="image/avif">
<source srcset="{{ '/assets/img/pinto-light.webp' | prepend:site.baseurl }}" type="image/webp">
<source srcset="{{ '/assets/img/pinto-light.png' | prepend:site.baseurl }}" type="image/png">
<img class="u-theme-light u-drop-shadow u-border u-max-width-100" src="{{ '/assets/img/pinto-light.png' | prepend:site.baseurl }}" width="600" alt="Movies Box home page"/>
</picture>
<picture>
<source srcset="{{ '/assets/img/pinto-dark.avif' | prepend:site.baseurl }}" type="image/avif">
<source srcset="{{ '/assets/img/pinto-dark.webp' | prepend:site.baseurl }}" type="image/webp">
<source srcset="{{ '/assets/img/pinto-dark.png' | prepend:site.baseurl }}" type="image/png">
<img class="u-theme-dark u-drop-shadow u-border u-max-width-100" src="{{ '/assets/img/pinto-dark.png' | prepend:site.baseurl }}" width="600" alt="Movies Box home page"/>
</picture>
</div>
It has been a long run since this issue, but we always kept in our mind that, at a moment, we want to be able to
run Hurl files in parallel. Now, with 4.3.0, we're introducing an opt-in option [`--parallel`] that will enable parallel
execution of Hurl files.
In Hurl 4.3.0, running files in test mode is (no change):
```shell
$ hurl --test *.hurl
```
With `--parallel`, you can choose to run your tests in parallel:
```shell
$ hurl --test --parallel *.hurl
```
To develop this feature, we take a lot of inspiration of the venerable [GNU Parallel].
In the parallel mode, each Hurl file is executed on its own thread, sharing nothing with other files. There is a thread
pool with size is roughly the current amount of CPUs and that can be configured with `--jobs` option. During parallel
execution, standard output and error are buffered for each file and only displayed on screen when a job file is finished.
This way, debug logs and messages are never interleaved between execution. Order of execution is not guaranteed
in `--parallel` mode but reports (HTML, TAP, Junit) keeps the input files order.
The parallelism used is multithread sync: the thread pool is instantiated for the whole run, each Hurl file is run
in its own thread, synchronously . We've not gone through the full multithreaded async route for implementation
simplicity. Moreover, there is no additional dependency, only the standard Rust lib with "classic" threads and multiple
producers / single consumer channels to communicate between threads. Surprinsingly,
For the 4.3.0, we've marked the `--parallel` option as "experimental" as we want to have feedbacks on it and insure that
everything works as designed. We plan to make this mode of execution the default when executing Hurl files with `--test`
in the Hurl 5.0.0 version.
Give it a try, if you think Hurl is fast, Oh Boy... Wait until you see the new parallel mode!
## Others
There are a lot other improvements with Hurl 4.3.0 and also a lot of bug fixes,
you can check the complete list of enhancements and bug fixes [in our release note].
If you like Hurl, don't hesitate to [give us a star on GitHub] or share it on [Twitter]!
We'll be happy to hear from you, either for enhancement requests or for sharing your success story using Hurl!
[Hurl]: https://hurl.dev
[curl]: https://curl.se
[Hurl 4.3.0]: https://github.com/Orange-OpenSource/hurl/releases/tag/4.3.0
[`--netrc`]: {% link _docs/manual.md %}#netrc
[`--netrc-file`]: {% link _docs/manual.md %}#netrc-file
[`--user`]: {% link _docs/manual.md %}#user
[AWS Signature Version 4]: https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html
[variables]: {% link _docs/templates.md %}#injecting-variables
[options documentation]: {% link _docs/manual.md %}#options
[`Options`]: {% link _docs/request.md %}#options
[`--max-size`]: {% link _docs/manual.md %}#max-size
[Predicates]: {% link _docs/asserting-response.md %}
[RFC-3339]: https://www.rfc-editor.org/rfc/rfc3339
[fish]: https://fishshell.com
[zsh]: https://ohmyz.sh
[PowerShell]: https://learn.microsoft.com/en-us/powershell/
[bash]: https://ftp.gnu.org/gnu/bash/
[Hurl's GitHub repository]: https://github.com/Orange-OpenSource/hurl/tree/master/completions
[one of our oldest issue]: https://github.com/Orange-OpenSource/hurl/issues/87
[GNU Parallel]: https://www.gnu.org/software/parallel/
5 changes: 4 additions & 1 deletion sites/hurl.dev/_sass/_code.scss
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ pre, code {
color: $ansi-green-light;
color: var(--ansi-green);
}
.gray {
color: $ansi-gray-light;
color: var(--ansi-gray);
}
.bright-cyan {
color: $ansi-bright-cyan-light;
color: var(--ansi-bright-cyan);
Expand All @@ -209,7 +213,6 @@ pre, code {
color: var(--ansi-bright-magenta);
font-weight: bold;
}

}

.language-rust {
Expand Down
4 changes: 4 additions & 0 deletions sites/hurl.dev/_sass/_colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ $bash-literal-string-double-light: darkgreen;
$bash-name-builtin-light: teal;
$shell-prompt-light: dimgray;
$ansi-green-light: darkgreen;
$ansi-gray-light: dimgray;
$ansi-bright-cyan-light: #35bbc7;
$ansi-bright-green-light: #33bd25;
$ansi-bright-red-light: #c33820;
Expand Down Expand Up @@ -110,6 +111,7 @@ $bash-literal-string-double-dark: forestgreen;
$bash-name-builtin-dark: #ff8000;
$shell-prompt-dark: dimgray;
$ansi-green-dark: #00c300;
$ansi-gray-dark: dimgray;
$ansi-bright-cyan-dark: cyan;
$ansi-bright-green-dark: lime;
$ansi-bright-red-dark: #ff6e67;
Expand Down Expand Up @@ -170,6 +172,7 @@ $hurl-structure-3-back-dark: $code-background-color-dark;
--bash-name-builtin: #{$bash-name-builtin-light};
--shell-prompt: #{$shell-prompt-light};
--ansi-green: #{$ansi-green-light};
--ansi-gray: #{$ansi-gray-light};
--ansi-bright-cyan: #{$ansi-bright-cyan-light};
--ansi-bright-green: #{$ansi-bright-green-light};
--ansi-bright-red: #{$ansi-bright-red-light};
Expand Down Expand Up @@ -240,6 +243,7 @@ $hurl-structure-3-back-dark: $code-background-color-dark;
--bash-name-builtin: #{$bash-name-builtin-dark};
--shell-prompt: #{$shell-prompt-dark};
--ansi-green: #{$ansi-green-dark};
--ansi-gray: #{$ansi-gray-dark};
--ansi-bright-cyan: #{$ansi-bright-cyan-dark};
--ansi-bright-green: #{$ansi-bright-green-dark};
--ansi-bright-red: #{$ansi-bright-red-dark};
Expand Down
Binary file added sites/hurl.dev/assets/img/emoji-smiling-face.avif
Binary file not shown.
Binary file added sites/hurl.dev/assets/img/emoji-smiling-face.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file added sites/hurl.dev/assets/img/emoji-surfer.avif
Binary file not shown.
Binary file added sites/hurl.dev/assets/img/emoji-surfer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sites/hurl.dev/assets/img/emoji-surfer.webp
Binary file not shown.
Binary file added sites/hurl.dev/assets/img/pinto-dark.avif
Binary file not shown.
Binary file added sites/hurl.dev/assets/img/pinto-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sites/hurl.dev/assets/img/pinto-dark.webp
Binary file not shown.
Binary file added sites/hurl.dev/assets/img/pinto-light.avif
Binary file not shown.
Binary file added sites/hurl.dev/assets/img/pinto-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sites/hurl.dev/assets/img/pinto-light.webp
Binary file not shown.

0 comments on commit caa86d4

Please sign in to comment.