Commit Graph

88 Commits

Author SHA1 Message Date
Diana Parra Corbacho d4148cd611 Mqtt test: Solve dependencies for web mqtt 2025-06-11 09:44:14 +02:00
David Ansari 98d6973b01 Add missing test
Follow up of https://github.com/rabbitmq/rabbitmq-server/pull/14006
2025-06-04 18:37:55 +02:00
Michael Klishin 24464a6c9b
Propagate one more Web MQTT test #14006
Trigger a 4.2.x alpha release build / trigger_alpha_build (push) Waiting to run Details
Test (make) / Build and Xref (1.17, 26) (push) Waiting to run Details
Test (make) / Build and Xref (1.17, 27) (push) Waiting to run Details
Test (make) / Test (1.17, 27, khepri) (push) Waiting to run Details
Test (make) / Test (1.17, 27, mnesia) (push) Waiting to run Details
Test (make) / Test mixed clusters (1.17, 27, khepri) (push) Waiting to run Details
Test (make) / Test mixed clusters (1.17, 27, mnesia) (push) Waiting to run Details
Test (make) / Type check (1.17, 27) (push) Waiting to run Details
Test Authentication/Authorization backends via mutiple messaging protocols / selenium (chrome, 1.17.3, 27.3) (push) Has been cancelled Details
Test Management UI with Selenium / selenium (chrome, 1.17.3, 27.3) (push) Has been cancelled Details
Test Authentication/Authorization backends via mutiple messaging protocols / summary-selenium (push) Has been cancelled Details
2025-06-04 19:41:09 +04:00
Marcial Rosales 57ef5ea64f Delete mqtt qos0 when connection closes 2025-06-04 10:49:19 +02:00
Diana Parra Corbacho d91c9d61d4
web_mqtt: propagate notify_consumer_quorum/qos0_queue_deleted to mqtt_shared_SUITE 2025-06-03 00:40:04 +04:00
Michael Klishin 9eaa22066b
web_mqtt: propagate notify_consumer_classic_queue_deleted to mqtt_shared_SUITE 2025-06-03 00:40:04 +04:00
David Ansari 21bd300d61 Support outgoing message interceptors 2025-04-23 14:01:42 +02:00
David Ansari 579c58603e Support AMQP over WebSocket (OSS part) 2025-01-27 17:50:47 +01:00
Michael Klishin 968eefa1bb
Bump (c) line year
There are no functional changes to this massive diff.
2025-01-01 17:54:10 -05:00
Michael Klishin f3540ee7d2
web_mqtt_shared_SUITE: propagate flow_classic_queue to mqtt_shared_SUITE #12907 12906 2024-12-09 23:13:55 -05:00
Loïc Hoguin 027700eec2
Add missing test case to web_mqtt_shared_SUITE 2024-09-30 12:35:44 +02:00
David Ansari f002029ebd
Do not open WebMQTT connection in MQTT plugin 2024-09-30 12:35:41 +02:00
Loïc Hoguin ddab3d523f
mqtt tests: Move v5 web_mqtt tests out of rabbitmq_mqtt 2024-09-30 12:35:41 +02:00
Loïc Hoguin 690b830e43
mqtt tests: Move web_mqtt tests out of rabbitmq_mqtt
The shared test suite was renamed only for clarity, but the
Web-MQTT test suites were renamed out of necessity: since
we are now adding the MQTT test directory to the code path
we need test suites to have different names to avoid
conflicts. We can't (easily) addpath only for this test suite
either since CT hooks don't call functions in a predictable
enough manner; it would always be hacky.
2024-09-30 12:35:41 +02:00
Michael Klishin 8b90d4a27c Allow for tagged values for a few more rabbitmq.conf settings 2024-08-13 16:27:00 -04:00
David Ansari 50116f0927 Require MQTT feature flags in 4.0
Require all MQTT feature flags and remove their compatibility code:
* delete_ra_cluster_mqtt_node
* rabbit_mqtt_qos0_queue
* mqtt_v5

