All the world's a server, and all the men and women merely clients
We're glad to announce our first major release 🎉 The primary purpose of this release is to separate CLI from library (and thus provide an ability to use WS Director programmatically).
You can run WS Director from your code using a simple API:
WSDirector.run(scenario_path_or_hash, url:, **options)
There are also various additions and improvements, see below.
Read also WebSocket Director: scenario-based integration tests for realtime apps
WS Director is now distributed in two forms (gems): wsdirector-core
and wsdirector-cli
. The latter includes the former and adds an executable and CLI-specific dependencies.
The receive
action is no order-independent.
Using receive
now looks up a matching message through all the mailbox (already received or newly arrived messages). If you need strict order guarantees, add ordered: true
to the receive
step. This change makes it easier to write scenario and reflect the asynchronous nature of WebSockets.
It's now possible (and recommended) to specify URL and scenario file via the -u
and -f
options respectively. It's still possible to specify URL and file path using the positional arguments.
Added Phoenix Channels protocol (v2) support.
Added support for partial receive
data matching (via data>
field).
Added connection options support (headers, cookies, query).
Added ability to load custom protocols when running wsdirector
CLI.
Added -vv
option to print colorful action logs.
[Experimental] Added WSDirector::Snapshot
, an utility class which could be used to record WebSocket interactions and dump them into files to re-use later (like VCR).
You can specify a sample
option for a step to only run this step by specified number of clients from the group:
- perform:
sample: ":scale / 2"
channel: "chat"
params:
id: 2
action: "speak"
data:
message: "Hello!"
Useful in combination with :scale
.
NOTE: Sample size is always greater or equal to 1.
Now you can, for example, parameterize scenarios with env vars:
- perform:
channel: "chat"
params:
id: <%= ENV["CHAT_ID"] %>
action: "speak"
data:
message: "Hello!"