Commit Graph

631 Commits

Author SHA1 Message Date
Michael Davis 38091430b5
make: Suppress Elixir charlist warning for dialyze target
The `:io.format/2` call was originally passed a single-quote string
(i.e. a charlist in Elixir terminology) which emits a warning in more
recent Elixir versions:

    warning: single-quoted strings represent charlists. Use ~c"" if you indeed want a charlist or use "" instead
    └─ nofile:1:12

This warning would pop up a few times when using `make dialyze` within
a deps directory. To resolve it we can switch the quoting so that the
eval string is wrapped in single quotes (equivalent for shell since this
line doesn't use variables) and the format argument is wrapped in double
quotes. This uses a binary in Elixir instead, but that's ok because
`io:format/3`'s `io:format()` parameter may either be an atom, string,
or binary.

This trick was copied from Makefile:49 which uses the same quoting.
2024-12-03 12:02:25 -05:00
Michal Kuratczyk 2c0fc70135
Abort restart-cluster if something goes wrong
For example, if the first restarted node doesn't start,
don't try to restart the other nodes. This mimics what
orchestrators such as Kubernetes or BOSH would do
(although they perform this check differently)
2024-10-30 12:58:35 +01:00
Jean-Sébastien Pédron c0be3c0648
rabbitmq-run.mk: Restart nodes in a cluster sequentially
... not in parallel.
2024-10-29 11:41:20 +01:00
Jean-Sébastien Pédron 624d9bae0c
rabbitmq-run.mk: Use a 60 seconds timeout for `rabbitmqctl wait`
... not 60 milliseconds.
2024-10-29 11:37:50 +01:00
Loïc Hoguin f68fc8bb94
Make CI: Add mixed version testing
This is enabled on main and for pull requests. Bazel remains
used in previous branches.
2024-10-25 13:50:05 +02:00
Loïc Hoguin ae984cc364
make: Set CT_LOGS_DIR to top-level logs/ directory
All CT logs will now be under <toplevel>/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.
2024-09-30 12:35:43 +02:00
Loïc Hoguin 9f8c17f587
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.
2024-09-30 12:35:42 +02:00
Loïc Hoguin f95c87082a
make: Include rabbitmq_cli ebin in code path only if in deps 2024-09-30 12:35:42 +02:00
Loïc Hoguin a17fb13a03
make: Initial work on using ct_master to run tests
Because `ct_master` is yet another Erlang node, and it is used
to run multiple CT nodes, meaning it is in a cluster of CT
nodes, the tests that change the net_ticktime could not
work properly anymore. This is because net_ticktime must
be the same value across the cluster.

The same value had to be set for all tests in order to solve
this. This is why it was changed to 5s across the board. The
lower net_ticktime was used in most places to speed up tests
that must deal with cluster failures, so that value is good
enough for these cases.

One test in amqp_client was using the net_ticktime to test
the behavior of the direct connection timeout with varying
net_ticktime configurations. The test now mocks the
`net_kernel:get_net_ticktime()` function to achieve the
same result.
2024-08-29 15:23:31 +02:00
Loïc Hoguin 7ad8e2856b
make: Restrict Erlang.mk plugin inclusion
This has no real impact on performance[1] but should
make it clear which application can run the broker
and/or publish to Hex.pm. In particular, applications
that we can't run the broker from will now give up
early if we try to.

Note that while the broker can't normally run from the
amqp_client application's directory, it can run from
tests and some of the tests start the broker.

[1] on my machine
2024-08-29 15:19:50 +02:00
Loïc Hoguin 445f3c9270
make: Move rabbitmq-early-test.mk to rabbitmq-early-plugin.mk
No real need to have two files, especially since it contains
only a few variable definitions. Plan is to only keep
separate files for larger features such as dist or run.
2024-08-29 15:19:50 +02:00
Loïc Hoguin 7421d4d15f
make: Additional cleanups 2024-08-29 15:19:50 +02:00
Loïc Hoguin d4222f8216
make: Remove emptied rabbitmq-tools.mk 2024-08-29 15:19:14 +02:00
Loïc Hoguin 7cb0c1b217
make: Refactor PROJECT_VERSION computation 2024-08-29 15:19:14 +02:00
Loïc Hoguin 48795d7cf3
make: Remove update-contributor-code-of-conduct target
The relevant files have been symlinked to the root file
for the past two years.
2024-08-29 15:19:14 +02:00
Loïc Hoguin d9d74d0964
make: Remove ct-logs-archive target
Hasn't been used for a long time.
2024-08-29 15:19:14 +02:00
Loïc Hoguin f3d0d4e113
make: Remove sync-gitremote sync-gituser targets
They are not useful for the monorepo.
2024-08-29 15:19:14 +02:00
Loïc Hoguin a5cfb1ea9a
make: Remove show-upstream-git-fetch-url and co
They haven't been necessary for quite some time.
2024-08-29 15:19:14 +02:00
Loïc Hoguin 4e8ad90cd0
make: Remove commits-since-release
This was only relevant before the monorepo.
2024-08-29 15:19:14 +02:00
Loïc Hoguin 31409e86b0
make: Remove show-branch target
Not useful in the monorepo.
2024-08-29 15:19:14 +02:00
Loïc Hoguin b8bcd5c27c
make: Remove sync-gitignore-from-main target
No longer relevant because of the monorepo
2024-08-29 15:19:14 +02:00
Loïc Hoguin e947e098bd
make: Remove rabbitmq-deps.mk related targets 2024-08-29 15:19:14 +02:00
Loïc Hoguin 7e7e6feb9d
make: Remove rabbitmq-tests.mk
Everything in this file seems to be dead code except
ct-slow/ct-fast, which have been replaced by their
equivalent in the rabbit Makefile.
2024-08-29 15:19:13 +02:00
David Ansari ffefefba0f Run with default wal_sync_method
...which is `datasync`

RA never pre-allocates the WAL anymore unless explicitly configured to.
2024-08-22 16:24:07 +00:00
Loïc Hoguin af49f5c526
make: Remove FAST_RUN_BROKER; make normal run-broker fast
The DIST step used rsync for copying files; changing this
to using cp/rm provides a noticeable speed boost.

Before this commit the situation was as follows. With
FAST_RUN_BROKER=1 we are pretty fast but don't benefit
from parallel make:

  make -C deps/rabbitmq_management run-broker FAST_RUN_BROKER=1
    2,04s user 1,57s system 90% cpu 4,016 total
  make -C deps/rabbitmq_management run-broker FAST_RUN_BROKER=1 -j8
    2,08s user 1,55s system 89% cpu 4,069 total

With FAST_RUN_BROKER=0 we are slow; on the other hand
we greatly benefit from parallel make:

  make -C deps/rabbitmq_management run-broker FAST_RUN_BROKER=0
    3,29s user 1,93s system 81% cpu 6,425 total
  make -C deps/rabbitmq_management run-broker FAST_RUN_BROKER=0 -j8
    3,36s user 1,90s system 142% cpu 3,695 total

The reason this method achieves such a result is because
the DIST step that takes a lot of time can be run in
parallel. In addition, this method results on only
the necessary plugins being available in the path,
therefore it doesn't discover unrelated plugins
during node startup, saving time.

By changing rsync to cp/rm, we get great results even
without parallel make:

  make -C deps/rabbitmq_management run-broker FAST_RUN_BROKER=0
    3,28s user 1,64s system 105% cpu 4,684 total
  make -C deps/rabbitmq_management run-broker FAST_RUN_BROKER=0 -j8
    3,27s user 1,65s system 135% cpu 3,640 total

We are within 1s of FAST_RUN_BROKER=1 by default, and
faster than FAST_RUN_BROKER=1 with parallel make. On
top of that, we greatly benefit when rebuilding as the
DIST files do not need to be rebuilt every time:

  make -C deps/rabbitmq_management run-broker FAST_RUN_BROKER=0
    2,94s user 1,40s system 107% cpu 4,035 total
  make -C deps/rabbitmq_management run-broker FAST_RUN_BROKER=0 -j8
    2,85s user 1,51s system 138% cpu 3,140 total

Therefore it only makes sense to remove FAST_RUN_BROKER,
and instead use the old method which is both more correct
and has more potential for optimisation.
2024-06-26 16:53:07 +02:00
Loïc Hoguin a64d1e67fc
Remove looking_glass
It has largely been superseded by `perf`. It is no longer
generally useful. It can always be added to BUILD_DEPS for
the rare cases it is needed, or installed locally and
pointed to by setting its path to ERL_LIBS.
2024-06-26 09:56:46 +02:00
Loïc Hoguin 2b03233ac1
make: Remove rabbitmq-macros.mk
It hasn't been used for some time. If compare_version
becomes necessary again in the future, it's in the history.
2024-06-25 13:39:38 +02:00
Loïc Hoguin 9f15e978b1
make: Remove xrefr
It is no longer used by Erlang.mk.
2024-06-25 13:08:08 +02:00
Loïc Hoguin 7e9cac3d00
make: Remove Travis-specific targets/config
This should no longer be used.
2024-06-24 14:12:02 +02:00
Loïc Hoguin 881ebc6138
make: Remove ANT variables
This should no longer be used.
2024-06-24 14:06:48 +02:00
Loïc Hoguin 31310d2315
make: Simplify looking for DEPS_DIR
With the monorepo the dependencies are either correct
or are the parent directory (when we are in a rabbit
application in deps/).
2024-06-24 14:06:46 +02:00
Loïc Hoguin efb695548a
make: Don't start all when run-broker a specific plugin
When FAST_RUN_BROKER=1 was introduced it helped reduce the
time to run the broker, but mistakenly was always starting
all plugins even when running run-broker against a specific
plugin, for example `make -C deps/rabbitmq_management run-broker`.

  Starting broker... completed with 36 plugins.

With this commit only the target plugin (and its dependencies)
will be started.

  Starting broker... completed with 3 plugins.

This also has a positive effect on start performance:

  make -C deps/rabbitmq_management run-broker  2,28s user 2,11s system 88% cpu 4,943 total
  make -C deps/rabbitmq_management run-broker  2,00s user 1,61s system 94% cpu 3,807 total
2024-06-13 10:37:28 +02:00
Michal Kuratczyk fde99508db
make restart-cluster (#11427)
Implement a rolling cluster restart similar
to what the Kubernetes Operator does
2024-06-11 12:25:49 +02:00
Loïc Hoguin fb339ebe7f
make: Don't search for rabbit/scripts
With the monorepo I do not believe we need to worry about
where the scripts are. They are always in deps/rabbit/scripts.
So we copy them from there directly.

This does not improve performance but should work better on
older environments.
2024-06-10 09:42:33 +02:00
Loïc Hoguin 3aa829fb9d
make: In install-scripts copy files all at once
Rather than one by one. I do not know why it was done that
way, but since that dates back before the monorepo, it may
no longer be necessary.

This has a small but noticeable speedup when building:

  make -C deps/rabbit  0,44s user 0,11s system 101% cpu 0,546 total
  make -C deps/rabbitmq_management  0,65s user 0,18s system 101% cpu 0,816 total

  make -C deps/rabbit  0,41s user 0,11s system 101% cpu 0,510 total
  make -C deps/rabbitmq_management  0,57s user 0,21s system 101% cpu 0,778 total
2024-06-10 09:42:33 +02:00
Loïc Hoguin 4f1ea93545
make: Restrict install-cli to the current working directory
Commit 5840834fa8 introduced
copying of scripts and escripts to the plugin currently
being worked on. At some point after that, in recent weeks,
the target would run for all applications being compiled,
and not just the plugin we have asked Make to build. This
led to increased build times.

This change ensures the scripts and escripts are only
copied for the directory we have ran Make in. So if
we simply do "make" this is the top-level directory.
If we do "make -C deps/rabbit" this is the rabbit
application's directory.

Doing this has a huge impact on performance when
rebuilding with no changes done to the source code:

  make  6,63s user 2,60s system 106% cpu 8,668 total
  make  2,88s user 1,30s system 117% cpu 3,567 total

And a less pronounced impact on specific applications
(results will vary):

  make -C deps/rabbit  0,50s user 0,18s system 100% cpu 0,677 total
  make -C deps/rabbit  0,43s user 0,12s system 101% cpu 0,551 total
2024-06-10 09:42:33 +02:00
Loïc Hoguin de8df83996
make: Easy code reloading for run-broker/start-cluster
This enables code reloading for single nodes and
for clusters. For single nodes using `make run-broker`
at least two terminals must be used: the one with
the broker, and the one doing the reloading.

When only using a single node (`make run-broker`),
the `RELOAD=1` variable can be passed to Make when
recompiling. This will lead to code reloading at
the end of compilation.

  make RELOAD=1

Alternatively the "reload-broker" target can be used:

  make all reload-broker

Special care must be given when the -j flag is used.
In that case it may be needed to separate compilation
and reloading in two separate calls:

  make && make reload-broker

The same considerations apply to clusters, only there
isn't a shorthand variable for them. Instead, the
"reload-cluster" target must be used:

  make all reload-cluster

Or:

  make && make reload-cluster

Either of these will compile and reload the modules
on all nodes of the cluster.

It is also possible to reload modules only on some nodes,
using `make reload-broker` with the variable "RABBITMQ_NODENAME"
set to the node you want to trigger a reload on. This could
be used to test scenarios where the code differs between
the nodes in the cluster.
2024-06-10 09:42:33 +02:00
Loïc Hoguin 769f19b58a
make: Don't build dist for run-broker by default
During development we want `make run-broker` to execute fast,
yet still pick up the changes we made in rabbit applications.
We can already do this by setting the appropriate variables.
This commit makes it so that this is the default. Now instead
of depending on the `dist` target we run plugins from the deps/
directory. And we depend on `all` to pick up changes.

This is equivalent to running
`make run-broker PLUGINS_FROM_DEPS_DIR=1 DIST_TARGET=all`.

It can be disabled by setting `FAST_RUN_BROKER=0`.

It doesn't invalide the `NOBUILD=1` variable which lets us
run the broker without recompiling (used in tests). It also
doesn't make `NOBUILD=1` faster (or slower).

The difference when running `make run-broker` by default is
roughly half the time of what it was before:

  make run-broker  16,67s user 10,42s system 101% cpu 26,567 total
  make run-broker  8,75s user 4,40s system 102% cpu 12,873 total

And it also applies to `make start-cluster`:

  make start-cluster  26,32s user 15,15s system 141% cpu 29,279 total
  make start-cluster  18,09s user 8,76s system 170% cpu 15,726 total
2024-06-10 09:42:33 +02:00
Jean-Sébastien Pédron 643fd53d88
rabbitmq-early-test.mk: Use same Dialyzer options as in Bazel 2024-05-24 11:06:11 +02:00
Rin Kuryloski fef064c906 Reduce ineffeciency introduced in b636f41
Use "ERL_LIBS =" instead of "ERL_LIBS :=" so that $(shell ... is not
called so often
2024-05-22 12:31:55 +02:00
Rin Kuryloski b636f41ef2 Allow adding rabbitmqctl to PLT_APPS 2024-04-29 12:47:10 +02:00
Jean-Sébastien Pédron e1a315e850
rabbit_peer_discovery: Use classic config peer discovery for `make start-cluster`
[Why]
So far, we use the CLI to create the cluster after starting the
individual nodes.

It's faster to use peer discovery and gives more exposure to the
feature. Thus it will be easier to quickly test changes to the peer
discovery subsystem with a simple `make start-cluster`.

[How]
We pass the classic configuration `cluster_nodes` application
environment variable to all nodes' command line.

This is only when the target is `start-cluster`, not `start-brokers`.
2023-12-07 15:51:54 +01:00
Jean-Sébastien Pédron d24315de55
rabbitmq-dist.mk: Install CLI scripts as part of the build
... instead of the `dist` target.

[Why]
We already do that when building tests. Thus it is more consistent to do
the same.

Also, it makes sense to ensure everything is ready before the `dist`
step. For instance, an Erlang release would not depend on the `dist`
target, just the build and it would still need the CLI to be ready.
2023-11-23 12:40:14 +01:00
Jean-Sébastien Pédron a26f95d26d
rabbitmq-run.mk: No need to {stop,start}_app when clustering
[Why]
`rabbitmqctl join_cluster` now takes care of stopping and restarting
whatever needs to be dealt with.
2023-10-26 11:22:48 +02:00
Jean-Sébastien Pédron 414f9509e1
rabbitmq-run.mk: Start nodes in parallel in `start-{brokers,cluster}`
[Why]
For Mnesia, we don't really care. However, for the upcoming use of
Khepri, we need that because the cluster will require at least a quorum
number of nodes to start to become available.

[How]
We simply rely on the shell's job management and wait for them to
complete.

We do the same for `stop-{brokers,cluster}` mostly for consistency's
sake.

It also makes starting nodes slightly faster.
2023-09-05 17:30:57 +02:00
Rin Kuryloski 0be657ee14 Fix offline `make dist`
See #7869. #7875 resulted in elixir apps (besides the cli) in the deps
dir. This triggered dormant makefile logic to compile such deps. It
turns out that it's unnecessary to pre-compile them, given the cli's
mix.exs file.
2023-05-16 12:05:25 +02:00
Luke Bakken cedf909270
Update mix_task_archve_deps to 1.0.0
Also update with SHA512 so that the download and install via `mix archive.install` works.

Related to: https://groups.google.com/g/rabbitmq-users/c/mSJMjyE20Nk
2022-12-12 16:43:32 -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
Luke Bakken 74cddc29ab
Update from `master` to `main`
Fixes #5980

Reference rabbitmq/rabbitmq-metronome#16
2022-10-03 12:32:04 -07:00
Philip Kuryloski 2e62cae69e Use rabbitmqctl await_startup instead if erl eval
when starting background nodes for tests
2022-05-04 13:33:03 +02:00