These feature flags were introduced in or before 3.13.0.
2024-07-10 10:27:59 +02:00
David Ansari 3fd96b509a Avoid rabbit_ct_helpers:is_mixed_versions/0
Fixes https://github.com/rabbitmq/rabbitmq-server/pull/10761#discussion_r1528039577 :
"Could you please check a real condition that the old
version can't be used as part of this test?
is_mixed_versions() will still return true in 10 years
when testing RabbitMQ 21.x against 22.x. This function should
almost never be used."
2024-03-21 16:42:57 +01:00
Michael Klishin e3051f84df Web MQTT command_SUITE: cosmetics 2024-03-17 00:38:34 -04:00
Michael Klishin 5ddc16f8a6 Web MQTT command_SUITE: skip in mixed version mode 2024-03-16 23:45:49 -04:00
LoisSotoLopez 481cac6430 Fix/9302 test list Web MQTT connections command
Discussion #9302
2024-03-16 13:08:30 -04:00
Michael Klishin 01092ff31f
(c) year bumps 2024-01-01 22:02:20 -05:00
Michael Klishin 1b642353ca
Update (c) according to [1]
1. https://investors.broadcom.com/news-releases/news-release-details/broadcom-and-vmware-intend-close-transaction-november-22-2023
2023-11-21 23:18:22 -05:00
Michael Klishin 71a23c3675 Renaming in follow-up to #8790
{prefix}.enable_file_handle_cache => {prefix}.use_file_handle_cache
2023-07-10 13:35:25 +04:00
Michael Klishin 1402183bc2 Introduce a way to disable FHC use in web_mqtt
Via `web_mqtt.enable_file_handle_cache`
2023-07-09 09:16:17 +04:00
Loïc Hoguin 610af302c6
Add support for LOCAL proxy header
This is what the proxy uses for health checks. In those cases
we use the socket's IP/ports for the connection name as we
have nothing else we can use.
2023-06-23 12:12:58 +02:00
Michal Kuratczyk d04b3afe9b verify_none in a couple of tests 2023-04-24 13:11:44 +00:00
Michal Kuratczyk 9345707739
verify_none in rfc6455_client 2023-04-14 16:15:21 +02:00
Chunyi Lyu 209f23fa2f
Revert "Format MQTT code with `erlfmt`" 2023-01-27 18:25:57 +00:00
Chunyi Lyu 1de9fcf582 Format mqtt files with erlfmt 2023-01-27 11:06:41 +00:00
David Ansari d651f87ea7 Share tests between MQTT and Web MQTT
New test suite deps/rabbitmq_mqtt/test/shared_SUITE contains tests that
are executed against both MQTT and Web MQTT.

This has two major advantages:
1. Eliminates test code duplication between rabbitmq_mqtt and
rabbitmq_web_mqtt making the tests easier to maintain and to understand.
2. Increases test coverage of Web MQTT.

It's acceptable to add a **test** dependency from rabbitmq_mqtt to
rabbitmq_web_mqtt. Obviously, there should be no such dependency
for non-test code.
2023-01-24 17:32:59 +00:00
David Ansari 7c1aa49361 Increase MQTT test coverage and fix edge cases 2023-01-24 17:32:59 +00:00
David Ansari fb6c8da2fc Block Web MQTT connection if memory or disk alarm
Previously (until RabbitMQ v3.11.x), a memory or disk alarm did
not block the Web MQTT connection because this feature was only
implemented half way through: The part that registers the Web MQTT
connection with rabbit_alarm was missing.
2023-01-24 17:32:59 +00:00
David Ansari 56e97a9142 Fix MQTT in management plugin
1. Allow to inspect an (web) MQTT connection.
2. Show MQTT client ID on connection page as part of client_properties.
3. Handle force_event_refresh (when management_plugin gets enabled
   after (web) MQTT connections got created).
4. Reduce code duplication between protocol readers.
5. Display '?' instead of 'NaN' in UI for absent queue metrics.
6. Allow an (web) MQTT connection to be closed via management_plugin.

