Commit Graph

562 Commits

Author SHA1 Message Date
Rin Kuryloski 8de8f59d47 Use gazelle generated bazel files
Bazel build files are now maintained primarily with `bazel run
gazelle`. This will analyze and merge changes into the build files as
necessitated by certain code changes (e.g. the introduction of new
modules).

In some cases there hints to gazelle in the build files, such as `#
gazelle:erlang...` or `# keep` comments. xref checks on plugins that
depend on the cli are a good example.
2023-04-17 18:13:18 +02:00
Rin Kuryloski 5cefbef029 Mark rabbitmq_ct_helpers/rabbitmq_ct_client_helpers as testonly 2023-02-28 21:20:32 +01:00
Rin Kuryloski ff7f2c279b Reduce the default number of attempts to start the broker in tests
With the containerized CI environment, port conflicts are much less
likely, so reducing the attempt count improves the feedback loop
2023-02-23 13:25:14 +01:00
Jean-Sébastien Pédron 42bcd94dce
rabbit_db_cluster: New module on top of databases clustering
This new module sits on top of `rabbit_mnesia` and provide an API with
all cluster-related functions.

`rabbit_mnesia` should be called directly inside Mnesia-specific code
only, `rabbit_mnesia_rename` or classic mirrored queues for instance.
Otherwise, `rabbit_db_cluster` must be used.

Several modules, in particular in `rabbitmq_cli`, continue to call
`rabbit_mnesia` as a fallback option if the `rabbit_db_cluster` module
unavailable. This will be the case when the CLI will interact with an
older RabbitMQ version.

This will help with the introduction of a new database backend.
2023-02-22 15:28:04 +01:00
Jean-Sébastien Pédron d65637190a
rabbit_nodes: Add list functions to clarify which nodes we are interested in
So far, we had the following functions to list nodes in a RabbitMQ
cluster:
* `rabbit_mnesia:cluster_nodes/1` to get members of the Mnesia cluster;
  the argument was used to select members (all members or only those
  running Mnesia and participating in the cluster)
* `rabbit_nodes:all/0` to get all members of the Mnesia cluster
* `rabbit_nodes:all_running/0` to get all members who currently run
  Mnesia

Basically:
* `rabbit_nodes:all/0` calls `rabbit_mnesia:cluster_nodes(all)`
* `rabbit_nodes:all_running/0` calls `rabbit_mnesia:cluster_nodes(running)`

We also have:
* `rabbit_node_monitor:alive_nodes/1` which filters the given list of
  nodes to only select those currently running Mnesia
* `rabbit_node_monitor:alive_rabbit_nodes/1` which filters the given
  list of nodes to only select those currently running RabbitMQ

Most of the code uses `rabbit_mnesia:cluster_nodes/1` or the
`rabbit_nodes:all*/0` functions. `rabbit_mnesia:cluster_nodes(running)`
or `rabbit_nodes:all_running/0` is often used as a close approximation
of "all cluster members running RabbitMQ". This list might be incorrect
in times where a node is joining the clustered or is being worked on
(i.e. Mnesia is running but not RabbitMQ).

With Khepri, there won't be the same possible approximation because we
will try to keep Khepri/Ra running even if RabbitMQ is stopped to
expand/shrink the cluster.

So in order to clarify what we want when we query a list of nodes, this
patch introduces the following functions:
* `rabbit_nodes:list_members/0` to get all cluster members, regardless
  of their state
* `rabbit_nodes:list_reachable/0` to get all cluster members we can
  reach using Erlang distribution, regardless of the state of RabbitMQ
* `rabbit_nodes:list_running/0` to get all cluster members who run
  RabbitMQ, regardless of the maintenance state
* `rabbit_nodes:list_serving/0` to get all cluster members who run
  RabbitMQ and are accepting clients

In addition to the list functions, there are the corresponding
`rabbit_nodes:is_*(Node)` checks and `rabbit_nodes:filter_*(Nodes)`
filtering functions.

The code is modified to use these new functions. One possible
significant change is that the new list functions will perform RPC calls
to query the nodes' state, unlike `rabbit_mnesia:cluster_nodes(running)`.
2023-02-13 12:58:40 +01:00
David Ansari 91b56bd85d Remove mixed version check in MQTT tests
In the MQTT test assertions, instead of checking whether the test runs
in mixed version mode where all non-required feature flags are disabled
by default, check whether the given feature flag is enabled.

Prior to this commit, once feature flag rabbit_mqtt_qos0_queue becomes
required, the test cases would have failed.
2023-02-09 10:53:50 +00:00
Alex Valiushko db99c252a0 Add setting to disable op policy edit via API 2023-02-06 14:36:10 -08:00
David Ansari d651f87ea7 Share tests between MQTT and Web MQTT
New test suite deps/rabbitmq_mqtt/test/shared_SUITE contains tests that
are executed against both MQTT and Web MQTT.

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

It's acceptable to add a **test** dependency from rabbitmq_mqtt to
rabbitmq_web_mqtt. Obviously, there should be no such dependency
for non-test code.
2023-01-24 17:32:59 +00:00
David Ansari 7c1aa49361 Increase MQTT test coverage and fix edge cases 2023-01-24 17:32:59 +00:00
David Ansari 3980c28596 Allow higher load on Mnesia by default
Prior to this commit, when connecting or disconnecting many thousands of
MQTT subscribers, RabbitMQ printed many times:
```
[warning] <0.241.0> Mnesia('rabbit@mqtt-rabbit-1-server-0.mqtt-rabbit-1-nodes.default'): ** WARNING ** Mnesia is overloaded: {dump_log,write_threshold}
```

