Commit Graph

93 Commits

Author SHA1 Message Date
Philip Kuryloski 3c0617eef0 use is_process_alive for a cleaner test
according to Michael's suggestion
2020-03-23 15:26:31 +01:00
Philip Kuryloski 16151baba3 Add worker_pool:dispatch_sync funtion
dispatch_sync sits inbetween the behavior of submit and submit_async,
blocking the caller until a worker begins the task, as opposed
to not blocking at all, or blocking util the task has finished.
This is useful when you want to throttle submissions to the pool
from a single process, such that all workers are busy, but there
exists no backlog of work for the pool.
2020-03-20 15:22:19 +01:00
Jean-Sébastien Pédron fa4b552a9b Update copyright (year 2020) 2020-03-10 15:26:49 +01:00
Jean-Sébastien Pédron dea423ad36 rabbit_env: Add `$RABBITMQ_CONFIG_FILES`
It is used to specify additional configuration files when using the
Cuttlefish format.

[#171491267]
2020-02-26 15:35:57 +01:00
Jean-Sébastien Pédron 3aa7dd1adb rabbit_env: Add $RABBITMQ_{PRODUCT_NAME,PRODUCT_VERSION,MOTD_FILE}
They are used to override the product name and version, and expand the
banners which are printed and logged on startup.

[#170054940]
2020-02-20 17:48:54 +01:00
Philip Kuryloski bc7e8e19f2 Remove systemd_notify_socket
The env var is now handled directly by rabbitmq_prelaunch rabbit_boot_state_systemd
2020-02-07 10:46:17 +01:00
Jean-Sébastien Pédron 994d0d4116 rabbit_env_SUITE: Check if $RABBITMQ_FEATURE_FLAGS is overridden
This happens when testing mixed-versions cluster in CI. This fixes the
test after commit 23a0a07e3a.

[#170149339]
2020-02-04 15:19:37 +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 ad8dbdaed6 rabbit_nodes_common: New name_type/1 function
It guesses the node name type, based on the host part of a node name.
I.e., if it contains at least a `.` character, it's a longname.

This matches the verification `net_kernel` does to make sure the node
name corresponds to the shortnames/longnames option.
2020-01-22 12:05:15 +01:00
Jean-Sébastien Pédron 23a0a07e3a rabbit_env: Record variables' origin
I.e. we record the fact that a particular value:
  * is the default value, or
  * comes from an environment variable, or
  * comes from querying a remote node

This required a significant refactoring of the module, which explains
the large diff.

At the same time, the testsuite was extended to cover more code and
situations.

This work permits us to move remaining environment variables checked by
`rabbit` to this module. They include:
  * $RABBITMQ_LOG_FF_REGISTRY
  * $RABBITMQ_FEATURE_FLAGS
  * $NOTIFY_SOCKET

[#170149339]
2020-01-21 12:46:06 +01:00
Jean-Sébastien Pédron 77b655bc71 rabbit_env: New module to prepare context based on environment
... and default values.

It can also query a remote node for some specific values. The use case
is the CLI which should know what the RabbitMQ node it controls uses
exactly.

It supports several new environment variables:

  RABBITMQ_DBG:
    Used to setup `dbg` for some simple tracing scenarios.

  RABBITMQ_ENABLED_PLUGINS:
    Used to list plugins to enable automatically on node startup.

  RABBITMQ_KEEP_PID_FILE_ON_EXIT:
    Used to indicate if the PID file should be removed or kept when the
    node exits.

  RABBITMQ_LOG:
    Used to configure the global and per-category log levels and enable
    ANSI colors.
2019-12-11 14:45:35 +01:00
Michael Klishin 5aef852257 Move some helpers from rabbitmq-management
Part of rabbitmq/rabbitmq-management#749.
2019-11-12 03:07:14 +03:00
Michael Klishin 485888bbcd Switch to eunit macros for assertions 2019-08-17 05:47:42 +10:00
codeadict 5fb17b0943 Add stop{1,3} functions to gen_server2
These functions utilize proc_lib:stop, which in turn utilizes sys:terminate.

They were introduced in
9d7d1207ff.

Closes: #266
2019-08-16 12:14:48 -04:00
Spring Operator 882876297b URL Cleanup
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener).

# HTTP URLs that Could Not Be Fixed
These URLs were unable to be fixed. Please review them to see if they can be manually resolved.

* http://blog.listincomprehension.com/search/label/procket (200) with 1 occurrences could not be migrated:
   ([https](https://blog.listincomprehension.com/search/label/procket) result ClosedChannelException).
* http://dozzie.jarowit.net/trac/wiki/TOML (200) with 1 occurrences could not be migrated:
   ([https](https://dozzie.jarowit.net/trac/wiki/TOML) result SSLHandshakeException).
* http://dozzie.jarowit.net/trac/wiki/subproc (200) with 1 occurrences could not be migrated:
   ([https](https://dozzie.jarowit.net/trac/wiki/subproc) result SSLHandshakeException).
* http://e2project.org (200) with 1 occurrences could not be migrated:
   ([https](https://e2project.org) result AnnotatedConnectException).
* http://erlang.org/doc/apps/erts/erl_ext_dist.html (200) with 1 occurrences could not be migrated:
   ([https](https://erlang.org/doc/apps/erts/erl_ext_dist.html) result ConnectTimeoutException).
* http://erlang.org/doc/man/erlang.html (200) with 1 occurrences could not be migrated:
   ([https](https://erlang.org/doc/man/erlang.html) result ConnectTimeoutException).
* http://nitrogenproject.com/ (200) with 2 occurrences could not be migrated:
   ([https](https://nitrogenproject.com/) result ConnectTimeoutException).
* http://proper.softlab.ntua.gr (200) with 1 occurrences could not be migrated:
   ([https](https://proper.softlab.ntua.gr) result SSLHandshakeException).
* http://yaws.hyber.org (200) with 1 occurrences could not be migrated:
   ([https](https://yaws.hyber.org) result AnnotatedConnectException).
* http://choven.ca (503) with 1 occurrences could not be migrated:
   ([https](https://choven.ca) result ConnectTimeoutException).

# Fixed URLs

## Fixed But Review Recommended
These URLs were fixed, but the https status was not OK. However, the https status was the same as the http request or http redirected to an https URL, so they were migrated. Your review is recommended.

* http://fixprotocol.org/ (301) with 1 occurrences migrated to:
  https://fixtrading.org ([https](https://fixprotocol.org/) result SSLHandshakeException).
* http://erldb.org (UnknownHostException) with 1 occurrences migrated to:
  https://erldb.org ([https](https://erldb.org) result UnknownHostException).
* http://host (UnknownHostException) with 1 occurrences migrated to:
  https://host ([https](https://host) result UnknownHostException).
* http://host:port/foo (UnknownHostException) with 2 occurrences migrated to:
  https://host:port/foo ([https](https://host:port/foo) result UnknownHostException).
* http://www.cs.indiana.edu/~burger/fp/index.html (301) with 1 occurrences migrated to:
  https://cs.indiana.edu/~burger/fp/index.html ([https](https://www.cs.indiana.edu/~burger/fp/index.html) result 404).

## Fixed Success
These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended.

* http://cloudi.org/ with 27 occurrences migrated to:
  https://cloudi.org/ ([https](https://cloudi.org/) result 200).
* http://en.wikipedia.org/wiki/X86-64 with 1 occurrences migrated to:
  https://en.wikipedia.org/wiki/X86-64 ([https](https://en.wikipedia.org/wiki/X86-64) result 200).
* http://erlware.org/ with 1 occurrences migrated to:
  https://erlware.org/ ([https](https://erlware.org/) result 200).
* http://inaka.github.io/cowboy-trails/ with 1 occurrences migrated to:
  https://inaka.github.io/cowboy-trails/ ([https](https://inaka.github.io/cowboy-trails/) result 200).
* http://lukego.livejournal.com/6753.html with 1 occurrences migrated to:
  https://lukego.livejournal.com/6753.html ([https](https://lukego.livejournal.com/6753.html) result 200).
* http://ninenines.eu with 6 occurrences migrated to:
  https://ninenines.eu ([https](https://ninenines.eu) result 200).
* http://semver.org/ with 1 occurrences migrated to:
  https://semver.org/ ([https](https://semver.org/) result 200).
* http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html with 1 occurrences migrated to:
  https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html ([https](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) result 200).
* http://www.actordb.com/ with 2 occurrences migrated to:
  https://www.actordb.com/ ([https](https://www.actordb.com/) result 200).
* http://www.cs.kent.ac.uk/projects/wrangler/Home.html with 1 occurrences migrated to:
  https://www.cs.kent.ac.uk/projects/wrangler/Home.html ([https](https://www.cs.kent.ac.uk/projects/wrangler/Home.html) result 200).
* http://www.erlang.org/ with 2 occurrences migrated to:
  https://www.erlang.org/ ([https](https://www.erlang.org/) result 200).
* http://www.mail-archive.com/asn1@asn1.org/msg00460.html with 1 occurrences migrated to:
  https://www.mail-archive.com/asn1@asn1.org/msg00460.html ([https](https://www.mail-archive.com/asn1@asn1.org/msg00460.html) result 200).
* http://www.rabbitmq.com/ with 2 occurrences migrated to:
  https://www.rabbitmq.com/ ([https](https://www.rabbitmq.com/) result 200).
* http://www.rabbitmq.com/amqp-0-9-1-errata.html with 1 occurrences migrated to:
  https://www.rabbitmq.com/amqp-0-9-1-errata.html ([https](https://www.rabbitmq.com/amqp-0-9-1-errata.html) result 200).
* http://www.rabbitmq.com/memory.html with 1 occurrences migrated to:
  https://www.rabbitmq.com/memory.html ([https](https://www.rabbitmq.com/memory.html) result 200).
* http://www.rebar3.org with 1 occurrences migrated to:
  https://www.rebar3.org ([https](https://www.rebar3.org) result 200).
* http://code.google.com/p/clink/issues/detail?id=141 with 1 occurrences migrated to:
  https://code.google.com/p/clink/issues/detail?id=141 ([https](https://code.google.com/p/clink/issues/detail?id=141) result 301).
* http://contributor-covenant.org with 1 occurrences migrated to:
  https://contributor-covenant.org ([https](https://contributor-covenant.org) result 301).
* http://contributor-covenant.org/version/1/3/0/ with 1 occurrences migrated to:
  https://contributor-covenant.org/version/1/3/0/ ([https](https://contributor-covenant.org/version/1/3/0/) result 301).
* http://inaka.github.com/apns4erl with 1 occurrences migrated to:
  https://inaka.github.com/apns4erl ([https](https://inaka.github.com/apns4erl) result 301).
* http://inaka.github.com/edis/ with 1 occurrences migrated to:
  https://inaka.github.com/edis/ ([https](https://inaka.github.com/edis/) result 301).
* http://lasp-lang.org/ with 1 occurrences migrated to:
  https://lasp-lang.org/ ([https](https://lasp-lang.org/) result 301).
* http://msdn.microsoft.com/en-us/library/aa366778 with 1 occurrences migrated to:
  https://msdn.microsoft.com/en-us/library/aa366778 ([https](https://msdn.microsoft.com/en-us/library/aa366778) result 301).
* http://msdn.microsoft.com/en-us/library/bb540814 with 1 occurrences migrated to:
  https://msdn.microsoft.com/en-us/library/bb540814 ([https](https://msdn.microsoft.com/en-us/library/bb540814) result 301).
* http://rabbitmq.com/documentation.html with 1 occurrences migrated to:
  https://rabbitmq.com/documentation.html ([https](https://rabbitmq.com/documentation.html) result 301).
* http://saleyn.github.com/erlexec with 1 occurrences migrated to:
  https://saleyn.github.com/erlexec ([https](https://saleyn.github.com/erlexec) result 301).
* http://www.erlang.org/doc/system_principles/versions.html with 1 occurrences migrated to:
  https://www.erlang.org/doc/system_principles/versions.html ([https](https://www.erlang.org/doc/system_principles/versions.html) result 301).
* http://www.mozilla.org/MPL/ with 66 occurrences migrated to:
  https://www.mozilla.org/MPL/ ([https](https://www.mozilla.org/MPL/) result 301).
* http://zhongwencool.github.io/observer_cli with 1 occurrences migrated to:
  https://zhongwencool.github.io/observer_cli ([https](https://zhongwencool.github.io/observer_cli) result 301).
2019-03-20 03:13:48 -05:00
Arnaud Cogoluègnes c8726cf2ac Handle empty binary payload when delivering message
Fixes #299
2019-02-07 14:47:50 +01:00
Jean-Sébastien Pédron b4c944c880 rabbit_misc: Consider 3.7.x and 3.8.x+ compatible
... in version_minor_equivalent().

Note that we'll need a special case to exclude 3.7.x versions which
don't have the feature flags modules.

At the same time, we introduce the `strict_version_minor_equivalent()`
function which has the behavior the initial function had before. This is
used in the context of plugin compatibility checks: plugins can specify
a `broker_version_requirements` property and at this point, plugins
compatible with 3.7.x should not be considered as compatible with 3.8.x.

[#159298729]
2019-02-01 10:45:29 +01:00
Arnaud Cogoluègnes b204adab45 Add member/2 to priority_queue module
To check whether a value is in the queue or not. Handle both
non-priority and priority queue. Based on lists:member/2, does not take
into account the priority of the value in the queue to check equality.

References rabbitmq/rabbitmq-server#1743
2018-10-24 16:06:51 +02:00
Michael Klishin 752254d92d rabbit_misc:pget/{2,3}: support maps
References rabbitmq/rabbitmq-federation#67, rabbitmq/rabbitmq-federation#70,
rabbitmq/rabbitmq-federation#73, rabbitmq/rabbitmq-federation#75.
2018-04-30 17:47:46 -05:00
Michael Klishin 2ac800d293 Introduce rabbit_data_coercion:{to_map/1, to_proplist/1}
References rabbitmq/rabbitmq-management#528, rabbitmq/rabbitmq-mqtt#156.
2018-01-02 22:25:16 +08:00
Gerhard Lazu 7f7bc843c3 Merge pull request #220 from rabbitmq/stop-gen_server2-stats-emissions-when-preparing-to-hibernate
Stop gen_server2 stats emissions when preparing to hibernate
2017-08-31 11:41:08 +02:00
Daniil Fedotov 0e02bcce6f Refactor gen_server2 stats callbacks.
Remove init_stats_fun callback, it is not used.
Do not use helper functions to call the callbacks,
it can cause weird performance issues.
2017-08-30 17:12:30 +01:00
Daniil Fedotov ee66704ffd Make tests compatible with R16B03 2017-08-30 12:57:44 +01:00
Daniil Fedotov 1b156cafa1 Add more checks to stats timer test. Fix expectations 2017-08-30 12:13:34 +01:00
Daniil Fedotov a1a1665b54 Add stats emission tests cleanup. Fix some expectations. 2017-08-29 18:35:23 +01:00
Daniil Fedotov f32476acf6 Test gen_server2 stats emission.
Test stats timer.
Test rabbit_core_metrics collection.
Test that stats timer stops on hibernation.
Test that stats timer stops on backoff.
2017-08-29 18:07:04 +01:00
Michael Klishin 355b8b8327 Merge branch 'stable' 2017-07-11 03:42:16 +03:00
Gerhard Lazu 8874e551cc Default memory high watermark to 1.0 when using a higher value
Prior to this change, setting the vm_memory_high_watermark to a value
higher than 1 (inclusive), would default to 0.4. This is different from
the behaviour when setting an absolute value, namely defaulting to the
total memory available.

Extracted common memory-related macros & records so that they can be
shared by tests.

re rabbitmq/rabbitmq-server#1285

[finishes #148470947]
2017-07-10 15:10:01 +01:00
Michael Klishin 872a61417d Merge branch 'stable' 2017-06-27 09:18:22 +03:00
Gerhard Lazu 6e270ed706 Add OTP version to server properties during connection negotiation
Even thought I was leaning towards EUnit at first, since CT was already there
and is already used for unit testing, it made the choice easy. I didn't
like the fact that I had to export the function to test it, but maybe
I'm missing something.

As for the test itself, I tried a couple of approaches and finally
settled on "if it starts with 'Erlang/OTP (MAJOR_VERSION)`, we're good.
Happy to hear better alternatives.
2017-06-26 21:55:57 +01:00
Jean-Sébastien Pédron 78d33ce463 unit_SUITE: Move auth_backend_internal_expand_topic_permission() to rabbitmq-server
The module it tests was already moved.

[#147436507]
2017-06-26 18:41:18 +02:00
Luke Bakken c7c8e9be77 Ensure amqp_client is a test dependency 2017-06-19 08:46:56 -07:00
Arnaud Cogoluègnes 0f9ee30883 Get topic variables to expand from AMQP params
Variables to expand are extracted from the AMQP params
(only internal, not network). This allows to propagate
some upstream variables (e.g. MQTT client_id).

References rabbitmq/rabbitmq-server#1229
2017-06-07 14:37:03 +02:00
Arnaud Cogoluègnes cb47d6e44a Expand username & vhost variables in topic perms
The expansion is done inside the internal authz backend
and the variables to expand are provided in a map from
the context parameter. This decoupling allows to provide
different variables to expand based on the caller context
(e.g. add other variables to expand from the MQTT plugin).

References rabbitmq/rabbbitmq-server#1229
2017-05-24 15:23:31 +02:00
Daniil Fedotov 968fc8a578 Do not assume Node part format in Pid binary.
Pid binary format has changed in OTP-20.0.
We can still get the node using node/1, so we can
skip the node part when decomposing a pid.
Added unit tests for decomposing and composing a pid and changing
the node.
2017-05-19 12:23:34 +01:00
Daniil Fedotov 349d881754 Do not assume Node part format in Pid binary.
Pid binary format has changed in OTP-20.0.
We can still get the node using node/1, so we can
skip the node part when decomposing a pid.
Added unit tests for decomposing and composing a pid and changing
the node.
2017-05-11 18:44:18 +01:00
Loïc Hoguin 6e87e1c3f7 Rename mochinum, mochiweb_util and ec_semver modules
They are pulled by amqp_client and can create conflicts with
other libraries when developers build releases with the Rabbit
client and Mochiweb, for example.

* mochiweb_util -> rabbit_http_util
* mochinum -> rabbit_numerical
* ec_semver -> rabbit_semver
2016-11-24 16:18:39 +01:00
Daniil Fedotov a9fcdd4520 No need for rand_compat 2016-11-21 16:25:16 +00:00
Arnaud Cogoluègnes 9b87acd2bb Move rabbit_pbe module to rabbitmq-common
So new CLI can use it.

References rabbitmq/rabbitmq-cli#118
2016-11-18 16:05:06 +01:00
Daniil Fedotov d6614c6bc7 4-number versions and binary versions test 2016-10-13 13:26:24 +01:00
Andrew Bruce 14a180ff85 Special case for 3.6.6 in version_minor_equivalent
3.6.6 will introduce a change to the schema.
e.g. 3.6.6 is not compatible with 3.6.5
This special case can be removed once 3.6.x reaches EOL

[#132175569]
2016-10-12 17:54:54 +01:00
Andrew Bruce 64238b139d Support semver-style prerelease identifiers in version parsing
Use ec_semver from erlware for implementation. This is the same module
used in rebar3.

This changes some existing behaviour, e.g.:

3.0 is now minor-equivalent to 3.0.0 and 3.0.0.1
'master' is now a valid in version_compare

Add property tests

[#131650399]
2016-10-12 17:54:46 +01:00
Jean-Sébastien Pédron 7df21e0ad0 unit_SUITE: add version equivalence tests
Moved from rabbitmq-server

[#131650399]
2016-10-12 17:44:01 +01:00