From 14fe08152f9044f8586087da17d4896f08cab0d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 5 Sep 2024 13:48:54 +0200 Subject: [PATCH 01/45] Merge feature_flags_with_unpriveleged_user_SUITE back in ff_SUITE On GH Actions we run as an unprivileged user by default. --- deps/rabbit/BUILD.bazel | 16 ----- deps/rabbit/app.bzl | 8 --- deps/rabbit/ct.test.spec | 1 - deps/rabbit/test/feature_flags_SUITE.erl | 3 + ...ure_flags_with_unpriveleged_user_SUITE.erl | 72 ------------------- 5 files changed, 3 insertions(+), 97 deletions(-) delete mode 100644 deps/rabbit/test/feature_flags_with_unpriveleged_user_SUITE.erl diff --git a/deps/rabbit/BUILD.bazel b/deps/rabbit/BUILD.bazel index b7ca6a7f84a1..dfde24add9fa 100644 --- a/deps/rabbit/BUILD.bazel +++ b/deps/rabbit/BUILD.bazel @@ -462,22 +462,6 @@ rabbitmq_integration_suite( size = "large", ) -rabbitmq_integration_suite( - name = "feature_flags_with_unpriveleged_user_SUITE", - size = "large", - additional_beam = [ - ":feature_flags_SUITE_beam_files", - ], - flaky = True, - shard_count = 2, - # The enabling_* tests chmod files and then expect writes to be blocked. - # This probably doesn't work because we are root in the remote docker image. - tags = ["no-remote-exec"], - runtime_deps = [ - "//deps/rabbit/test/feature_flags_SUITE_data/my_plugin:erlang_app", - ], -) - rabbitmq_integration_suite( name = "msg_size_metrics_SUITE", runtime_deps = [ diff --git a/deps/rabbit/app.bzl b/deps/rabbit/app.bzl index bc0ad2830a5b..4832861d9782 100644 --- a/deps/rabbit/app.bzl +++ b/deps/rabbit/app.bzl @@ -994,14 +994,6 @@ def test_suite_beam_files(name = "test_suite_beam_files"): app_name = "rabbit", erlc_opts = "//:test_erlc_opts", ) - erlang_bytecode( - name = "feature_flags_with_unpriveleged_user_SUITE_beam_files", - testonly = True, - srcs = ["test/feature_flags_with_unpriveleged_user_SUITE.erl"], - outs = ["test/feature_flags_with_unpriveleged_user_SUITE.beam"], - app_name = "rabbit", - erlc_opts = "//:test_erlc_opts", - ) erlang_bytecode( name = "list_consumers_sanity_check_SUITE_beam_files", testonly = True, diff --git a/deps/rabbit/ct.test.spec b/deps/rabbit/ct.test.spec index 8d662b8c1f3c..6740594c1500 100644 --- a/deps/rabbit/ct.test.spec +++ b/deps/rabbit/ct.test.spec @@ -48,7 +48,6 @@ cli_forget_cluster_node_SUITE , feature_flags_SUITE , feature_flags_v2_SUITE -, feature_flags_with_unpriveleged_user_SUITE , list_consumers_sanity_check_SUITE , list_queues_online_and_offline_SUITE , logging_SUITE diff --git a/deps/rabbit/test/feature_flags_SUITE.erl b/deps/rabbit/test/feature_flags_SUITE.erl index 23f690b32c29..cf1ff3e2e7eb 100644 --- a/deps/rabbit/test/feature_flags_SUITE.erl +++ b/deps/rabbit/test/feature_flags_SUITE.erl @@ -64,6 +64,7 @@ groups() -> [ enable_feature_flag_in_a_healthy_situation, enable_unsupported_feature_flag_in_a_healthy_situation, + enable_feature_flag_when_ff_file_is_unwritable, required_feature_flag_enabled_by_default, required_plugin_feature_flag_enabled_by_default, required_plugin_feature_flag_enabled_after_activation, @@ -73,6 +74,7 @@ groups() -> [ enable_feature_flag_in_a_healthy_situation, enable_unsupported_feature_flag_in_a_healthy_situation, + enable_feature_flag_when_ff_file_is_unwritable, enable_feature_flag_with_a_network_partition, mark_feature_flag_as_enabled_with_a_network_partition, required_feature_flag_enabled_by_default, @@ -653,6 +655,7 @@ enable_unsupported_feature_flag_in_a_healthy_situation(Config) -> False, is_feature_flag_enabled(Config, FeatureName)). +%% This test case must run as an unprivileged user. enable_feature_flag_when_ff_file_is_unwritable(Config) -> Supported = rabbit_ct_broker_helpers:is_feature_flag_supported( Config, ff_from_testsuite), diff --git a/deps/rabbit/test/feature_flags_with_unpriveleged_user_SUITE.erl b/deps/rabbit/test/feature_flags_with_unpriveleged_user_SUITE.erl deleted file mode 100644 index d8b627da39d4..000000000000 --- a/deps/rabbit/test/feature_flags_with_unpriveleged_user_SUITE.erl +++ /dev/null @@ -1,72 +0,0 @@ -%% This Source Code Form is subject to the terms of the Mozilla Public -%% License, v. 2.0. If a copy of the MPL was not distributed with this -%% file, You can obtain one at https://mozilla.org/MPL/2.0/. -%% -%% Copyright (c) 2007-2024 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved. -%% - --module(feature_flags_with_unpriveleged_user_SUITE). - --include_lib("eunit/include/eunit.hrl"). - --export([suite/0, - all/0, - groups/0, - init_per_suite/1, - end_per_suite/1, - init_per_group/2, - end_per_group/2, - init_per_testcase/2, - end_per_testcase/2, - - enable_feature_flag_when_ff_file_is_unwritable/1 - ]). - -suite() -> - [{timetrap, {minutes, 5}}]. - -all() -> - [ - {group, enabling_on_single_node}, - {group, enabling_in_cluster} - ]. - -groups() -> - [ - {enabling_on_single_node, [], - [ - enable_feature_flag_when_ff_file_is_unwritable - ]}, - {enabling_in_cluster, [], - [ - enable_feature_flag_when_ff_file_is_unwritable - ]} - ]. - -%% This suite exists to allow running a portion of the feature_flags_SUITE -%% under separate conditions in ci - -init_per_suite(Config) -> - feature_flags_SUITE:init_per_suite(Config). - -end_per_suite(Config) -> - feature_flags_SUITE:end_per_suite(Config). - -init_per_group(Group, Config) -> - feature_flags_SUITE:init_per_group(Group, Config). - -end_per_group(Group, Config) -> - feature_flags_SUITE:end_per_group(Group, Config). - -init_per_testcase(Testcase, Config) -> - feature_flags_SUITE:init_per_testcase(Testcase, Config). - -end_per_testcase(Testcase, Config) -> - feature_flags_SUITE:end_per_testcase(Testcase, Config). - -%% ------------------------------------------------------------------- -%% Testcases. -%% ------------------------------------------------------------------- - -enable_feature_flag_when_ff_file_is_unwritable(Config) -> - feature_flags_SUITE:enable_feature_flag_when_ff_file_is_unwritable(Config). From 30a8de328789440fc2bcfdb3e962dfb6c77ac35a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 3 Sep 2024 13:32:41 +0200 Subject: [PATCH 02/45] rabbit tests: Delete some temporary files to reduce log sizes --- deps/rabbit/test/backing_queue_SUITE.erl | 1 + 1 file changed, 1 insertion(+) diff --git a/deps/rabbit/test/backing_queue_SUITE.erl b/deps/rabbit/test/backing_queue_SUITE.erl index 10129201b9dc..2b4ce444c991 100644 --- a/deps/rabbit/test/backing_queue_SUITE.erl +++ b/deps/rabbit/test/backing_queue_SUITE.erl @@ -517,6 +517,7 @@ msg_store_file_scan1(Config) -> Expected = gen_result(Blocks), Path = gen_msg_file(Config, Blocks), Result = rabbit_msg_store:scan_file_for_valid_messages(Path), + ok = file:delete(Path), case Result of Expected -> ok; _ -> {expected, Expected, got, Result} From 645942cf956515b8e6f8d15d579184179509a59c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 10 Sep 2024 16:02:38 +0200 Subject: [PATCH 03/45] make: Move dep_osiris in rabbitmq-components.mk Otherwise some plugins can't build if we try to run tests directly after checkout. This is because the plugins depend on osiris as well as rabbit, but there is no dep_osiris defined in the plugin itself. --- deps/rabbit/Makefile | 1 - rabbitmq-components.mk | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/rabbit/Makefile b/deps/rabbit/Makefile index e2ff17050323..066e863decc9 100644 --- a/deps/rabbit/Makefile +++ b/deps/rabbit/Makefile @@ -135,7 +135,6 @@ TEST_DEPS = rabbitmq_ct_helpers rabbitmq_ct_client_helpers meck proper amqp_clie PLT_APPS += mnesia runtime_tools dep_syslog = git https://github.com/schlagert/syslog 4.0.0 -dep_osiris = git https://github.com/rabbitmq/osiris v1.8.3 dep_systemd = hex 0.6.1 define usage_xml_to_erl diff --git a/rabbitmq-components.mk b/rabbitmq-components.mk index 683bed9ca367..7f4ed26236ab 100644 --- a/rabbitmq-components.mk +++ b/rabbitmq-components.mk @@ -48,6 +48,7 @@ dep_gen_batch_server = hex 0.8.8 dep_jose = hex 1.11.10 dep_khepri = hex 0.16.0 dep_khepri_mnesia_migration = hex 0.7.0 +dep_osiris = git https://github.com/rabbitmq/osiris v1.8.3 dep_prometheus = hex 4.11.0 dep_ra = hex 2.14.0 dep_ranch = hex 2.1.0 From f4f375c6a9ef6cb03f0f12ad7f06698fa4786d6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 2 Sep 2024 14:55:02 +0200 Subject: [PATCH 04/45] Use Make in CI This is a proof of concept that mostly works but is missing some tests, such as rabbitmq_mqtt or rabbitmq_cli. It also doesn't apply to mixed version testing yet. --- .github/workflows/test-make-ct-par.yaml | 55 +++++++++++++ .github/workflows/test-make-ct-seq.yaml | 64 +++++++++++++++ .github/workflows/test-make-jobs.yaml | 95 ++++++++++++++++++++++ .github/workflows/test-make.yaml | 66 +++++++++++++++ .github/workflows/test-mixed-versions.yaml | 4 +- .github/workflows/test.yaml | 21 ++++- deps/rabbit/Makefile | 94 ++++++++++++++++++++- deps/rabbitmq_mqtt/test/shared_SUITE.erl | 2 + rabbitmq-components.mk | 3 + 9 files changed, 397 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/test-make-ct-par.yaml create mode 100644 .github/workflows/test-make-ct-seq.yaml create mode 100644 .github/workflows/test-make-jobs.yaml create mode 100644 .github/workflows/test-make.yaml diff --git a/.github/workflows/test-make-ct-par.yaml b/.github/workflows/test-make-ct-par.yaml new file mode 100644 index 000000000000..24a8ab649e3c --- /dev/null +++ b/.github/workflows/test-make-ct-par.yaml @@ -0,0 +1,55 @@ +name: Parallel CT (make) +on: + workflow_call: + inputs: + erlang_version: + required: true + type: number + elixir_version: + required: true + type: number + metadata_store: + required: true + type: string + make_target: + required: true + type: string + plugin: + required: true + type: string +jobs: + test: + name: ${{ inputs.plugin }} (${{ inputs.make_target }}) + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: CHECKOUT REPOSITORY + uses: actions/checkout@v4 + + - name: SETUP OTP & ELIXIR + uses: erlef/setup-beam@v1.17 + with: + otp-version: ${{ inputs.erlang_version }} + elixir-version: ${{ inputs.elixir_version }} + hexpm-mirrors: | + https://builds.hex.pm + https://cdn.jsdelivr.net/hex + + - name: SETUP DOTNET (rabbit) + uses: actions/setup-dotnet@v4 + if: inputs.plugin == 'rabbit' + with: + dotnet-version: '3.1.x' + + - name: RUN TESTS + run: | + make -C deps/${{ inputs.plugin }} ${{ inputs.make_target }} RABBITMQ_METADATA_STORE=${{ inputs.metadata_store }} + + - name: UPLOAD TEST LOGS + if: always() + uses: actions/upload-artifact@v4 + with: + name: CT logs (${{ inputs.plugin }} ${{ inputs.make_target }} OTP-${{ inputs.erlang_version }} ${{ inputs.metadata_store }}) + path: | + deps/${{ inputs.plugin }}/logs/ + !deps/${{ inputs.plugin }}/logs/**/log_private diff --git a/.github/workflows/test-make-ct-seq.yaml b/.github/workflows/test-make-ct-seq.yaml new file mode 100644 index 000000000000..c8d0b144daab --- /dev/null +++ b/.github/workflows/test-make-ct-seq.yaml @@ -0,0 +1,64 @@ +name: Sequential CT (make) +on: + workflow_call: + inputs: + erlang_version: + required: true + type: number + elixir_version: + required: true + type: number + metadata_store: + required: true + type: string + plugin: + required: true + type: string +jobs: + test: + name: ${{ inputs.plugin }} (tests) + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: CHECKOUT REPOSITORY + uses: actions/checkout@v4 + + - name: SETUP OTP & ELIXIR + uses: erlef/setup-beam@v1.17 + with: + otp-version: ${{ inputs.erlang_version }} + elixir-version: ${{ inputs.elixir_version }} + hexpm-mirrors: | + https://builds.hex.pm + https://cdn.jsdelivr.net/hex + + - name: SETUP rabbitmq_auth_backend_ldap + if: inputs.plugin == 'rabbitmq_auth_backend_ldap' + run: | + sudo apt-get update && \ + sudo apt-get install -y \ + apparmor-utils \ + ldap-utils \ + slapd + + sudo aa-complain `which slapd` + +# @todo Why? +# - name: CLI COMPILE WARNINGS AS ERRORS +# if: inputs.plugin == 'rabbitmq_cli' +# run: | +# bazel build //deps/rabbitmq_cli:compile_warnings_as_errors \ +# --verbose_failures + + - name: RUN TESTS + run: | + make -C deps/${{ inputs.plugin }} tests RABBITMQ_METADATA_STORE=${{ inputs.metadata_store }} + + - name: UPLOAD TEST LOGS + if: always() + uses: actions/upload-artifact@v4 + with: + name: CT logs (${{ inputs.plugin }} OTP-${{ inputs.erlang_version }} ${{ inputs.metadata_store }}) + path: | + deps/${{ inputs.plugin }}/logs/ + !deps/${{ inputs.plugin }}/logs/**/log_private diff --git a/.github/workflows/test-make-jobs.yaml b/.github/workflows/test-make-jobs.yaml new file mode 100644 index 000000000000..aa03ab377b8c --- /dev/null +++ b/.github/workflows/test-make-jobs.yaml @@ -0,0 +1,95 @@ +name: Test jobs (make) +on: + workflow_call: + inputs: + erlang_version: + required: true + type: number + elixir_version: + required: true + type: number + metadata_store: + required: true + type: string +jobs: + test-rabbit: + name: Test rabbit + strategy: + fail-fast: false + matrix: + make_target: + - parallel-ct-set-1 + - parallel-ct-set-2 + - parallel-ct-set-3 + - parallel-ct-set-4 + - ct-clustering_management + - eunit ct-dead_lettering + - ct-feature_flags + - ct-metadata_store_clustering + - ct-quorum_queue + - ct-rabbit_stream_queue + uses: ./.github/workflows/test-make-ct-par.yaml + with: + erlang_version: ${{ inputs.erlang_version }} + elixir_version: ${{ inputs.elixir_version }} + metadata_store: ${{ inputs.metadata_store }} + make_target: ${{ matrix.make_target }} + plugin: rabbit + +# @todo test-mqtt using parallel ct + + test-ct-seq: + name: Test plugins + strategy: + fail-fast: false + matrix: + plugin: + - amqp10_client + - amqp10_common + - amqp_client + - oauth2_client + - rabbit_common + - rabbitmq_amqp_client + - rabbitmq_auth_backend_cache + - rabbitmq_auth_backend_http + - rabbitmq_auth_backend_ldap + - rabbitmq_auth_backend_oauth2 + - rabbitmq_auth_mechanism_ssl + - rabbitmq_consistent_hash_exchange + - rabbitmq_event_exchange + - rabbitmq_federation + - rabbitmq_federation_management + - rabbitmq_federation_prometheus + - rabbitmq_jms_topic_exchange + - rabbitmq_management + - rabbitmq_management_agent + - rabbitmq_peer_discovery_common + - rabbitmq_peer_discovery_consul + - rabbitmq_peer_discovery_etcd + - rabbitmq_peer_discovery_k8s + - rabbitmq_prelaunch + - rabbitmq_prometheus + - rabbitmq_recent_history_exchange + - rabbitmq_sharding + - rabbitmq_shovel + - rabbitmq_shovel_management + - rabbitmq_shovel_prometheus + - rabbitmq_stomp + - rabbitmq_stream + - rabbitmq_stream_common + - rabbitmq_stream_management + - rabbitmq_tracing + - rabbitmq_trust_store + - rabbitmq_web_dispatch + - rabbitmq_web_mqtt + - rabbitmq_web_stomp + uses: ./.github/workflows/test-make-ct-seq.yaml + with: + erlang_version: ${{ inputs.erlang_version }} + elixir_version: ${{ inputs.elixir_version }} + metadata_store: ${{ inputs.metadata_store }} + plugin: ${{ matrix.plugin }} + +# @todo Test rabbitmq_cli + +# @todo Dialyzer xref diff --git a/.github/workflows/test-make.yaml b/.github/workflows/test-make.yaml new file mode 100644 index 000000000000..ae40c88d34b2 --- /dev/null +++ b/.github/workflows/test-make.yaml @@ -0,0 +1,66 @@ +name: Test (make) +on: + push: + branches: + - main + - bump-otp-for-oci + - bump-rbe-* + paths: + - deps/** + - scripts/** + - Makefile + - plugins.mk + - rabbitmq-components.mk + - .github/workflows/test-make.yaml + pull_request: +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true +jobs: + version-matrix: + name: Test + strategy: + fail-fast: false + matrix: + erlang_version: + - 26 + - 27 + elixir_version: + - 1.17 + metadata_store: + - mnesia + - khepri + uses: ./.github/workflows/test-make-jobs.yaml + with: + erlang_version: ${{ matrix.erlang_version }} + elixir_version: ${{ matrix.elixir_version }} + metadata_store: ${{ matrix.metadata_store }} + + build: + name: Build + strategy: + fail-fast: false + matrix: + erlang_version: + - 26 + - 27 + elixir_version: + - 1.17 + # @todo Add macOS and Windows. + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: CHECKOUT REPOSITORY + uses: actions/checkout@v4 + + - name: SETUP OTP & ELIXIR + uses: erlef/setup-beam@v1.17 + with: + otp-version: ${{ matrix.erlang_version }} + elixir-version: ${{ matrix.elixir_version }} + hexpm-mirrors: | + https://builds.hex.pm + https://cdn.jsdelivr.net/hex + + - name: BUILD + run: make diff --git a/.github/workflows/test-mixed-versions.yaml b/.github/workflows/test-mixed-versions.yaml index d287d8e437e4..efb261cbf1dc 100644 --- a/.github/workflows/test-mixed-versions.yaml +++ b/.github/workflows/test-mixed-versions.yaml @@ -2,7 +2,7 @@ name: Test Mixed Version Clusters on: push: branches: - - main +# - main - v4.0.x - v3.13.x - bump-otp-* @@ -20,7 +20,7 @@ on: - BUILD.* - '*.bzl' - '*.bazel' - - .github/workflows/test-mixed-versions.yaml +# - .github/workflows/test-mixed-versions.yaml pull_request: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 582de0367802..c984ef89c4df 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -2,7 +2,7 @@ name: Test on: push: branches: - - main +# - main - v4.0.x - v3.13.x - v3.12.x @@ -22,7 +22,7 @@ on: - '*.bzl' - '*.bazel' - .github/workflows/test.yaml - pull_request: +# pull_request: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true @@ -142,6 +142,23 @@ jobs: repo_cache_key: ${{ needs.check-workflow.outputs.repo_cache_key }} plugin: trust_store_http secrets: inherit + test-rabbit-make: +# needs: +# - check-workflow +# - test-amqp10_client +# - test-amqp10_common +# - test-amqp_client +# - test-oauth2_client +# - test-rabbit_common +# - test-rabbitmq_ct_client_helpers +# - test-rabbitmq_ct_helpers +# - test-rabbitmq_stream_common +# - test-trust_store_http + uses: ./.github/workflows/test-plugin-make.yaml + with: + repo_cache_key: ${{ needs.check-workflow.outputs.repo_cache_key }} + plugin: rabbit + secrets: inherit test-rabbit-0: needs: - check-workflow diff --git a/deps/rabbit/Makefile b/deps/rabbit/Makefile index 066e863decc9..5371d688ec8c 100644 --- a/deps/rabbit/Makefile +++ b/deps/rabbit/Makefile @@ -236,7 +236,7 @@ define ct_master.erl peer:call(Pid2, persistent_term, put, [rabbit_ct_tcp_port_base, 25000]), peer:call(Pid3, persistent_term, put, [rabbit_ct_tcp_port_base, 27000]), peer:call(Pid4, persistent_term, put, [rabbit_ct_tcp_port_base, 29000]), - ct_master:run("ct.test.spec"), + ct_master:run("$1"), peer:stop(Pid4), peer:stop(Pid3), peer:stop(Pid2), @@ -244,9 +244,97 @@ define ct_master.erl halt() endef -ct-master: test-build +# @todo We must ensure that the CT_OPTS also apply to ct-master +# @todo We should probably refactor ct_master.erl to have node init in a separate .erl +# @todo We would benefit from having rabbit nodes started with peer (no leftovers) +# @todo We need ct-master to be expanded to all components and not just rabbit +# @todo Generate ct.test.spec from Makefile variables instead of hardcoded for ct-master + + +#PARALLEL_CT_NUM_NODES ?= 4 +#PARALLEL_CT_NODE_NAME = rabbit_shard$1@localhost +#PARALLEL_CT_NODE_INIT_FUN = fun(Pid, Num) -> peer:call(Pid, net_kernel, set_net_ticktime, [5]), peer:call(Pid, persistent_term, put, [rabbit_ct_tcp_port_base, 21000 + 2000 * Num]) end + +#PARALLEL_CT_NUM_SETS = 8 + + +PARALLEL_CT_SET_1_A = amqp_client unit_cluster_formation_locking_mocks unit_cluster_formation_sort_nodes unit_collections unit_config_value_encryption unit_connection_tracking +PARALLEL_CT_SET_1_B = amqp_address amqp_auth amqp_credit_api_v2 amqp_system signal_handling single_active_consumer unit_access_control_authn_authz_context_propagation unit_access_control_credential_validation unit_amqp091_content_framing unit_amqp091_server_properties unit_app_management +PARALLEL_CT_SET_1_C = amqp_proxy_protocol amqpl_consumer_ack amqpl_direct_reply_to backing_queue bindings rabbit_db_maintenance rabbit_db_msup rabbit_db_policy rabbit_db_queue rabbit_db_topic_exchange rabbit_direct_reply_to_prop cluster_limit cluster_minority term_to_binary_compat_prop topic_permission transactions unicode unit_access_control +PARALLEL_CT_SET_1_D = amqqueue_backward_compatibility channel_interceptor channel_operation_timeout classic_queue classic_queue_prop config_schema peer_discovery_dns peer_discovery_tmp_hidden_node per_node_limit per_user_connection_channel_limit + +PARALLEL_CT_SET_2_A = cluster confirms_rejects consumer_timeout rabbit_access_control rabbit_confirms rabbit_core_metrics_gc rabbit_cuttlefish rabbit_db_binding rabbit_db_exchange +PARALLEL_CT_SET_2_B = clustering_recovery crashing_queues deprecated_features direct_exchange_routing_v2 disconnect_detected_during_alarm exchanges unit_gen_server2 +PARALLEL_CT_SET_2_C = disk_monitor dynamic_qq unit_disk_monitor unit_file_handle_cache unit_log_management unit_operator_policy +PARALLEL_CT_SET_2_D = queue_length_limits queue_parallel quorum_queue_member_reconciliation rabbit_fifo rabbit_fifo_dlx rabbit_stream_coordinator + +PARALLEL_CT_SET_3_A = definition_import per_user_connection_channel_limit_partitions per_vhost_connection_limit_partitions policy priority_queue_recovery rabbit_fifo_prop rabbit_fifo_v0 rabbit_stream_sac_coordinator unit_credit_flow unit_queue_consumers unit_queue_location unit_quorum_queue +PARALLEL_CT_SET_3_B = cluster_upgrade list_consumers_sanity_check list_queues_online_and_offline logging lqueue maintenance_mode rabbit_fifo_q +PARALLEL_CT_SET_3_C = cli_forget_cluster_node feature_flags_v2 mc_unit message_containers_deaths_v2 message_size_limit metadata_store_migration +PARALLEL_CT_SET_3_D = metadata_store_phase1 metrics mirrored_supervisor msg_store peer_discovery_classic_config proxy_protocol runtime_parameters unit_stats_and_metrics unit_supervisor2 unit_vm_memory_monitor + +PARALLEL_CT_SET_4_A = clustering_events rabbit_local_random_exchange rabbit_message_interceptor rabbitmq_4_0_deprecations unit_pg_local unit_plugin_directories unit_plugin_versioning unit_policy_validators unit_priority_queue +PARALLEL_CT_SET_4_B = per_user_connection_tracking per_vhost_connection_limit rabbit_fifo_dlx_integration rabbit_fifo_int +PARALLEL_CT_SET_4_C = per_vhost_msg_store per_vhost_queue_limit priority_queue upgrade_preparation vhost +PARALLEL_CT_SET_4_D = per_user_connection_channel_tracking product_info publisher_confirms_parallel queue_type rabbitmq_queues_cli_integration rabbitmqctl_integration rabbitmqctl_shutdown routing + +PARALLEL_CT_SET_1 = $(sort $(PARALLEL_CT_SET_1_A) $(PARALLEL_CT_SET_1_B) $(PARALLEL_CT_SET_1_C) $(PARALLEL_CT_SET_1_D)) +PARALLEL_CT_SET_2 = $(sort $(PARALLEL_CT_SET_2_A) $(PARALLEL_CT_SET_2_B) $(PARALLEL_CT_SET_2_C) $(PARALLEL_CT_SET_2_D)) +PARALLEL_CT_SET_3 = $(sort $(PARALLEL_CT_SET_3_A) $(PARALLEL_CT_SET_3_B) $(PARALLEL_CT_SET_3_C) $(PARALLEL_CT_SET_3_D)) +PARALLEL_CT_SET_4 = $(sort $(PARALLEL_CT_SET_4_A) $(PARALLEL_CT_SET_4_B) $(PARALLEL_CT_SET_4_C) $(PARALLEL_CT_SET_4_D)) + +SEQUENTIAL_CT_SUITES = clustering_management dead_lettering feature_flags metadata_store_clustering quorum_queue rabbit_stream_queue +PARALLEL_CT_SUITES = $(PARALLEL_CT_SET_1) $(PARALLEL_CT_SET_2) $(PARALLEL_CT_SET_3) $(PARALLEL_CT_SET_4) + +ifneq ($(filter-out $(SEQUENTIAL_CT_SUITES) $(PARALLEL_CT_SUITES),$(CT_SUITES)),) +$(error Some test suites in CT_SUITES but not configured for CI.) +endif + + + +define tpl_parallel_ct_test_spec +{logdir, "logs/"}. +{logdir, master, "logs/"}. +{create_priv_dir, all_nodes, auto_per_run}. + +{node, shard1, 'rabbit_shard1@localhost'}. +{node, shard2, 'rabbit_shard2@localhost'}. +{node, shard3, 'rabbit_shard3@localhost'}. +{node, shard4, 'rabbit_shard4@localhost'}. + +{define, 'Set1', [$(call comma_list,$(addsuffix _SUITE,$1))]}. +{define, 'Set2', [$(call comma_list,$(addsuffix _SUITE,$2))]}. +{define, 'Set3', [$(call comma_list,$(addsuffix _SUITE,$3))]}. +{define, 'Set4', [$(call comma_list,$(addsuffix _SUITE,$4))]}. + +{suites, shard1, "test/", 'Set1'}. +{suites, shard2, "test/", 'Set2'}. +{suites, shard3, "test/", 'Set3'}. +{suites, shard4, "test/", 'Set4'}. +endef + +define parallel_ct_set_target +tpl_parallel_ct_test_spec_set_$1 = $$(call tpl_parallel_ct_test_spec,$(PARALLEL_CT_SET_$(1)_A),$(PARALLEL_CT_SET_$(1)_B),$(PARALLEL_CT_SET_$(1)_C),$(PARALLEL_CT_SET_$(1)_D)) + +parallel-ct-set-$(1): test-build + $(verbose) mkdir -p $(CT_LOGS_DIR) + $(verbose) $$(call core_render,tpl_parallel_ct_test_spec_set_$(1),ct.set-$(1).spec) + $$(call erlang,$$(call ct_master.erl,ct.set-$(1).spec),-sname parallel_ct_$(PROJECT)@localhost -hidden -kernel net_ticktime 5) +endef + +$(foreach set,1 2 3 4,$(eval $(call parallel_ct_set_target,$(set)))) + + + + + + + + + +parallel-ct: test-build $(verbose) mkdir -p $(CT_LOGS_DIR) - $(call erlang,$(ct_master.erl),-sname rabbit_master@localhost -hidden -kernel net_ticktime 5) + $(call erlang,$(call ct_master.erl,ct.test.spec),-sname parallel_ct_$(PROJECT)@localhost -hidden -kernel net_ticktime 5) # -------------------------------------------------------------------- # Compilation. diff --git a/deps/rabbitmq_mqtt/test/shared_SUITE.erl b/deps/rabbitmq_mqtt/test/shared_SUITE.erl index 16afac557d82..aa518e5d46f0 100644 --- a/deps/rabbitmq_mqtt/test/shared_SUITE.erl +++ b/deps/rabbitmq_mqtt/test/shared_SUITE.erl @@ -54,6 +54,7 @@ all() -> [{group, mqtt}, + %% @todo Move web_mqtt to rabbitmq_web_mqtt directly. {group, web_mqtt}]. %% The code being tested under v3 and v4 is almost identical. @@ -218,6 +219,7 @@ init_per_testcase(Testcase, Config) -> init_per_testcase0(Testcase, Config) -> Nodes = rabbit_ct_broker_helpers:get_node_configs(Config, nodename), + %% @todo This should only be necessary for Bazel's mixed version testing. [ok = rabbit_ct_broker_helpers:enable_plugin(Config, N, rabbitmq_web_mqtt) || N <- Nodes], rabbit_ct_helpers:testcase_started(Config, Testcase). diff --git a/rabbitmq-components.mk b/rabbitmq-components.mk index 7f4ed26236ab..08903247d5ba 100644 --- a/rabbitmq-components.mk +++ b/rabbitmq-components.mk @@ -60,6 +60,9 @@ dep_seshat = git https://github.com/rabbitmq/seshat v0.6.1 dep_stdout_formatter = hex 0.2.4 dep_sysmon_handler = hex 1.3.0 +# @todo Move up in the list later. +dep_osiris = git https://github.com/rabbitmq/osiris v1.8.3 + # RabbitMQ applications found in the monorepo. # # Note that rabbitmq_server_release is not a real application From 690b830e4355d2749385195d93bbc091a8cd739c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 11 Sep 2024 11:44:50 +0200 Subject: [PATCH 05/45] 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. --- deps/rabbitmq_mqtt/Makefile | 2 +- ...shared_SUITE.erl => mqtt_shared_SUITE.erl} | 23 +--- deps/rabbitmq_web_mqtt/Makefile | 8 +- ...d_SUITE.erl => web_mqtt_command_SUITE.erl} | 2 +- ...E.erl => web_mqtt_config_schema_SUITE.erl} | 2 +- .../certs/cacert.pem | 0 .../certs/cert.pem | 0 .../certs/key.pem | 0 .../rabbitmq_web_mqtt.snippets | 36 +++---- ....erl => web_mqtt_proxy_protocol_SUITE.erl} | 2 +- .../test/web_mqtt_shared_SUITE.erl | 100 ++++++++++++++++++ ...em_SUITE.erl => web_mqtt_system_SUITE.erl} | 2 +- 12 files changed, 134 insertions(+), 43 deletions(-) rename deps/rabbitmq_mqtt/test/{shared_SUITE.erl => mqtt_shared_SUITE.erl} (99%) rename deps/rabbitmq_web_mqtt/test/{command_SUITE.erl => web_mqtt_command_SUITE.erl} (99%) rename deps/rabbitmq_web_mqtt/test/{config_schema_SUITE.erl => web_mqtt_config_schema_SUITE.erl} (97%) rename deps/rabbitmq_web_mqtt/test/{config_schema_SUITE_data => web_mqtt_config_schema_SUITE_data}/certs/cacert.pem (100%) rename deps/rabbitmq_web_mqtt/test/{config_schema_SUITE_data => web_mqtt_config_schema_SUITE_data}/certs/cert.pem (100%) rename deps/rabbitmq_web_mqtt/test/{config_schema_SUITE_data => web_mqtt_config_schema_SUITE_data}/certs/key.pem (100%) rename deps/rabbitmq_web_mqtt/test/{config_schema_SUITE_data => web_mqtt_config_schema_SUITE_data}/rabbitmq_web_mqtt.snippets (80%) rename deps/rabbitmq_web_mqtt/test/{proxy_protocol_SUITE.erl => web_mqtt_proxy_protocol_SUITE.erl} (99%) create mode 100644 deps/rabbitmq_web_mqtt/test/web_mqtt_shared_SUITE.erl rename deps/rabbitmq_web_mqtt/test/{system_SUITE.erl => web_mqtt_system_SUITE.erl} (99%) diff --git a/deps/rabbitmq_mqtt/Makefile b/deps/rabbitmq_mqtt/Makefile index 824c472487c9..d77b5c5850eb 100644 --- a/deps/rabbitmq_mqtt/Makefile +++ b/deps/rabbitmq_mqtt/Makefile @@ -43,7 +43,7 @@ export BUILD_WITHOUT_QUIC LOCAL_DEPS = ssl DEPS = ranch rabbit_common rabbit amqp10_common -TEST_DEPS = emqtt ct_helper rabbitmq_ct_helpers rabbitmq_ct_client_helpers rabbitmq_management rabbitmq_web_mqtt amqp_client rabbitmq_consistent_hash_exchange rabbitmq_amqp_client rabbitmq_stomp rabbitmq_stream +TEST_DEPS = emqtt ct_helper rabbitmq_ct_helpers rabbitmq_ct_client_helpers rabbitmq_management amqp_client rabbitmq_consistent_hash_exchange rabbitmq_amqp_client rabbitmq_stomp rabbitmq_stream PLT_APPS += rabbitmqctl elixir diff --git a/deps/rabbitmq_mqtt/test/shared_SUITE.erl b/deps/rabbitmq_mqtt/test/mqtt_shared_SUITE.erl similarity index 99% rename from deps/rabbitmq_mqtt/test/shared_SUITE.erl rename to deps/rabbitmq_mqtt/test/mqtt_shared_SUITE.erl index aa518e5d46f0..aa6735fb202e 100644 --- a/deps/rabbitmq_mqtt/test/shared_SUITE.erl +++ b/deps/rabbitmq_mqtt/test/mqtt_shared_SUITE.erl @@ -10,7 +10,9 @@ %% %% In other words, this test suite should not contain any test case that is executed %% only with a particular plugin or particular MQTT version. --module(shared_SUITE). +%% +%% When adding a test case here the same function must be defined in web_mqtt_shared_SUITE. +-module(mqtt_shared_SUITE). -compile([export_all, nowarn_export_all]). @@ -53,24 +55,13 @@ -define(RC_SESSION_TAKEN_OVER, 16#8E). all() -> - [{group, mqtt}, - %% @todo Move web_mqtt to rabbitmq_web_mqtt directly. - {group, web_mqtt}]. + [{group, mqtt}]. %% The code being tested under v3 and v4 is almost identical. %% To save time in CI, we therefore run only a very small subset of tests in v3. groups() -> [ {mqtt, [], - [{cluster_size_1, [], - [{v3, [], cluster_size_1_tests_v3()}, - {v4, [], cluster_size_1_tests()}, - {v5, [], cluster_size_1_tests()}]}, - {cluster_size_3, [], - [{v4, [], cluster_size_3_tests()}, - {v5, [], cluster_size_3_tests()}]} - ]}, - {web_mqtt, [], [{cluster_size_1, [], [{v3, [], cluster_size_1_tests_v3()}, {v4, [], cluster_size_1_tests()}, @@ -175,9 +166,6 @@ end_per_suite(Config) -> init_per_group(mqtt, Config) -> rabbit_ct_helpers:set_config(Config, {websocket, false}); -init_per_group(web_mqtt, Config) -> - rabbit_ct_helpers:set_config(Config, {websocket, true}); - init_per_group(Group, Config) when Group =:= v3; Group =:= v4; @@ -218,9 +206,6 @@ init_per_testcase(Testcase, Config) -> init_per_testcase0(Testcase, Config). init_per_testcase0(Testcase, Config) -> - Nodes = rabbit_ct_broker_helpers:get_node_configs(Config, nodename), - %% @todo This should only be necessary for Bazel's mixed version testing. - [ok = rabbit_ct_broker_helpers:enable_plugin(Config, N, rabbitmq_web_mqtt) || N <- Nodes], rabbit_ct_helpers:testcase_started(Config, Testcase). end_per_testcase(T, Config) diff --git a/deps/rabbitmq_web_mqtt/Makefile b/deps/rabbitmq_web_mqtt/Makefile index 9919e7cb82cd..0b658c3b0599 100644 --- a/deps/rabbitmq_web_mqtt/Makefile +++ b/deps/rabbitmq_web_mqtt/Makefile @@ -19,7 +19,7 @@ export BUILD_WITHOUT_QUIC LOCAL_DEPS = ssl DEPS = rabbit_common rabbit cowboy rabbitmq_mqtt -TEST_DEPS = emqtt rabbitmq_ct_helpers rabbitmq_ct_client_helpers rabbitmq_management +TEST_DEPS = emqtt rabbitmq_ct_helpers rabbitmq_ct_client_helpers rabbitmq_management rabbitmq_stomp PLT_APPS += rabbitmqctl elixir cowlib @@ -34,3 +34,9 @@ DEP_PLUGINS = rabbit_common/mk/rabbitmq-plugin.mk include ../../rabbitmq-components.mk include ../../erlang.mk + +# We are using mqtt_shared_SUITE from rabbitmq_mqtt. +CT_OPTS += -pa ../rabbitmq_mqtt/test/ + +test-build:: + $(verbose) $(MAKE) -C ../rabbitmq_mqtt test-dir diff --git a/deps/rabbitmq_web_mqtt/test/command_SUITE.erl b/deps/rabbitmq_web_mqtt/test/web_mqtt_command_SUITE.erl similarity index 99% rename from deps/rabbitmq_web_mqtt/test/command_SUITE.erl rename to deps/rabbitmq_web_mqtt/test/web_mqtt_command_SUITE.erl index c526d8c4f217..1d31536cf005 100644 --- a/deps/rabbitmq_web_mqtt/test/command_SUITE.erl +++ b/deps/rabbitmq_web_mqtt/test/web_mqtt_command_SUITE.erl @@ -5,7 +5,7 @@ %% Copyright (c) 2007-2024 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved. --module(command_SUITE). +-module(web_mqtt_command_SUITE). -compile([export_all, nowarn_export_all]). -include_lib("eunit/include/eunit.hrl"). diff --git a/deps/rabbitmq_web_mqtt/test/config_schema_SUITE.erl b/deps/rabbitmq_web_mqtt/test/web_mqtt_config_schema_SUITE.erl similarity index 97% rename from deps/rabbitmq_web_mqtt/test/config_schema_SUITE.erl rename to deps/rabbitmq_web_mqtt/test/web_mqtt_config_schema_SUITE.erl index 694d7ea5a25a..7b280eccfc1b 100644 --- a/deps/rabbitmq_web_mqtt/test/config_schema_SUITE.erl +++ b/deps/rabbitmq_web_mqtt/test/web_mqtt_config_schema_SUITE.erl @@ -5,7 +5,7 @@ %% Copyright (c) 2007-2024 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved. %% --module(config_schema_SUITE). +-module(web_mqtt_config_schema_SUITE). -compile(export_all). diff --git a/deps/rabbitmq_web_mqtt/test/config_schema_SUITE_data/certs/cacert.pem b/deps/rabbitmq_web_mqtt/test/web_mqtt_config_schema_SUITE_data/certs/cacert.pem similarity index 100% rename from deps/rabbitmq_web_mqtt/test/config_schema_SUITE_data/certs/cacert.pem rename to deps/rabbitmq_web_mqtt/test/web_mqtt_config_schema_SUITE_data/certs/cacert.pem diff --git a/deps/rabbitmq_web_mqtt/test/config_schema_SUITE_data/certs/cert.pem b/deps/rabbitmq_web_mqtt/test/web_mqtt_config_schema_SUITE_data/certs/cert.pem similarity index 100% rename from deps/rabbitmq_web_mqtt/test/config_schema_SUITE_data/certs/cert.pem rename to deps/rabbitmq_web_mqtt/test/web_mqtt_config_schema_SUITE_data/certs/cert.pem diff --git a/deps/rabbitmq_web_mqtt/test/config_schema_SUITE_data/certs/key.pem b/deps/rabbitmq_web_mqtt/test/web_mqtt_config_schema_SUITE_data/certs/key.pem similarity index 100% rename from deps/rabbitmq_web_mqtt/test/config_schema_SUITE_data/certs/key.pem rename to deps/rabbitmq_web_mqtt/test/web_mqtt_config_schema_SUITE_data/certs/key.pem diff --git a/deps/rabbitmq_web_mqtt/test/config_schema_SUITE_data/rabbitmq_web_mqtt.snippets b/deps/rabbitmq_web_mqtt/test/web_mqtt_config_schema_SUITE_data/rabbitmq_web_mqtt.snippets similarity index 80% rename from deps/rabbitmq_web_mqtt/test/config_schema_SUITE_data/rabbitmq_web_mqtt.snippets rename to deps/rabbitmq_web_mqtt/test/web_mqtt_config_schema_SUITE_data/rabbitmq_web_mqtt.snippets index ab6735cbc830..4d592eee3124 100644 --- a/deps/rabbitmq_web_mqtt/test/config_schema_SUITE_data/rabbitmq_web_mqtt.snippets +++ b/deps/rabbitmq_web_mqtt/test/web_mqtt_config_schema_SUITE_data/rabbitmq_web_mqtt.snippets @@ -73,18 +73,18 @@ {ssl_with_listener, "web_mqtt.ssl.listener = 127.0.0.2:15671 web_mqtt.ssl.backlog = 1024 - web_mqtt.ssl.certfile = test/config_schema_SUITE_data/certs/cert.pem - web_mqtt.ssl.keyfile = test/config_schema_SUITE_data/certs/key.pem - web_mqtt.ssl.cacertfile = test/config_schema_SUITE_data/certs/cacert.pem + web_mqtt.ssl.certfile = test/web_mqtt_config_schema_SUITE_data/certs/cert.pem + web_mqtt.ssl.keyfile = test/web_mqtt_config_schema_SUITE_data/certs/key.pem + web_mqtt.ssl.cacertfile = test/web_mqtt_config_schema_SUITE_data/certs/cacert.pem web_mqtt.ssl.password = changeme", [{rabbitmq_web_mqtt, [{ssl_config, [{ip,"127.0.0.2"}, {port,15671}, {backlog,1024}, - {certfile,"test/config_schema_SUITE_data/certs/cert.pem"}, - {keyfile,"test/config_schema_SUITE_data/certs/key.pem"}, - {cacertfile,"test/config_schema_SUITE_data/certs/cacert.pem"}, + {certfile,"test/web_mqtt_config_schema_SUITE_data/certs/cert.pem"}, + {keyfile,"test/web_mqtt_config_schema_SUITE_data/certs/key.pem"}, + {cacertfile,"test/web_mqtt_config_schema_SUITE_data/certs/cacert.pem"}, {password,<<"changeme">>}]}]}], [rabbitmq_web_mqtt]}, @@ -92,9 +92,9 @@ "web_mqtt.ssl.ip = 127.0.0.2 web_mqtt.ssl.port = 15671 web_mqtt.ssl.backlog = 1024 - web_mqtt.ssl.certfile = test/config_schema_SUITE_data/certs/cert.pem - web_mqtt.ssl.keyfile = test/config_schema_SUITE_data/certs/key.pem - web_mqtt.ssl.cacertfile = test/config_schema_SUITE_data/certs/cacert.pem + web_mqtt.ssl.certfile = test/web_mqtt_config_schema_SUITE_data/certs/cert.pem + web_mqtt.ssl.keyfile = test/web_mqtt_config_schema_SUITE_data/certs/key.pem + web_mqtt.ssl.cacertfile = test/web_mqtt_config_schema_SUITE_data/certs/cacert.pem web_mqtt.ssl.password = changeme web_mqtt.ssl.versions.tls1_2 = tlsv1.2 @@ -105,9 +105,9 @@ {ip,"127.0.0.2"}, {port,15671}, {backlog,1024}, - {certfile,"test/config_schema_SUITE_data/certs/cert.pem"}, - {keyfile,"test/config_schema_SUITE_data/certs/key.pem"}, - {cacertfile,"test/config_schema_SUITE_data/certs/cacert.pem"}, + {certfile,"test/web_mqtt_config_schema_SUITE_data/certs/cert.pem"}, + {keyfile,"test/web_mqtt_config_schema_SUITE_data/certs/key.pem"}, + {cacertfile,"test/web_mqtt_config_schema_SUITE_data/certs/cacert.pem"}, {password,<<"changeme">>}, {versions,['tlsv1.2','tlsv1.1']} @@ -117,9 +117,9 @@ {ssl_ciphers, "web_mqtt.ssl.port = 15671 web_mqtt.ssl.backlog = 1024 - web_mqtt.ssl.certfile = test/config_schema_SUITE_data/certs/cert.pem - web_mqtt.ssl.keyfile = test/config_schema_SUITE_data/certs/key.pem - web_mqtt.ssl.cacertfile = test/config_schema_SUITE_data/certs/cacert.pem + web_mqtt.ssl.certfile = test/web_mqtt_config_schema_SUITE_data/certs/cert.pem + web_mqtt.ssl.keyfile = test/web_mqtt_config_schema_SUITE_data/certs/key.pem + web_mqtt.ssl.cacertfile = test/web_mqtt_config_schema_SUITE_data/certs/cacert.pem web_mqtt.ssl.password = changeme web_mqtt.ssl.honor_cipher_order = true @@ -142,9 +142,9 @@ [{ssl_config, [{port,15671}, {backlog,1024}, - {certfile,"test/config_schema_SUITE_data/certs/cert.pem"}, - {keyfile,"test/config_schema_SUITE_data/certs/key.pem"}, - {cacertfile,"test/config_schema_SUITE_data/certs/cacert.pem"}, + {certfile,"test/web_mqtt_config_schema_SUITE_data/certs/cert.pem"}, + {keyfile,"test/web_mqtt_config_schema_SUITE_data/certs/key.pem"}, + {cacertfile,"test/web_mqtt_config_schema_SUITE_data/certs/cacert.pem"}, {password,<<"changeme">>}, {honor_cipher_order, true}, diff --git a/deps/rabbitmq_web_mqtt/test/proxy_protocol_SUITE.erl b/deps/rabbitmq_web_mqtt/test/web_mqtt_proxy_protocol_SUITE.erl similarity index 99% rename from deps/rabbitmq_web_mqtt/test/proxy_protocol_SUITE.erl rename to deps/rabbitmq_web_mqtt/test/web_mqtt_proxy_protocol_SUITE.erl index d13426342d30..7f9e9adb2f8d 100644 --- a/deps/rabbitmq_web_mqtt/test/proxy_protocol_SUITE.erl +++ b/deps/rabbitmq_web_mqtt/test/web_mqtt_proxy_protocol_SUITE.erl @@ -5,7 +5,7 @@ %% Copyright (c) 2007-2024 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved. %% --module(proxy_protocol_SUITE). +-module(web_mqtt_proxy_protocol_SUITE). -compile([export_all, nowarn_export_all]). diff --git a/deps/rabbitmq_web_mqtt/test/web_mqtt_shared_SUITE.erl b/deps/rabbitmq_web_mqtt/test/web_mqtt_shared_SUITE.erl new file mode 100644 index 000000000000..4cb1c843c2eb --- /dev/null +++ b/deps/rabbitmq_web_mqtt/test/web_mqtt_shared_SUITE.erl @@ -0,0 +1,100 @@ +%% This Source Code Form is subject to the terms of the Mozilla Public +%% License, v. 2.0. If a copy of the MPL was not distributed with this +%% file, You can obtain one at https://mozilla.org/MPL/2.0/. +%% +%% Copyright (c) 2007-2024 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved. + +%% This test suite uses test cases shared by rabbitmq_mqtt. +-module(web_mqtt_shared_SUITE). +-compile([export_all, + nowarn_export_all]). + +all() -> + mqtt_shared_SUITE:all(). + +groups() -> + mqtt_shared_SUITE:groups(). + +suite() -> + mqtt_shared_SUITE:suite(). + +init_per_suite(Config) -> + mqtt_shared_SUITE:init_per_suite(Config). + +end_per_suite(Config) -> + mqtt_shared_SUITE:end_per_suite(Config). + +init_per_group(mqtt, Config) -> + %% This is the main difference with rabbitmq_mqtt. + rabbit_ct_helpers:set_config(Config, {websocket, true}); +init_per_group(Group, Config) -> + mqtt_shared_SUITE:init_per_group(Group, Config). + +end_per_group(Group, Config) -> + mqtt_shared_SUITE:end_per_group(Group, Config). + +init_per_testcase(Testcase, Config) -> + mqtt_shared_SUITE:init_per_testcase(Testcase, Config). + +end_per_testcase(Testcase, Config) -> + mqtt_shared_SUITE:end_per_testcase(Testcase, Config). + +global_counters(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +block_only_publisher(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +many_qos1_messages(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +session_expiry(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +cli_close_all_connections(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +cli_close_all_user_connections(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +management_plugin_connection(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +management_plugin_enable(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +disconnect(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +pubsub_shared_connection(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +pubsub_separate_connections(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +will_with_disconnect(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +will_without_disconnect(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +decode_basic_properties(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +quorum_queue_rejects(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +events(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +internal_event_handler(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +non_clean_sess_reconnect_qos1(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +non_clean_sess_reconnect_qos0(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +non_clean_sess_reconnect_qos0_and_qos1(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +non_clean_sess_empty_client_id(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +subscribe_same_topic_same_qos(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +subscribe_same_topic_different_qos(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +subscribe_multiple(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +large_message_mqtt_to_mqtt(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +large_message_amqp_to_mqtt(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +keepalive(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +keepalive_turned_off(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +block(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +amqp_to_mqtt_qos0(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +clean_session_disconnect_client(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +clean_session_node_restart(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +clean_session_node_kill(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +rabbit_status_connection_count(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +trace(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +trace_large_message(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +max_packet_size_unauthenticated(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +max_packet_size_authenticated(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +default_queue_type(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +incoming_message_interceptors(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +utf8(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +retained_message_conversion(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +bind_exchange_to_exchange(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +bind_exchange_to_exchange_single_message(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +pubsub(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +queue_down_qos1(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +consuming_classic_queue_down(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +flow_quorum_queue(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +flow_stream(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +rabbit_mqtt_qos0_queue(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +rabbit_mqtt_qos0_queue_kill_node(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +cli_list_queues(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +delete_create_queue(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +session_reconnect(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +session_takeover(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +duplicate_client_id(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +publish_to_all_queue_types_qos0(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +publish_to_all_queue_types_qos1(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +maintenance(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). diff --git a/deps/rabbitmq_web_mqtt/test/system_SUITE.erl b/deps/rabbitmq_web_mqtt/test/web_mqtt_system_SUITE.erl similarity index 99% rename from deps/rabbitmq_web_mqtt/test/system_SUITE.erl rename to deps/rabbitmq_web_mqtt/test/web_mqtt_system_SUITE.erl index 35af6e923d28..3b01af7f1e06 100644 --- a/deps/rabbitmq_web_mqtt/test/system_SUITE.erl +++ b/deps/rabbitmq_web_mqtt/test/web_mqtt_system_SUITE.erl @@ -5,7 +5,7 @@ %% Copyright (c) 2007-2024 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved. %% --module(system_SUITE). +-module(web_mqtt_system_SUITE). -include_lib("eunit/include/eunit.hrl"). From ddab3d523f1faad8639365e761e0d28ce9de67f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 11 Sep 2024 13:15:48 +0200 Subject: [PATCH 06/45] mqtt tests: Move v5 web_mqtt tests out of rabbitmq_mqtt --- deps/rabbitmq_mqtt/test/v5_SUITE.erl | 12 +- deps/rabbitmq_web_mqtt/Makefile | 2 +- .../test/web_mqtt_v5_SUITE.erl | 114 ++++++++++++++++++ 3 files changed, 116 insertions(+), 12 deletions(-) create mode 100644 deps/rabbitmq_web_mqtt/test/web_mqtt_v5_SUITE.erl diff --git a/deps/rabbitmq_mqtt/test/v5_SUITE.erl b/deps/rabbitmq_mqtt/test/v5_SUITE.erl index 475b9450af9a..72df49577639 100644 --- a/deps/rabbitmq_mqtt/test/v5_SUITE.erl +++ b/deps/rabbitmq_mqtt/test/v5_SUITE.erl @@ -42,16 +42,11 @@ -define(RC_TOPIC_ALIAS_INVALID, 16#94). all() -> - [{group, mqtt}, - {group, web_mqtt}]. + [{group, mqtt}]. groups() -> [ {mqtt, [], - [{cluster_size_1, [shuffle], cluster_size_1_tests()}, - {cluster_size_3, [shuffle], cluster_size_3_tests()} - ]}, - {web_mqtt, [], [{cluster_size_1, [shuffle], cluster_size_1_tests()}, {cluster_size_3, [shuffle], cluster_size_3_tests()} ]} @@ -153,9 +148,6 @@ end_per_suite(Config) -> init_per_group(mqtt, Config) -> rabbit_ct_helpers:set_config(Config, {websocket, false}); -init_per_group(web_mqtt, Config) -> - rabbit_ct_helpers:set_config(Config, {websocket, true}); - init_per_group(Group, Config0) -> Nodes = case Group of cluster_size_1 -> 1; @@ -198,8 +190,6 @@ init_per_testcase(T, Config) -> init_per_testcase0(T, Config). init_per_testcase0(Testcase, Config) -> - Nodes = rabbit_ct_broker_helpers:get_node_configs(Config, nodename), - [ok = rabbit_ct_broker_helpers:enable_plugin(Config, N, rabbitmq_web_mqtt) || N <- Nodes], rabbit_ct_helpers:testcase_started(Config, Testcase). end_per_testcase(T, Config) diff --git a/deps/rabbitmq_web_mqtt/Makefile b/deps/rabbitmq_web_mqtt/Makefile index 0b658c3b0599..812d467f1911 100644 --- a/deps/rabbitmq_web_mqtt/Makefile +++ b/deps/rabbitmq_web_mqtt/Makefile @@ -19,7 +19,7 @@ export BUILD_WITHOUT_QUIC LOCAL_DEPS = ssl DEPS = rabbit_common rabbit cowboy rabbitmq_mqtt -TEST_DEPS = emqtt rabbitmq_ct_helpers rabbitmq_ct_client_helpers rabbitmq_management rabbitmq_stomp +TEST_DEPS = emqtt rabbitmq_ct_helpers rabbitmq_ct_client_helpers rabbitmq_management rabbitmq_stomp rabbitmq_consistent_hash_exchange PLT_APPS += rabbitmqctl elixir cowlib diff --git a/deps/rabbitmq_web_mqtt/test/web_mqtt_v5_SUITE.erl b/deps/rabbitmq_web_mqtt/test/web_mqtt_v5_SUITE.erl new file mode 100644 index 000000000000..5012ddd4d0b8 --- /dev/null +++ b/deps/rabbitmq_web_mqtt/test/web_mqtt_v5_SUITE.erl @@ -0,0 +1,114 @@ +%% This Source Code Form is subject to the terms of the Mozilla Public +%% License, v. 2.0. If a copy of the MPL was not distributed with this +%% file, You can obtain one at https://mozilla.org/MPL/2.0/. +%% +%% Copyright (c) 2007-2024 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved. + +%% This test suite uses test cases shared by rabbitmq_mqtt. +-module(web_mqtt_v5_SUITE). +-compile([export_all, + nowarn_export_all]). + +all() -> + v5_SUITE:all(). + +groups() -> + v5_SUITE:groups(). + +suite() -> + v5_SUITE:suite(). + +init_per_suite(Config) -> + v5_SUITE:init_per_suite(Config). + +end_per_suite(Config) -> + v5_SUITE:end_per_suite(Config). + +init_per_group(mqtt, Config) -> + %% This is the main difference with rabbitmq_mqtt. + rabbit_ct_helpers:set_config(Config, {websocket, true}); +init_per_group(Group, Config) -> + v5_SUITE:init_per_group(Group, Config). + +end_per_group(Group, Config) -> + v5_SUITE:end_per_group(Group, Config). + +init_per_testcase(Testcase, Config) -> + v5_SUITE:init_per_testcase(Testcase, Config). + +end_per_testcase(Testcase, Config) -> + v5_SUITE:end_per_testcase(Testcase, Config). + +client_set_max_packet_size_publish(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +client_set_max_packet_size_connack(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +client_set_max_packet_size_invalid(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +message_expiry(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +message_expiry_will_message(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +message_expiry_retained_message(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +session_expiry_classic_queue_disconnect_decrease(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +session_expiry_quorum_queue_disconnect_decrease(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +session_expiry_disconnect_zero_to_non_zero(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +session_expiry_disconnect_non_zero_to_zero(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +session_expiry_disconnect_infinity_to_zero(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +session_expiry_disconnect_to_infinity(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +session_expiry_reconnect_non_zero(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +session_expiry_reconnect_zero(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +session_expiry_reconnect_infinity_to_zero(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +client_publish_qos2(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +client_rejects_publish(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +client_receive_maximum_min(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +client_receive_maximum_large(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +unsubscribe_success(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +unsubscribe_topic_not_found(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +subscription_option_no_local(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +subscription_option_no_local_wildcards(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +subscription_option_retain_as_published(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +subscription_option_retain_as_published_wildcards(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +subscription_option_retain_handling(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +subscription_identifier(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +subscription_identifier_amqp091(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +subscription_identifier_at_most_once_dead_letter(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +at_most_once_dead_letter_detect_cycle(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +subscription_options_persisted(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +subscription_options_modify(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +subscription_options_modify_qos1(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +subscription_options_modify_qos0(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +session_upgrade_v3_v5_qos1(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +session_upgrade_v3_v5_qos0(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +session_upgrade_v3_v5_amqp091_pub(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +compatibility_v3_v5(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +session_upgrade_v3_v5_unsubscribe(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +session_upgrade_v4_v5_no_queue_bind_permission(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +amqp091_cc_header(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +publish_property_content_type(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +publish_property_payload_format_indicator(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +publish_property_response_topic_correlation_data(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +publish_property_user_property(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +disconnect_with_will(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +will_qos2(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +will_delay_greater_than_session_expiry(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +will_delay_less_than_session_expiry(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +will_delay_equals_session_expiry(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +will_delay_session_expiry_zero(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +will_delay_reconnect_no_will(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +will_delay_reconnect_with_will(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +will_delay_session_takeover(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +will_delay_message_expiry(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +will_delay_message_expiry_publish_properties(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +will_delay_properties(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +will_properties(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +retain_properties(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +topic_alias_client_to_server(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +topic_alias_server_to_client(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +topic_alias_bidirectional(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +topic_alias_invalid(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +topic_alias_unknown(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +topic_alias_disallowed(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +topic_alias_retained_message(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +topic_alias_disallowed_retained_message(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +extended_auth(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +headers_exchange(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +consistent_hash_exchange(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +session_migrate_v3_v5(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +session_takeover_v3_v5(Config) -> v5_SUITE:?FUNCTION_NAME(Config). +will_delay_node_restart(Config) -> v5_SUITE:?FUNCTION_NAME(Config). From f002029ebd0224587bb23ee12f8ae65c131c4583 Mon Sep 17 00:00:00 2001 From: David Ansari Date: Wed, 11 Sep 2024 13:51:19 +0200 Subject: [PATCH 07/45] Do not open WebMQTT connection in MQTT plugin --- deps/rabbitmq_mqtt/test/command_SUITE.erl | 6 ------ deps/rabbitmq_web_mqtt/test/web_mqtt_command_SUITE.erl | 9 +++++++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/deps/rabbitmq_mqtt/test/command_SUITE.erl b/deps/rabbitmq_mqtt/test/command_SUITE.erl index 528c4b0b1b97..864727077c40 100644 --- a/deps/rabbitmq_mqtt/test/command_SUITE.erl +++ b/deps/rabbitmq_mqtt/test/command_SUITE.erl @@ -85,12 +85,6 @@ run(Config) -> %% No connections [] = 'Elixir.Enum':to_list(?COMMAND:run([], Opts)), - %% Open a WebMQTT connection, command won't list it - WebMqttConfig = [{websocket, true} | Config], - _C0 = connect(<<"simpleWebMqttClient">>, WebMqttConfig, [{ack_timeout, 1}]), - - [] = 'Elixir.Enum':to_list(?COMMAND:run([], Opts)), - %% Open a connection C1 = connect(<<"simpleClient">>, Config, [{ack_timeout, 1}]), diff --git a/deps/rabbitmq_web_mqtt/test/web_mqtt_command_SUITE.erl b/deps/rabbitmq_web_mqtt/test/web_mqtt_command_SUITE.erl index 1d31536cf005..04d50f7fb582 100644 --- a/deps/rabbitmq_web_mqtt/test/web_mqtt_command_SUITE.erl +++ b/deps/rabbitmq_web_mqtt/test/web_mqtt_command_SUITE.erl @@ -16,6 +16,7 @@ [connect/3, connect/4]). -define(COMMAND, 'Elixir.RabbitMQ.CLI.Ctl.Commands.ListWebMqttConnectionsCommand'). +-define(MQTT_COMMAND, 'Elixir.RabbitMQ.CLI.Ctl.Commands.ListMqttConnectionsCommand'). all() -> [ @@ -93,12 +94,16 @@ run(BaseConfig) -> [] = 'Elixir.Enum':to_list(?COMMAND:run([<<"client_id">>], Opts)), %% Open a WebMQTT connection - C2 = connect(<<"simpleWebMqttClient">>, Config, [{ack_timeout, 1}]), timer:sleep(200), + %% WebMQTT CLI should list only WebMQTT connection. [[{client_id, <<"simpleWebMqttClient">>}]] = - 'Elixir.Enum':to_list(?COMMAND:run([<<"client_id">>], Opts)), + 'Elixir.Enum':to_list(?COMMAND:run([<<"client_id">>], Opts)), + + %% MQTT CLI should list only MQTT connection. + [[{client_id, <<"simpleMqttClient">>}]] = + 'Elixir.Enum':to_list(?MQTT_COMMAND:run([<<"client_id">>], Opts)), C3 = connect(<<"simpleWebMqttClient1">>, Config, [{ack_timeout, 1}]), timer:sleep(200), From f4a24c7f16042b5614a69fb9cf6d81b5a498236d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 11 Sep 2024 14:49:38 +0200 Subject: [PATCH 08/45] make: Run rabbitmq_mqtt tests via parallel-ct --- .github/workflows/test-make-jobs.yaml | 15 +++++- deps/rabbitmq_mqtt/Makefile | 78 +++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-make-jobs.yaml b/.github/workflows/test-make-jobs.yaml index aa03ab377b8c..e548474faeef 100644 --- a/.github/workflows/test-make-jobs.yaml +++ b/.github/workflows/test-make-jobs.yaml @@ -36,7 +36,20 @@ jobs: make_target: ${{ matrix.make_target }} plugin: rabbit -# @todo test-mqtt using parallel ct + test-rabbitmq-mqtt: + name: Test rabbitmq_mqtt + strategy: + fail-fast: false + matrix: + make_target: + - parallel-ct-set-1 + uses: ./.github/workflows/test-make-ct-par.yaml + with: + erlang_version: ${{ inputs.erlang_version }} + elixir_version: ${{ inputs.elixir_version }} + metadata_store: ${{ inputs.metadata_store }} + make_target: ${{ matrix.make_target }} + plugin: rabbitmq_mqtt test-ct-seq: name: Test plugins diff --git a/deps/rabbitmq_mqtt/Makefile b/deps/rabbitmq_mqtt/Makefile index d77b5c5850eb..274bd9defb5d 100644 --- a/deps/rabbitmq_mqtt/Makefile +++ b/deps/rabbitmq_mqtt/Makefile @@ -59,3 +59,81 @@ include ../../erlang.mk clean:: if test -d test/java_SUITE_data; then cd test/java_SUITE_data && $(MAKE) clean; fi + + + + + +# @todo Move most of this in common files. + +define ct_master.erl + StartOpts = #{ + host => "localhost", + connection => standard_io, + args => ["-hidden"] + }, + {ok, Pid1, _} = peer:start(StartOpts#{name => "rabbit_shard1"}), + {ok, Pid2, _} = peer:start(StartOpts#{name => "rabbit_shard2"}), + {ok, Pid3, _} = peer:start(StartOpts#{name => "rabbit_shard3"}), + {ok, Pid4, _} = peer:start(StartOpts#{name => "rabbit_shard4"}), + peer:call(Pid1, net_kernel, set_net_ticktime, [5]), + peer:call(Pid2, net_kernel, set_net_ticktime, [5]), + peer:call(Pid3, net_kernel, set_net_ticktime, [5]), + peer:call(Pid4, net_kernel, set_net_ticktime, [5]), + peer:call(Pid1, persistent_term, put, [rabbit_ct_tcp_port_base, 23000]), + peer:call(Pid2, persistent_term, put, [rabbit_ct_tcp_port_base, 25000]), + peer:call(Pid3, persistent_term, put, [rabbit_ct_tcp_port_base, 27000]), + peer:call(Pid4, persistent_term, put, [rabbit_ct_tcp_port_base, 29000]), + ct_master:run("$1"), + peer:stop(Pid4), + peer:stop(Pid3), + peer:stop(Pid2), + peer:stop(Pid1), + halt() +endef + +PARALLEL_CT_SET_1_A = auth retainer +PARALLEL_CT_SET_1_B = cluster command config config_schema mc_mqtt packet_prop \ + processor protocol_interop proxy_protocol rabbit_mqtt_confirms reader util +PARALLEL_CT_SET_1_C = java v5 +PARALLEL_CT_SET_1_D = mqtt_shared + +PARALLEL_CT_SUITES = $(PARALLEL_CT_SET_1_A) $(PARALLEL_CT_SET_1_B) $(PARALLEL_CT_SET_1_C) $(PARALLEL_CT_SET_1_D) + +ifneq ($(filter-out $(PARALLEL_CT_SUITES),$(CT_SUITES)),) +$(error Some test suites in CT_SUITES but not configured for CI.) +endif + + + +define tpl_parallel_ct_test_spec +{logdir, "logs/"}. +{logdir, master, "logs/"}. +{create_priv_dir, all_nodes, auto_per_run}. + +{node, shard1, 'rabbit_shard1@localhost'}. +{node, shard2, 'rabbit_shard2@localhost'}. +{node, shard3, 'rabbit_shard3@localhost'}. +{node, shard4, 'rabbit_shard4@localhost'}. + +{define, 'Set1', [$(call comma_list,$(addsuffix _SUITE,$1))]}. +{define, 'Set2', [$(call comma_list,$(addsuffix _SUITE,$2))]}. +{define, 'Set3', [$(call comma_list,$(addsuffix _SUITE,$3))]}. +{define, 'Set4', [$(call comma_list,$(addsuffix _SUITE,$4))]}. + +{suites, shard1, "test/", 'Set1'}. +{suites, shard2, "test/", 'Set2'}. +{suites, shard3, "test/", 'Set3'}. +{suites, shard4, "test/", 'Set4'}. +endef + +define parallel_ct_set_target +tpl_parallel_ct_test_spec_set_$1 = $$(call tpl_parallel_ct_test_spec,$(PARALLEL_CT_SET_$(1)_A),$(PARALLEL_CT_SET_$(1)_B),$(PARALLEL_CT_SET_$(1)_C),$(PARALLEL_CT_SET_$(1)_D)) + +parallel-ct-set-$(1): test-build + $(verbose) mkdir -p $(CT_LOGS_DIR) + $(verbose) $$(call core_render,tpl_parallel_ct_test_spec_set_$(1),ct.set-$(1).spec) + $$(call erlang,$$(call ct_master.erl,ct.set-$(1).spec),-sname parallel_ct_$(PROJECT)@localhost -hidden -kernel net_ticktime 5) +endef + +$(foreach set,1,$(eval $(call parallel_ct_set_target,$(set)))) From 5327ce3e2f5550aee15775cb286b9e9af5929f40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 12 Sep 2024 13:44:19 +0200 Subject: [PATCH 09/45] make CI: Simplify test-rabbitmq-mqtt --- .github/workflows/test-make-jobs.yaml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/test-make-jobs.yaml b/.github/workflows/test-make-jobs.yaml index e548474faeef..8c0ec0bacebc 100644 --- a/.github/workflows/test-make-jobs.yaml +++ b/.github/workflows/test-make-jobs.yaml @@ -38,17 +38,12 @@ jobs: test-rabbitmq-mqtt: name: Test rabbitmq_mqtt - strategy: - fail-fast: false - matrix: - make_target: - - parallel-ct-set-1 uses: ./.github/workflows/test-make-ct-par.yaml with: erlang_version: ${{ inputs.erlang_version }} elixir_version: ${{ inputs.elixir_version }} metadata_store: ${{ inputs.metadata_store }} - make_target: ${{ matrix.make_target }} + make_target: parallel-ct-set-1 plugin: rabbitmq_mqtt test-ct-seq: From b5011f058f11cd8ef2f41480292c928cc6be07b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 12 Sep 2024 14:06:09 +0200 Subject: [PATCH 10/45] make CI: Simplify workflows --- .github/workflows/test-make-ct-seq.yaml | 64 ------------------- .github/workflows/test-make-jobs.yaml | 15 +++-- ...make-ct-par.yaml => test-make-target.yaml} | 13 +++- 3 files changed, 23 insertions(+), 69 deletions(-) delete mode 100644 .github/workflows/test-make-ct-seq.yaml rename .github/workflows/{test-make-ct-par.yaml => test-make-target.yaml} (82%) diff --git a/.github/workflows/test-make-ct-seq.yaml b/.github/workflows/test-make-ct-seq.yaml deleted file mode 100644 index c8d0b144daab..000000000000 --- a/.github/workflows/test-make-ct-seq.yaml +++ /dev/null @@ -1,64 +0,0 @@ -name: Sequential CT (make) -on: - workflow_call: - inputs: - erlang_version: - required: true - type: number - elixir_version: - required: true - type: number - metadata_store: - required: true - type: string - plugin: - required: true - type: string -jobs: - test: - name: ${{ inputs.plugin }} (tests) - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - name: CHECKOUT REPOSITORY - uses: actions/checkout@v4 - - - name: SETUP OTP & ELIXIR - uses: erlef/setup-beam@v1.17 - with: - otp-version: ${{ inputs.erlang_version }} - elixir-version: ${{ inputs.elixir_version }} - hexpm-mirrors: | - https://builds.hex.pm - https://cdn.jsdelivr.net/hex - - - name: SETUP rabbitmq_auth_backend_ldap - if: inputs.plugin == 'rabbitmq_auth_backend_ldap' - run: | - sudo apt-get update && \ - sudo apt-get install -y \ - apparmor-utils \ - ldap-utils \ - slapd - - sudo aa-complain `which slapd` - -# @todo Why? -# - name: CLI COMPILE WARNINGS AS ERRORS -# if: inputs.plugin == 'rabbitmq_cli' -# run: | -# bazel build //deps/rabbitmq_cli:compile_warnings_as_errors \ -# --verbose_failures - - - name: RUN TESTS - run: | - make -C deps/${{ inputs.plugin }} tests RABBITMQ_METADATA_STORE=${{ inputs.metadata_store }} - - - name: UPLOAD TEST LOGS - if: always() - uses: actions/upload-artifact@v4 - with: - name: CT logs (${{ inputs.plugin }} OTP-${{ inputs.erlang_version }} ${{ inputs.metadata_store }}) - path: | - deps/${{ inputs.plugin }}/logs/ - !deps/${{ inputs.plugin }}/logs/**/log_private diff --git a/.github/workflows/test-make-jobs.yaml b/.github/workflows/test-make-jobs.yaml index 8c0ec0bacebc..6c260887b48c 100644 --- a/.github/workflows/test-make-jobs.yaml +++ b/.github/workflows/test-make-jobs.yaml @@ -28,7 +28,7 @@ jobs: - ct-metadata_store_clustering - ct-quorum_queue - ct-rabbit_stream_queue - uses: ./.github/workflows/test-make-ct-par.yaml + uses: ./.github/workflows/test-make-target.yaml with: erlang_version: ${{ inputs.erlang_version }} elixir_version: ${{ inputs.elixir_version }} @@ -38,7 +38,7 @@ jobs: test-rabbitmq-mqtt: name: Test rabbitmq_mqtt - uses: ./.github/workflows/test-make-ct-par.yaml + uses: ./.github/workflows/test-make-target.yaml with: erlang_version: ${{ inputs.erlang_version }} elixir_version: ${{ inputs.elixir_version }} @@ -46,7 +46,7 @@ jobs: make_target: parallel-ct-set-1 plugin: rabbitmq_mqtt - test-ct-seq: + test-plugin-generic: name: Test plugins strategy: fail-fast: false @@ -91,13 +91,20 @@ jobs: - rabbitmq_web_dispatch - rabbitmq_web_mqtt - rabbitmq_web_stomp - uses: ./.github/workflows/test-make-ct-seq.yaml + uses: ./.github/workflows/test-make-target.yaml with: erlang_version: ${{ inputs.erlang_version }} elixir_version: ${{ inputs.elixir_version }} metadata_store: ${{ inputs.metadata_store }} + make_target: tests plugin: ${{ matrix.plugin }} # @todo Test rabbitmq_cli +# @todo Why this step? +# - name: CLI COMPILE WARNINGS AS ERRORS +# if: inputs.plugin == 'rabbitmq_cli' +# run: | +# bazel build //deps/rabbitmq_cli:compile_warnings_as_errors \ +# --verbose_failures # @todo Dialyzer xref diff --git a/.github/workflows/test-make-ct-par.yaml b/.github/workflows/test-make-target.yaml similarity index 82% rename from .github/workflows/test-make-ct-par.yaml rename to .github/workflows/test-make-target.yaml index 24a8ab649e3c..bc3b001a7588 100644 --- a/.github/workflows/test-make-ct-par.yaml +++ b/.github/workflows/test-make-target.yaml @@ -1,4 +1,4 @@ -name: Parallel CT (make) +name: Test target (make) on: workflow_call: inputs: @@ -41,6 +41,17 @@ jobs: with: dotnet-version: '3.1.x' + - name: SETUP SLAPD (rabbitmq_auth_backend_ldap) + if: inputs.plugin == 'rabbitmq_auth_backend_ldap' + run: | + sudo apt-get update && \ + sudo apt-get install -y \ + apparmor-utils \ + ldap-utils \ + slapd + + sudo aa-complain `which slapd` + - name: RUN TESTS run: | make -C deps/${{ inputs.plugin }} ${{ inputs.make_target }} RABBITMQ_METADATA_STORE=${{ inputs.metadata_store }} From d9770fb18cae3e2b51fbd50a4783f854ab17a8ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 12 Sep 2024 15:21:17 +0200 Subject: [PATCH 11/45] make CI: Add xref job --- .github/workflows/test-make-jobs.yaml | 2 +- .github/workflows/test-make.yaml | 28 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-make-jobs.yaml b/.github/workflows/test-make-jobs.yaml index 6c260887b48c..b97a9bf692e4 100644 --- a/.github/workflows/test-make-jobs.yaml +++ b/.github/workflows/test-make-jobs.yaml @@ -107,4 +107,4 @@ jobs: # bazel build //deps/rabbitmq_cli:compile_warnings_as_errors \ # --verbose_failures -# @todo Dialyzer xref +# @todo Dialyzer diff --git a/.github/workflows/test-make.yaml b/.github/workflows/test-make.yaml index ae40c88d34b2..28344883bced 100644 --- a/.github/workflows/test-make.yaml +++ b/.github/workflows/test-make.yaml @@ -64,3 +64,31 @@ jobs: - name: BUILD run: make + + xref: + name: Xref + strategy: + fail-fast: false + matrix: + erlang_version: + - 26 + - 27 + elixir_version: + - 1.17 + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: CHECKOUT REPOSITORY + uses: actions/checkout@v4 + + - name: SETUP OTP & ELIXIR + uses: erlef/setup-beam@v1.17 + with: + otp-version: ${{ matrix.erlang_version }} + elixir-version: ${{ matrix.elixir_version }} + hexpm-mirrors: | + https://builds.hex.pm + https://cdn.jsdelivr.net/hex + + - name: XREF + run: make xref From 9b2d2c1295abf151999f32a9b03e9736b59dd4f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 12 Sep 2024 15:59:32 +0200 Subject: [PATCH 12/45] make CI: Run Dialyzer --- ...st-make-jobs.yaml => test-make-tests.yaml} | 6 +- .github/workflows/test-make-type-check.yaml | 79 +++++++++++++++++++ .github/workflows/test-make.yaml | 67 +++++++--------- 3 files changed, 109 insertions(+), 43 deletions(-) rename .github/workflows/{test-make-jobs.yaml => test-make-tests.yaml} (98%) create mode 100644 .github/workflows/test-make-type-check.yaml diff --git a/.github/workflows/test-make-jobs.yaml b/.github/workflows/test-make-tests.yaml similarity index 98% rename from .github/workflows/test-make-jobs.yaml rename to .github/workflows/test-make-tests.yaml index b97a9bf692e4..b75ec2e0984f 100644 --- a/.github/workflows/test-make-jobs.yaml +++ b/.github/workflows/test-make-tests.yaml @@ -1,4 +1,4 @@ -name: Test jobs (make) +name: Run tests (make) on: workflow_call: inputs: @@ -46,7 +46,7 @@ jobs: make_target: parallel-ct-set-1 plugin: rabbitmq_mqtt - test-plugin-generic: + test-plugin: name: Test plugins strategy: fail-fast: false @@ -106,5 +106,3 @@ jobs: # run: | # bazel build //deps/rabbitmq_cli:compile_warnings_as_errors \ # --verbose_failures - -# @todo Dialyzer diff --git a/.github/workflows/test-make-type-check.yaml b/.github/workflows/test-make-type-check.yaml new file mode 100644 index 000000000000..f675a918c6e4 --- /dev/null +++ b/.github/workflows/test-make-type-check.yaml @@ -0,0 +1,79 @@ +name: Type check (make) +on: + workflow_call: + inputs: + erlang_version: + required: true + type: number + elixir_version: + required: true + type: number +jobs: + type-check-plugin: + name: Type check plugins + strategy: + fail-fast: false + matrix: + plugin: + # These are using plugin-specific test jobs. + - rabbit + - rabbitmq_mqtt + # These are from the test-plugin test job. + - amqp10_client + - amqp10_common + - amqp_client + - oauth2_client + - rabbit_common + - rabbitmq_amqp_client + - rabbitmq_auth_backend_cache + - rabbitmq_auth_backend_http + - rabbitmq_auth_backend_ldap + - rabbitmq_auth_backend_oauth2 + - rabbitmq_auth_mechanism_ssl + - rabbitmq_consistent_hash_exchange + - rabbitmq_event_exchange + - rabbitmq_federation + - rabbitmq_federation_management + - rabbitmq_federation_prometheus + - rabbitmq_jms_topic_exchange + - rabbitmq_management + - rabbitmq_management_agent + - rabbitmq_peer_discovery_common + - rabbitmq_peer_discovery_consul + - rabbitmq_peer_discovery_etcd + - rabbitmq_peer_discovery_k8s + - rabbitmq_prelaunch + - rabbitmq_prometheus + - rabbitmq_recent_history_exchange + - rabbitmq_sharding + - rabbitmq_shovel + - rabbitmq_shovel_management + - rabbitmq_shovel_prometheus + - rabbitmq_stomp + - rabbitmq_stream + - rabbitmq_stream_common + - rabbitmq_stream_management + - rabbitmq_tracing + - rabbitmq_trust_store + - rabbitmq_web_dispatch + - rabbitmq_web_mqtt + - rabbitmq_web_stomp + # These have tests but we don't want to run them + # in this workflow so no corresponding test job. + - rabbitmq_aws + - rabbitmq_ct_helpers + - rabbitmq_peer_discovery_aws + # These do not have tests at this time so no corresponding test job. + - rabbitmq_ct_client_helpers + - rabbitmq_random_exchange + - rabbitmq_top + - rabbitmq_web_mqtt_examples + - rabbitmq_web_stomp_examples + - trust_store_http + uses: ./.github/workflows/test-make-target.yaml + with: + erlang_version: ${{ inputs.erlang_version }} + elixir_version: ${{ inputs.elixir_version }} + metadata_store: khepri # Not actually used. + make_target: dialyze + plugin: ${{ matrix.plugin }} diff --git a/.github/workflows/test-make.yaml b/.github/workflows/test-make.yaml index 28344883bced..5224de01b89b 100644 --- a/.github/workflows/test-make.yaml +++ b/.github/workflows/test-make.yaml @@ -17,27 +17,8 @@ concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: - version-matrix: - name: Test - strategy: - fail-fast: false - matrix: - erlang_version: - - 26 - - 27 - elixir_version: - - 1.17 - metadata_store: - - mnesia - - khepri - uses: ./.github/workflows/test-make-jobs.yaml - with: - erlang_version: ${{ matrix.erlang_version }} - elixir_version: ${{ matrix.elixir_version }} - metadata_store: ${{ matrix.metadata_store }} - - build: - name: Build + build-and-xref: + name: Build and Xref strategy: fail-fast: false matrix: @@ -65,8 +46,11 @@ jobs: - name: BUILD run: make - xref: - name: Xref + - name: XREF + run: make xref + + test: + name: Test strategy: fail-fast: false matrix: @@ -75,20 +59,25 @@ jobs: - 27 elixir_version: - 1.17 - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - name: CHECKOUT REPOSITORY - uses: actions/checkout@v4 - - - name: SETUP OTP & ELIXIR - uses: erlef/setup-beam@v1.17 - with: - otp-version: ${{ matrix.erlang_version }} - elixir-version: ${{ matrix.elixir_version }} - hexpm-mirrors: | - https://builds.hex.pm - https://cdn.jsdelivr.net/hex + metadata_store: + - mnesia + - khepri + uses: ./.github/workflows/test-make-tests.yaml + with: + erlang_version: ${{ matrix.erlang_version }} + elixir_version: ${{ matrix.elixir_version }} + metadata_store: ${{ matrix.metadata_store }} - - name: XREF - run: make xref + type-check: + name: Type check + strategy: + fail-fast: false + matrix: + erlang_version: # Latest OTP + - 27 + elixir_version: # Latest Elixir + - 1.17 + uses: ./.github/workflows/test-make-type-check.yaml + with: + erlang_version: ${{ matrix.erlang_version }} + elixir_version: ${{ matrix.elixir_version }} From dad0bfcca9a1544190e0ec4d7e0a085b5c1819cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Fri, 13 Sep 2024 14:16:40 +0200 Subject: [PATCH 13/45] make CI: Run rabbitmq_aws eunit tests --- .github/workflows/test-make-tests.yaml | 1 + .github/workflows/test-make-type-check.yaml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-make-tests.yaml b/.github/workflows/test-make-tests.yaml index b75ec2e0984f..614902e6c5d8 100644 --- a/.github/workflows/test-make-tests.yaml +++ b/.github/workflows/test-make-tests.yaml @@ -63,6 +63,7 @@ jobs: - rabbitmq_auth_backend_ldap - rabbitmq_auth_backend_oauth2 - rabbitmq_auth_mechanism_ssl + - rabbitmq_aws - rabbitmq_consistent_hash_exchange - rabbitmq_event_exchange - rabbitmq_federation diff --git a/.github/workflows/test-make-type-check.yaml b/.github/workflows/test-make-type-check.yaml index f675a918c6e4..2566e6745998 100644 --- a/.github/workflows/test-make-type-check.yaml +++ b/.github/workflows/test-make-type-check.yaml @@ -30,6 +30,7 @@ jobs: - rabbitmq_auth_backend_ldap - rabbitmq_auth_backend_oauth2 - rabbitmq_auth_mechanism_ssl + - rabbitmq_aws - rabbitmq_consistent_hash_exchange - rabbitmq_event_exchange - rabbitmq_federation @@ -60,7 +61,6 @@ jobs: - rabbitmq_web_stomp # These have tests but we don't want to run them # in this workflow so no corresponding test job. - - rabbitmq_aws - rabbitmq_ct_helpers - rabbitmq_peer_discovery_aws # These do not have tests at this time so no corresponding test job. From 97363dfeaea1606b084c050fe50b46012f6cb90b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Fri, 13 Sep 2024 15:31:36 +0200 Subject: [PATCH 14/45] make CI: Run most rabbitmq_peer_discovery_aws tests The integration_SUITE has to run in a separate workflow due to needing secrets. --- .github/workflows/test-make-tests.yaml | 12 ++++++++++++ .github/workflows/test-make-type-check.yaml | 5 ++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-make-tests.yaml b/.github/workflows/test-make-tests.yaml index 614902e6c5d8..acb3bb214cc5 100644 --- a/.github/workflows/test-make-tests.yaml +++ b/.github/workflows/test-make-tests.yaml @@ -46,6 +46,18 @@ jobs: make_target: parallel-ct-set-1 plugin: rabbitmq_mqtt + # The integration_SUITE requires secrets and + # is therefore run from a separate workflow. + test-rabbitmq-peer-discovery-aws: + name: Test rabbitmq_peer_discovery_aws (partially) + uses: ./.github/workflows/test-make-target.yaml + with: + erlang_version: ${{ inputs.erlang_version }} + elixir_version: ${{ inputs.elixir_version }} + metadata_store: ${{ inputs.metadata_store }} + make_target: ct-config_schema ct-unit + plugin: rabbitmq_peer_discovery_aws + test-plugin: name: Test plugins strategy: diff --git a/.github/workflows/test-make-type-check.yaml b/.github/workflows/test-make-type-check.yaml index 2566e6745998..3c18ec76fc00 100644 --- a/.github/workflows/test-make-type-check.yaml +++ b/.github/workflows/test-make-type-check.yaml @@ -18,6 +18,7 @@ jobs: # These are using plugin-specific test jobs. - rabbit - rabbitmq_mqtt + - rabbitmq_peer_discovery_aws # These are from the test-plugin test job. - amqp10_client - amqp10_common @@ -59,10 +60,8 @@ jobs: - rabbitmq_web_dispatch - rabbitmq_web_mqtt - rabbitmq_web_stomp - # These have tests but we don't want to run them - # in this workflow so no corresponding test job. + # This one we do not want to run tests so no corresponding test job. - rabbitmq_ct_helpers - - rabbitmq_peer_discovery_aws # These do not have tests at this time so no corresponding test job. - rabbitmq_ct_client_helpers - rabbitmq_random_exchange From f95c87082a56219aa7e0548028097e7989c4aa44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 16 Sep 2024 10:28:48 +0200 Subject: [PATCH 15/45] make: Include rabbitmq_cli ebin in code path only if in deps --- deps/rabbit_common/mk/rabbitmq-build.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deps/rabbit_common/mk/rabbitmq-build.mk b/deps/rabbit_common/mk/rabbitmq-build.mk index 010045f5c37a..93d9613c17ce 100644 --- a/deps/rabbit_common/mk/rabbitmq-build.mk +++ b/deps/rabbit_common/mk/rabbitmq-build.mk @@ -8,9 +8,10 @@ TEST_ERLC_OPTS += +nowarn_export_all -ifneq ($(filter-out rabbit_common amqp_client,$(PROJECT)),) +ifneq ($(filter rabbitmq_cli,$(BUILD_DEPS) $(DEPS)),) # Add the CLI ebin directory to the code path for the compiler: plugin # CLI extensions may access behaviour modules defined in this directory. + RMQ_ERLC_OPTS += -pa $(DEPS_DIR)/rabbitmq_cli/_build/dev/lib/rabbitmqctl/ebin endif From 9f8c17f5874b9e6d1bed94b3f60bfa8b56f17b17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 16 Sep 2024 11:32:20 +0200 Subject: [PATCH 16/45] make: Fix build errors for apps that have rabbit in TEST_DEPS We want them to install CLI scripts only for the test build, otherwise Dialyzer or others will fail in a clean run. --- deps/rabbit_common/mk/rabbitmq-dist.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/deps/rabbit_common/mk/rabbitmq-dist.mk b/deps/rabbit_common/mk/rabbitmq-dist.mk index 1d0254452fec..f55fe1ef08ea 100644 --- a/deps/rabbit_common/mk/rabbitmq-dist.mk +++ b/deps/rabbit_common/mk/rabbitmq-dist.mk @@ -212,7 +212,10 @@ CLI_ESCRIPTS_LOCK = $(CLI_ESCRIPTS_DIR).lock ifeq ($(MAKELEVEL),0) ifneq ($(filter-out rabbit_common amqp10_common rabbitmq_stream_common,$(PROJECT)),) +# These do not depend on 'rabbit' as DEPS but may as TEST_DEPS. +ifneq ($(filter-out amqp_client amqp10_client rabbitmq_amqp_client rabbitmq_ct_helpers,$(PROJECT)),) app:: install-cli +endif test-build:: install-cli endif endif From 5e3942478f79101082af8fd96aef582706da018c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 16 Sep 2024 11:52:23 +0200 Subject: [PATCH 17/45] amqp10_common: Don't dialyze tests or from source by default --- deps/amqp10_common/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/amqp10_common/Makefile b/deps/amqp10_common/Makefile index db36c18b9419..6208fecad785 100644 --- a/deps/amqp10_common/Makefile +++ b/deps/amqp10_common/Makefile @@ -24,7 +24,7 @@ define HEX_TARBALL_EXTRA_METADATA } endef -DIALYZER_OPTS += --src -r test -DTEST +#DIALYZER_OPTS += --src -r test -DTEST BUILD_DEPS = rabbit_common TEST_DEPS = rabbitmq_ct_helpers proper From 5086553bdd45b1eb5b194c1b46ed5e8d7940280e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 16 Sep 2024 12:03:25 +0200 Subject: [PATCH 18/45] make: Correct rabbitmq_prelaunch/rabbitmq_stream_common deps --- deps/rabbit/Makefile | 1 - deps/rabbitmq_prelaunch/Makefile | 4 ++-- deps/rabbitmq_stream_common/Makefile | 4 +--- rabbitmq-components.mk | 1 + 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/deps/rabbit/Makefile b/deps/rabbit/Makefile index 5371d688ec8c..76b7606da5f9 100644 --- a/deps/rabbit/Makefile +++ b/deps/rabbit/Makefile @@ -135,7 +135,6 @@ TEST_DEPS = rabbitmq_ct_helpers rabbitmq_ct_client_helpers meck proper amqp_clie PLT_APPS += mnesia runtime_tools dep_syslog = git https://github.com/schlagert/syslog 4.0.0 -dep_systemd = hex 0.6.1 define usage_xml_to_erl $(subst __,_,$(patsubst $(DOCS_DIR)/rabbitmq%.1.xml, src/rabbit_%_usage.erl, $(subst -,_,$(1)))) diff --git a/deps/rabbitmq_prelaunch/Makefile b/deps/rabbitmq_prelaunch/Makefile index 38c4b940ab3e..ee82d02d3c39 100644 --- a/deps/rabbitmq_prelaunch/Makefile +++ b/deps/rabbitmq_prelaunch/Makefile @@ -3,9 +3,9 @@ PROJECT_DESCRIPTION = RabbitMQ prelaunch setup PROJECT_VERSION = 4.0.0 PROJECT_MOD = rabbit_prelaunch_app -DEPS = rabbit_common cuttlefish thoas +DEPS = rabbit_common cuttlefish thoas osiris systemd -PLT_APPS += runtime_tools eunit osiris systemd +PLT_APPS += runtime_tools eunit DEP_PLUGINS = rabbit_common/mk/rabbitmq-build.mk diff --git a/deps/rabbitmq_stream_common/Makefile b/deps/rabbitmq_stream_common/Makefile index c159f0eb5593..a6b7c71ae117 100644 --- a/deps/rabbitmq_stream_common/Makefile +++ b/deps/rabbitmq_stream_common/Makefile @@ -7,11 +7,9 @@ define PROJECT_ENV endef -DEPS = +DEPS = osiris TEST_DEPS = rabbitmq_ct_helpers rabbitmq_ct_client_helpers -PLT_APPS = osiris - DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-plugin.mk # We do not depend on rabbit therefore can't run the broker. DEP_PLUGINS = rabbit_common/mk/rabbitmq-build.mk diff --git a/rabbitmq-components.mk b/rabbitmq-components.mk index 08903247d5ba..53c10ad63132 100644 --- a/rabbitmq-components.mk +++ b/rabbitmq-components.mk @@ -54,6 +54,7 @@ dep_ra = hex 2.14.0 dep_ranch = hex 2.1.0 dep_recon = hex 2.5.3 dep_redbug = hex 2.0.7 +dep_systemd = hex 0.6.1 dep_thoas = hex 1.0.0 dep_observer_cli = hex 1.7.5 dep_seshat = git https://github.com/rabbitmq/seshat v0.6.1 From 85e358642b32de621e8cd523d20dbcf1a91f8100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 16 Sep 2024 12:40:59 +0200 Subject: [PATCH 19/45] Fix OTP-27 Dialyzer errors in rabbit --- deps/rabbit/src/rabbit_channel_tracking.erl | 4 ++-- deps/rabbit/src/rabbit_connection_tracking.erl | 4 ++-- deps/rabbit/src/rabbit_msg_store.erl | 4 ++-- deps/rabbit/src/rabbit_time_travel_dbg.erl | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/deps/rabbit/src/rabbit_channel_tracking.erl b/deps/rabbit/src/rabbit_channel_tracking.erl index 0931352416df..bd37d59bf9e8 100644 --- a/deps/rabbit/src/rabbit_channel_tracking.erl +++ b/deps/rabbit/src/rabbit_channel_tracking.erl @@ -126,7 +126,7 @@ unregister_tracked_by_pid(ChPid) when node(ChPid) == node() -> case ets:lookup(?TRACKED_CHANNEL_TABLE, ChPid) of [] -> ok; [#tracked_channel{username = Username}] -> - ets:update_counter(?TRACKED_CHANNEL_TABLE_PER_USER, Username, -1), + _ = ets:update_counter(?TRACKED_CHANNEL_TABLE_PER_USER, Username, -1), ets:delete(?TRACKED_CHANNEL_TABLE, ChPid) end. @@ -139,7 +139,7 @@ unregister_tracked(ChId = {Node, _Name}) when Node == node() -> case get_tracked_channel_by_id(ChId) of [] -> ok; [#tracked_channel{pid = ChPid, username = Username}] -> - ets:update_counter(?TRACKED_CHANNEL_TABLE_PER_USER, Username, -1), + _ = ets:update_counter(?TRACKED_CHANNEL_TABLE_PER_USER, Username, -1), ets:delete(?TRACKED_CHANNEL_TABLE, ChPid) end. diff --git a/deps/rabbit/src/rabbit_connection_tracking.erl b/deps/rabbit/src/rabbit_connection_tracking.erl index 207bcd9fc570..4ac1b8065324 100644 --- a/deps/rabbit/src/rabbit_connection_tracking.erl +++ b/deps/rabbit/src/rabbit_connection_tracking.erl @@ -151,8 +151,8 @@ unregister_tracked(ConnId = {Node, _Name}) when Node =:= node() -> case ets:lookup(?TRACKED_CONNECTION_TABLE, ConnId) of [] -> ok; [#tracked_connection{vhost = VHost, username = Username}] -> - ets:update_counter(?TRACKED_CONNECTION_TABLE_PER_USER, Username, -1), - ets:update_counter(?TRACKED_CONNECTION_TABLE_PER_VHOST, VHost, -1), + _ = ets:update_counter(?TRACKED_CONNECTION_TABLE_PER_USER, Username, -1), + _ = ets:update_counter(?TRACKED_CONNECTION_TABLE_PER_VHOST, VHost, -1), ets:delete(?TRACKED_CONNECTION_TABLE, ConnId) end. diff --git a/deps/rabbit/src/rabbit_msg_store.erl b/deps/rabbit/src/rabbit_msg_store.erl index c5b02f6eb9c4..b28506ab2ab8 100644 --- a/deps/rabbit/src/rabbit_msg_store.erl +++ b/deps/rabbit/src/rabbit_msg_store.erl @@ -1050,7 +1050,7 @@ internal_sync(State = #msstate { current_file_handle = CurHdl, flying_write(Key, #msstate { flying_ets = FlyingEts }) -> case ets:lookup(FlyingEts, Key) of [{_, ?FLYING_WRITE}] -> - ets:update_counter(FlyingEts, Key, ?FLYING_WRITE_DONE), + _ = ets:update_counter(FlyingEts, Key, ?FLYING_WRITE_DONE), %% We only remove the object if it hasn't changed %% (a remove may be sent while we were processing the write). true = ets:delete_object(FlyingEts, {Key, ?FLYING_IS_WRITTEN}), @@ -1318,7 +1318,7 @@ update_msg_cache(CacheEts, MsgId, Msg) -> %% but without the debug log that we don't want as the update is %% more likely to fail following recent reworkings. try - ets:update_counter(CacheEts, MsgId, {3, +1}), + _ = ets:update_counter(CacheEts, MsgId, {3, +1}), ok catch error:badarg -> %% The entry must have been removed between diff --git a/deps/rabbit/src/rabbit_time_travel_dbg.erl b/deps/rabbit/src/rabbit_time_travel_dbg.erl index 4ab6674514de..7d8b480e5ac9 100644 --- a/deps/rabbit/src/rabbit_time_travel_dbg.erl +++ b/deps/rabbit/src/rabbit_time_travel_dbg.erl @@ -28,7 +28,7 @@ start(Pid, Apps) -> TracerPid = spawn_link(?MODULE, init, []), {ok, _} = dbg:tracer(process, {fun (Msg, _) -> TracerPid ! Msg end, []}), _ = [dbg:tpl(M, []) || M <- Mods], - dbg:p(Pid, [c]), + _ = dbg:p(Pid, [c]), ok. apps_to_mods([], Acc) -> From 861943835f8e0b9b1d2cf8ef1d96de0da4a22005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 16 Sep 2024 12:48:14 +0200 Subject: [PATCH 20/45] Fix OTP-27 Dialyzer errors in rabbit_common --- .../rabbit_common/src/rabbit_core_metrics.erl | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/deps/rabbit_common/src/rabbit_core_metrics.erl b/deps/rabbit_common/src/rabbit_core_metrics.erl index c06b73bc457d..8b5430076f53 100644 --- a/deps/rabbit_common/src/rabbit_core_metrics.erl +++ b/deps/rabbit_common/src/rabbit_core_metrics.erl @@ -124,8 +124,8 @@ terminate() -> connection_created(Pid, Infos) -> ets:insert(connection_created, {Pid, Infos}), - ets:update_counter(connection_churn_metrics, node(), {2, 1}, - ?CONNECTION_CHURN_METRICS), + _ = ets:update_counter(connection_churn_metrics, node(), {2, 1}, + ?CONNECTION_CHURN_METRICS), ok. connection_closed(Pid) -> @@ -133,8 +133,8 @@ connection_closed(Pid) -> ets:delete(connection_metrics, Pid), %% Delete marker ets:update_element(connection_coarse_metrics, Pid, {5, 1}), - ets:update_counter(connection_churn_metrics, node(), {3, 1}, - ?CONNECTION_CHURN_METRICS), + _ = ets:update_counter(connection_churn_metrics, node(), {3, 1}, + ?CONNECTION_CHURN_METRICS), ok. connection_stats(Pid, Infos) -> @@ -148,16 +148,16 @@ connection_stats(Pid, Recv_oct, Send_oct, Reductions) -> channel_created(Pid, Infos) -> ets:insert(channel_created, {Pid, Infos}), - ets:update_counter(connection_churn_metrics, node(), {4, 1}, - ?CONNECTION_CHURN_METRICS), + _ = ets:update_counter(connection_churn_metrics, node(), {4, 1}, + ?CONNECTION_CHURN_METRICS), ok. channel_closed(Pid) -> ets:delete(channel_created, Pid), ets:delete(channel_metrics, Pid), ets:delete(channel_process_metrics, Pid), - ets:update_counter(connection_churn_metrics, node(), {5, 1}, - ?CONNECTION_CHURN_METRICS), + _ = ets:update_counter(connection_churn_metrics, node(), {5, 1}, + ?CONNECTION_CHURN_METRICS), ok. channel_stats(Pid, Infos) -> @@ -276,20 +276,20 @@ queue_stats(Name, MessagesReady, MessagesUnacknowledge, Messages, Reductions) -> queue_declared(_Name) -> %% Name is not needed, but might be useful in the future. - ets:update_counter(connection_churn_metrics, node(), {6, 1}, - ?CONNECTION_CHURN_METRICS), + _ = ets:update_counter(connection_churn_metrics, node(), {6, 1}, + ?CONNECTION_CHURN_METRICS), ok. queue_created(_Name) -> %% Name is not needed, but might be useful in the future. - ets:update_counter(connection_churn_metrics, node(), {7, 1}, - ?CONNECTION_CHURN_METRICS), + _ = ets:update_counter(connection_churn_metrics, node(), {7, 1}, + ?CONNECTION_CHURN_METRICS), ok. queue_deleted(Name) -> ets:delete(queue_coarse_metrics, Name), - ets:update_counter(connection_churn_metrics, node(), {8, 1}, - ?CONNECTION_CHURN_METRICS), + _ = ets:update_counter(connection_churn_metrics, node(), {8, 1}, + ?CONNECTION_CHURN_METRICS), %% Delete markers ets:update_element(queue_metrics, Name, {3, 1}), CQX = ets:select(channel_queue_exchange_metrics, match_spec_cqx(Name)), @@ -302,8 +302,8 @@ queue_deleted(Name) -> end, CQ). queues_deleted(Queues) -> - ets:update_counter(connection_churn_metrics, node(), {8, length(Queues)}, - ?CONNECTION_CHURN_METRICS), + _ = ets:update_counter(connection_churn_metrics, node(), {8, length(Queues)}, + ?CONNECTION_CHURN_METRICS), [ delete_queue_metrics(Queue) || Queue <- Queues ], [ begin From ec95c1a88d9c86cce4b779c9ebda4234e3ae0149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 16 Sep 2024 12:48:40 +0200 Subject: [PATCH 21/45] rabbit_common: Remove 'cover' related code from 'rabbit_misc' This is very old code that is likely no longer used. Removing it helps avoid depending on cover. --- deps/rabbit_common/src/rabbit_misc.erl | 61 -------------------------- 1 file changed, 61 deletions(-) diff --git a/deps/rabbit_common/src/rabbit_misc.erl b/deps/rabbit_common/src/rabbit_misc.erl index c67d36adc8fe..1821abb75eca 100644 --- a/deps/rabbit_common/src/rabbit_misc.erl +++ b/deps/rabbit_common/src/rabbit_misc.erl @@ -26,9 +26,6 @@ -export([table_lookup/2, set_table_value/4, amqp_table/1, to_amqp_table/1]). -export([r/3, r/2, r_arg/4, rs/1, queue_resource/2, exchange_resource/2]). --export([enable_cover/0, report_cover/0]). --export([enable_cover/1, report_cover/1]). --export([start_cover/1]). -export([throw_on_error/2, with_exit_handler/2, is_abnormal_exit/1, filter_exit_map/2]). -export([ensure_ok/2]). @@ -165,11 +162,6 @@ {invalid_type, rabbit_framing:amqp_field_type()}) | rabbit_types:r(K) when is_subtype(K, atom()). -spec rs(rabbit_types:r(atom())) -> string(). --spec enable_cover() -> ok_or_error(). --spec start_cover([{string(), string()} | string()]) -> 'ok'. --spec report_cover() -> 'ok'. --spec enable_cover([file:filename() | atom()]) -> ok_or_error(). --spec report_cover([file:filename() | atom()]) -> 'ok'. -spec throw_on_error (atom(), thunk(rabbit_types:error(any()) | {ok, A} | A)) -> A. -spec with_exit_handler(thunk(A), thunk(A)) -> A. @@ -449,59 +441,6 @@ queue_resource(VHostPath, Name) -> exchange_resource(VHostPath, Name) -> r(VHostPath, exchange, Name). -enable_cover() -> enable_cover(["."]). - -enable_cover(Dirs) -> - lists:foldl(fun (Dir, ok) -> - case cover:compile_beam_directory( - filename:join(lists:concat([Dir]),"ebin")) of - {error, _} = Err -> Err; - _ -> ok - end; - (_Dir, Err) -> - Err - end, ok, Dirs). - -start_cover(NodesS) -> - {ok, _} = cover:start([rabbit_nodes_common:make(N) || N <- NodesS]), - ok. - -report_cover() -> report_cover(["."]). - -report_cover(Dirs) -> [report_cover1(lists:concat([Dir])) || Dir <- Dirs], ok. - -report_cover1(Root) -> - Dir = filename:join(Root, "cover"), - ok = filelib:ensure_dir(filename:join(Dir, "junk")), - lists:foreach(fun (F) -> file:delete(F) end, - filelib:wildcard(filename:join(Dir, "*.html"))), - {ok, SummaryFile} = file:open(filename:join(Dir, "summary.txt"), [write]), - {CT, NCT} = - lists:foldl( - fun (M,{CovTot, NotCovTot}) -> - {ok, {M, {Cov, NotCov}}} = cover:analyze(M, module), - ok = report_coverage_percentage(SummaryFile, - Cov, NotCov, M), - {ok,_} = cover:analyze_to_file( - M, - filename:join(Dir, atom_to_list(M) ++ ".html"), - [html]), - {CovTot+Cov, NotCovTot+NotCov} - end, - {0, 0}, - lists:sort(cover:modules())), - ok = report_coverage_percentage(SummaryFile, CT, NCT, 'TOTAL'), - ok = file:close(SummaryFile), - ok. - -report_coverage_percentage(File, Cov, NotCov, Mod) -> - io:fwrite(File, "~6.2f ~tp~n", - [if - Cov+NotCov > 0 -> 100.0*Cov/(Cov+NotCov); - true -> 100.0 - end, - Mod]). - %% @doc Halts the emulator returning the given status code to the os. %% On Windows this function will block indefinitely so as to give the io %% subsystem time to flush stdout completely. From aa43139192014831bea942a85811741cd887d156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 16 Sep 2024 13:03:02 +0200 Subject: [PATCH 22/45] Fix OTP-27 Dialyzer errors in trust_store_http --- deps/trust_store_http/src/trust_store_http.erl | 4 ++-- deps/trust_store_http/src/trust_store_http_app.erl | 2 +- deps/trust_store_http/src/trust_store_list_handler.erl | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/deps/trust_store_http/src/trust_store_http.erl b/deps/trust_store_http/src/trust_store_http.erl index d32b647b547c..315196f8b042 100644 --- a/deps/trust_store_http/src/trust_store_http.erl +++ b/deps/trust_store_http/src/trust_store_http.erl @@ -5,8 +5,8 @@ main([]) -> io:format("~nStarting trust store server ~n", []), - application:ensure_all_started(trust_store_http), + {ok, _} = application:ensure_all_started(trust_store_http), io:format("~nTrust store server started on port ~tp ~n", [application:get_env(trust_store_http, port, undefined)]), user_drv:start(), - timer:sleep(infinity). \ No newline at end of file + timer:sleep(infinity). diff --git a/deps/trust_store_http/src/trust_store_http_app.erl b/deps/trust_store_http/src/trust_store_http_app.erl index 2fd861405a51..84a2b7e83d0a 100644 --- a/deps/trust_store_http/src/trust_store_http_app.erl +++ b/deps/trust_store_http/src/trust_store_http_app.erl @@ -15,7 +15,7 @@ start(_Type, _Args) -> {"/certs/[...]", cowboy_static, {dir, Directory, [{mimetypes, {<<"text">>, <<"html">>, []}}]}}]} ]), - case get_ssl_options() of + _ = case get_ssl_options() of undefined -> start_http(Dispatch, Port); SslOptions -> start_https(Dispatch, Port, SslOptions) end, diff --git a/deps/trust_store_http/src/trust_store_list_handler.erl b/deps/trust_store_http/src/trust_store_list_handler.erl index a09bf0306cfe..416dfc253d99 100644 --- a/deps/trust_store_http/src/trust_store_list_handler.erl +++ b/deps/trust_store_http/src/trust_store_list_handler.erl @@ -25,7 +25,7 @@ respond(Files, Req, State) -> respond_error(Reason, Req, State) -> Error = io_lib:format("Error listing certificates ~tp", [Reason]), logger:log(error, "~ts", [Error]), - Req2 = cowboy_req:reply(500, [], iolist_to_binary(Error), Req), + Req2 = cowboy_req:reply(500, #{}, iolist_to_binary(Error), Req), {ok, Req2, State}. json_encode(Files) -> @@ -40,7 +40,6 @@ cert_id(FileName, FileDate, FileHash) -> cert_path(FileName) -> iolist_to_binary(["/certs/", FileName]). --spec list_files(string()) -> [{string(), file:date_time(), integer()}]. list_files(Directory) -> case file:list_dir(Directory) of {ok, FileNames} -> From c0c2c2fbd9122190f91efffe1b08cb40b24cd431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 16 Sep 2024 13:14:25 +0200 Subject: [PATCH 23/45] Fix OTP-27 Dialyzer errors in rabbitmq_trust_store --- deps/rabbitmq_trust_store/Makefile | 2 +- .../src/rabbit_trust_store_http_provider.erl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deps/rabbitmq_trust_store/Makefile b/deps/rabbitmq_trust_store/Makefile index 77440b74080d..58b73990da58 100644 --- a/deps/rabbitmq_trust_store/Makefile +++ b/deps/rabbitmq_trust_store/Makefile @@ -10,7 +10,7 @@ define PROJECT_ENV endef DEPS = rabbit_common rabbit -LOCAL_DEPS += ssl crypto public_key inets +LOCAL_DEPS = ssl crypto public_key inets ## We need the Cowboy's test utilities TEST_DEPS = rabbitmq_ct_helpers rabbitmq_ct_client_helpers amqp_client ct_helper trust_store_http dep_ct_helper = git https://github.com/extend/ct_helper.git master diff --git a/deps/rabbitmq_trust_store/src/rabbit_trust_store_http_provider.erl b/deps/rabbitmq_trust_store/src/rabbit_trust_store_http_provider.erl index 5e0aee535451..a5f0e59dbaf8 100644 --- a/deps/rabbitmq_trust_store/src/rabbit_trust_store_http_provider.erl +++ b/deps/rabbitmq_trust_store/src/rabbit_trust_store_http_provider.erl @@ -65,8 +65,8 @@ join_url(BaseUrl, CertPath) -> string:strip(rabbit_data_coercion:to_list(CertPath), left, $/). init(Config) -> - inets:start(httpc, [{profile, ?PROFILE}]), - _ = application:ensure_all_started(ssl), + _ = inets:start(httpc, [{profile, ?PROFILE}]), + {ok, _} = application:ensure_all_started(ssl), Options = proplists:get_value(proxy_options, Config, []), httpc:set_options(Options, ?PROFILE). From 5222bea44ea04109a0b001cc84271cc0e444c17b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 16 Sep 2024 13:45:59 +0200 Subject: [PATCH 24/45] ldap auth backend: Drop support for pre-OTP-25 search results The search results record change was done in OTP-25, which is no longer supported. So we can use the modern search results record and drop the compatibility clauses. For more context: * 8d8847e069e * https://github.com/erlang/otp/pull/5538 --- .../src/rabbit_auth_backend_ldap.erl | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/deps/rabbitmq_auth_backend_ldap/src/rabbit_auth_backend_ldap.erl b/deps/rabbitmq_auth_backend_ldap/src/rabbit_auth_backend_ldap.erl index f84a19a683ea..bba6767a3ce4 100644 --- a/deps/rabbitmq_auth_backend_ldap/src/rabbit_auth_backend_ldap.erl +++ b/deps/rabbitmq_auth_backend_ldap/src/rabbit_auth_backend_ldap.erl @@ -378,14 +378,8 @@ search_groups(LDAP, Desc, GroupsBase, Scope, DN) -> []; {ok, {referral, Referrals}} -> {error, {referrals_not_supported, Referrals}}; - %% support #eldap_search_result before and after - %% https://github.com/erlang/otp/pull/5538 - {ok, {eldap_search_result, [], _Referrals}} -> - []; {ok, {eldap_search_result, [], _Referrals, _Controls}}-> []; - {ok, {eldap_search_result, Entries, _Referrals}} -> - [ON || #eldap_entry{object_name = ON} <- Entries]; {ok, {eldap_search_result, Entries, _Referrals, _Controls}} -> [ON || #eldap_entry{object_name = ON} <- Entries] end. @@ -470,10 +464,6 @@ object_exists(DN, Filter, LDAP) -> {scope, eldap:baseObject()}]) of {ok, {referral, Referrals}} -> {error, {referrals_not_supported, Referrals}}; - %% support #eldap_search_result before and after - %% https://github.com/erlang/otp/pull/5538 - {ok, {eldap_search_result, Entries, _Referrals}} -> - length(Entries) > 0; {ok, {eldap_search_result, Entries, _Referrals, _Controls}} -> length(Entries) > 0; {error, _} = E -> @@ -487,14 +477,8 @@ attribute(DN, AttributeName, LDAP) -> {attributes, [AttributeName]}]) of {ok, {referral, Referrals}} -> {error, {referrals_not_supported, Referrals}}; - %% support #eldap_search_result before and after - %% https://github.com/erlang/otp/pull/5538 - {ok, {eldap_search_result, E = [#eldap_entry{}|_], _Referrals}} -> - get_attributes(AttributeName, E); {ok, {eldap_search_result, E = [#eldap_entry{}|_], _Referrals, _Controls}} -> get_attributes(AttributeName, E); - {ok, {eldap_search_result, _Entries, _Referrals}} -> - {error, not_found}; {ok, {eldap_search_result, _Entries, _Referrals, _Controls}} -> {error, not_found}; {error, _} = E -> @@ -890,18 +874,9 @@ dn_lookup(Username, LDAP) -> {attributes, ["distinguishedName"]}]) of {ok, {referral, Referrals}} -> {error, {referrals_not_supported, Referrals}}; - %% support #eldap_search_result before and after - %% https://github.com/erlang/otp/pull/5538 - {ok, {eldap_search_result, [#eldap_entry{object_name = DN}], _Referrals}}-> - ?L1("DN lookup: ~ts -> ~ts", [Username, DN]), - DN; {ok, {eldap_search_result, [#eldap_entry{object_name = DN}], _Referrals, _Controls}}-> ?L1("DN lookup: ~ts -> ~ts", [Username, DN]), DN; - {ok, {eldap_search_result, Entries, _Referrals}} -> - rabbit_log_ldap:warning("Searching for DN for ~ts, got back ~tp", - [Filled, Entries]), - Filled; {ok, {eldap_search_result, Entries, _Referrals, _Controls}} -> rabbit_log_ldap:warning("Searching for DN for ~ts, got back ~tp", [Filled, Entries]), From 67eee5602c7efb0a315a17c9246ace5bb4c20dd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 17 Sep 2024 10:12:48 +0200 Subject: [PATCH 25/45] Fix OTP-27 Dialyzer errors in rabbitmq_ct_helpers --- deps/rabbitmq_ct_helpers/Makefile | 8 +++++++- .../src/rabbit_control_helper.erl | 6 ++++-- .../src/rabbit_ct_broker_helpers.erl | 16 +++++++--------- .../src/rabbit_ct_config_schema.erl | 8 ++++---- .../src/rabbit_ct_helpers.erl | 9 ++++----- .../src/rabbit_ct_vm_helpers.erl | 17 +++++++++-------- .../src/rabbit_mgmt_test_util.erl | 2 +- 7 files changed, 36 insertions(+), 30 deletions(-) diff --git a/deps/rabbitmq_ct_helpers/Makefile b/deps/rabbitmq_ct_helpers/Makefile index 64f917a2f5cf..405118580fc8 100644 --- a/deps/rabbitmq_ct_helpers/Makefile +++ b/deps/rabbitmq_ct_helpers/Makefile @@ -2,7 +2,13 @@ PROJECT = rabbitmq_ct_helpers PROJECT_DESCRIPTION = Common Test helpers for RabbitMQ DEPS = rabbit_common proper inet_tcp_proxy meck -TEST_DEPS = rabbit +LOCAL_DEPS = common_test eunit inets +#TEST_DEPS = rabbit + +# We are calling one function from 'rabbit' so we need it in the PLT. +# But really this should be a full dependency; or we don't use the +# function anymore; or move it to rabbit_common. @todo +dialyze: DEPS += rabbit XREF_IGNORE = [ \ {'Elixir.OptionParser',split,1}, \ diff --git a/deps/rabbitmq_ct_helpers/src/rabbit_control_helper.erl b/deps/rabbitmq_ct_helpers/src/rabbit_control_helper.erl index de51925db73a..31a80a159040 100644 --- a/deps/rabbitmq_ct_helpers/src/rabbit_control_helper.erl +++ b/deps/rabbitmq_ct_helpers/src/rabbit_control_helper.erl @@ -40,7 +40,8 @@ wait_for_async_command(Node) -> command_with_output(Command, Node, Args, Opts) -> Formatted = format_command(Command, Node, Args, Opts), - CommandResult = 'Elixir.RabbitMQCtl':exec_command( + Mod = 'Elixir.RabbitMQCtl', %% To silence a Dialyzer warning. + CommandResult = Mod:exec_command( Formatted, fun(Output,_,_) -> Output end), ct:pal("Executed command ~tp against node ~tp~nResult: ~tp~n", [Formatted, Node, CommandResult]), CommandResult. @@ -50,7 +51,8 @@ format_command(Command, Node, Args, Opts) -> [Command, format_args(Args), format_options([{"--node", Node} | Opts])]), - 'Elixir.OptionParser':split(iolist_to_binary(Formatted)). + Mod = 'Elixir.OptionParser', %% To silence a Dialyzer warning. + Mod:split(iolist_to_binary(Formatted)). format_args(Args) -> iolist_to_binary([ io_lib:format("~tp ", [Arg]) || Arg <- Args ]). diff --git a/deps/rabbitmq_ct_helpers/src/rabbit_ct_broker_helpers.erl b/deps/rabbitmq_ct_helpers/src/rabbit_ct_broker_helpers.erl index 0c362f872573..fac3626882fd 100644 --- a/deps/rabbitmq_ct_helpers/src/rabbit_ct_broker_helpers.erl +++ b/deps/rabbitmq_ct_helpers/src/rabbit_ct_broker_helpers.erl @@ -393,7 +393,7 @@ wait_for_rabbitmq_nodes(Config, Starting, NodeConfigs, Clustered) -> NodeConfigs1 = [NC || {_, NC} <- NodeConfigs], Config1 = rabbit_ct_helpers:set_config(Config, {rmq_nodes, NodeConfigs1}), - stop_rabbitmq_nodes(Config1), + _ = stop_rabbitmq_nodes(Config1), Error; {Pid, I, NodeConfig} when NodeConfigs =:= [] -> wait_for_rabbitmq_nodes(Config, Starting -- [Pid], @@ -917,7 +917,7 @@ wait_for_node_handling(Procs, Fun, T0, Results) -> move_nonworking_nodedir_away(NodeConfig) -> ConfigFile = ?config(erlang_node_config_filename, NodeConfig), ConfigDir = filename:dirname(ConfigFile), - case os:getenv("RABBITMQ_CT_HELPERS_DELETE_UNUSED_NODES") =/= false + ok = case os:getenv("RABBITMQ_CT_HELPERS_DELETE_UNUSED_NODES") =/= false andalso ?OTP_RELEASE >= 23 of true -> file:del_dir_r(ConfigDir); @@ -1135,7 +1135,7 @@ stop_rabbitmq_node(Config, NodeConfig) -> {"RABBITMQ_NODENAME_FOR_PATHS=~ts", [InitialNodename]} ], Cmd = ["stop-node" | MakeVars], - case rabbit_ct_helpers:get_config(Config, rabbitmq_run_cmd) of + {ok, _} = case rabbit_ct_helpers:get_config(Config, rabbitmq_run_cmd) of undefined -> rabbit_ct_helpers:make(Config, SrcDir, Cmd); RunCmd -> @@ -1914,10 +1914,8 @@ restart_node(Config, Node) -> stop_node(Config, Node) -> NodeConfig = get_node_config(Config, Node), - case stop_rabbitmq_node(Config, NodeConfig) of - {skip, _} = Error -> Error; - _ -> ok - end. + _ = stop_rabbitmq_node(Config, NodeConfig), + ok. stop_node_after(Config, Node, Sleep) -> timer:sleep(Sleep), @@ -1940,7 +1938,7 @@ kill_node(Config, Node) -> _ -> rabbit_misc:format("kill -9 ~ts", [Pid]) end, - os:cmd(Cmd), + _ = os:cmd(Cmd), await_os_pid_death(Pid). kill_node_after(Config, Node, Sleep) -> @@ -2231,7 +2229,7 @@ if_cover(F) -> os:getenv("COVERAGE") } of {false, false} -> ok; - _ -> F() + _ -> _ = F(), ok end. setup_meck(Config) -> diff --git a/deps/rabbitmq_ct_helpers/src/rabbit_ct_config_schema.erl b/deps/rabbitmq_ct_helpers/src/rabbit_ct_config_schema.erl index 7baee0264bb8..09c9b6108734 100644 --- a/deps/rabbitmq_ct_helpers/src/rabbit_ct_config_schema.erl +++ b/deps/rabbitmq_ct_helpers/src/rabbit_ct_config_schema.erl @@ -24,7 +24,7 @@ init_schemas(App, Config) -> run_snippets(Config) -> {ok, [Snippets]} = file:consult(?config(conf_snippets, Config)), ct:pal("Loaded config schema snippets: ~tp", [Snippets]), - lists:map( + lists:foreach( fun({N, S, C, P}) -> ok = test_snippet(Config, {snippet_id(N), S, []}, C, P, true); ({N, S, A, C, P}) -> @@ -70,12 +70,12 @@ test_snippet(Config, Snippet = {SnipID, _, _}, Expected, _Plugins, Sort) -> write_snippet(Config, {Name, Conf, Advanced}) -> ResultsDir = ?config(results_dir, Config), - file:make_dir(filename:join(ResultsDir, Name)), + _ = file:make_dir(filename:join(ResultsDir, Name)), ConfFile = filename:join([ResultsDir, Name, "config.conf"]), AdvancedFile = filename:join([ResultsDir, Name, "advanced.config"]), - file:write_file(ConfFile, Conf), - rabbit_file:write_term_file(AdvancedFile, [Advanced]), + ok = file:write_file(ConfFile, Conf), + ok = rabbit_file:write_term_file(AdvancedFile, [Advanced]), {ConfFile, AdvancedFile}. generate_config(ConfFile, AdvancedFile) -> diff --git a/deps/rabbitmq_ct_helpers/src/rabbit_ct_helpers.erl b/deps/rabbitmq_ct_helpers/src/rabbit_ct_helpers.erl index 801de565d125..d9e34cf38fa6 100644 --- a/deps/rabbitmq_ct_helpers/src/rabbit_ct_helpers.erl +++ b/deps/rabbitmq_ct_helpers/src/rabbit_ct_helpers.erl @@ -155,10 +155,10 @@ redirect_logger_to_ct_logs(Config) -> ct:pal( ?LOW_IMPORTANCE, "Configuring logger to send logs to common_test logs"), - logger:set_handler_config(cth_log_redirect, level, debug), + ok = logger:set_handler_config(cth_log_redirect, level, debug), %% Let's use the same format as RabbitMQ itself. - logger:set_handler_config( + ok = logger:set_handler_config( cth_log_redirect, formatter, rabbit_prelaunch_early_logging:default_file_formatter(#{})), @@ -170,7 +170,7 @@ redirect_logger_to_ct_logs(Config) -> cth_log_redirect_any_domains, cth_log_redirect_any_domains, LogCfg), - logger:remove_handler(default), + ok = logger:remove_handler(default), ct:pal( ?LOW_IMPORTANCE, @@ -686,7 +686,6 @@ load_elixir(Config) -> ElixirLibDir -> ct:pal(?LOW_IMPORTANCE, "Elixir lib dir: ~ts~n", [ElixirLibDir]), true = code:add_pathz(ElixirLibDir), - application:load(elixir), {ok, _} = application:ensure_all_started(elixir), Config end. @@ -947,7 +946,7 @@ port_receive_loop(Port, Stdout, Options, Until, DumpTimer) -> end, receive {Port, {exit_status, X}} -> - timer:cancel(DumpTimer), + _ = timer:cancel(DumpTimer), DropStdout = lists:member(drop_stdout, Options) orelse Stdout =:= "", if diff --git a/deps/rabbitmq_ct_helpers/src/rabbit_ct_vm_helpers.erl b/deps/rabbitmq_ct_helpers/src/rabbit_ct_vm_helpers.erl index b98cb0dd862a..490ccda377f7 100644 --- a/deps/rabbitmq_ct_helpers/src/rabbit_ct_vm_helpers.erl +++ b/deps/rabbitmq_ct_helpers/src/rabbit_ct_vm_helpers.erl @@ -499,7 +499,7 @@ spawn_terraform_vms(Config) -> rabbit_ct_helpers:register_teardown_steps( Config1, teardown_steps()); _ -> - destroy_terraform_vms(Config), + _ = destroy_terraform_vms(Config), {skip, "Terraform failed to spawn VM"} end. @@ -520,7 +520,7 @@ destroy_terraform_vms(Config) -> ] ++ TfVarFlags ++ [ TfConfigDir ], - rabbit_ct_helpers:exec(Cmd, [{env, Env}]), + {ok, _} = rabbit_ct_helpers:exec(Cmd, [{env, Env}]), Config. terraform_var_flags(Config) -> @@ -696,7 +696,7 @@ ensure_instance_count(Config, TRef) -> poll_vms(Config) end; true -> - timer:cancel(TRef), + _ = timer:cancel(TRef), rabbit_ct_helpers:set_config(Config, {terraform_poll_done, true}) end; @@ -760,7 +760,7 @@ initialize_ct_peers(Config, NodenamesMap, IPAddrsMap) -> set_inet_hosts(Config) -> CTPeers = get_ct_peer_entries(Config), inet_db:set_lookup([file, native]), - [begin + _ = [begin Hostname = ?config(hostname, CTPeerConfig), IPAddr = ?config(ipaddr, CTPeerConfig), inet_db:add_host(IPAddr, [Hostname]), @@ -831,7 +831,7 @@ wait_for_ct_peers(Config, [CTPeer | Rest] = CTPeers, TRef) -> end end; wait_for_ct_peers(Config, [], TRef) -> - timer:cancel(TRef), + _ = timer:cancel(TRef), Config. set_ct_peers_code_path(Config) -> @@ -864,7 +864,7 @@ download_dirs(Config) -> ?MODULE, prepare_dirs_to_download_archives, [Config]), - inets:start(), + _ = inets:start(), download_dirs(Config, ConfigsPerCTPeer). download_dirs(_, [{skip, _} = Error | _]) -> @@ -964,7 +964,7 @@ add_archive_to_list(Config, Archive) -> start_http_server(Config) -> PrivDir = ?config(priv_dir, Config), {ok, Hostname} = inet:gethostname(), - inets:start(), + _ = inets:start(), Options = [{port, 0}, {server_name, Hostname}, {server_root, PrivDir}, @@ -1021,7 +1021,8 @@ do_setup_ct_logs_proxies(Nodes) -> [begin user_io_proxy(Node), ct_logs_proxy(Node) - end || Node <- Nodes]. + end || Node <- Nodes], + ok. user_io_proxy(Node) -> ok = setup_proxy(Node, user). diff --git a/deps/rabbitmq_ct_helpers/src/rabbit_mgmt_test_util.erl b/deps/rabbitmq_ct_helpers/src/rabbit_mgmt_test_util.erl index ca606adf9530..20b833194624 100644 --- a/deps/rabbitmq_ct_helpers/src/rabbit_mgmt_test_util.erl +++ b/deps/rabbitmq_ct_helpers/src/rabbit_mgmt_test_util.erl @@ -107,7 +107,7 @@ uri_base_from(Config, Node) -> uri_base_from(Config, Node, Base) -> Port = mgmt_port(Config, Node), Prefix = get_uri_prefix(Config), - Uri = rabbit_mgmt_format:print("http://localhost:~w~ts/~ts", [Port, Prefix, Base]), + Uri = list_to_binary(lists:flatten(io_lib:format("http://localhost:~w~ts/~ts", [Port, Prefix, Base]))), binary_to_list(Uri). get_uri_prefix(Config) -> From b8723d6cd284b4e1a6420ca6c809fc9a874610e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 17 Sep 2024 13:13:34 +0200 Subject: [PATCH 26/45] Fix some OTP-27 Dialyzer errors in rabbitmq_peer_discovery_etcd And disable those checks in CI for now. We are getting errors because of the eetcd dependency and we can't upgrade at this time (see comment in the commit). --- .github/workflows/test-make-type-check.yaml | 6 +++++- .../src/rabbitmq_peer_discovery_etcd_v3_client.erl | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-make-type-check.yaml b/.github/workflows/test-make-type-check.yaml index 3c18ec76fc00..a2caf822b9e8 100644 --- a/.github/workflows/test-make-type-check.yaml +++ b/.github/workflows/test-make-type-check.yaml @@ -42,7 +42,11 @@ jobs: - rabbitmq_management_agent - rabbitmq_peer_discovery_common - rabbitmq_peer_discovery_consul - - rabbitmq_peer_discovery_etcd + # @todo We are getting errors because of wrong types + # in the eetcd dep. But upgrading requires using gun 2.0, + # which we can't because another app's dep, emqtt, requires + # gun 1.3.x. So for now we don't type check this plugin. + #- rabbitmq_peer_discovery_etcd - rabbitmq_peer_discovery_k8s - rabbitmq_prelaunch - rabbitmq_prometheus diff --git a/deps/rabbitmq_peer_discovery_etcd/src/rabbitmq_peer_discovery_etcd_v3_client.erl b/deps/rabbitmq_peer_discovery_etcd/src/rabbitmq_peer_discovery_etcd_v3_client.erl index 9a0fc9da426f..082c5c09c7bc 100644 --- a/deps/rabbitmq_peer_discovery_etcd/src/rabbitmq_peer_discovery_etcd_v3_client.erl +++ b/deps/rabbitmq_peer_discovery_etcd/src/rabbitmq_peer_discovery_etcd_v3_client.erl @@ -87,7 +87,7 @@ callback_mode() -> [state_functions, state_enter]. terminate(Reason, State, Data) -> rabbit_log:debug("etcd v3 API client will terminate in state ~tp, reason: ~tp", [State, Reason]), - disconnect(?ETCD_CONN_NAME, Data), + _ = disconnect(?ETCD_CONN_NAME, Data), rabbit_log:debug("etcd v3 API client has disconnected"), rabbit_log:debug("etcd v3 API client: total number of connections to etcd is ~tp", [length(eetcd_conn_sup:info())]), ok. @@ -157,13 +157,13 @@ recover(internal, start, Data = #statem_data{endpoints = Endpoints, connection_m }}; {error, Errors} -> [rabbit_log:error("etcd peer discovery: failed to connect to endpoint ~tp: ~tp", [Endpoint, Err]) || {Endpoint, Err} <- Errors], - ensure_disconnected(?ETCD_CONN_NAME, Data), + _ = ensure_disconnected(?ETCD_CONN_NAME, Data), Actions = [{state_timeout, reconnection_interval(), recover}], {keep_state, reset_statem_data(Data), Actions} end; recover(state_timeout, _PrevState, Data) -> rabbit_log:debug("etcd peer discovery: connection entered a reconnection delay state"), - ensure_disconnected(?ETCD_CONN_NAME, Data), + _ = ensure_disconnected(?ETCD_CONN_NAME, Data), {next_state, recover, reset_statem_data(Data)}; recover({call, From}, Req, _Data) -> rabbit_log:error("etcd v3 API: client received a call ~tp while not connected, will do nothing", [Req]), From 7fca6e955cfb26d0ba5dee70dd4d1ada193c1552 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 17 Sep 2024 13:49:31 +0200 Subject: [PATCH 27/45] make CI: Don't warn about missing CT log files This can happen if the plugin isn't using CT, or if running Dialyzer, for example. --- .github/workflows/test-make-target.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-make-target.yaml b/.github/workflows/test-make-target.yaml index bc3b001a7588..7a8cb09e1547 100644 --- a/.github/workflows/test-make-target.yaml +++ b/.github/workflows/test-make-target.yaml @@ -64,3 +64,4 @@ jobs: path: | deps/${{ inputs.plugin }}/logs/ !deps/${{ inputs.plugin }}/logs/**/log_private + if-no-files-found: ignore From 55f0559152c033ed29128f44fa85f61367be2e60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 17 Sep 2024 14:10:55 +0200 Subject: [PATCH 28/45] make CI: Disable Elixir problem matchers in tests They are still enabled in the build job. --- .github/workflows/test-make-target.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test-make-target.yaml b/.github/workflows/test-make-target.yaml index 7a8cb09e1547..76228c7ae51d 100644 --- a/.github/workflows/test-make-target.yaml +++ b/.github/workflows/test-make-target.yaml @@ -34,6 +34,9 @@ jobs: hexpm-mirrors: | https://builds.hex.pm https://cdn.jsdelivr.net/hex + # This currently only applies to Elixir; and can be safely + # restricted to the build jobs to avoid duplication in output. + disable_problem_matchers: true - name: SETUP DOTNET (rabbit) uses: actions/setup-dotnet@v4 From 71ec3396f6751ccb3d9e9aadb462f5bd411b7935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 19 Sep 2024 13:52:35 +0200 Subject: [PATCH 29/45] cli: Start a background node to run the tests --- deps/rabbitmq_cli/Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/deps/rabbitmq_cli/Makefile b/deps/rabbitmq_cli/Makefile index 75afb38acd18..185b1407c893 100644 --- a/deps/rabbitmq_cli/Makefile +++ b/deps/rabbitmq_cli/Makefile @@ -113,7 +113,12 @@ rel:: $(ESCRIPTS) @: tests:: $(ESCRIPTS) - $(gen_verbose) $(MIX_TEST) $(TEST_FILE) + $(verbose) $(MAKE) -C ../../ install-cli + $(verbose) $(MAKE) -C ../../ run-background-broker PLUGINS="rabbit rabbitmq_federation rabbitmq_stomp rabbitmq_stream_management amqp_client" + $(gen_verbose) $(MIX_TEST) $(TEST_FILE); \ + RES=$$?; \ + $(MAKE) -C ../../ stop-node; \ + exit $$RES .PHONY: test From 1c797387f7aff0ffba0e2dc3c4fa3becd345d5b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 19 Sep 2024 14:35:34 +0200 Subject: [PATCH 30/45] cli: Add 4.1.0 to mock plugin's versions --- .../ebin/mock_rabbitmq_plugin_for_3_8.app | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/rabbitmq_cli/test/fixtures/plugins/plugins_with_version_requirements/mock_rabbitmq_plugin_for_3_8-0.1.0/ebin/mock_rabbitmq_plugin_for_3_8.app b/deps/rabbitmq_cli/test/fixtures/plugins/plugins_with_version_requirements/mock_rabbitmq_plugin_for_3_8-0.1.0/ebin/mock_rabbitmq_plugin_for_3_8.app index 94f286b72257..8ea87019ad7d 100644 --- a/deps/rabbitmq_cli/test/fixtures/plugins/plugins_with_version_requirements/mock_rabbitmq_plugin_for_3_8-0.1.0/ebin/mock_rabbitmq_plugin_for_3_8.app +++ b/deps/rabbitmq_cli/test/fixtures/plugins/plugins_with_version_requirements/mock_rabbitmq_plugin_for_3_8-0.1.0/ebin/mock_rabbitmq_plugin_for_3_8.app @@ -6,5 +6,5 @@ {applications, [kernel,stdlib,rabbit]}, {mod, {mock_rabbitmq_plugins_01_app, []}}, {env, []}, - {broker_version_requirements, ["3.9.0", "3.10.0", "3.11.0", "3.12.0", "3.13.0", "4.0.0"]} + {broker_version_requirements, ["3.9.0", "3.10.0", "3.11.0", "3.12.0", "3.13.0", "4.0.0", "4.1.0"]} ]}. From 8669b24c0798e8363e21e81adaef1b610ff2ced9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 19 Sep 2024 14:36:32 +0200 Subject: [PATCH 31/45] make CI: Run rabbitmq_cli tests --- .github/workflows/test-make-tests.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-make-tests.yaml b/.github/workflows/test-make-tests.yaml index acb3bb214cc5..13242c4a3d58 100644 --- a/.github/workflows/test-make-tests.yaml +++ b/.github/workflows/test-make-tests.yaml @@ -76,6 +76,7 @@ jobs: - rabbitmq_auth_backend_oauth2 - rabbitmq_auth_mechanism_ssl - rabbitmq_aws + - rabbitmq_cli - rabbitmq_consistent_hash_exchange - rabbitmq_event_exchange - rabbitmq_federation From beaa476aa169912e3c87dcdb1f67d7f5d36fec70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 19 Sep 2024 15:31:39 +0200 Subject: [PATCH 32/45] make CI: Always fetch tags The fetch-tags option of actions/checkout@v4 does not work as intended so they are fetched manually instead. --- .github/workflows/test-make-target.yaml | 3 +++ .github/workflows/test-make.yaml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/test-make-target.yaml b/.github/workflows/test-make-target.yaml index 76228c7ae51d..995bb8733d78 100644 --- a/.github/workflows/test-make-target.yaml +++ b/.github/workflows/test-make-target.yaml @@ -26,6 +26,9 @@ jobs: - name: CHECKOUT REPOSITORY uses: actions/checkout@v4 + - name: FETCH TAGS + run: git fetch --tags + - name: SETUP OTP & ELIXIR uses: erlef/setup-beam@v1.17 with: diff --git a/.github/workflows/test-make.yaml b/.github/workflows/test-make.yaml index 5224de01b89b..46abebd33b78 100644 --- a/.github/workflows/test-make.yaml +++ b/.github/workflows/test-make.yaml @@ -34,6 +34,9 @@ jobs: - name: CHECKOUT REPOSITORY uses: actions/checkout@v4 + - name: FETCH TAGS + run: git fetch --tags + - name: SETUP OTP & ELIXIR uses: erlef/setup-beam@v1.17 with: From a8df6f32fb4b8bbe4804735d64701388d54c3cc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Fri, 20 Sep 2024 12:42:00 +0200 Subject: [PATCH 33/45] make CI: Set a correct broker version for CLI tests --- .github/workflows/test-make-target.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/test-make-target.yaml b/.github/workflows/test-make-target.yaml index 995bb8733d78..0ba2dba5b6ca 100644 --- a/.github/workflows/test-make-target.yaml +++ b/.github/workflows/test-make-target.yaml @@ -59,9 +59,17 @@ jobs: sudo aa-complain `which slapd` - name: RUN TESTS + if: inputs.plugin != 'rabbitmq_cli' run: | make -C deps/${{ inputs.plugin }} ${{ inputs.make_target }} RABBITMQ_METADATA_STORE=${{ inputs.metadata_store }} + # rabbitmq_cli needs a correct broker version for two of its tests. + # But setting PROJECT_VERSION makes other plugins fail. + - name: RUN TESTS (rabbitmq_cli) + if: inputs.plugin == 'rabbitmq_cli' + run: | + make -C deps/${{ inputs.plugin }} ${{ inputs.make_target }} RABBITMQ_METADATA_STORE=${{ inputs.metadata_store }} PROJECT_VERSION="4.1.0" + - name: UPLOAD TEST LOGS if: always() uses: actions/upload-artifact@v4 From 6b3b0e5c3faab457736261a3c77d7ae93f1b354a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 23 Sep 2024 12:15:16 +0200 Subject: [PATCH 34/45] CLI: Make a test more reliable --- deps/rabbitmq_cli/test/core/json_stream_test.exs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deps/rabbitmq_cli/test/core/json_stream_test.exs b/deps/rabbitmq_cli/test/core/json_stream_test.exs index ccbe0c54b65f..0d736fb8af61 100644 --- a/deps/rabbitmq_cli/test/core/json_stream_test.exs +++ b/deps/rabbitmq_cli/test/core/json_stream_test.exs @@ -12,6 +12,8 @@ defmodule JsonStreamTest do test "format_output map with atom keys is converted to JSON object" do assert @formatter.format_output(%{a: :apple, b: :beer}, %{}) == "{\"a\":\"apple\",\"b\":\"beer\"}" + or @formatter.format_output(%{a: :apple, b: :beer}, %{}) == + "{\"b\":\"beer\",\"a\":\"apple\"}" end test "format_output map with binary keys is converted to JSON object" do From ae984cc364d53dc9106582090d915f9768c7d82d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 24 Sep 2024 13:40:54 +0200 Subject: [PATCH 35/45] make: Set CT_LOGS_DIR to top-level logs/ directory All CT logs will now be under /logs. An improved test workflow would be to always keep the logs/all_runs.html page open in the browser and refresh it whenever tests are run in any of the rabbit applications. --- .github/workflows/test-make-target.yaml | 4 ++-- deps/rabbit/Makefile | 4 ++-- deps/rabbit_common/mk/rabbitmq-early-plugin.mk | 4 ++++ deps/rabbitmq_mqtt/Makefile | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-make-target.yaml b/.github/workflows/test-make-target.yaml index 0ba2dba5b6ca..2367ae5157fb 100644 --- a/.github/workflows/test-make-target.yaml +++ b/.github/workflows/test-make-target.yaml @@ -76,6 +76,6 @@ jobs: with: name: CT logs (${{ inputs.plugin }} ${{ inputs.make_target }} OTP-${{ inputs.erlang_version }} ${{ inputs.metadata_store }}) path: | - deps/${{ inputs.plugin }}/logs/ - !deps/${{ inputs.plugin }}/logs/**/log_private + logs/ + !logs/**/log_private if-no-files-found: ignore diff --git a/deps/rabbit/Makefile b/deps/rabbit/Makefile index 76b7606da5f9..19fc5a20e471 100644 --- a/deps/rabbit/Makefile +++ b/deps/rabbit/Makefile @@ -292,8 +292,8 @@ endif define tpl_parallel_ct_test_spec -{logdir, "logs/"}. -{logdir, master, "logs/"}. +{logdir, "$(CT_LOGS_DIR)"}. +{logdir, master, "$(CT_LOGS_DIR)"}. {create_priv_dir, all_nodes, auto_per_run}. {node, shard1, 'rabbit_shard1@localhost'}. diff --git a/deps/rabbit_common/mk/rabbitmq-early-plugin.mk b/deps/rabbit_common/mk/rabbitmq-early-plugin.mk index 5fdc38754e5e..1b8aaa3f422a 100644 --- a/deps/rabbit_common/mk/rabbitmq-early-plugin.mk +++ b/deps/rabbit_common/mk/rabbitmq-early-plugin.mk @@ -10,6 +10,10 @@ dialyze: ERL_LIBS = $(APPS_DIR):$(DEPS_DIR):$(DEPS_DIR)/rabbitmq_cli/_build/dev/ # Common Test flags. # -------------------------------------------------------------------- +ifneq ($(PROJECT),rabbitmq_server_release) +CT_LOGS_DIR = $(abspath $(CURDIR)/../../logs) +endif + # We start the common_test node as a hidden Erlang node. The benefit # is that other Erlang nodes won't try to connect to each other after # discovering the common_test node if they are not meant to. diff --git a/deps/rabbitmq_mqtt/Makefile b/deps/rabbitmq_mqtt/Makefile index 274bd9defb5d..4b5f002670af 100644 --- a/deps/rabbitmq_mqtt/Makefile +++ b/deps/rabbitmq_mqtt/Makefile @@ -107,8 +107,8 @@ endif define tpl_parallel_ct_test_spec -{logdir, "logs/"}. -{logdir, master, "logs/"}. +{logdir, "$(CT_LOGS_DIR)"}. +{logdir, master, "$(CT_LOGS_DIR)"}. {create_priv_dir, all_nodes, auto_per_run}. {node, shard1, 'rabbit_shard1@localhost'}. From 4c80dde2331069dc489062cf9f6c794e33aca608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 24 Sep 2024 15:52:46 +0200 Subject: [PATCH 36/45] make CI: Use strings instead of numbers for OTP/Ex versions As recommended by erlef/setup-beam. --- .github/workflows/test-make-target.yaml | 4 ++-- .github/workflows/test-make-tests.yaml | 4 ++-- .github/workflows/test-make-type-check.yaml | 4 ++-- .github/workflows/test-make.yaml | 16 ++++++++-------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test-make-target.yaml b/.github/workflows/test-make-target.yaml index 2367ae5157fb..7d08bca09b2c 100644 --- a/.github/workflows/test-make-target.yaml +++ b/.github/workflows/test-make-target.yaml @@ -4,10 +4,10 @@ on: inputs: erlang_version: required: true - type: number + type: string elixir_version: required: true - type: number + type: string metadata_store: required: true type: string diff --git a/.github/workflows/test-make-tests.yaml b/.github/workflows/test-make-tests.yaml index 13242c4a3d58..c21a4ca382d5 100644 --- a/.github/workflows/test-make-tests.yaml +++ b/.github/workflows/test-make-tests.yaml @@ -4,10 +4,10 @@ on: inputs: erlang_version: required: true - type: number + type: string elixir_version: required: true - type: number + type: string metadata_store: required: true type: string diff --git a/.github/workflows/test-make-type-check.yaml b/.github/workflows/test-make-type-check.yaml index a2caf822b9e8..bf977874aff9 100644 --- a/.github/workflows/test-make-type-check.yaml +++ b/.github/workflows/test-make-type-check.yaml @@ -4,10 +4,10 @@ on: inputs: erlang_version: required: true - type: number + type: string elixir_version: required: true - type: number + type: string jobs: type-check-plugin: name: Type check plugins diff --git a/.github/workflows/test-make.yaml b/.github/workflows/test-make.yaml index 46abebd33b78..b5d09338b821 100644 --- a/.github/workflows/test-make.yaml +++ b/.github/workflows/test-make.yaml @@ -23,10 +23,10 @@ jobs: fail-fast: false matrix: erlang_version: - - 26 - - 27 + - '26' + - '27' elixir_version: - - 1.17 + - '1.17' # @todo Add macOS and Windows. runs-on: ubuntu-latest timeout-minutes: 30 @@ -58,10 +58,10 @@ jobs: fail-fast: false matrix: erlang_version: - - 26 - - 27 + - '26' + - '27' elixir_version: - - 1.17 + - '1.17' metadata_store: - mnesia - khepri @@ -77,9 +77,9 @@ jobs: fail-fast: false matrix: erlang_version: # Latest OTP - - 27 + - '27' elixir_version: # Latest Elixir - - 1.17 + - '1.17' uses: ./.github/workflows/test-make-type-check.yaml with: erlang_version: ${{ matrix.erlang_version }} From aee0cd0079734c03c1c940ab5f904c847e7c4094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 25 Sep 2024 12:24:08 +0200 Subject: [PATCH 37/45] make & make CI: Small cleanups --- .github/workflows/test-make-tests.yaml | 8 ------ .github/workflows/test-make.yaml | 2 -- .github/workflows/test-mixed-versions.yaml | 4 +-- .github/workflows/test.yaml | 22 ++++++++-------- deps/rabbit/Makefile | 29 +++++----------------- deps/rabbitmq_mqtt/Makefile | 8 ++---- rabbitmq-components.mk | 3 --- 7 files changed, 21 insertions(+), 55 deletions(-) diff --git a/.github/workflows/test-make-tests.yaml b/.github/workflows/test-make-tests.yaml index c21a4ca382d5..a0142656815d 100644 --- a/.github/workflows/test-make-tests.yaml +++ b/.github/workflows/test-make-tests.yaml @@ -112,11 +112,3 @@ jobs: metadata_store: ${{ inputs.metadata_store }} make_target: tests plugin: ${{ matrix.plugin }} - -# @todo Test rabbitmq_cli -# @todo Why this step? -# - name: CLI COMPILE WARNINGS AS ERRORS -# if: inputs.plugin == 'rabbitmq_cli' -# run: | -# bazel build //deps/rabbitmq_cli:compile_warnings_as_errors \ -# --verbose_failures diff --git a/.github/workflows/test-make.yaml b/.github/workflows/test-make.yaml index b5d09338b821..85e04fea086c 100644 --- a/.github/workflows/test-make.yaml +++ b/.github/workflows/test-make.yaml @@ -3,8 +3,6 @@ on: push: branches: - main - - bump-otp-for-oci - - bump-rbe-* paths: - deps/** - scripts/** diff --git a/.github/workflows/test-mixed-versions.yaml b/.github/workflows/test-mixed-versions.yaml index efb261cbf1dc..d287d8e437e4 100644 --- a/.github/workflows/test-mixed-versions.yaml +++ b/.github/workflows/test-mixed-versions.yaml @@ -2,7 +2,7 @@ name: Test Mixed Version Clusters on: push: branches: -# - main + - main - v4.0.x - v3.13.x - bump-otp-* @@ -20,7 +20,7 @@ on: - BUILD.* - '*.bzl' - '*.bazel' -# - .github/workflows/test-mixed-versions.yaml + - .github/workflows/test-mixed-versions.yaml pull_request: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c984ef89c4df..786f403af131 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -143,17 +143,17 @@ jobs: plugin: trust_store_http secrets: inherit test-rabbit-make: -# needs: -# - check-workflow -# - test-amqp10_client -# - test-amqp10_common -# - test-amqp_client -# - test-oauth2_client -# - test-rabbit_common -# - test-rabbitmq_ct_client_helpers -# - test-rabbitmq_ct_helpers -# - test-rabbitmq_stream_common -# - test-trust_store_http + needs: + - check-workflow + - test-amqp10_client + - test-amqp10_common + - test-amqp_client + - test-oauth2_client + - test-rabbit_common + - test-rabbitmq_ct_client_helpers + - test-rabbitmq_ct_helpers + - test-rabbitmq_stream_common + - test-trust_store_http uses: ./.github/workflows/test-plugin-make.yaml with: repo_cache_key: ${{ needs.check-workflow.outputs.repo_cache_key }} diff --git a/deps/rabbit/Makefile b/deps/rabbit/Makefile index 19fc5a20e471..33b7764e1464 100644 --- a/deps/rabbit/Makefile +++ b/deps/rabbit/Makefile @@ -217,6 +217,11 @@ ct-slow: CT_OPTS += -ct_hooks rabbit_ct_hook [] +# Parallel CT. +# +# @todo We must ensure that the CT_OPTS also apply to ct-master +# @todo We should probably refactor ct_master.erl to have node init in a separate .erl + define ct_master.erl StartOpts = #{ host => "localhost", @@ -243,20 +248,6 @@ define ct_master.erl halt() endef -# @todo We must ensure that the CT_OPTS also apply to ct-master -# @todo We should probably refactor ct_master.erl to have node init in a separate .erl -# @todo We would benefit from having rabbit nodes started with peer (no leftovers) -# @todo We need ct-master to be expanded to all components and not just rabbit -# @todo Generate ct.test.spec from Makefile variables instead of hardcoded for ct-master - - -#PARALLEL_CT_NUM_NODES ?= 4 -#PARALLEL_CT_NODE_NAME = rabbit_shard$1@localhost -#PARALLEL_CT_NODE_INIT_FUN = fun(Pid, Num) -> peer:call(Pid, net_kernel, set_net_ticktime, [5]), peer:call(Pid, persistent_term, put, [rabbit_ct_tcp_port_base, 21000 + 2000 * Num]) end - -#PARALLEL_CT_NUM_SETS = 8 - - PARALLEL_CT_SET_1_A = amqp_client unit_cluster_formation_locking_mocks unit_cluster_formation_sort_nodes unit_collections unit_config_value_encryption unit_connection_tracking PARALLEL_CT_SET_1_B = amqp_address amqp_auth amqp_credit_api_v2 amqp_system signal_handling single_active_consumer unit_access_control_authn_authz_context_propagation unit_access_control_credential_validation unit_amqp091_content_framing unit_amqp091_server_properties unit_app_management PARALLEL_CT_SET_1_C = amqp_proxy_protocol amqpl_consumer_ack amqpl_direct_reply_to backing_queue bindings rabbit_db_maintenance rabbit_db_msup rabbit_db_policy rabbit_db_queue rabbit_db_topic_exchange rabbit_direct_reply_to_prop cluster_limit cluster_minority term_to_binary_compat_prop topic_permission transactions unicode unit_access_control @@ -289,8 +280,6 @@ ifneq ($(filter-out $(SEQUENTIAL_CT_SUITES) $(PARALLEL_CT_SUITES),$(CT_SUITES)), $(error Some test suites in CT_SUITES but not configured for CI.) endif - - define tpl_parallel_ct_test_spec {logdir, "$(CT_LOGS_DIR)"}. {logdir, master, "$(CT_LOGS_DIR)"}. @@ -323,13 +312,7 @@ endef $(foreach set,1 2 3 4,$(eval $(call parallel_ct_set_target,$(set)))) - - - - - - - +# @todo Generate ct.test.spec from Makefile variables instead of hardcoded for ct-master parallel-ct: test-build $(verbose) mkdir -p $(CT_LOGS_DIR) diff --git a/deps/rabbitmq_mqtt/Makefile b/deps/rabbitmq_mqtt/Makefile index 4b5f002670af..cd8685dfced5 100644 --- a/deps/rabbitmq_mqtt/Makefile +++ b/deps/rabbitmq_mqtt/Makefile @@ -60,10 +60,8 @@ include ../../erlang.mk clean:: if test -d test/java_SUITE_data; then cd test/java_SUITE_data && $(MAKE) clean; fi - - - - +# Parallel CT. +# # @todo Move most of this in common files. define ct_master.erl @@ -104,8 +102,6 @@ ifneq ($(filter-out $(PARALLEL_CT_SUITES),$(CT_SUITES)),) $(error Some test suites in CT_SUITES but not configured for CI.) endif - - define tpl_parallel_ct_test_spec {logdir, "$(CT_LOGS_DIR)"}. {logdir, master, "$(CT_LOGS_DIR)"}. diff --git a/rabbitmq-components.mk b/rabbitmq-components.mk index 53c10ad63132..b6361f61d0cd 100644 --- a/rabbitmq-components.mk +++ b/rabbitmq-components.mk @@ -61,9 +61,6 @@ dep_seshat = git https://github.com/rabbitmq/seshat v0.6.1 dep_stdout_formatter = hex 0.2.4 dep_sysmon_handler = hex 1.3.0 -# @todo Move up in the list later. -dep_osiris = git https://github.com/rabbitmq/osiris v1.8.3 - # RabbitMQ applications found in the monorepo. # # Note that rabbitmq_server_release is not a real application From 4530fb5d970ef3dfa360c8f8fcdf84e5c1d38662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 25 Sep 2024 13:24:36 +0200 Subject: [PATCH 38/45] make: Add new CT suites and clarify check on CT_SUITES --- deps/rabbit/Makefile | 4 ++-- deps/rabbitmq_mqtt/Makefile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deps/rabbit/Makefile b/deps/rabbit/Makefile index 33b7764e1464..75abc561e0c9 100644 --- a/deps/rabbit/Makefile +++ b/deps/rabbit/Makefile @@ -265,7 +265,7 @@ PARALLEL_CT_SET_3_D = metadata_store_phase1 metrics mirrored_supervisor msg_stor PARALLEL_CT_SET_4_A = clustering_events rabbit_local_random_exchange rabbit_message_interceptor rabbitmq_4_0_deprecations unit_pg_local unit_plugin_directories unit_plugin_versioning unit_policy_validators unit_priority_queue PARALLEL_CT_SET_4_B = per_user_connection_tracking per_vhost_connection_limit rabbit_fifo_dlx_integration rabbit_fifo_int -PARALLEL_CT_SET_4_C = per_vhost_msg_store per_vhost_queue_limit priority_queue upgrade_preparation vhost +PARALLEL_CT_SET_4_C = msg_size_metrics unit_msg_size_metrics per_vhost_msg_store per_vhost_queue_limit priority_queue upgrade_preparation vhost PARALLEL_CT_SET_4_D = per_user_connection_channel_tracking product_info publisher_confirms_parallel queue_type rabbitmq_queues_cli_integration rabbitmqctl_integration rabbitmqctl_shutdown routing PARALLEL_CT_SET_1 = $(sort $(PARALLEL_CT_SET_1_A) $(PARALLEL_CT_SET_1_B) $(PARALLEL_CT_SET_1_C) $(PARALLEL_CT_SET_1_D)) @@ -277,7 +277,7 @@ SEQUENTIAL_CT_SUITES = clustering_management dead_lettering feature_flags metada PARALLEL_CT_SUITES = $(PARALLEL_CT_SET_1) $(PARALLEL_CT_SET_2) $(PARALLEL_CT_SET_3) $(PARALLEL_CT_SET_4) ifneq ($(filter-out $(SEQUENTIAL_CT_SUITES) $(PARALLEL_CT_SUITES),$(CT_SUITES)),) -$(error Some test suites in CT_SUITES but not configured for CI.) +$(error Some test suites in CT_SUITES but not configured for CI: $(filter-out $(SEQUENTIAL_CT_SUITES) $(PARALLEL_CT_SUITES),$(CT_SUITES))) endif define tpl_parallel_ct_test_spec diff --git a/deps/rabbitmq_mqtt/Makefile b/deps/rabbitmq_mqtt/Makefile index cd8685dfced5..63427c949327 100644 --- a/deps/rabbitmq_mqtt/Makefile +++ b/deps/rabbitmq_mqtt/Makefile @@ -99,7 +99,7 @@ PARALLEL_CT_SET_1_D = mqtt_shared PARALLEL_CT_SUITES = $(PARALLEL_CT_SET_1_A) $(PARALLEL_CT_SET_1_B) $(PARALLEL_CT_SET_1_C) $(PARALLEL_CT_SET_1_D) ifneq ($(filter-out $(PARALLEL_CT_SUITES),$(CT_SUITES)),) -$(error Some test suites in CT_SUITES but not configured for CI.) +$(error Some test suites in CT_SUITES but not configured for CI: $(filter-out $(PARALLEL_CT_SUITES),$(CT_SUITES))) endif define tpl_parallel_ct_test_spec From addb0607fd3f103e7dd03887538914fe63d4e749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 25 Sep 2024 15:42:37 +0200 Subject: [PATCH 39/45] Make rabbit_global_counters:overview/0 generally available Previously it was only available when TEST=1 was set. --- deps/rabbit/src/rabbit_global_counters.erl | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/deps/rabbit/src/rabbit_global_counters.erl b/deps/rabbit/src/rabbit_global_counters.erl index 7b480c91d6cf..f9239163d850 100644 --- a/deps/rabbit/src/rabbit_global_counters.erl +++ b/deps/rabbit/src/rabbit_global_counters.erl @@ -13,6 +13,7 @@ boot_step/0, init/1, init/2, + overview/0, prometheus_format/0, increase_protocol_counter/3, messages_received/2, @@ -37,10 +38,6 @@ messages_dead_lettered_confirmed/3 ]). --ifdef(TEST). --export([overview/0]). --endif. - %% PROTOCOL COUNTERS: -define(MESSAGES_RECEIVED, 1). -define(MESSAGES_RECEIVED_CONFIRM, 2). @@ -197,10 +194,8 @@ init(Labels = [{queue_type, QueueType}, {dead_letter_strategy, DLS}], DeadLetter Counters = seshat:new(?MODULE, Labels, DeadLetterCounters), persistent_term:put({?MODULE, QueueType, DLS}, Counters). --ifdef(TEST). overview() -> seshat:overview(?MODULE). --endif. prometheus_format() -> seshat:format(?MODULE). From 027700eec2b8eff3cdde30816ffad9f9223f3b68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 25 Sep 2024 15:59:20 +0200 Subject: [PATCH 40/45] Add missing test case to web_mqtt_shared_SUITE --- deps/rabbitmq_web_mqtt/test/web_mqtt_shared_SUITE.erl | 1 + 1 file changed, 1 insertion(+) diff --git a/deps/rabbitmq_web_mqtt/test/web_mqtt_shared_SUITE.erl b/deps/rabbitmq_web_mqtt/test/web_mqtt_shared_SUITE.erl index 4cb1c843c2eb..f3818b34ee06 100644 --- a/deps/rabbitmq_web_mqtt/test/web_mqtt_shared_SUITE.erl +++ b/deps/rabbitmq_web_mqtt/test/web_mqtt_shared_SUITE.erl @@ -40,6 +40,7 @@ end_per_testcase(Testcase, Config) -> mqtt_shared_SUITE:end_per_testcase(Testcase, Config). global_counters(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). +message_size_metrics(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). block_only_publisher(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). many_qos1_messages(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). session_expiry(Config) -> mqtt_shared_SUITE:?FUNCTION_NAME(Config). From f54e307aee211eb58f94203ee1d9fe1e0f97eb6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 25 Sep 2024 17:22:55 +0200 Subject: [PATCH 41/45] CT: No longer wait 3 minutes for node start Reverting back to the default 1 minute. The problem with 3 minutes is that this is exceedingly long and when there are problems the test time increases exponentially. --- deps/rabbitmq_ct_helpers/src/rabbit_ct_broker_helpers.erl | 1 - 1 file changed, 1 deletion(-) diff --git a/deps/rabbitmq_ct_helpers/src/rabbit_ct_broker_helpers.erl b/deps/rabbitmq_ct_helpers/src/rabbit_ct_broker_helpers.erl index fac3626882fd..6d343d6c0c1d 100644 --- a/deps/rabbitmq_ct_helpers/src/rabbit_ct_broker_helpers.erl +++ b/deps/rabbitmq_ct_helpers/src/rabbit_ct_broker_helpers.erl @@ -741,7 +741,6 @@ do_start_rabbitmq_node(Config, NodeConfig, I) -> {"RABBITMQ_SERVER_START_ARGS=~ts", [StartArgs1]}, {"RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS=+S 2 +sbwt very_short +A 24 ~ts", [AdditionalErlArgs]}, "RABBITMQ_LOG=debug", - "RMQCTL_WAIT_TIMEOUT=180", {"TEST_TMPDIR=~ts", [PrivDir]} | ExtraArgs], Cmd = ["start-background-broker" | MakeVars], From a0ee6ddb6976e9fa2ba6676a010459a35901e3b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Fri, 27 Sep 2024 11:46:57 +0200 Subject: [PATCH 42/45] Bazel fixes following renaming of test suites --- deps/rabbitmq_mqtt/BUILD.bazel | 2 +- deps/rabbitmq_web_mqtt/BUILD.bazel | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/deps/rabbitmq_mqtt/BUILD.bazel b/deps/rabbitmq_mqtt/BUILD.bazel index aeaf1d9c725a..0133271063fd 100644 --- a/deps/rabbitmq_mqtt/BUILD.bazel +++ b/deps/rabbitmq_mqtt/BUILD.bazel @@ -226,7 +226,7 @@ rabbitmq_integration_suite( ) rabbitmq_integration_suite( - name = "shared_SUITE", + name = "mqtt_shared_SUITE", size = "large", additional_beam = [ ":test_util_beam", diff --git a/deps/rabbitmq_web_mqtt/BUILD.bazel b/deps/rabbitmq_web_mqtt/BUILD.bazel index f9561e14ffaf..49b62e9f1aa8 100644 --- a/deps/rabbitmq_web_mqtt/BUILD.bazel +++ b/deps/rabbitmq_web_mqtt/BUILD.bazel @@ -103,11 +103,11 @@ eunit( broker_for_integration_suites() rabbitmq_integration_suite( - name = "config_schema_SUITE", + name = "web_mqtt_config_schema_SUITE", ) rabbitmq_integration_suite( - name = "command_SUITE", + name = "web_mqtt_command_SUITE", additional_beam = [ "test/rabbit_web_mqtt_test_util.beam", ], @@ -117,7 +117,7 @@ rabbitmq_integration_suite( ) rabbitmq_integration_suite( - name = "proxy_protocol_SUITE", + name = "web_mqtt_proxy_protocol_SUITE", additional_beam = [ "test/src/rabbit_ws_test_util.beam", "test/src/rfc6455_client.beam", @@ -125,7 +125,23 @@ rabbitmq_integration_suite( ) rabbitmq_integration_suite( - name = "system_SUITE", + name = "web_mqtt_shared_SUITE", + additional_beam = [ + "test/src/rabbit_ws_test_util.beam", + "test/src/rfc6455_client.beam", + ], +) + +rabbitmq_integration_suite( + name = "web_mqtt_system_SUITE", + additional_beam = [ + "test/src/rabbit_ws_test_util.beam", + "test/src/rfc6455_client.beam", + ], +) + +rabbitmq_integration_suite( + name = "web_mqtt_v5_SUITE", additional_beam = [ "test/src/rabbit_ws_test_util.beam", "test/src/rfc6455_client.beam", From 994abc1a8c2215c2ed5411c0db597821c85d758b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Fri, 27 Sep 2024 12:00:27 +0200 Subject: [PATCH 43/45] Bazel CI: Fix workflow templates --- .../workflows/templates/test.template.yaml | 4 ++-- .github/workflows/test.yaml | 19 ------------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/.github/workflows/templates/test.template.yaml b/.github/workflows/templates/test.template.yaml index bf2dfdf631c6..4999f4ccc223 100644 --- a/.github/workflows/templates/test.template.yaml +++ b/.github/workflows/templates/test.template.yaml @@ -22,7 +22,7 @@ name: Test on: push: branches: - - main +#! - main - v4.0.x - v3.13.x - v3.12.x @@ -42,7 +42,7 @@ on: - '*.bzl' - '*.bazel' - .github/workflows/test.yaml - pull_request: +#! pull_request: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 786f403af131..b71b77fa2e5e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -2,7 +2,6 @@ name: Test on: push: branches: -# - main - v4.0.x - v3.13.x - v3.12.x @@ -22,7 +21,6 @@ on: - '*.bzl' - '*.bazel' - .github/workflows/test.yaml -# pull_request: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true @@ -142,23 +140,6 @@ jobs: repo_cache_key: ${{ needs.check-workflow.outputs.repo_cache_key }} plugin: trust_store_http secrets: inherit - test-rabbit-make: - needs: - - check-workflow - - test-amqp10_client - - test-amqp10_common - - test-amqp_client - - test-oauth2_client - - test-rabbit_common - - test-rabbitmq_ct_client_helpers - - test-rabbitmq_ct_helpers - - test-rabbitmq_stream_common - - test-trust_store_http - uses: ./.github/workflows/test-plugin-make.yaml - with: - repo_cache_key: ${{ needs.check-workflow.outputs.repo_cache_key }} - plugin: rabbit - secrets: inherit test-rabbit-0: needs: - check-workflow From 9fed03a6d69f20dd03d25282b9c2891fe12472b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 30 Sep 2024 12:37:24 +0200 Subject: [PATCH 44/45] Add missing suites to non-CI parallel-ct --- deps/rabbit/ct.test.spec | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/deps/rabbit/ct.test.spec b/deps/rabbit/ct.test.spec index 6740594c1500..e1027d06105f 100644 --- a/deps/rabbit/ct.test.spec +++ b/deps/rabbit/ct.test.spec @@ -65,7 +65,8 @@ ]}. {define, 'Set4', [ - peer_discovery_dns_SUITE + msg_size_metrics_SUITE +, peer_discovery_dns_SUITE , peer_discovery_tmp_hidden_node_SUITE , per_node_limit_SUITE , per_user_connection_channel_limit_SUITE @@ -80,6 +81,7 @@ , product_info_SUITE , proxy_protocol_SUITE , publisher_confirms_parallel_SUITE +, unit_msg_size_metrics_SUITE ]}. {define, 'Set5', [ From 7fe78a3af9c7fad31a5e471653e223695731b54e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 30 Sep 2024 14:25:01 +0200 Subject: [PATCH 45/45] Better fix for a Dialyzer warning The previous fix was leading to a badmatch in some cases, including when trying to stop a node that was already stopped. --- deps/rabbitmq_ct_helpers/src/rabbit_ct_broker_helpers.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/rabbitmq_ct_helpers/src/rabbit_ct_broker_helpers.erl b/deps/rabbitmq_ct_helpers/src/rabbit_ct_broker_helpers.erl index 6d343d6c0c1d..b01ea002842e 100644 --- a/deps/rabbitmq_ct_helpers/src/rabbit_ct_broker_helpers.erl +++ b/deps/rabbitmq_ct_helpers/src/rabbit_ct_broker_helpers.erl @@ -1134,7 +1134,7 @@ stop_rabbitmq_node(Config, NodeConfig) -> {"RABBITMQ_NODENAME_FOR_PATHS=~ts", [InitialNodename]} ], Cmd = ["stop-node" | MakeVars], - {ok, _} = case rabbit_ct_helpers:get_config(Config, rabbitmq_run_cmd) of + _ = case rabbit_ct_helpers:get_config(Config, rabbitmq_run_cmd) of undefined -> rabbit_ct_helpers:make(Config, SrcDir, Cmd); RunCmd ->