Each MQTT subscription causes queues and bindings to be written into Mnesia.

In order to allow for higher Mnesia load, the user can configure
```
[
 {mnesia,[
  {dump_log_write_threshold, 10000}
 ]}
].
```
in advanced.config

or set this value via
```
RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="-mnesia dump_log_write_threshold 10000"
```

The Mnesia default for dump_log_write_threshold is 1,000.
The Mnesia default for dump_log_time_threshold is 180,000 ms.

It is reasonable to increase the default for dump_log_write_threshold from
1,000 to 5,000 and in return decrease the default dump_log_time_threshold
from 3 minutes to 1.5 minutes.
This way, users can achieve higher MQTT scalability by default.

This setting cannot be changed at Mnesia runtime, it needs to be set
before Mnesia gets started.
Since the rabbitmq_mqtt plugin can be enabled dynamically after Mnesia
started, this setting must therefore apply globally to RabbitMQ.

Users can continue to set their own defaults via advanced.config or
RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS. They continue to be respected
as shown by the new test suite included in this commit.
2023-01-24 17:30:10 +00:00
David Ansari 4c15299196 Delete old emqttc client
Instead use latest emqtt client for Web MQTT tests.
2023-01-24 17:29:07 +00:00
David Ansari 77da78f478 Get most auth_SUITE tests green
Some tests which require clean_start=false
or QoS1 are skipped for now.

Differentiate between v3 and v4:
v4 allows for an error code in SUBACK frame.
2023-01-24 17:29:07 +00:00
Jean-Sébastien Pédron 09094f207f
rabbit_feature_flags: Remove v1 code
`feature_flags_v2` is required now, so we can drop the old code path.
2023-01-10 13:18:22 +01:00
Michael Klishin ec4f1dba7d
(c) year bump: 2022 => 2023 2023-01-01 23:17:36 -05:00
Alexey Lebedeff b51304d233 Bazel 6 compatibility
Directory name for tools in runfiles is a bit unpredictable. Maybe
there is a better way, but at least this should cover all the cases
that I've observed.

One unexpected consequence is that this directory name can contains `~`,
and it's not being properly escaped in `ct:pal` calls (causing
badarg's for `io:format/4`.
2022-12-21 20:40:24 +01:00
Simon Unge 32097035dc See #6016. Add HTTP to fetch app environment config 2022-12-11 20:38:53 -08:00
Jean-Sébastien Pédron 99b14fd0fa
rabbit_env: Rename `mnesia_*dir` to `data_*dir`
The location and name of this directory remains the same for
compatibility reasons. Therefore, it sill contains "mnesia" in its name.
However, semantically, we want this directory to be unrelated to Mnesia.

In the end, many subsystems write files and directories there, including
Mnesia, all Ra systems and in the future, Khepri.
2022-11-30 13:00:49 +01:00
David Ansari 1b1a775160 Support coverage when node being killed by index 2022-11-10 15:04:31 +01:00
David Ansari 5bf8192982 Support code coverage
Previously it was not possible to see code coverage for the majority of
test cases: integration tests that create RabbitMQ nodes.
It was only possible to see code coverage for unit tests.
This commit allows to see code coverage for tests that create RabbitMQ
nodes.

The only thing you need to do is setting the `COVER` variable, for example
```
make -C deps/rabbitmq_mqtt ct COVER=1
```
will show you coverage across all tests in the MQTT plugin.

Whenever a RabbitMQ node is started `ct_cover:add_nodes/1` is called.
Contrary to the documentation which states

> To have effect, this function is to be called from init_per_suite/1 (see common_test) before any tests are performed.

I found that it also works in init_per_group/1 or even within the test cases themselves.

Whenever a RabbitMQ node is stopped or killed `ct_cover:remove_nodes/1`
is called to transfer results from the RabbitMQ node to the CT node.

Since the erlang.mk file writes a file called `test/ct.cover.spec`
including the line:
```
{export,".../rabbitmq-server/deps/rabbitmq_mqtt/cover/ct.coverdata"}.
```
results across all test suites will be accumulated in that file.

The accumulated result can be seen through the link `Coverage log` on the test suite result pages.
2022-11-10 15:04:31 +01:00
Luke Bakken 7fe159edef
Yolo-replace format strings
Replaces `~s` and `~p` with their unicode-friendly counterparts.

```
git ls-files *.erl | xargs sed -i.ORIG -e s/~s>/~ts/g -e s/~p>/~tp/g
```
2022-10-10 10:32:03 +04:00
David Ansari b6952540a3 Remove rabbit_misc:atom_to_binary/1
Nowadays, we have erlang:atom_to_binary/1.
2022-09-09 10:52:38 +00:00
Rin Kuryloski fc271bd5b1 Fixup other references to the master branch, which has moved to main 2022-08-16 09:50:10 +02:00
Michael Klishin d0276eb32e
Terraform: add AMIs for Fedora 34 and 35
Pair: @the-mikedavis
2022-08-05 17:25:29 +04:00
Michael Klishin 681db60cec
Terraform: Erlang packages for 24 and 25 have long been available 2022-08-05 16:16:29 +04:00
Michael Klishin d216d4293e
Remove a few tests that are no longer relevant
Back in 2016, JSON encoding and
much of the Erlang ecosystem used
proplists, which can lead to duplicate
keys in JSON documents.

