Load test framework, written in Elixir, that targets HTTP APIs.
You will need to install Elixir v1.18+ in order to run blast.
Build the escript using just build, then use the artifact like so:
./blast -hWith nix installed you can run:
nix run . -- -hor
nix develop
just build
./blast -h # escriptIf you're using nix with flake support you can also install it:
nix profile add .When started a simple web interface is started on localhost:4000.
However, to be able to start blast you need to configure it.
The configuration is done through an Elixir module in a file you specify. A minimal example looks something like this:
defmodule Blast do
# The module must always include this.
use Blastfile
# This is the first required function.
# It must return a valid URL to be used as the base for the requests.
def base_url() do
"https://myapi.example"
end
# This is the second required function.
# It must return a non-empty list of maps that specifies the requests to send.
def requests() do
[
%{
method: "get",
path: "/resource" # all paths are relative to the base URL.
}
]
end
endNote
Don't know Elixir? Don't worry! The syntax is very simple.
By default blast will look for a blast.ex[s] file in the current working directory,
but you can specify a location with the -b/--blastfile option.
Here a small breakdown of the most important options that you need in order to run blast. The module, and sometimes function definitions will be omitted for brewity.
All requests are specified by atleast method and path, where path is relative to the base URL:
def base_url() do
"http://myapi.cool"
endRequests are given by the requests() function:
def requests() do
[
%{method: "get", path: "/resource/path"},
%{method: "get", path: "/testing?fail=true"},
]
endThe %{} syntax is a map in Elixir, and each request requires atleast:
method: HTTP method, lower case or upper case.path: Relative path of the request URL.
HTTP Headers can be specified per request using the headers key:
%{
method: "get",
path: "/testing",
headers: [
# These are called tuples.
{"name1", "value1"},
{"name2", "value2"},
]
}HTTP Headers to include for every request can be specified with the default_headers() function:
# This should return a list of two-element tuples.
def default_headers() do
[
# These are called tuples
{"name1", "value1"},
{"name2", "value2"},
]
endFor a full specification of the blast module see the docs.
I recommend using the nix flake, like so:
nix develop # It takes a while the first time
mix deps.get # Fetch dependencies
iex -S mix # Start the application in IExNote that when running iex -S mix:
- Starts the server as well
- Using
recompileinside iex will recompile and restart the application - The
./examples/basic.exis loaded as the blastfile