Commit Graph

144 Commits

Author SHA1 Message Date
Alexey Lebedeff 87532c4af4 Make test/development related makefile vars lazy
They were trying to run `hostname` and `which`, which produced a bunch
of error messages in a hermetic build environment.

And performance of those `shell` calls is not very important, as they
are caled just a few times during script runtime anyway (there is a
hack to make these lazy, but evaluating only once - but it's hardly
worth it).
2021-08-06 17:32:04 +02:00
Pavel Heimlich 020b22f9ea fix hostname(1) calls on Solaris 2021-06-17 13:23:05 +02:00
Arnaud Cogoluègnes c42930acb0
Set stream plugin default port to 5552 2021-05-19 15:38:52 +02:00
kjnilsson b576242952 Increase rabbit_stream_queue_SUITE timetrap
And set the default of make start-cluster to 3 nodes.
2021-04-06 15:50:22 +01:00
Philip Kuryloski 768a87980d Remove extra spaces in the RABBITMQ_PLUGINS_DIR during tests 2021-03-29 16:59:53 +02:00
Philip Kuryloski 0e7b537af7 Fix self-referencing recursive make variable
Introduced in 388654c542
2021-03-29 14:18:17 +02:00
Philip Kuryloski 388654c542
Add a partial Bazel build (#2938)
Adds WORKSPACE.bazel, BUILD.bazel & *.bzl files for partial build & test with Bazel. Introduces a build-time dependency on https://github.com/rabbitmq/bazel-erlang
2021-03-29 11:01:43 +02:00
Jean-Sébastien Pédron cdcf602749
Switch from Lager to the new Erlang Logger API for logging
The configuration remains the same for the end-user. The only exception
is the log root directory: it is now set through the `log_root`
application env. variable in `rabbit`. People using the Cuttlefish-based
configuration file are not affected by this exception.

The main change is how the logging facility is configured. It now
happens in `rabbit_prelaunch_logging`. The `rabbit_lager` module is
removed.

The supported outputs remain the same: the console, text files, the
`amq.rabbitmq.log` exchange and syslog.

The message text format slightly changed: the timestamp is more precise
(now to the microsecond) and the level can be abbreviated to always be
4-character long to align all messages and improve readability. Here is
an example:

    2021-03-03 10:22:30.377392+01:00 [dbug] <0.229.0> == Prelaunch DONE ==
    2021-03-03 10:22:30.377860+01:00 [info] <0.229.0>
    2021-03-03 10:22:30.377860+01:00 [info] <0.229.0>  Starting RabbitMQ 3.8.10+115.g071f3fb on Erlang 23.2.5
    2021-03-03 10:22:30.377860+01:00 [info] <0.229.0>  Licensed under the MPL 2.0. Website: https://rabbitmq.com

The example above also shows that multiline messages are supported and
each line is prepended with the same prefix (the timestamp, the level
and the Erlang process PID).

JSON is also supported as a message format and now for any outputs.
Indeed, it is possible to use it with e.g. syslog or the exchange. Here
is an example of a JSON-formatted message sent to syslog:

    Mar  3 11:23:06 localhost rabbitmq-server[27908] <0.229.0> - {"time":"2021-03-03T11:23:06.998466+01:00","level":"notice","msg":"Logging: configured log handlers are now ACTIVE","meta":{"domain":"rabbitmq.prelaunch","file":"src/rabbit_prelaunch_logging.erl","gl":"<0.228.0>","line":311,"mfa":["rabbit_prelaunch_logging","configure_logger",1],"pid":"<0.229.0>"}}

For quick testing, the values accepted by the `$RABBITMQ_LOGS`
environment variables were extended:
  * `-` still means stdout
  * `-stderr` means stderr
  * `syslog:` means syslog on localhost
  * `exchange:` means logging to `amq.rabbitmq.log`

`$RABBITMQ_LOG` was also extended. It now accepts a `+json` modifier (in
addition to the existing `+color` one). With that modifier, messages are
formatted as JSON intead of plain text.

The `rabbitmqctl rotate_logs` command is deprecated. The reason is
Logger does not expose a function to force log rotation. However, it
will detect when a file was rotated by an external tool.

From a developer point of view, the old `rabbit_log*` API remains
supported, though it is now deprecated. It is implemented as regular
modules: there is no `parse_transform` involved anymore.

In the code, it is recommended to use the new Logger macros. For
instance, `?LOG_INFO(Format, Args)`. If possible, messages should be
augmented with some metadata. For instance (note the map after the
message):

    ?LOG_NOTICE("Logging: switching to configured handler(s); following "
                "messages may not be visible in this log output",
                #{domain => ?RMQLOG_DOMAIN_PRELAUNCH}),

Domains in Erlang Logger parlance are the way to categorize messages.
Some predefined domains, matching previous categories, are currently
defined in `rabbit_common/include/logging.hrl` or headers in the
relevant plugins for plugin-specific categories.

At this point, very few messages have been converted from the old
`rabbit_log*` API to the new macros. It can be done gradually when
working on a particular module or logging.

The Erlang builtin console/file handler, `logger_std_h`, has been forked
because it lacks date-based file rotation. The configuration of
date-based rotation is identical to Lager. Once the dust has settled for
this feature, the goal is to submit it upstream for inclusion in Erlang.
The forked module is calld `rabbit_logger_std_h` and is based
`logger_std_h` in Erlang 23.0.
2021-03-11 15:17:36 +01:00
Gerhard Lazu 5ac24dd2be
Make start-cluster work when run in the top-level
Subsequent nodes fail to start since ports are already in use. This
makes it possible to start multiple nodes locally with all plugins
enabled.

Signed-off-by: Gerhard Lazu <gerhard@lazu.co.uk>
2021-03-10 13:15:44 +00:00
Arnaud Cogoluègnes 7b1f7692c7
Use port 5551 for streams when starting cluster 2021-02-26 11:48:02 +01:00
Jean-Sébastien Pédron a45e87e57b
mk/rabbitmq-run.mk: Compute rabbitmq_stream TCP port based on $(RABBITMQ_NODE_PORT)
We already do this for other TCP ports RabbitMQ listens on. This fixes
the use of `gmake start-cluster` with the rabbitmq_stream plugin
enabled.
2021-02-25 10:47:50 +01:00
Arnaud Cogoluègnes 749faa85fa Add stream plugin port in start-cluster target 2020-09-30 14:41:59 +01:00
dcorbacho 0cec212896 Stream queue data dir 2020-09-30 14:41:59 +01:00
Luke Bakken af7466c1c8 Use PLATFORM to determine hostname command 2020-04-20 07:50:57 -07:00
Luke Bakken 30dbad3214 Use "hostname -s" only on Darwin
Fixes #374
2020-04-17 12:31:08 -07:00
Jean-Sébastien Pédron e3cd5fad8d rabbitmq-run.mk: Replace two CLI calls with fast equivalents
The CLI has a high startup time. To speed up the
`start-background-broker` and `stop-node` recipes, two CLI calls are
replaced by two more basic commands which achieve the same goal.
2020-04-14 14:20:04 +02:00
Jean-Sébastien Pédron c6b0d1a767 rabbitmq-run.mk: Remove uses of $RABBITMQ_SCHEMA_DIR
This is unused by RabbitMQ after the completion of
rabbitmq/rabbitmq-server#2180.
2020-03-19 10:36:39 +01:00
Jean-Sébastien Pédron bb3f355b37 rabbitmq-run.mk: Build RabbitMQ once when using start-{brokers,cluster}
... instead of once per started nodes.
2020-03-17 18:42:12 +01:00
Jean-Sébastien Pédron 13bbfa0dfd rabbitmq-run.mk: Use := instead of ?= in target-specific var. assignment
The documentation says we should be able to use ?=, but apparently it
affects the way variables are passed to sub-make.

The issue we had is that using: `make start-cluster RABBITMQ_CONFIG_FILE=...`
didn't work as expected: `$(RABBITMQ_CONFIG_FILE)` made it to the
sub-make but not to the sub-make's recipe.

Using := fixes the problem.

Doing that is ok because assigning `$(RABBITMQ_CONFIG_FILE)` in the
environment or on make(1)'s command line will override the
target-specific variable anyway.
2020-03-17 18:38:20 +01:00
Jean-Sébastien Pédron b175b2e667 rabbitmq-run.mk: Re-use $(comma) from Erlang.mk 2020-03-17 18:34:54 +01:00
Luke Bakken d59d332bd1 Fix leading tabs 2020-03-16 07:52:23 -07:00
Gerhard Lazu 382565c507 Double-escape \ so that the config file is generated correctly
Thanks @lukebakken!

Signed-off-by: Gerhard Lazu <gerhard@lazu.co.uk>
2020-03-16 10:52:39 +00:00
Gerhard Lazu 7bfbdba2df Use a better colour for all debug logs
They were plain by default & are now blue which works really well with
Gruvbox Dark. I couldn't change just the debug color, had to redefine
them all.

cc @dumbbell @lukebakken

Signed-off-by: Gerhard Lazu <gerhard@lazu.co.uk>
2020-03-13 23:21:03 +00:00
Gerhard Lazu 1da5f922fe Keep test_rabbitmq_config_with_tls in sync with the default one
Signed-off-by: Gerhard Lazu <gerhard@lazu.co.uk>
2020-03-13 23:19:39 +00:00
Gerhard Lazu f54691f4b9 Enable colourful debug logging by default
When running the broker locally, in dev, this is what most of us want.
To change this, use e.g. RABBITMQ_LOG=info (previous default).

Signed-off-by: Gerhard Lazu <gerhard@lazu.co.uk>
2020-03-11 12:02:04 +00:00
Jean-Sébastien Pédron 6d48b5f7d3 rabbitmq-run.mk: Set Ra's wal_sync_method to `sync`
This turns off WAL preallocation and saves 400+ MiB per node directory.

This setting only applies to nodes started with `make run-broker` or
from our testsuites. RabbitMQ default configuration remains unaffected.
2020-03-09 13:03:12 +01:00
Jean-Sébastien Pédron 5dc227a6eb rabbitmq-run.mk: Skip builds in `make run-broker NOBUILD=1`
This can allow for faster RabbitMQ startup time when we know there is
nothing to compile.
2020-03-03 18:33:46 +01:00
Jean-Sébastien Pédron 7638a5439f rabbitmq-run.mk: Set console log level to debug
Exactly as we previously set the file log level to debug.

Note that it does not enable logging on the console, it only changes the
default log level if the user of `make run-broker` enables console
logging (using `make run-broker RABBITMQ_LOGS=-`).

[#171131596]
2020-02-13 09:54:45 +01:00
Jean-Sébastien Pédron 780dd0de40 rabbit_env: Set $RABBITMQ_ENABLED_PLUGINS to an empty string to disable all plugins
The previous value accepted for this behavior was "NONE". But it's more
intuitive to set it to nothing.

`rabbitmq-run.mk` is also updated to allow `$RABBITMQ_ENABLED_PLUGINS`
to be overriden e.g. on the command line.
2020-01-24 12:54:43 +01:00
Jean-Sébastien Pédron 6ba6dd63f5 Merge pull request #344 from rabbitmq/lrb-mqtt-stomp-start-cluster
Add MQTT and STOMP port calc to start-cluster
2019-12-18 11:41:34 +01:00
Luke Bakken 101371778a Remove RABBITMQ_GENERATED_CONFIG_DIR
No longer applies after merge of rabbitmq/rabbitmq-server#2180
2019-12-16 11:00:12 -08:00
Luke Bakken edf8f892d4 Add MQTT and STOMP port calc to start-cluster 2019-12-12 07:35:38 -08:00
Jean-Sébastien Pédron e2f4fc3e04 rabbitmq-run.mk: Don't run rabbitmq-plugins(8) to enable plugins
This is handled by the `rabbitmq_prelaunch` application now, based on
the value of `$RABBITMQ_ENABLED_PLUGINS`.

`$(RABBITMQ_ENABLED_PLUGINS_FILE)` depended on `dist`. This dependency
was moved to individual `run-*` and `start-*` targets.

While here, re-use `test-dist` instead of `dist` if the build was
already done for tests.

The testsuites default to run `make test-dist` as a first step.
Therefore later, when it starts a node, it should re-use that instead of
depending on `make dist` which will rebuild the tested project and
remove test dependencies from plugins.

This is useful (and mandatory in fact) now that `rabbit` is packaged
like plugins because, in the case of rabbitmq-erlang-client for
instance, the broker is a `$(TEST_DEPS)`: if starting a node runs `make
dist`, the broker will be removed.
2019-12-11 14:45:39 +01:00
Jean-Sébastien Pédron 5840834fa8 rabbitmq-dist.mk, rabbitmq-run.mk: Copy scripts & escripts
... to the plugin being worked on, instead of locating `rabbit` and
taking the scripts there.

It greatly simplifies the use of RabbitMQ and plugins inside a
development working copy because the layout is closer to what we would
have in a package. I.e. there are far less special cases.
2019-12-11 14:45:39 +01:00
Jean-Sébastien Pédron 2625f43086 rabbitmq-run.mk: Fix generated rabbitmq-server configuration
To configure the AMQP TCP listener, the key is `tcp_listeners`, not
`listeners`.
2019-09-13 13:47:16 +02:00
Jean-Sébastien Pédron ad52a23bb5 rabbitmq-run.mk: Set $RABBITMQ_BASE
Otherwise on Windows, the broker may read system files: this would
pollute the test environment.
2019-09-03 18:14:38 +02:00
Jean-Sébastien Pédron 3dd58ae12a rabbitmq-run.mk: Bump `rabbitmqctl wait` timeout from 10 to 60 seconds
... when we wait for a node started in the background.

This helps when the PID is written asynchronously by the Erlang node
instead of the rabbitmq-server(8) script: in this case, the `rabbitmqctl
wait` command may start to wait earlier in the former situation than the
latter one, and thus timeout earlier.
2019-09-03 18:10:48 +02:00
Jean-Sébastien Pédron 57c14b1214 rabbitmq-{build,run,tools}.mk: Pass several variables to sub-makes
This saves a lot of time because:
1. we don't spawn a shell each time to compute the same value;
2. elixir(1) has a long startup time.

In my tests, a no-op gmake in `rabbit` goes from 2.5 seconds to 0.9
seconds.
2019-08-14 11:29:07 +02:00
Jean-Sébastien Pédron 79d7969c16 rabbitmq-run.mk: No need to find erl_call(1)
We don't use it anymore in the Makefiles. This speeds up the build
because we don't spawn a shell for something useless in the end.
2019-08-14 11:27:06 +02:00
Jean-Sébastien Pédron 16b702e0ca rabbitmq-run.mk: Use GNU Make functions to prepare $(DIST_ERL_LIBS)
... instead of Unix commands and a one-liner which assumes that `:` is
the path separator. This speeds up the build because we don't spawn a
shell.

While here, also remove `$(APPS_DIR)` from `$(ERL_LIBS)`.
2019-08-14 11:25:27 +02:00
Jean-Sébastien Pédron 4af40e2d25 rabbitmq-run.mk: Compute MQTT and STOMP TCP ports for `run-broker`
They are based on `$(RABBITMQ_NODE_PORT)`, like the management plugin's
computed port.
2019-07-26 13:20:57 +02:00
Gerhard Lazu 05b3f9dedd Fix start-brokers / start-cluster make target
`-ra data_dir` is not necessary. It was also missing a \
2019-05-09 18:02:14 +01:00
Gerhard Lazu fbe2ac4cdb Allow RABBITMQ_CONFIG_FILE make variable to be overwritten 2019-04-17 13:27:31 +01:00
Jean-Sébastien Pédron 844c591027 Revert "rabbitmq-run.mk: Increase lager message rate threshold from 50 to 5000"
We don't need this anymore, now that the high watermark is bumped
automatically when the log level is set to `debug` in rabbit_lager.

This reverts commit 49956c6423.
2019-03-18 11:41:28 +01:00
kjnilsson 1e6fed8e4e Replace use of erl_call with rabbitmqctl
The stop-node command is the only make target still using erl_call who
is prone to breakage (broken in OTP 21.3) and can readily be replaced
with rabbitmqctl stop.
2019-03-14 15:26:24 +00:00
Jean-Sébastien Pédron d216e67183 rabbitmq-run.mk: Set `$LEAVE_PLUGINS_DISABLED` to start broker without plugins
I.e, plugins are available but left disabled at broker start. It is
still possible to enable them using rabbitmq-plugins(1).
2019-03-01 15:52:38 +01:00
Jean-Sébastien Pédron ef6aa904c9 rabbitmq-run.mk: Allow to set `$RABBITMQ_PLUGINS_DIR` when starting a broker 2019-03-01 15:50:14 +01:00
Jean-Sébastien Pédron 49956c6423 rabbitmq-run.mk: Increase lager message rate threshold from 50 to 5000
Otherwise, it drops too many messages and the log file becomes useless
when debugging.
2019-02-01 10:45:29 +01:00
Jean-Sébastien Pédron 43e40f3370 rabbitmq-run.mk: Log debug messages when using `make run-broker` 2019-02-01 10:45:29 +01:00
Jean-Sébastien Pédron dca9cad83a rabbitmq-run.mk: Configure `$RABBITMQ_FEATURE_FLAGS`
[#159298729]
2019-02-01 10:45:29 +01:00