In 2022 some JSON libraries only
decode JSON to maps, and maps
have unique keys, so these tests
are not worth adjusting or reproducing
with maps.

Per discussion with the team.
2022-07-29 10:34:52 +04:00
Rin Kuryloski ba855445a2 Restore the mixed-ness of mixed version testing
When the fetch of the secondary umbrella was moved into bzlmod, this
changed its path at the time of test execution. Tests will now fail if
a secondary umbrella is specified for bazel, but does not exist. The
path is also corrected.
2022-07-21 12:04:41 +02:00
David Ansari ad27021630 Use microsecond abbreviation 'us' instead of 'µs'
'us' is used when Unicode is not available.

Prior to this commit:
```
$ kubectl logs r1-server-0 -c rabbitmq | ag time
2022-06-30 13:37:35.253927+00:00 [debug] <0.336.0> wal: recovered 00000003.wal time taken 0ms
2022-06-30 13:37:35.262592+00:00 [debug] <0.349.0> wal: recovered 00000003.wal time taken 0ms
2022-06-30 13:37:35.489016+00:00 [debug] <0.352.0> Feature flags: time to find supported feature flags: 76468 �s
2022-06-30 13:37:35.495193+00:00 [debug] <0.352.0> Feature flags: time to regen registry: 6032 �s
2022-06-30 13:37:35.500574+00:00 [debug] <0.361.0> Feature flags: time to find supported feature flags: 937 �s
2022-06-30 13:37:35.500603+00:00 [debug] <26705.398.0> Feature flags: time to find supported feature flags: 891 �s
2022-06-30 13:37:35.507998+00:00 [debug] <26705.398.0> Feature flags: time to regen registry: 7199 �s
2022-06-30 13:37:35.509092+00:00 [debug] <0.361.0> Feature flags: time to regen registry: 8396 �s
```
2022-06-30 13:54:25 +00:00
Jean-Sébastien Pédron cefb6aaef5
cth_log_redirect_any_domains: common_test hook to handle domain-specific log messages
common_test installs its own logger handler, which is great.
Unfortunately, this logger handler drops all messages having a domain,
except when the domain is among the domains used by Erlang itself.

In RabbitMQ, we use logger domains to categorize messages. Therefore
those messages are dropped by the common_test's logger handler.

This commit introduces another logger handler which sits on top of the
common_test one and makes sure messages with a domain are logged as
well.
2022-06-28 10:13:19 +02:00
Loïc Hoguin dc70cbf281
Update Erlang.mk and switch to new xref code 2022-05-31 13:51:12 +02:00
Michael Klishin 7c47d0925a
Revert "Correct a double quote introduced in #4603"
This reverts commit 6a44e0e2ef.

That wiped a lot of files unintentionally
2022-04-20 16:05:56 +04:00
Michael Klishin 6a44e0e2ef
Correct a double quote introduced in #4603 2022-04-20 16:01:29 +04:00
Luke Bakken dba25f6462
Replace files with symlinks
This prevents duplicated and out-of-date instructions.
2022-04-15 06:04:29 -07:00
David Ansari 1315b1d4b1 Prefer running nodes for replica selection
When declaring a quorum queue or a stream, select its replicas in the
following order:
1. local RabbitMQ node (to have data locality for declaring client)
2. running RabbitMQ nodes
3. RabbitMQ nodes with least quorum queue or stream replicas (to have a "balanced" RabbitMQ cluster).

From now on, quorum queues and streams behave the same way for replica
selection strategy and leader locator strategy.
2022-04-07 11:55:19 +02:00
Philip Kuryloski 1ad078e4e6 Remove extra copies of rabbitmq-components.mk & erlang.mk 2022-03-24 15:20:09 +01:00
Michael Klishin c38a3d697d
Bump (c) year 2022-03-21 01:21:56 +04:00
David Ansari 6eed54ffae Move eventually and consistently to rabbit_ct_helpers
so that these functions can be reused in other tests.

Inspired by Gomega's Eventually and Consistently functions.
See https://onsi.github.io/gomega/#making-asynchronous-assertions

"Eventually checks that an assertion eventually passes. Eventually blocks
when called and attempts an assertion periodically until it passes or a
timeout occurs. Both the timeout and polling interval are configurable
as optional arguments."

"Consistently checks that an assertion passes for a period of time. It
does this by polling its argument repeatedly during the period. It fails
if the matcher ever fails during that period."
2022-02-28 16:28:09 +01:00
Philip Kuryloski bc1a8b725d Adjust catch clause to causing flakiness in some suites 2022-02-23 10:33:35 +01:00
Luke Bakken 59e211d97e
Support Elixir 1.13
This is the build error prior to these changes:

```
* rabbit_common (/home/bakkenl/development/rabbitmq/rabbitmq-server/deps/rabbit_common)
  could not find an app file at "_build/dev/lib/rabbit_common/ebin/rabbit_common.app". This may happen if the dependency was not yet compiled or the dependency indeed has no app file (then you can pass app: false as option)
** (Mix) Can't continue due to errors on dependencies
```