For 6. this commit takes the same approach as already done for the stream
plugin:
The stream plugin registers neither with {type, network} nor {type,
direct}.
We cannot use gen_server:call/3 anymore to close the connection
because the web MQTT connection cannot handle gen_server calls (only
casts).
Strictly speaking, this commit requires a feature flag to allow to force
closing stream connections from the management plugin during a rolling
update. However, given that this is rather an edge case, and there is a
workaround (connect to the node directly hosting the stream connection),
this commit will not introduce a new feature flag.
2023-01-24 17:30:10 +00:00
Chunyi Lyu 340e930d28 Web mqtt returns 1002 with mqtt parsing error
- it is a mqtt protocol error
2023-01-24 17:30:10 +00:00
Chunyi Lyu 482bef519d Stop rabbit_mqtt_packet:parse from crashing in web mqtt
- add a wrapper for mqtt parse/2 to prevent crashing when
parse/2 fails to parse a packet
- add invalid packet test case for web mqtt; server will respond
status code 1007, same status code as framing error
2023-01-24 17:30:10 +00:00
David Ansari bd0acb33e4 Remove test helper util:connect_to_node/3
because this method is superfluous given that util:connect
already exists.
2023-01-24 17:30:10 +00:00
Chunyi Lyu d5e497f8b6 Web mqtt: backfill test for connecting with duplicated id 2023-01-24 17:30:10 +00:00
Chunyi Lyu 2a7f22fa26 Web mqtt: close connection when receive invalid data
- from https://www.rfc-editor.org/rfc/rfc6455#section-7.4.1,
code `1003` is for "an endpoint is terminating the connection
because it has received a type of data it cannot accept"
2023-01-24 17:30:10 +00:00
Chunyi Lyu b3215ebaf1 Set close header when close connection in web_mqtt init/2 2023-01-24 17:30:10 +00:00
David Ansari 15636fdb90 Rename frame to packet
The MQTT protocol specs define the term "MQTT Control Packet".
The MQTT specs never talk about "frame".

Let's reflect this naming in the source code since things get confusing
otherwise:
Packets belong to MQTT.
Frames belong to AMQP 0.9.1 or web sockets.
2023-01-24 17:30:10 +00:00
Chunyi Lyu 1180429c96 Terminate connection if mqtt not found in web sup protocol
- per MQTT spec
2023-01-24 17:30:10 +00:00
David Ansari 6605a16830 Fix rabbitmq_web_mqtt:system_SUITE-mixed 2023-01-24 17:30:10 +00:00
David Ansari 76f4598d92 Send last will if client did not DISCONNECT
"The Will Message MUST be published when the Network Connection is subsequently
closed unless the Will Message has been deleted by the Server on receipt of a
DISCONNECT Packet [MQTT-3.1.2-8].
Situations in which the Will Message is published include, but are not limited to:
•	An I/O error or network failure detected by the Server.
•	The Client fails to communicate within the Keep Alive time.
•	The Client closes the Network Connection without first sending a DISCONNECT Packet.
•	The Server closes the Network Connection because of a protocol error.
"

Prior to this commit, the will message was not sent in all scenarios
where it should have been sent.

In this commit, the will message is always sent unless the client sent a
DISCONNECT packet to the server.

We achieve this by sending the will message in the terminate callback.

Note that the Reason passed into the terminate callback of
rabbit_web_mqtt_handler is the atom 'stop' (that is, we cannot pass a custom
reason here).

Therefore, in order to know within the terminate callback whether the client
sent a DISCONNECT packet, we have to modify the process state.
Rather than including a new field into the process state record which requires
1 additional word per MQTT connection (i.e. expensive with millions of
MQTT connection processes - we want to keep the process state small),
we intead modify the state just before stopping the process to
{SendWill, State}.
2023-01-24 17:30:10 +00:00
Chunyi Lyu fb81a92116 Add ws_connect helper to web mqtt tests 2023-01-24 17:29:08 +00:00
David Ansari 9fd5704e30 Fix mixed version Web MQTT system tests
In mixed verion tests all non-required feature flags are disabled.
Therefore, MQTT client ID tracking happens in Ra.
The Ra client sends commands asynchronously when registering and
deregistering the client ID.

Also, add more tests.
2023-01-24 17:29:07 +00:00
David Ansari 4c15299196 Delete old emqttc client
Instead use latest emqtt client for Web MQTT tests.
2023-01-24 17:29:07 +00:00
Chunyi Lyu df491d3489 Use eqmtt client in web mqtt tests 2023-01-24 17:29:07 +00:00
Chunyi Lyu 1925862b1e Test drain closing connections in web mqtt
- web mqtt connections are tracked by rabbitmq_mqtt and will be
closed by mqtt event handler at node drain.
2023-01-24 17:29:07 +00:00
David Ansari 5710a9474a Support MQTT Keepalive in WebMQTT
Share the same MQTT keepalive code between rabbit_mqtt_reader and
rabbit_web_mqtt_handler.

Add MQTT keepalive test in both plugins rabbitmq_mqtt and
rabbitmq_web_mqtt.
2023-01-24 17:29:07 +00:00
David Ansari 6f00ccb3ad Get all existing rabbitmq_web_mqtt tests green 2023-01-24 17:29:07 +00:00