Commit Graph

737 Commits

Author SHA1 Message Date
terry-xiaoyu 3405dbaf5c Ordered messaging via multiple gen_rpc clients 2019-10-28 21:01:53 +08:00
zhanghongtong 9ef4e62219 Add more test cases for emqx_alarm_handler 2019-10-28 20:37:15 +08:00
terry-xiaoyu f7d3c01308 Merge branch 'develop' into clean_acl_cache 2019-10-28 18:02:41 +08:00
terry-xiaoyu c1d768ff74 Add API for clean and get acl cache 2019-10-28 17:53:53 +08:00
zhanghongtong 73bfaa038b Add more test cases for emqx_packet 2019-10-25 10:08:57 +08:00
张奇怪 c713d619da
Add more test cases (#2992)
* 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
2019-10-24 15:41:26 +08:00
Feng Lee d5412c8d34 Merge branch 'gen-ct' into develop 2019-10-23 16:36:17 +08:00
Feng Lee 7be110cdef Add more test cases 2019-10-23 16:35:15 +08:00
terry-xiaoyu 9aef5d60e0 Fix testcase for logger_formatter 2019-10-23 10:26:25 +08:00
Feng Lee fca7a7e761 Merge branch 'connection-test-using-meck' into develop 2019-10-21 19:53:53 +08:00
terry-xiaoyu cb77b229b8 Add testcase for emqx_logger_formatter 2019-10-21 18:35:32 +08:00
Feng Lee 7117dde879 Add more test cases for connection, channel and session modules 2019-10-21 17:14:50 +08:00
Feng Lee 26eab630b3 Add test cases for emqx_channel module 2019-10-20 19:20:38 +08:00
Feng Lee aecda09b9a Add more test cases 2019-10-19 20:18:34 +08:00
Feng Lee cd4adbada0 Add more test cases for connection, channel and session modules 2019-10-18 18:53:31 +08:00
Feng Lee a09b87fc94 Add more test cases for connecton module using meck 2019-10-15 17:28:20 +08:00
Feng Lee a1877f3f42 Return the '{enter, connected}' event first 2019-10-14 13:04:49 +08:00
Feng Lee 6233aa7d46 Ensure the 'conn_state' be 'disconnected' after socket closed 2019-10-12 19:14:33 +08:00
terry-xiaoyu 7f730ffec6 Revert client_id options in the testcases 2019-10-12 18:05:34 +08:00
Feng Lee 932821360f Merge branch 'new-connection-module' into develop 2019-10-12 17:08:48 +08:00
Feng Lee cce0dbd3cf Improve the connection, ws_connection and channel modules 2019-10-12 17:05:37 +08:00
terry-xiaoyu 54e11d3bb5 Fix client_id options in testcases 2019-10-12 15:10:49 +08:00
terry-xiaoyu 47a192ee34 Avoid process crash report for arbitrary exit reason 2019-10-12 14:48:39 +08:00
zhouzb d004a5b68e Rename 'client_id' field to 'clientid' 2019-09-29 16:46:27 +08:00
Feng Lee e8491b69a9 Merge branch 'clientinfo' into develop 2019-09-29 11:00:24 +08:00
Feng Lee 977b551bbf Fix the test cases for session, channel and connection modules 2019-09-29 10:53:59 +08:00
Feng Lee 8ab682151d Improve the connection and channel modules
- Rename the 'client_id' field to 'clientid'
- Support publish stats in channel module
- Update test cases for frame and channel modules
2019-09-29 10:22:02 +08:00
tigercl 9fed1667bb
Merge pull request #2921 from emqx/ct-metrics
Add test cases for new/1, all/0 functions
2019-09-29 09:59:59 +08:00
Feng Lee fcb1b83495 Rename the 'client_id' option to 'clientid' 2019-09-28 10:06:16 +08:00
Feng Lee 20ddd498fc Rename the 'client_id' field to 'clientid' 2019-09-24 17:06:25 +08:00
JianBo He 26e1d3bcef Fix emqx_cm_SUITE failed 2019-09-21 16:22:33 +08:00
terry-xiaoyu 18b401d5fc Fix testcases for new object field protocol 2019-09-21 13:50:18 +08:00
terry-xiaoyu eb0826ef3f Fix testcases for new object field protocol 2019-09-21 12:37:08 +08:00
Feng Lee d945ee4972 Add test cases for new/1, all/0 functions 2019-09-20 23:25:19 +08:00
Feng Lee 699fea4869 Sleep 100 milliseconds 2019-09-20 22:42:33 +08:00
tigercl b72a82e50b
Merge pull request #2919 from emqx/fix-test-cases
Add 'unregister_channel/1' function and test cases
2019-09-20 19:57:47 +08:00
Feng Lee d0a8086d73 Add 'unregister_channel/1' function and test cases 2019-09-20 19:42:59 +08:00
terry-xiaoyu a108f292c2 Ensure expiry_interval expired in testcase 2019-09-20 19:26:56 +08:00
terry-xiaoyu 2c07fc310e Unload meck before testcase ends 2019-09-20 19:15:35 +08:00
terry-xiaoyu 3a39442a1c Update testcases for session module 2019-09-20 18:50:31 +08:00
zhouzb fd455e57eb Fix the test case 't_mod_presence' 2019-09-20 18:38:28 +08:00
terry-xiaoyu 4d214fb6e2 Fix session not saved after maybe_resume_session 2019-09-20 18:28:44 +08:00
zhouzb f0a1ffc3b1 Fix test case 2019-09-20 17:58:31 +08:00
Feng Lee 6aac73f51f Fix the test case 't_handle_disconnect' 2019-09-20 16:48:21 +08:00
terry-xiaoyu b5c9def06a Add testcases for print and usage 2019-09-20 16:18:24 +08:00
Feng Lee 1a3261b186
Merge branch 'develop' into remove-protocol-module 2019-09-20 16:17:44 +08:00
zhouzb 24bfaa768d Call emqx_flapping:detect and generate alarm when flapping is detected 2019-09-20 15:01:51 +08:00
zhouzb a9dd94b2b5 Improve mechanism of waiting for session to expire 2019-09-20 15:01:51 +08:00
Feng Lee 3202ed2392 Improve the 'channel' module and add more 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'
2019-09-20 14:38:16 +08:00
Feng Lee 81e2f47126 Add test cases for emqx_ctl module 2019-09-20 13:47:05 +08:00
Feng Lee 8ecc9ab88a Add test case 't_undefined_headers' 2019-09-19 11:53:29 +08:00
Feng Lee 65cb9dbf38 Add test cases for 'reason/1' 2019-09-19 11:16:13 +08:00
Feng Lee 3705f4f929 Rewrite the test cases for extended modules 2019-09-19 11:04:29 +08:00
Feng Lee c067a43990 Update test cases 2019-09-19 06:06:25 +08:00
Feng Lee ad7e0ae436 Use 'peerhost' to replace 'peername' 2019-09-18 19:44:28 +08:00
Feng Lee 00f3a2f939 Use 'peerhost' to replace 'peername' 2019-09-18 19:17:30 +08:00
turtled 46659854da Fix test cases 2019-09-16 20:25:19 +08:00
zhouzb 0c7c720018 Add delay in test case 2019-09-16 17:51:36 +08:00
zhouzb e35eaa97b3 Fix test case 2019-09-16 17:36:22 +08:00
zhouzb 1667cbd359 Fix test cases 2019-09-16 16:05:06 +08:00
tigercl fc553b8cee
Merge pull request #2803 from emqx/fix_msg_expiry
Fix Message-Expiry-Interval not working
2019-09-16 14:45:22 +08:00
Feng Lee 4764a7707c Rewrite the emqx_packet module and improve channel pipeline (#2903)
Add use_username_as_clientid/1 function and Improve function 'pipeline/3'
2019-09-16 14:17:36 +08:00
Feng Lee 681ae511a8 Introduce the 'strict_mode' option and validate MQTT header (#2898)
Introduce the 'strict_mode' option and validate MQTT header
2019-09-16 14:02:31 +08:00
tigercl 35822ff97a
Fix handling for MQTT spec (#2892)
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
2019-09-16 13:51:50 +08:00
Feng Lee 594153c0fb Merge branch 'boot' into develop 2019-09-10 16:26:20 +08:00
Feng Lee a3daa533e7 Add a test case for the new flapping module 2019-09-10 16:20:56 +08:00
Feng Lee 88321fe6fe Remove the emqx_config module
- Remove the emqx_config module
- Move get_env/1, get_env/2 to emqx module
2019-09-09 10:18:10 +08:00
Feng Lee 6eedcb0eda Add test cases for emqx_boot module 2019-09-06 19:17:31 +08:00
Feng Lee 7175e4a74c Set 'boot_modules' when starting emqx apps. 2019-09-06 17:36:34 +08:00
terry-xiaoyu 983973c841 Fix set_chan_stats incorrect 2019-09-05 15:59:18 +08:00
Feng Lee 4ba92b6a3b Fix test case 't_handle_deliver' 2019-09-05 15:02:20 +08:00
Feng Lee 847375d2fb Improve connection and channel modules (#2860)
Improve the connection and channel modules
2019-09-05 14:17:15 +08:00
Feng Lee 62f0f0ccbc Add more test cases for 'emqx_misc' module 2019-08-28 14:29:44 +08:00
GilbertWong 0e9647b601 Delete useless include lib 2019-08-28 11:19:51 +08:00
GilbertWong 783e29d6f7 Add test case for emqx_mod_rewrite 2019-08-28 11:19:51 +08:00
terry-xiaoyu 6352f9e2dc Update testcase emqx_channel:handle_out 2019-08-23 15:20:25 +08:00
tigercl ebc1bd77a9
Send the will message immediately when the network connection is closed by the client (#2834)
Send the will message immediately when the network connection is closed by the client
2019-08-23 14:41:52 +08:00
Feng Lee c69a2b1b48 Ensure session expiration (#2825)
Ensure session expiration
2019-08-23 09:35:29 +08:00
Feng Lee 8b03371a4a Improve the keepalive, connection, channel and session modules (#2813) 2019-08-22 16:38:25 +08:00
tigercl 201428279b
Merge pull request #2817 from emqx/test_emqx_config
Remove redundant code and add test case
2019-08-22 16:13:50 +08:00
GilbertWong 3f20bcf58f Relace emqx_client with emqtt 2019-08-22 14:27:29 +08:00
zhouzb 94c56b5e31 Remove redundant code and add test case 2019-08-21 14:12:34 +08:00
Feng Lee ae33b6037e Fix the test suites. 2019-08-17 14:39:04 +08:00
Feng Lee 52b2f31ced Merge branch 'improve-channel-design-again' into develop 2019-08-17 14:09:26 +08:00
Feng Lee f26505d40a Implement session takeover and resumption.
- Implement session takeover
- Remove `init_proc_mng_policy/1' from emqx_misc module
- Remove `conn_proc_mng_policy/1' from emqx_misc module
- Add `emqx_oom' module to monitor OOM of channel process
2019-08-17 13:37:48 +08:00
tigercl c1fd5f89f1 Make codes compliance with mqtt protocol specifications (#2790)
* Make codes compliance with mqtt protocol specifications

* Fix test case

* Remove emqx_protocol:puback/4
2019-08-17 09:15:43 +08:00
terry-xiaoyu fa1adf5cfb Fix Message-Expiry-Interval not working 2019-08-16 18:27:22 +08:00
tigercl 2e26cd244a Improve test coverage (#2799)
* Improve test coverage

* Improve test coverage for emqx_cm

* Improve test coverage for emqx_cm_registry

* Fix emqx_client_SUITE
2019-08-16 18:25:49 +08:00
Feng Lee d63eccd8b8 Add test cases for emqx_keepalive module (#2784)
* Improve the keepalive module
2019-08-16 18:24:39 +08:00
JianBo He acf54509f5 Add emqx_plugins module test case (#2801) 2019-08-16 18:21:51 +08:00
Gilbert 79744af681 Wrapper proper test cases into common test cases (#2785)
* 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
2019-08-16 18:07:12 +08:00
JianBo He 8e401968f2 Add testcase for emqx_mod_sup 2019-08-16 17:48:37 +08:00
Shawn b2ddcb26e2
Testcase logf (#2800)
* Add test cases for logger formatter

* Remove the unregister API
2019-08-16 15:11:38 +08:00
Feng Lee 444972968f Improve emqx_mqtt_props module and add test cases 2019-08-12 14:29:38 +08:00
terry-xiaoyu 0c24bfd78c Make emqx_tracer more reliable 2019-08-09 19:59:39 +08:00
周子博 07fcc152e2 Fix test cases 2019-08-09 19:56:42 +08:00
GilbertWong b5aebb19b9 Fix stats test cases 2019-08-09 16:51:28 +08:00
GilbertWong 26cfc20867 Run test via common test 2019-08-09 16:43:54 +08:00
turtled 91a8dbda56 Fix conflicts 2019-08-09 16:41:11 +08:00
terry-xiaoyu 2fcda7d891 Dirty update testcases for shared_sub 2019-08-09 15:44:29 +08:00
GilbertWong 857b3df93d Fix the test cases of websocket channel 2019-08-09 15:30:00 +08:00
Feng Lee a324965240 Add more test cases for emqx_protocol module 2019-08-09 14:29:49 +08:00
周子博 85c33ce81f Fix test cases 2019-08-09 14:24:05 +08:00
GilbertWong 251f1a7174 Disable flapping test cases 2019-08-09 14:16:50 +08:00
Gilbert abb4b07665
Add session proper test cases (#2768)
* Add session proper test cases
* Remove useless mockers
2019-08-09 14:15:34 +08:00
GilbertWong 61ee889113 Fix client bug 2019-08-09 13:40:07 +08:00
Feng Lee 916afc1c74 Add test cases for emqx_protocol module
- Add emqx_session:info/2 for unit tests
- Add emqx_protocol:set/3 for unit tests
- Fix the `check_sub/3` of emqx_mqtt_caps
2019-08-09 11:33:52 +08:00
Feng Lee a2d5b834da Improve emqx_pmon module and add more test cases 2019-08-08 22:42:45 +08:00
Feng Lee 6513a32d37
Merge pull request #2766 from emqx/improve-mqtt-caps-module
Improve mqtt caps module
2019-08-08 22:35:32 +08:00
Feng Lee bd061415c9 Rewrite the emqx_mqtt_caps module and add 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
2019-08-08 14:11:26 +08:00
Gilbert 96b341fde5
Add proper tests for base62 (#2761)
* Add proper tests for base62

* Delete useless comment
2019-08-07 09:24:03 +08:00
Feng Lee 4afa02ee48 Update all the test cases 2019-08-06 09:04:37 +08:00
Feng Lee c4faeab45a Move test/run_emqx.escript -> scripts/run_emqx.escript 2019-08-03 14:08:20 +08:00
Feng Lee c8317a230d Update copyright 2019-08-03 11:43:30 +08:00
GilbertWong 2aa9b2aa4e Specify mnesia dir for `make run` command 2019-08-03 11:10:25 +08:00
周子博 ef9cbe51eb Fix conflict 2019-08-02 10:41:46 +08:00
周子博 0cdb0d5591 Remove all dependencies on emqx_client.hrl 2019-08-02 10:20:09 +08:00
Feng Lee c95a89ed1e Merge branch 'nchannel' into develop 2019-07-31 14:03:48 +08:00
terry-xiaoyu b0e2b7db0c Support inter-node messages via RPC cast 2019-07-27 12:59:07 +08:00
Feng Lee 6b84eb0595 Rewrite the channel, protocol and session modules. 2019-07-22 17:08:53 +08:00
terry-xiaoyu 7472e531b1 Remove log handler for alarms 2019-07-11 13:27:03 +08:00
GilbertWong 234037aee1 Fix will message mechanism for websocket channel 2019-07-11 09:43:52 +08:00
GilbertWong 41dcb4acf2 Delete slave.config 2019-07-11 09:20:38 +08:00
Feng Lee 8c37ea3f38 Fix conflict 2019-07-02 14:02:42 +08:00
周子博 8234b616e5 Fix test case 2019-06-29 12:38:57 +08:00
terry-xiaoyu 96fff39535 Change default logger level to warning 2019-06-28 21:34:21 +08:00
Gilbert 9df6345a6c Remove bridge functions from emqx (#2652)
* Remove bridge functions from emqx
2019-06-26 19:33:17 +08:00
Feng Lee 9ee0a4d171 Fix the function_clause error when publishing QoS2 message 2019-06-25 17:35:58 +08:00
Feng Lee f32a415a83 Merge branch 'channel3' 2019-06-25 15:55:31 +08:00
Gilbert 475cabde4d Fix issue#2619 (#2646)
* 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
2019-06-21 21:21:49 +08:00
Gilbert 20188f9189 Optimize develop workflow and support make run and code hot swapping (#2644)
* Optimize develop workflow and support make run and code hot swapping
2019-06-21 20:52:27 +08:00
tigercl 0c7c4ee417 Using fixed topic for system message of alarm (#2647)
* Using fixed topic for system message of alarm
2019-06-21 19:51:58 +08:00
Gilbert 1d23d7de86
Optimize test workflow (#2642)
* Optimize test suites workflow

* Better format of makefile

* Fix protocol suite

* Add emqx_access_SUITE
2019-06-20 11:44:44 +08:00
Feng Lee 3877c4db1a Merge branch 'channel2' into channel3 2019-06-18 16:49:26 +08:00
Feng Lee 1d88f8fd9e Improve the emqx_connection, emqx_ws_connection and emqx_frame modules (#2611)
* 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
2019-06-14 12:44:27 +08:00
Gilbert d3e7d1f0c9 Fix websocket bug (#2615)
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.
2019-06-14 11:33:44 +08:00
Feng Lee de978d4771 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
2019-06-12 10:31:44 +08:00
Feng Lee d386b27e8a Adopt channel architecture and improve the MQTT frame parser 2019-06-11 23:18:38 +08:00
Feng Lee f801ff1e53 Optimize metrics using counters and persistent_term (#2597)
* Optimize emqx_metrics module using persistent_term and counters in OTP 22
2019-06-05 23:16:35 +08:00
Gilbert 0857b976ed Better zone (#2548) 2019-05-25 22:29:23 +08:00
HeeeJianBo 87ffa77ade Fix lookup_session_pids return data type error 2019-05-25 22:28:34 +08:00
spring2maz ac0e637a4b Delete APPLICATION macro from erl-opts in rebar.config 2019-05-24 10:16:10 +08:00
spring2maz d0131ec663 Pin emqx-ct-helpers v1.1 (#2495)
* Pin emqx-ct-helpers v1.1.1

* Fix loaded_plugins touch command
2019-05-04 04:41:08 +08:00
spring2maz 97476b8bde Build with rebar3 (#2475)
* 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
2019-04-28 09:40:39 +08:00
Gilbert Wong b3927ff730 Add emqx_ct_helpers as deps and refactor test suites 2019-04-25 13:41:22 +08:00
Gilbert Wong bcbb4b68e9 Add flapping detect feature 2019-04-19 16:34:33 +08:00
Gilbert Wong f1616c33d9 Convert value of attribute table to map 2019-04-13 10:35:59 +08:00
Gilbert Wong 81ef5b9b8d Support cookie based auth 2019-04-12 19:25:22 +08:00
Shawn a53320069b Fix trace logger level not work (#2408)
* Fix trace logger level not work #2385
2019-04-10 09:14:53 +08:00
JianBo He aad2d7378e Put peername into messsage headers (#2390)
* Put peername into the message.heaers
2019-04-04 13:41:03 +08:00
Shawn 2306789755 Remove bin_key_map/1 (#2393)
* Remove bin_key_map/1

* Fix Travis-CI failure
2019-04-03 19:41:21 +08:00
Feng Lee 60c2b8bc08 Add more functions to read fields of 'message' record
- Add id/1, topic/1, from/1, payload/1 and timestamp/1 functions
- Improve the test cases
2019-04-02 15:15:13 +08:00
Gilbert Wong 7baa317d55 Delete useless assert to pass ci 2019-03-28 13:48:06 +08:00
Feng Lee dba16aeea5 Add 'remove_header/2', 'get_headers/1' functions
- Adopt new 'export' style
- Add 'remove_header/2', 'get_headers/1' functions
- Remove 'remove_topic_alias/1' function
2019-03-22 11:31:26 +08:00
JianBo He 8a73c62f66 Fix followed packet parse failure (#2333)
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.
2019-03-20 10:14:52 +08:00
Gilbert Wong d020ac0390 Delay receive waiting time 2019-03-18 14:20:52 +08:00
YoukiLin 88c32b2c41 Fix emqx_rpc badargs bug 2019-03-16 21:27:41 +08:00
Shawn 02fe8560e2
Improve emqx_hooks and credentials (#2309)
* 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
2019-03-16 10:43:53 +08:00
Feng Lee 56718e35cb Add emqx_topic:tokens/1 function (#2305)
* Add emqx_topic:tokens/1 function
2019-03-13 23:31:44 +08:00
Shawn 111b66121c
Support TLS/DTLS PSK (#2297)
* Improve filter functions for emqx-hook

* Add PSK hook

* Reset hook args for filter functions
2019-03-13 22:24:19 +08:00
spring2maz 48450d1d37 Move request response out of emqx client (#2293)
* 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
2019-03-13 11:27:25 +08:00
Gilbert Wong 27a7105fac Fix emqx_alarm_handler_SUITE
Prior to this change, emqx_alarm_handler_SUITE read emqx.conf rather
gen.emqx.conf which would trigger unexpected errors

This change fix this issue.
2019-03-13 10:52:15 +08:00
周子博 6816c1ac3e Delete needless test case in emqx_protocol_SUITE 2019-03-12 10:17:22 +08:00
spring2maz 1e27098e8c Drain msg queue for deterministic test 2019-03-05 04:28:01 +01:00
spring2maz a056a4cbde Eliminate {error, inflight_full} from publish call to emqx_client
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.
2019-03-05 03:47:33 +01:00
turtled 22aa7d4668 Rm acl_deny_action_ct test case 2019-02-28 22:19:19 +08:00
tigercl da755b88c7 Add monitors and alarm handler (#2266)
* Add monitors and alarm handler
2019-02-28 18:25:17 +08:00
Gilbert c26d13b057 Fix test case (#2275)
* Fix t_rpc test
2019-02-28 18:07:16 +08:00
turtled c8e2840126 Merge fix conflicts 2019-02-28 17:02:39 +08:00
linjun 814fd3fc9e Fix test case 2019-02-28 16:36:47 +08:00
Gilbert Wong 7efd7b3ec0 Rename portal to bridge 2019-02-28 15:31:54 +08:00
Gilbert 771f8c052a
Merge branch 'develop' into introduce-new-bridge-impl 2019-02-28 15:14:40 +08:00
Feng Lee e3bc8e4f0a Support batch delivery
- Upgrade the emqx_session module to support batch delivery
- Update emqx_protocol:deliver/2 to support batch delivery
- Update some test cases
2019-02-28 15:09:13 +08:00
Feng Lee 08204fc7a8 Improve the emqx_connection module using gen_statem behaviour (#2235) 2019-02-28 15:08:29 +08:00
linjun 37c7e684b0 Adjusting code 2019-02-28 14:32:13 +08:00
linjun 16165ce935 Use conn_mod instead of socktype 2019-02-28 11:32:05 +08:00
Gilbert Wong 911a813891 Fix copyright and unify log method 2019-02-28 11:18:12 +08:00
spring2maz 9dbc34c376 Ack replayq and allow retry in tests 2019-02-28 11:17:27 +08:00
Gilbert Wong ec37225333 Add emqx_portal interfaces 2019-02-28 11:17:27 +08:00
Gilbert Wong 921a45a505 Fix emqx_portal_mqtt_tests start function 2019-02-28 11:17:27 +08:00
spring2maz d4495fd8e7 Add manual start API 2019-02-28 11:17:27 +08:00
Gilbert 796fc3b1ba Fix app config generation (#2245) 2019-02-28 11:17:27 +08:00
spring2maz 1626cade28 Deleted batch publish support in emqx_portal_client
eqmx_portal_mqtt has to do single message publish calls for now
Also fix a bug in emqx_portal_mqtt ack collector
2019-02-28 11:17:27 +08:00
spring2maz 086a1d56b9 Drop unused config schema
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
2019-02-28 11:17:27 +08:00
spring2maz efc9e34033 Make use of BUMP_PACKET_ID the only way to generate packet IDs 2019-02-28 11:17:27 +08:00
spring2maz 786a6eb696 Add APIs for subscription add / delete 2019-02-28 11:17:27 +08:00
spring2maz 599f5c8d4f Add API emqx_portal:ensure_forward_absent 2019-02-28 11:17:27 +08:00
spring2maz 2903a810ce Add emqx_portal:ensure_foreard_present API 2019-02-28 11:17:27 +08:00
spring2maz 9e78c18681 Add get_forwards and get_subscriptions protal APIs 2019-02-28 11:17:27 +08:00
spring2maz 67376727c9 Add batch send support for emqx_client:publish/2
also cover emqx_portal_mqtt with CT
2019-02-28 11:17:27 +08:00
spring2maz b9e8bde3b0 Add first CT test for emqx_portal based on rpc 2019-02-28 11:17:27 +08:00
spring2maz 6d51d78dfc Add portal transport over emqx_client. 2019-02-28 11:17:27 +08:00
spring2maz fbe67e6784 Introduce new bridge impl 2019-02-28 11:17:27 +08:00
linjun 1fe7431370 Adjusting test case 2019-02-27 16:33:49 +08:00
linjun e16f2fe1fd Increasing coverage for emqx_message 2019-02-22 17:11:02 +08:00
张奇怪 44d3eff094 Auto-pull-request-by-2019-02-19 (#2232)
* Update Copyright to 2019 (#2191)

* Disable bridges by default (#2189)

* Fix warning logger args emqx#2195

* Ambiguity elimination (#2217)

* Fix emqx_ws_connection: prevent crashes on pong (#2210)

* Issue#2184 (#2194)

* Delete dep-vsn-check

* Format app.src
2019-02-19 14:00:34 +08:00
turtled 31e95b56c4 Update Copyright to 2019 2019-01-29 10:43:25 +08:00
turtleDeng 00863acea3
Merge emqx30 (#2181)
* Change the reason code in will topic acl check (#2168)

* Fix bridge bug (#2160)

* Limit bridge QoS less than 1

* Improve shared sub dispatch implementation. (#2144)

* Upgrade ekka, esockd libraries

* Improve the 'try_open_session' function

* Reload config (#2180)
2019-01-25 13:01:48 +08:00
Shawn b8929a46c1 Fix the EXIT outputs in Travis CI (#2154)
* 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
2019-01-17 17:14:51 +08:00
tigercl bc31faac6b Fix will msg (#2156)
* Remove will_msg and will_topic from protocol state

* Modify try_open_session/1
2019-01-17 13:57:42 +08:00
YoukiLin 3748cd434d Add test case for emqx_sys_mon (#2150) 2019-01-12 23:09:39 +08:00
Gilbert Wong 7aa46896df Fix typo 2019-01-11 16:41:20 +08:00
Gilbert Wong ec03f8e1fa Fix the deliver packet bug and add test case 2019-01-11 16:41:20 +08:00
turtleDeng a5f9466040 QoS0 msg support msgid (#2145)
* QoS0 msg support msgid

* Fix testcase
2019-01-11 11:47:10 +08:00
Feng Lee fe0f5333b3 Improve the pool design
- Move 'emqx_pool:start_link/0' to emqx_pool_sup module
- Use the new log macros
- Add more test cases
2019-01-10 08:49:58 +08:00
Feng Lee 36a4eaec02 Fix the test case for 'emqx_router:print_routes/1' 2019-01-09 12:10:54 +08:00
Feng Lee 52241a7804 Add more test cases for code coverage 2019-01-09 11:57:22 +08:00
Feng Lee d27c824ed8 Add test case for emqx_trie:empty/0 2019-01-09 11:57:22 +08:00
Gilbert 9f83544fce
Fix failed testcase (#2127)
* 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
2019-01-06 19:53:01 +08:00
YoukiLin 78b3c375d8
Improving 'emqx_ws_connection' coverage (#2107) 2019-01-03 12:59:39 +08:00
turtleDeng 6a1ebe299a
Merge emqx32 to emqx30 (#2112) 2018-12-28 19:44:41 +08:00
Gilbert 1797aadbe7 Fix unsuback compat (#2102) 2018-12-22 18:47:38 +08:00
turtled 7d3357e0f3 Merge emqx32 2018-12-21 16:01:32 +08:00
Feng Lee 10e5210581 Workaround ssl:setopts(SslSock, [{active, N}]) (#2095)
* Set '{active, true}' for SSL socket
2018-12-21 15:39:24 +08:00
tigercl 31bf01fd7a Fix bug in topic alias maximum (#2074)
* Fix bug in topic alias maximum
2018-12-21 14:01:21 +08:00
Gilbert bf7f10ecd1 Add will topic validation and acl check (#2075)
* Add will topic validation and acl check
2018-12-21 10:49:03 +08:00
Feng Lee c93d0fb174 Add test cases for emqx_gc module 2018-12-21 10:28:33 +08:00
Gilbert Wong 1007105b57 Delete metrics test in session test suite 2018-12-20 22:31:19 +08:00
turtled b4833d6973 Fixed conflicts 2018-12-20 22:23:20 +08:00
YoukiLin 6b538d2363 Add test cases for 'emqx_cm' and 'emqx_sm' (#2073)
Add test cases for 'emqx_cm' and 'emqx_cn'
2018-12-20 21:03:40 +08:00
Feng Lee 14cffcf7fb Add the 'emqx_pd' module
Add utility functions for erlang process dictionary
Add test cases for emqx_pd
2018-12-20 16:45:25 +08:00
tigercl 97474171d0 Better report errors in acl.conf (#2065) 2018-12-19 23:06:48 +08:00
turtled 7a1ec580b0 Update broker test cases 2018-12-19 17:18:26 +08:00
Gilbert 7d9e350bbe Add option to disconnect client in case acl deny (#2059)
* Add option to disconnect client in case acl deny
2018-12-19 10:34:06 +08:00
turtled 666d9706a3 Fixed conflicts 2018-12-18 16:41:10 +08:00
Feng Lee 721b72b96a Add 'active_n' option to optimize the CPU usage of emqx_connection (#2060)
* Add 'active_n' option to optimize the CPU usage of emqx_connection

* Supports batch processing 'DOWN' events
2018-12-17 19:53:29 +08:00
turtled 34370ef622 Merge branch 'issue#1983' into emqx30 2018-12-14 17:55:36 +08:00
Feng Lee 2a747c9d53 Improve the subscription sharding. 2018-12-12 13:40:01 +08:00
Feng Lee b279eff181 Add t_mnesia/1 test case 2018-12-12 13:40:01 +08:00
Feng Lee 33830d8120 Improve the design of trie, router and broker modules
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
2018-12-12 13:40:01 +08:00
周子博 ec2e289776 Fix crash in emqx_acl_internal:filter/2 2018-12-10 11:13:25 +08:00
Feng Lee faac09eac9 Merge subscription sharding 2018-12-10 10:28:01 +08:00
Gilbert Wong e0eb76afa6 Fix subscription 2018-12-08 16:09:54 +08:00
Feng Lee bce1ddc5c4 Implement a hash-based subscription sharding 2018-12-06 18:45:07 +08:00
Feng Lee b4d981daf2 Add a sequence module to generate index for subscription sharding 2018-12-04 15:59:24 +08:00
Gilbert Wong 61030c8d10 Add eunit tests to increase coverage. 2018-12-03 09:15:10 +08:00
Gilbert 295a9d692e
Fix the coverage shaky (#2010) 2018-11-30 19:16:48 +08:00
周子博 ddb9eaef7b Improve test coverage of emqx_metrics 2018-11-30 17:44:29 +08:00
周子博 ea62b15c87 Alter apis provided by emqx_metrics, and use existing timer to commit metrics 2018-11-30 17:44:29 +08:00
周子博 194dbc02c8 Add batch commit for metrics 2018-11-30 17:44:29 +08:00
Feng Lee 21ed012a0c Add an elegant batch module 2018-11-29 10:13:09 +08:00
周子博 5c291ff23e Fix the 'route_batch_delete' config 2018-11-28 16:04:04 +08:00
tigercl 14b8036576 Use username replace id(issue#1737) (#1961)
* Use username replace id(issue#1737)

* Add test case for issue#1737

* Make with_connection/2 support batch connect
2018-11-21 22:51:33 +08:00
spring2maz a2c658ba19 Add acking mechamism for shared dispatch (#1872)
* 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.
2018-11-21 22:49:45 +08:00
Gilbert 16821490ce Fix issue#1874 (#1964)
* 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
2018-11-19 13:34:03 +08:00
turtled faeda253e1 Fix conflicts 2018-11-10 11:44:55 +08:00
terry-xiaoyu 997958aed1 Change the start_link API for emqx_client
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`.
2018-11-09 17:43:04 +08:00
Gilbert Wong 32d3826440 Replace macro QOS$i to QOS_$I
The two styles of qos macro name in one project is chaotic. It is not
a good practice.

So I change the QOS$i to QOS_$i
2018-11-08 20:42:31 +08:00
terry-xiaoyu 94dbdffd59 New logger formatter with meta-data 2018-11-02 18:38:07 +08:00
spring2maz ae743ad1f0 Rewrite emqx_mqueue.erl
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
2018-10-27 14:21:53 +02:00
tigercl 64cb920b3b
Merge branch 'emqx30' into improve_connect 2018-10-27 14:27:25 +08:00
turtleDeng 8788cb2158
Merge pull request #1921 from emqx/improve_test_cases
Improve test cases
2018-10-26 19:45:18 +08:00
周子博 92251d4a8a Make more normalize 2018-10-26 17:45:13 +08:00
tigercl abb2e5c918
Improve test cases, and fix some bugs (#1920)
* Improve emqx_banned, emqx_pqueue, emqx_router test cases

* Improve emqx_broker test case, and fix bug in emqx_broker

* Add emqx_hooks to CT_SUITES
2018-10-26 17:27:02 +08:00
Gilbert 0b44c1b75f
improve_test_cases 2018-10-26 17:25:31 +08:00
周子博 e56252dac6 Fix bugs in test cases 2018-10-26 14:34:22 +08:00
Gilbert 7544a21e25
Add test cases for emqx_bridge, emqx_mod_rewrite (#1914) 2018-10-26 14:04:33 +08:00
周子博 ffa220a87d Fix bug in test case 2018-10-26 10:46:56 +08:00
周子博 6675e3d496 Implement will message delay publish in session, add test case for clean start and will message in connect packet 2018-10-25 14:26:31 +08:00
Gilbert Wong a1092a6784 Add eunit cases and fix typo. 2018-10-24 15:59:22 +08:00
tigercl 873a08dc94
Improve coverage for emqx_hooks, and add test case for emqx_mod_sup (#1892)
Improve coverage for emqx_hooks, and add test case for emqx_mod_sup
2018-10-19 16:21:43 +08:00
tigercl 55a12c1ab4
Merge branch 'emqx30' into improve_connect 2018-10-19 16:03:17 +08:00
huangdan 73658b3953 Merged emqx_misc_SUITE to emqx_misc_tests (#1890)
* Merged emqx_misc_SUITE to emqx_misc_tests
2018-10-19 09:46:25 +02:00
Gilbert 4c40f75f4b Request & Response (broker and client) (#1819)
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
2018-10-18 19:21:05 +02:00
spring2maz 7e7d99fbad Change more stats callbacks to full M:F/A
Including emqx_sm emqx_cm emqx_router_helper
2018-10-19 00:22:29 +08:00
spring2maz 4082f3ade2 Improve stats test
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
2018-10-19 00:22:29 +08:00
周子博 6ffd0ac44f Increase coverage for emqx_protocol 2018-10-10 18:35:47 +08:00
周子博 12da230662 Increase coverage 2018-10-10 15:53:01 +08:00
spring2maz e3f2ae8db8 Change from customized total heap size check to set process flag
The `max_heap_size` process flag can be used to limit total
heap size of a process, and it gives much more detailed
crash log if the limit is hit.
2018-09-29 21:36:34 +08:00
周子博 a77f8d28f9 Improve coverage 2018-09-29 14:47:21 +08:00
周子博 2d354ca883 Improve topic alias maximum in connect packet 2018-09-29 14:47:21 +08:00
周子博 064db65206 improve receive maximum in connect packet 2018-09-29 14:47:21 +08:00
spring2maz 0b0ef9bd54 Fix default QoS in test cases 2018-09-25 22:09:13 +08:00
spring2maz 3b9247994d Refine emqx_mock_client
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
2018-09-22 10:51:38 +02:00
spring2maz b35d37c92d Add new shared subscription dispatch strategy
'random' was already there before this change
Added two new strategies: 'sticky' and 'round_robin'
'sticky' is made default as it is the cheapest
2018-09-22 10:50:34 +02:00
tigercl 03f607c1b2 Fix issue#1833 and #1834 (#1845) 2018-09-22 16:10:24 +08:00
turtleDeng 8653732bae Revert "Calculate the 1.5 keep alive time exactly" 2018-09-22 14:52:31 +08:00
spring2maz b61615323b Move shutdown policy config to zone configs 2018-09-21 18:58:18 +02:00
spring2maz f70d16e387 Add a test case to cover timeout message flush in emqx_misc 2018-09-21 18:58:18 +02:00
spring2maz 6fca651a84 Add connection/session shutdown policy
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
2018-09-21 18:58:18 +02:00
spring2maz 721f237bc4 Rewrite emqx_gc.erl
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
2018-09-21 22:56:34 +08:00
周子博 b1d4ec750a Remove the same test cases as emqx_keepalive 2018-09-20 17:58:54 +08:00
周子博 2c350bf5fb Match test case for last change 2018-09-20 17:19:21 +08:00
HuangDan 3822ff987b Fix function args
Add test cases for emqx_pool module
2018-09-18 09:15:46 +08:00
周子博 5eb92e37cc Remove check for MQTT path, and normalize code 2018-09-14 11:49:17 +08:00
周子博 5465b015be Add test case for last change 2018-09-14 11:49:17 +08:00
Gilbert Wong 45b2686e1c Delete unnecessary code
Prior to this change, there are multiple deprecated functions.
2018-09-14 09:45:34 +08:00
HuangDan fde6a2a4c3 Fixed issue #1811
Add tests case for issue #1811
2018-09-13 22:55:15 +08:00
Gilbert Wong caedcee2de fix listerners and access suites
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.
2018-09-08 09:33:37 +02:00
周子博 08bab7efa4 Fix bugs in test cases 2018-09-08 11:49:20 +08:00
turtleDeng c0ddbba5db
Merge pull request #1794 from spring2maz/generate-temp-config-for-test
Generate a config file for testing
2018-09-07 21:50:35 +08:00
turtleDeng 0ec461484e
Merge pull request #1790 from emqx/emqx30-feng
Improve the Hooks' design
2018-09-07 21:46:30 +08:00
Gilbert 84e43c587d
Merge branch 'emqx30' into emqx30 2018-09-07 18:49:11 +08:00
turtleDeng cb058143a5
Merge pull request #1792 from huangdan/master
Add test cases for mqtt5 connect packet
2018-09-07 18:03:37 +08:00
turtleDeng ba176f2073
Merge pull request #1797 from terry-xiaoyu/banned_api_v2
Update for banned API
2018-09-07 17:50:30 +08:00
周子博 1c5615c957 Stop emqx_zone when emqx_mqtt_caps test over 2018-09-07 17:22:24 +08:00
terry-xiaoyu dd8513ad35 Update for banned API
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.
2018-09-07 14:10:16 +08:00
spring2maz 3a94d7ddae Generate a config file for testing
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
2018-09-07 07:04:04 +02:00
Feng Lee 304a24ca6a Code Review: Update the zone module
1. Add force_reload/0 management API
2. Change the reload interval to 5 minutes
2018-09-07 10:26:14 +08:00
Gilbert Wong 765ab5ad7b Add condition to handle when mqx_topic_alias do not exist 2018-09-06 19:09:29 +08:00