Telling `mix` to compile `rabbit_common` ensures that the following
links are created:

```
$ ll deps/rabbitmq_cli/_build/dev/lib/rabbit_common/
total 8
drwxr-xr-x  2 bakkenl bakkenl 4096 Jan 20 09:46 .
drwxr-xr-x 10 bakkenl bakkenl 4096 Jan 20 09:46 ..
lrwxrwxrwx  1 bakkenl bakkenl   33 Jan 20 09:46 ebin -> ../../../../../rabbit_common/ebin
lrwxrwxrwx  1 bakkenl bakkenl   36 Jan 20 09:46 include -> ../../../../../rabbit_common/include
```
2022-02-04 19:02:23 +03:00
Philip Kuryloski efcd881658 Use rules_erlang v2
bazel-erlang has been renamed rules_erlang. v2 is a substantial
refactor that brings Windows support. While this alone isn't enough to
run all rabbitmq-server suites on windows, one can at least now start
the broker (bazel run broker) and run the tests that do not start a
background broker process
2022-01-18 13:43:46 +01:00
Luke Bakken 6de0656fce
Add redbug library
`redbug` compliments `recon` well and has a better tracing interface IMHO.
2022-01-11 16:22:05 -08:00
Philip Kuryloski 3b48ebabf7 Fixup the "Failed to symlink private_log directory." error in bazel
While it doesn't cause any tests to fail, it's confusing to see it in
the logs
2021-11-16 13:25:53 +01:00
Philip Kuryloski 1f7db0fa35 Update rabbit_ct_broker_helpers:force_vhost_failure/4 for erpc
https://www.erlang.org/doc/man/erpc.html#call-5
2021-11-15 10:53:10 +01:00
Philip Kuryloski 76287fb30c format with bazel files with buildifier 2021-11-02 18:24:26 +01:00
Philip Kuryloski 8c0eece3cd Adjustments for the latest bazel-erlang 2021-11-02 16:24:26 +01:00
Philip Kuryloski 862917955b Adopt new default branch for ra 2021-10-06 13:36:32 +02:00
Alexey Lebedeff 46df4f1689 Update makefiles/bazel to reflect CT helpers repo merge-in 2021-09-30 10:48:11 +02:00
Alexey Lebedeff efce6b9f0d Allocate tcp port for prometheus plugin 2021-09-22 09:13:33 +02:00
Philip Kuryloski efe8da4d41 Allow the rabbit_ct_config_schema helper to work on v3.8 & v3.9
by checking for the presence of lager on the code path as a marker
distinguising rabbit versions
2021-09-07 14:47:51 +02:00
Alexey Lebedeff 1e8ba5bffc Use elixir itself to find its lib directory
This removes all the guesswork from the process. E.g. the old version
was not working with elixir from nixpkgs/NixOS.
2021-08-11 15:41:00 +02:00
Philip Kuryloski 6fec1faea5 Additional rpc -> erpc updates 2021-07-21 09:21:41 +02:00
Philip Kuryloski 6edb1ea016 Use bazel-erlang 1.1.0 2021-07-12 19:06:20 +02:00
Philip Kuryloski dbb09f1bf5 Add ?awaitMatch/4 to rabbit_assert.hrl
?awaitMatch/4 is the same as ?awaitMatch/3, but where the polling
interval is configurable
2021-07-05 15:21:27 +02:00
Philip Kuryloski f8c09121c1 Revert "Add ?awaitMatch/4 to rabbit_assert.hrl"
This reverts commit 3bb9d0084d.
2021-07-05 11:46:51 +02:00
Philip Kuryloski 3bb9d0084d Add ?awaitMatch/4 to rabbit_assert.hrl
?awaitMatch/4 is the same as ?awaitMatch/3, but where the polling
interval is configurable
2021-07-05 11:40:42 +02:00
Philip Kuryloski 07220e4e13 Fix handling of `broker_with_plugins` config "flag" under bazel
If unset, the flag actually has no effect, rather than assumed to be false
2021-06-30 16:20:11 +02:00
Philip Kuryloski 77073529a6 Use bazel-erlang 1.0.0 2021-06-29 16:49:53 +02:00
Philip Kuryloski f0941c806d Add is_mixed_versions/0
So that the check can be performed before run_setup_steps on a Config
2021-06-25 11:06:17 +02:00
Philip Kuryloski 4c4e2926ea Avoid using mixed cluster args for node start in normal tests
Enhances b56cc4d0fb
2021-06-24 10:28:30 +02:00
Philip Kuryloski b56cc4d0fb Activate plugins correctly in bazel mixed version cluster tests
Bazel mixed version nodes are prebuilt with all plugins, so they need
an alternate mechanism than gnu make for selecting which plugins to enable
2021-06-23 12:17:48 +02:00
Philip Kuryloski 88134b416e Follow up changes for the rpc:call -> erpc:call change
Some tests would make rpc calls, ignoring the result. Since erpc
throws errors, this broke some tests. This commit restores the
non-throw behavior to add_vhost, delete_vhost, add_user,
set_user_tags, delete_user & clear_permissions.
2021-06-22 11:06:27 +02:00
Philip Kuryloski 67e9f02075 Use `erpc:call/{4,5}` in `rabbit_ct_broker_helpers:rpc/{4,5}`
erpc was introduced in Erlang 23, and importantly now provides much
more information when a call fails, like the stacktrace
2021-06-21 17:17:42 +02:00
Philip Kuryloski f5719cd45f Updates for mixed version testing with bazel 2021-06-18 13:01:11 +02:00
Michael Klishin 4126807e71 rabbit_mgmt_test_util: modernize for recent JSX versions 2021-06-12 08:10:36 +08:00
Michael Klishin 820ed74d21 Merge pull request #48 from rabbitmq/stream-tls
Add stream TLS port
2021-05-14 00:24:11 +03:00
dcorbacho f0009e4008 Add stream TLS port 2021-05-13 17:00:03 +02:00
Michael Klishin ca017ac42c Export init_skip_as_error_flag/1 2021-04-30 17:01:26 +03:00
Michael Klishin 45c037d12a Merge pull request #46 from Ayanda-D/poison-messages-in-classic-queues
Add rabbit_ct_broker_helpers:set_ha_policy_all/2
2021-04-30 15:59:44 +03:00
Michael Klishin 488d0d90bb Use Buster for all Erlang versions we support
(cherry picked from commit 61600caf32e8c5c64ea44da4dd1bcdf16b117893)
2021-04-19 17:50:11 +03:00
Michael Klishin ca3f5eaa10 Use -auto-approve instead of -force for forward Terraform compat 2021-04-19 17:03:11 +03:00
Michael Klishin 8ebb059d54 Revert "Upgrade VM helpers to Terraform 0.15.0"
This reverts commit bade323f67.
2021-04-19 17:00:21 +03:00
Michael Klishin 844a63b324 Revert "Adapt more flags to Terraform 0.15"
This reverts commit dbb52257f8.
2021-04-19 17:00:08 +03:00
Michael Klishin 3d9a8aebc4 Run apt-get update before installing any packages 2021-04-19 16:34:15 +03:00
Michael Klishin 34a2e995c7 Install GnuPG as it isn't available on Buster by default 2021-04-19 16:28:45 +03:00
Michael Klishin ad54825b77 Erlang setup: modernize, switch away from Bintray 2021-04-19 16:19:26 +03:00
Michael Klishin dbb52257f8 Adapt more flags to Terraform 0.15 2021-04-17 00:21:39 +03:00
Michael Klishin eda3be6fcd Ignore a few more Terraform 0.15 artefacts 2021-04-17 00:18:42 +03:00
Michael Klishin bade323f67 Upgrade VM helpers to Terraform 0.15.0
See [1]. Docker images are already upgraded
in the CI/CD repo.

