* Add more test cases for emqx_stats and emqx_os_mon
Fix test case error for emqx_ws_connection
* Add more test cases for emqx_sys_mon
* Update erlang otp to 22.1 for travis ci
* Delete readable=false for make ct
* Add unset_all_env for emqx_zone and update test cases
- Rename the 'Client' field to 'ClientInfo'
- Remove the 'expiry_interval' from session record
- Add more test cases for emqx_zone module
- Add more test cases for emqx_banned module
- Add more test cases for emqx_message module
- Remove 'sockname', 'conn_mod' fields from type 'client'
Fix invalid QoS and protocol name, fix handling for Topic-Alias-Maximum and Maximum-Packet-Size, and send DISCONNECT Packet to client when the session is taken over
* Wrapper proper test cases into common test cases
* Improve test cases for reason code module (#2789)
* Split 3 proper tests into 3 ct cases
* Improve test cases for client, rpc and request-response
* Add psk suites to increase coverage
* Add sys test cases
- Rename `mqtt_retain_available` to `retain_available`
- Rename `mqtt_wildcard_subscription` to `wildcard_subscription`
- Rename `mqtt_shared_subscription` to `shared_subscription`
- Add `emqx_zone:unset_env/2` API for unit test
* Fix issue#2619
Prior to this change, websocket connection would not be disconnected
when dataframe type is other frametype. However, in mqtt spec, it
shoud be disconnected.
This change fix this inconsistent behaviour with mqtt 5.0
* Adopt channel architecture and improve the MQTT frame parser
* Update the test cases for emqx_channel, emqx_protocol
- Improve emqx_client to Use the new emqx_frame:parse/2
- Update the ct suites for emqx_channel, emqx_ws_channel
* Fix test case
Fix websocket bug.
Prior to this change, websocket connection would be closed directly
without sending connack packet when acl check fails.
This change fix this bug.
* Pin cuttlefish rebar3 branch
* No shallow clone for rebar3
* Replace timer:sleep with receive after for deterministic
* Build with only rebar3
* bbmustache as a test dependency
* Change to plain deps
* Use shallow clone by default
* Add ct-helpers as test dep
To fix issue#2303(https://github.com/emqx/emqx/issues/2303)
It will report the following error, when a connection sends a TCP frame contained many of MQTT packet and followed a split MQTT packet.
* Improve emqx_hooks and credentials
1. Modify the return modes of emqx hooks.
Change the return value of hook functions to:
- ok: stop the hook chain and return ok
- {error, Reason}: stop the hook chain and return error
- continue: continue the hook chain
And the return value of emqx_hooks:run/2 is changed to:
- ok
- {error, Reason}
And the return value of emqx_hooks:run/3:
- {ok, Acc}
- {error, Reason, Acc}
2. Treat password as a member of credentials.
Password should be wrapped in the `credentials` data-structure, as the
username/password pair together consists of an authentication method.
There can be some methods using some other credential data (e.g.
a JWT token), and these credential data should also be wrapped in the
the `credentials` data-structure.
An event `client.authenticate` is triggered when an user logs in:
```erlang
emqx_hooks:run('client.authenticate', [], Credentials)
```
A `default callback` that deny/allow any user (according to the
`allow_anonymous` config) should be appended to the end of the
callback chain.
The `credentails` is passed through all of the callbacks, and
can be changed over in this process.
* Refactor emqx hooks return mode
* Remove password from PState
* Delete response_topic_prefix
The Response-Infomation in CONNACK was misinterpreated, it should
not be a broker's global config, instead, it should be per-client
or even per-session prefix/suffix mechanism
* Delete request-response code from emqx_client
* Add request-response test code
* meck as default dependency --- temp workaround for dep-vsn-check
Prior to this change, if a emqx_client:publish/? caller sends in
QoS=1/2 messages too fast, emqx_client may return
`{error, inflight_full}` which could put put the caller to an
awkward situation: there seem to be no ohter option except for
putting self to a sleep-n-retry infinite loop.
In this change, a new gen_statm state 'inflight_full' is introduced
as a sub-state of 'connected'. When emqx_client is in 'inflight_full'
state, it postpone all publish calls (for QoS=1/2) until inflight
window size shrinks.
bridge.$name.transport was added before we decided to derive
transport portocol based on the 'address' config.
i.e. when it's a remote erlang node, use gen_rpc
otherwise (must be IP or hostnmae), we should estabilish mqtt connection
* Fix the Exit in testcases
* Fix Exit in emqx_mod_sup_SUITE
* Update testcases for log_tracer
* Fix Exit in emqx_protocol_SUITE
* Add will_acl_check
* Fix more Exits
* Fix failed test case
Prior to this change, terry-xiaoyu enhanced the cuttlefish to
support emqx enterprise edtion configuration entries. But it cause 6
test case failed.
* Fix dep-vsn-check
1. Add do_add_route/1 do_add_route/2, do_delete_route/1,
do_delete_route/2 APIs in emqx_router module
2. Improve the code of emqx_trie module
3. Update the emqx_broker module to call the new APIs of emqx_router
* Add acking mechamism for shared dispatch
For QoS0 messages, no acking
For QoS1/2 messages, 'ACK' at any of events below:
- ACK when QoS is downgraded to 0
- Message is sent to connection process
'NACK' at any of events below:
- Message queue is full and the receiving session starts to drop old messages
- The receiving session crash
Upon 'NACK', messages are dispatched to the 'next' subscriber in the group,
depending on the shared subscription dispatch strategy.
* Fix issue#1874
Prior to this change, if user use one client connect emqx with mqtt
v3.1.1, the client subscribe the topic and publish message to this
topic, it would receive this message itself published, this commit
provide a configure option to let user ignore the message itself published.
This change fix issue 1874.
* Small Fix
* Fix bug
* Better design
* Fix compile warning and improve coverage
* Better design to solve the performance issue
* Fix typo
* Fix typo
* Delete spaces in end of lines.
* Do not use anonymous function
* Better performance
Prior to this change, emqx_client:start_link does 2 works in one call:
- init an erlang process for emqx_client
- send MQTT CONNECT to remote broker
But this solution have some drawbacks:
- the return value of `start_link` compiles the return values of the 2
works: {ok, Pid, MqttResult}. It is inconsistent with the return value
of `gen_statem:start_link`, may causes confusions.
- the return mode of the 2 works are different:
`start_link` should always return {ok, Pid} or {error, Reason}, but
connecting to mqtt may throw out exceptions as it handles the
socket. But the caller couldn't have thought of the exception, he would
pattern match on the result of `emqx_client:start_link`, but it crashed!
- If the init work succeed but the connection failed, the caller couldn't
get a Pid from the return value, but indeed it was created inside the
emqx_client. This hides the fact that the Pid was created, and when the
Pid dies, the caller would receive an message from a Pid it doesn' know about.
This change divived these 2 work into 2 APIs:
- `start_link/1` is to build and verify the options, and returns {ok,Pid}
(on success) or {error, Reason} (on failure).
- `connect/1` is to send MQTT CONNECT, and returns {ok, MQTTResult::properties()} or
{error, MQTTReason}. MQTT reason codes will contains in the `MQTTReason`.
Fixed bugs:
- Priority queue lack of a `len + 1` logic in `in/2`
Changed behaviors:
- Topics not found in priority table (from config) will be treated with default priority,
instead of hasing topic name to a priority number.
- Default priority is now configurable (it was always lower than all configured priorities)
- The dropped message due to reaching `max_len` is now returned from `in/2`,
so the queue owner (`in/2` caller) can perform autopsy on it
Add request & response support for CONNECT & CONNACK
Prior to this change, there is no validate and specified process for
Request-Response-Information and Response-Information
Also added basic Request/Response functionality to emqx_client implementation
Before this change, the stats callback provided by emqx_broker_helper
was an anonymous function with module local context.
This commit changes it to a full fun M:F/A style callback for:
1. More robust to hot beam reload
2. Faster/smaller variable to construct
3. Easier test
Before this change, eqmx_mock_client uses a shared ets table
to store last received message, this causes troulbe when we
want to start / stop two or more clients in one test case
the ets table gets owned by the first spanwed client and
gets closed when the owner client dies.
Now it keeps the last received message in process state
and a gen_server call is added to retrieve it for verification
Along with this change in emqx_mock_client, it made possible
to write test case to verify the actual subscriber pid
used in shared subscription strategy, so test cases were
added (and modified) to verify different strategies
The hibernation behaviour is also changed (implicitly) in this commit:
Prior to this change, connection/session always hibernates after
the stats timer expires regardless of messages in mailbox.
After this commit, connection/session process only goes to hibernate
when the timer expires AND there is nothing left in the mailbox to
process
The implementation prior to this commit supports
only one gc enforcement policy which is message count threshold.
The new implementation introduces 1 more: volume threshold based
Prior to this change, listeners test suites did not start cowboy which
is responsible for websocket connections. and access suites start
duplicated processes and these actions are wrong
This change fix the problem states above.
Use `mnesia:foldl` to traverse mnesia rather than `mnesia:first` and
`mnesia:next`, as a badarg exception would occur if the record was
deleted while travering the whole table.
Prior to this change, the template file etc/emqx.conf is used
directly in testing, as a result, mustache style directories
are created e.g. `{{ platform_log_dir }}` which should have been
replaced with a config varialbe e.g. `log`
In this change, Makefile targets are added as `ct` dependency
to download bbmustach, load the template input, replace with
variableds defined in 'vars' file, finally to etc/gen.emqx.conf.
The direct usage of etc/emqx.conf in test code are replaced with
gen.emqx.conf