Documentation
¶
Overview ¶
Package mqtt implements the "mqtt" protocol.Protocol driver, for load testing an MQTT 3.1.1 broker. It uses the Eclipse Paho client.
Each call to Do opens its own connection, does one job, and closes. That measures connect, publish and delivery time under load. It is not a long-lived session. The job is chosen with -opt mode=...:
publish connect, publish the body, wait for the broker's ack. This
is the default.
subscribe connect, subscribe, wait for count messages.
roundtrip connect, subscribe, publish the body, wait until this
iteration's own message comes back. This measures delivery
through the broker. The body must contain {id}, so the driver
can tell its own message from another user's.
Options (set with -opt key=value):
mode publish (default), subscribe, or roundtrip.
topic The topic. Required. {id} is replaced by this
iteration's unique client id, so each iteration can
have its own topic. Publish and roundtrip topics must
not have wildcards.
qos 0 (default), 1, or 2.
retain true to publish the message as retained.
username The user name.
password_env The name of an environment variable that holds the
password. It needs username. The password is never put
on the command line.
client_id A prefix for the client ids (default "vegaload"). Each
iteration adds a unique suffix, because a broker closes
an older connection that has the same id.
count subscribe and roundtrip: messages to wait for (default 1).
expect subscribe: every message must contain this text.
keepalive Keep-alive time, such as 30s (default 30s).
Every iteration asks for a clean session, so the broker keeps nothing between iterations. The body is the message payload. {id} in it is replaced too. Use an mqtts:// target for TLS.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Options = []string{
"mode", "topic", "qos", "retain", "username", "password_env",
"client_id", "count", "expect", "keepalive",
}
Options are the -opt keys this driver accepts. The command's protocol table uses the same list, so the two cannot differ.
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver is an MQTT protocol.Protocol.
func New ¶
New returns a ready-to-use Driver for target. target.URL is mqtt://host or mqtts://host, with an optional :port (1883, or 8883 for mqtts).
New returns an error only for a configuration problem, never for the broker being unreachable, which Do reports per call.
func NewWithPassword ¶
func NewWithPassword(target protocol.Target, timeout time.Duration, password string) (*Driver, error)
NewWithPassword is New for a caller that already holds the password, such as a scenario script that read it from an environment variable it was given. The command line never uses it: there the password is read from the environment variable that password_env names. password_env and a password given here are not allowed together.
func (*Driver) Close ¶
Close implements protocol.Protocol. Do opens and closes its own connection every call, so Driver holds nothing to release.