1. https://www.terraform.io/upgrade-guides/0-15.html
2021-04-17 00:16:49 +03:00
Philip Kuryloski b9760d2f60 Allow unused test node dirs to be deleted rather than removed
by setting RABBITMQ_CT_HELPERS_DELETE_UNUSED_NODES in the env

helps reduce disk usage of tests
2021-04-15 09:30:53 +02:00
Michael Klishin 57eb064824 openssl.cnf: use sha256 for default_md
Modern Python and OpenSSL versions
can reject certificates that use SHA-1
as insufficiently secure.

This is the case with Python 3 on Debian
Buster, for example

Per discussion with @pjk25 @dumbbell
2021-04-14 19:00:39 +03:00
Philip Kuryloski bdc32c7f1f Make rabbit_srcdir is optional under bazel
d8d910ddd2 inadvertantly made it required
2021-04-13 12:41:54 +02:00
Philip Kuryloski d8d910ddd2 Adjustments for rabbitmq_federation under bazel 2021-04-13 11:23:39 +02:00
Philip Kuryloski de1839302a Fix for the consolidation of erlang.mk and rabbitmq-components.mk
After theses files were consolidated at the root of rabbitmq-server,
they were no longer uploaded to terraformed vms as needed. We now
check for the files at their original location, falling back to the
central location for upload.
2021-04-09 11:56:28 +02:00
Jean-Sébastien Pédron 25213067c5 rabbit_ct_config_schema: Remove default value for {rabbit, [{log, _}]}
This helper is designed to perform exact matching between the generated
configuration and the expected value. This does not work at all if the
schema has default values for untested configuration variables.

The correct solution would be to rewrite this helper and all testsuites
using it to do pattern matching instead. But in the meantime, work
around this design issue by removing the `{rabbit, {log, _}}`
configuration key.
2021-03-30 10:12:45 +02:00
Jean-Sébastien Pédron a2b7d73762 erlang.mk: Update to add support for Rebar lock file version 1.2.0 2021-03-29 11:57:57 +02:00
Philip Kuryloski d273660c92 Add Bazel build (#47)
Add Bazel build files corresponding to rabbitmq/rabbitmq-server#2938

The gnu make build should remain unchanged by theses additions
2021-03-29 11:27:33 +02:00
Michael Klishin 700f5c0baf Log loaded config schema snippets 2021-02-22 15:20:22 +03:00
Jean-Sébastien Pédron 4b190d27b7 tools/terraform: Fix warning reported by Terraform
We shouldn't interpolate a variable alone in a string: we should use the
variable directly.
2021-01-04 15:47:22 +01:00
Philip Kuryloski 58faef1e2e Update fetching of rabbit and rabbit_common deps 2020-12-16 09:32:41 +01:00
Philip Kuryloski 2efb44b8d5 Once again raise an error when add_code_path_to_node fails
A previous commit to increase logging would allow the call to continue
after errors.
2020-12-16 09:31:02 +01:00
Philip Kuryloski 483ccdc35e Add additional logging when adding code paths to remote nodes
rabbitmq_ct_broker_helpers:add_code_path_to_node/2
2020-12-16 09:30:47 +01:00
Jean-Sébastien Pédron d8bb5d2484 rabbit_ct_helpers: Use timer:send_after/2 instead of erlang:start_timer/4
It looks like the message sent by erlang:start_timer/4 conflicts without
something else, perhaps inside common_test.

Hopefully, by using timer:send_after/2 and thus another message format,
the possible conflict will go away.
2020-11-24 12:15:22 +01:00
Ayanda-D 61d0a2cdad Add rabbit_ct_broker_helpers:set_ha_policy_all/2 2020-11-20 09:36:42 +00:00
Jean-Sébastien Pédron 762e35cee6 rabbit_ct_helpers: Dump command output every 30 seconds
It should be useful to see what long-running or hanging commands
already printed so far, before they finish (if ever.
2020-11-04 12:39:16 +01:00
Arnaud Cogoluègnes 0293d6b4d6 Update rabbitmq-components.mk 2020-11-03 14:27:38 +01:00
Jean-Sébastien Pédron 40e3703a7d rabbit_ct_broker_helpers: Catch another possible exception in force_vhost_failure/4
The following code may exit with a badmatch, the vhost is gone in
between:

    get_message_store_pid(Config, Node, VHost) ->
        {ok, VHostSup} = rpc(Config, Node,
                             rabbit_vhost_sup_sup, get_vhost_sup, [VHost]),

That's what we now catch in `force_vhost_failure/4`.
2020-11-02 14:39:25 +01:00
Jean-Sébastien Pédron 8555cfe67b tools/terraform: Fix warnings reported by recent versions of Terraform 2020-10-22 15:25:24 +02:00
Jean-Sébastien Pédron 96a369e4b3 rabbit_ct_vm_helpers: Always pass `-auto-approve` to terraform(1)
We didn't do it when querying the manifest. Unfortunately, recently
terraform(1) started to prompt for confirmation. The command was thus
stuck and the testcase was timing out.
2020-10-22 15:23:19 +02:00
Michael Klishin c63475272e Update rabbitmq-components.mk 2020-10-21 12:55:34 +03:00
Michael Klishin e1066dc81b Introduce rabbit_ct_broker_helpers:clear_all_alarms/2
and fix resource limit clauses in clear_alarms/3
2020-10-07 22:13:33 +03:00
Michael Klishin f2c6602a65 More alarm-related helpers 2020-10-06 20:24:01 +03:00
Michael Klishin 8757b7e64f Introduce more alarm related broker helpers
Inspired by rabbitmq/rabbitmq-management#844.
2020-10-06 15:22:16 +03:00
Arnaud Cogoluègnes 34e5781eb9 Add stream TCP port to start broker 2020-09-30 16:33:28 +01:00
Michael Klishin 25cb487b5e Make it easy to close all connections on a node
from a test. HTTP API test suites would greatly benefit
from this.
2020-09-24 11:41:11 +03:00
Michael Klishin b6830f968d Introduce set_policy_in_vhost/{7,8} 2020-09-11 17:35:33 +03:00
Michael Klishin 4c15e493c1 Introduce rabbit_ct_helpers:await_condition/1 2020-08-30 18:13:18 +03:00
Ayanda-D c1fbc0b70d Add set_user_limits/{3,4} and clear_user_limits/{3,4} helpers 2020-08-30 18:11:16 +03:00
Ayanda-D 243255b8ab Add forget_cluster_node/{3,4} broker helper 2020-08-30 18:11:15 +03:00
Luke Bakken 48e448ce2e Update rabbitmq-components.mk 2020-08-04 08:41:47 -07:00
Jean-Sébastien Pédron 7903a69836 Update rabbitmq-components.mk 2020-07-30 12:06:52 +02:00
Luke Bakken c34dab4a38 Update rabbitmq-components.mk 2020-07-29 10:02:02 -07:00
Jean-Sébastien Pédron e97357c8f4 tools/terraform: Use Debian package for Erlang 23
We don't need to compile it from sources anymore.
2020-07-24 19:42:36 +02:00
Jean-Sébastien Pédron e73523d456 tools/terraform: Switch to m5.large instance type by default
The m4.large could build Erlang and the testsuite could run in 28
minutes. That's an improvment, but we are still close to the limit.

Rather than bump the limit, try with an m5.large. It's also a bit
cheaper to my surprise.
2020-07-23 11:26:13 +02:00
Jean-Sébastien Pédron 7cfca2e57b rabbit_ct_broker_helpers: Remove trailing whitespaces 2020-07-23 10:34:18 +02:00
Jean-Sébastien Pédron aae024f958 tools/terraform: Switch to m4.large instance type by default
The previous default of t2.micro was insufficient to compile Erlang from
sources in under 30 minutes. This caused the integration testsuite to
timeout.

Hopefully an m4.large instance type will be enough.
2020-07-23 10:34:03 +02:00
Michael Klishin 769a24cfa5 Merge branch 'rabbitmq-server-2321' 2020-07-21 23:46:52 +03:00
Luke Bakken 5df63198b4 Explicitly add `master` to work around ninenines/erlang.mk#898 2020-07-21 09:13:39 -07:00
dcorbacho 44a8f953bb Update erlang.mk 2020-07-21 14:32:14 +01:00
Michael Klishin 4730b6d933 Update rabbitmq-components.mk 2020-07-21 13:12:46 +03:00
Michael Klishin 52b8a3f909 Update rabbitmq-components.mk 2020-07-21 03:42:52 +03:00
dcorbacho 809741f367 Revert drop of Exhibit B on MPL 2.0 2020-07-20 16:58:33 +01:00
Michael Klishin 33bb90bccc Update MPL2 license file, drop Exhibit B
and add a VMware copyright notice.

We did not mean to make this code Incompatible with Secondary Licenses
as defined in [1].

1. https://www.mozilla.org/en-US/MPL/2.0/FAQ/
2020-07-17 14:53:07 +03:00
Gerhard Lazu 639a2e76ef Add more logging and verify inet_tcp_proxy_dist return values
This is sometimes failing in GitHub Actions and we don't know why:
https://github.com/rabbitmq/rabbitmq-server/runs/877118328?check_suite_focus=true#step:6:6099

We confirmed in the logs that only 1 out of 3 nodes get unblocked. The
CT suite hits the 15 minute time trap and fails. We don't know whether
this rpc call doesn't make it through to the first or second node, or if
it does and the rpc call simply doesn't return within the time window.
We can't address this if we don't know where the problem lies, so this
will give us more insight when it fails again.

Signed-off-by: Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com>
2020-07-16 17:44:47 +01:00
dcorbacho 3c9ce68ef8 Switch to Mozilla Public License 2.0 (MPL 2.0) 2020-07-11 19:56:11 +01:00
Michael Klishin 55529859eb More maintenance mode helpers 2020-07-09 09:57:10 +03:00
Michael Klishin 56a87dcd5a A typo 2020-07-09 09:57:10 +03:00
Michael Klishin b30e86b93d More maintenance mode-related functions 2020-07-09 09:57:09 +03:00
Michael Klishin dbfd401668 Node maintenance mode helpers for rabbitmq/rabbitmq-server#2321 2020-07-09 09:57:09 +03:00
Philip Kuryloski 0236c64ace Reduce chances of variable capture in ?awaitMatch
Attempt to name all of the variables in the macro such that they are less
likely to collide with any existing bindings.
2020-07-06 12:08:23 +02:00
Philip Kuryloski 9479c2e9cc Add ?awaitMatch macro
awaitMatch(Guard, Expr, Timeout) reevaluates Expr until it matches
Guard up to Timeout milliseconds from now. It returns the matched
value, in the event said value is useful later in a test.

Additionally simplify an instance of ?assertEqual(true, ... to ?assert(
2020-07-02 11:33:17 +02:00
Jean-Sébastien Pédron d930d0ea84 Update erlang.mk 2020-06-23 17:13:47 +02:00
Michael Klishin b455417b48 Bump Recon to 2.5.1
for Erlang 23 compatibility of 'rabbitmq-diagnostics observer'

References zhongwencool/observer_cli#68.
2020-06-09 08:22:14 +03:00
Jean-Sébastien Pédron d6fd834e91 tools/terraform: Add support for Erlang 24 (Git master) 2020-05-15 14:37:30 +02:00
Jean-Sébastien Pédron 1804aff244 rabbit_ct_helpers: `fail_if_no_peer_cert` must be false if `verify` set to `verify_none`
Erlang Git master started to report the combination of
verify=none/fail_if_no_peer_cert=true as incompatible options.
2020-05-15 11:49:36 +02:00
Jean-Sébastien Pédron 5cdfb280de rabbit_ct_broker_helpers: Override node name in stop_rabbitmq_node()
... if it changed compared to the one passed to start-background-broker.
2020-05-06 17:55:24 +02:00
Jean-Sébastien Pédron 9b2be8340d rabbit_ct_broker_helpers: Use same make(1) vars for node start & stop
This fixes an issue when a node was starting from the secondary
Umbrella, but stopped from the primary one.
2020-05-06 16:35:35 +02:00
Jean-Sébastien Pédron 3469b98d25 rabbit_ct_broker_helpers: Skip build only if starting node from cwd
`make test-dist` was already executed for project being tested,
therefore we can skip the build to save time when a RabbitMQ node is
started from there.

However, if the node is to be started from another place (i.e. `rabbit`
when plugins are disabled), we must not skip the build because the
project might have no .ez. files created at this point.
2020-05-04 18:35:46 +02:00
Gerhard Lazu edbdd2229f Revert nodes clustering in parallel
This reverts part of
dc5a04a503
because tests started failing in GitHub Actions with:

    2020-04-30 16:38:32.238 [error] <0.228.0> Supervisor inet_tcp_proxy_dist_conn_sup had child
                                              {undefined,false,#Ref<0.301488671.524812289.157484>}
                                              started with
                                              {inet_tcp_proxy_dist,dist_proc_start_link,undefined} at <0.776.0>
                                              exit with reason net_tick_timeout in context child_terminated

We suspect that this is due to CPU contention on GitHub Actions shared runners.
When 5 Erlang VM nodes with 2 schedulers each start at the same time on a
host with 2 CPUs and then try to cluster via rabbitmqctl (which starts
5 more Erlang VMs), the 5 second net_tick_time is not long enough.
Rather than increasing the net_tick_time, we are choosing to put less
pressure on the host by clustering nodes one-by-one rather than all at
once.

Pair @dumbbell

Signed-off-by: Gerhard Lazu <gerhard@lazu.co.uk>
2020-04-30 18:39:50 +01:00
Philip Kuryloski 4b4dd1b212 Add the option for a timeout in rabbit_ct_helpers:exec
So now there is exec/3 with an infinite default timeout, and exec/4 with a millisecond timeout. Also applies to rabbit_ct_broker_helpers:rabbitmqctl.
2020-04-29 16:23:05 +02:00
dcorbacho a57b3a8561 Increase vhost failure retries
It should solve the flaky tests where vhosts cannot be made to fail
2020-04-27 17:22:34 +01:00
Jean-Sébastien Pédron 8e8dd045e5 Update erlang.mk 2020-04-21 16:18:07 +02:00
Jean-Sébastien Pédron 8bf8640695 rabbit_ct_broker_helpers: Call `make stop-node` directly
I don't remember why I used `stop-rabbit-on-node` then `stop-node`. But
this was two CLI runs which costed a lot in time.

Now, `stop-node` does not use the CLI anymore and getting rid of
`stop-rabbit-on-node` reduces the number of CLI runs to 0, improving the
time it takes to stop RabbitMQ significantly: it shaved about 1 second,
giving a stop time of about 3 seconds now on my laptop.
2020-04-21 15:36:05 +02:00
Jean-Sébastien Pédron dc5a04a503 rabbit_ct_broker_helpers: nodes clustering in parallel
We were already starting nodes in parallel, but they were clustered one
by one. Now, clustering happens in parallel as well to speed things up a
bit.
2020-04-21 15:34:48 +02:00
Jean-Sébastien Pédron 4e7d737bd1 rabbit_ct_broker_helpers: Use new inet_tcp_proxy_dist API
See rabbitmq/inet_tcp_proxy#3.
2020-04-15 13:19:56 +02:00
Jean-Sébastien Pédron 5c0003e5a4 tools/terraform: Fix warnings reported by Terraform 0.12.x 2020-04-14 12:47:03 +02:00
Michael Klishin 5b7c20fa7d Add more minors to erlang_version_to_system
we list all 23.x minors for forward compatibility.
When a release is missing from this map,
test suites that start VMs for their test begin
failing.
2020-04-13 10:25:07 +03:00
Michael Klishin 3fedafc797 Introduce rabbit_ct_helpers:await_condition/2 and await_condition_with_retries/2
For cases where a condition can materialize eventually but
we do not know when exactly since we have to observe it from
the outside.

E.g. a cluster of nodes can be formed in a second or two, there's
a randomized delay on startup involved by design.
2020-03-31 19:10:48 +03:00
Jean-Sébastien Pédron b3caf2daff rabbit_ct_broker_helpers: Stop node if start-background-broker failed
If the `start-background-broker` recipe fails, it is possible that the
node was started but the follow-up wait/status failed.

To not let a, unused node around, we try to stop it in case of a failure
and ignore the result of that stop recipe.

This situation happened in CI where Elixir seems to crash (one of the
two CLI commands we run after starting the node):

    Logger - error: {removed_failing_handler,'Elixir.Logger'}
    Logger - error: {removed_failing_handler,'Elixir.Logger'}
    Logger - error: {removed_failing_handler,'Elixir.Logger'}
    escript: exception error: undefined function 'Elixir.Exception':blame/3
      in function  'Elixir.Kernel.CLI':format_error/3 (lib/kernel/cli.ex, line 82)
      in call from 'Elixir.Kernel.CLI':print_error/3 (lib/kernel/cli.ex, line 173)
      in call from 'Elixir.Kernel.CLI':exec_fun/2 (lib/kernel/cli.ex, line 150)
      in call from 'Elixir.Kernel.CLI':run/1 (lib/kernel/cli.ex, line 47)
      in call from escript:run/2 (escript.erl, line 758)
      in call from escript:start/1 (escript.erl, line 277)
      in call from init:start_em/1
    .../rabbit_common/mk/rabbitmq-run.mk:323: recipe for target 'start-background-broker' failed

In this case, rabbit_ct_broker_helpers tried again to start the node and
it worked. But it affected an unrelated testcase later because it tried
to use a TCP port already used by that left-over node.
2020-03-25 11:14:56 +01:00
Jean-Sébastien Pédron f1d31c9620 rabbit_ct_broker_helpers: Fix indentation 2020-03-25 11:14:38 +01:00
Jean-Sébastien Pédron 78c0bfcce4 rabbit_ct_broker_helpers: Do not rebuild RabbitMQ when starting a node
rabbitmq_ct_helpers ensures everything is built earlier, so no need to
try again. This saves a bit of time and hopefully fixes a few
situations where RabbitMQ is recompiled without test code.
2020-03-23 14:50:07 +01:00
Michael Klishin 19feb846ea rabbit_ct_broker_helpers: introduce reset_node/2, force_reset_node/2
Pair: @dumbbell.
2020-03-16 12:20:54 +03:00