|
| 1 | +## Overview |
| 2 | + |
| 3 | +RabbitMQ projects use pull requests to discuss, collaborate on and accept code contributions. |
| 4 | +Pull requests is the primary place of discussing code changes. |
| 5 | + |
| 6 | +## How to Contribute |
| 7 | + |
| 8 | +The process is fairly standard: |
| 9 | + |
| 10 | + * Present your idea to the RabbitMQ core team using [GitHub Discussions](https://github.com/rabbitmq/rabbitmq-server/discussions) or [RabbitMQ community Discord server](https://rabbitmq.com/discord) |
| 11 | + * Fork the repository or repositories you plan on contributing to |
| 12 | + * Run `git clean -xfffd && gmake clean && gmake distclean && gmake` to build all subprojects from scratch |
| 13 | + * Create a branch with a descriptive name |
| 14 | + * Make your changes, run tests, ensure correct code formatting, commit with a [descriptive message](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html), push to your fork |
| 15 | + * Submit pull requests with an explanation what has been changed and **why** |
| 16 | + * Submit a filled out and signed [Contributor Agreement](https://cla.pivotal.io/) if needed (see below) |
| 17 | + * Be patient. We will get to your pull request eventually |
| 18 | + |
| 19 | + |
| 20 | +## Running Tests |
| 21 | + |
| 22 | +Test suites of individual subprojects can be run from the subproject directory under |
| 23 | +`deps/*`. For example, for the core broker: |
| 24 | + |
| 25 | +``` shell |
| 26 | +# Running all server suites in parallel will take between 30 and 40 minutes on reasonably |
| 27 | +# recent multi-core machines. This is rarely necessary in development environments. |
| 28 | +# Running individual test suites or groups of test suites can be enough. |
| 29 | +# |
| 30 | + |
| 31 | +# Before you start: this will terminate all running nodes, make processes and Common Test processes |
| 32 | +killall -9 beam.smp; killall -9 erl; killall -9 make; killall -9 epmd; killall -9 erl_setup_child; killall -9 ct_run |
| 33 | + |
| 34 | +# the core broker subproject |
| 35 | +cd deps/rabbit |
| 36 | + |
| 37 | +# cleans build artifacts |
| 38 | +git clean -xfffd |
| 39 | +gmake clean; gmake distclean |
| 40 | + |
| 41 | +# builds the broker and all of its dependencies |
| 42 | +gmake |
| 43 | +# runs an integration test suite, tests/rabbit_fifo_SUITE with CT (Common Test) |
| 44 | +gmake ct-rabbit_fifo |
| 45 | +# runs an integration test suite, tests/quorum_queue_SUITE with CT (Common Test) |
| 46 | +gmake ct-quorum_queue |
| 47 | +# runs an integration test suite, tests/queue_parallel_SUITE with CT (Common Test) |
| 48 | +gmake ct-queue_parallel |
| 49 | +# runs a unit test suite tests/unit_log_management_SUITE with CT (Common Test) |
| 50 | +gmake ct-unit_log_management |
| 51 | +``` |
| 52 | + |
| 53 | +### Running Specific Groups or Tests |
| 54 | + |
| 55 | +All `ct-*` Make targets support a `t=` argument which are transformed to [`-group` and `-case` Common Test runner options](https://www.erlang.org/doc/apps/common_test/run_test_chapter.html). |
| 56 | + |
| 57 | +``` shell |
| 58 | +# Runs a a group of tests named 'all_tests_with_prefix' in suite 'test/rabbit_mgmt_http_SUITE.erl' |
| 59 | +gmake ct-rabbit_mgmt_http t="all_tests_with_prefix" |
| 60 | + |
| 61 | +# Runs a test named 'users_test' in group 'all_tests_with_prefix' in suite 'test/rabbit_mgmt_http_SUITE.erl' |
| 62 | +gmake ct-rabbit_mgmt_http t="all_tests_with_prefix:users_test" |
| 63 | +# Runs a test named 'queues_test' in group 'all_tests_with_prefix' in suite 'test/rabbit_mgmt_http_SUITE.erl' |
| 64 | +gmake ct-rabbit_mgmt_http t="all_tests_with_prefix:queues_test" |
| 65 | +``` |
| 66 | + |
| 67 | +### Running Tests with a Specific Schema Data Store |
| 68 | + |
| 69 | +Set `RABBITMQ_METADATA_STORE` to either `khepri` or `mnesia` to make the Common Test suites |
| 70 | +use a specific [schema data store]() (metadata store): |
| 71 | + |
| 72 | +``` shell |
| 73 | +RABBITMQ_METADATA_STORE=khepri gmake ct-quorum_queue |
| 74 | +``` |
| 75 | + |
| 76 | +Or, with Nu shell: |
| 77 | + |
| 78 | +```nu |
| 79 | +with-env {'RABBITMQ_METADATA_STORE': 'khepri'} { gmake ct-quorum_queue } |
| 80 | +``` |
| 81 | + |
| 82 | + |
| 83 | +## Running Single Nodes from Source |
| 84 | + |
| 85 | +``` shell |
| 86 | +# Run from repository root. |
| 87 | +# Starts a node with the management plugin enabled |
| 88 | +gmake run-broker RABBITMQ_PLUGINS=rabbitmq_management |
| 89 | +``` |
| 90 | + |
| 91 | +The nodes will be started in the background. They will use `rabbit@{hostname}` for its name, so CLI will be able to contact |
| 92 | +it without an explicit `-n` (`--node`) argument: |
| 93 | + |
| 94 | +```shell |
| 95 | +# Run from repository root. |
| 96 | +./sbin/rabbitmq-diagnostics status |
| 97 | +``` |
| 98 | + |
| 99 | +## Running Clusters from Source |
| 100 | + |
| 101 | +``` shell |
| 102 | +# Run from repository root. |
| 103 | +# Starts a three node cluster with the management plugin enabled |
| 104 | +gmake start-cluster NODES=3 RABBITMQ_PLUGINS=rabbitmq_management |
| 105 | +``` |
| 106 | + |
| 107 | +The node will use `rabbit-{n}@{hostname}` for names, so CLI must |
| 108 | +be explicitly given explicit an `-n` (`--node`) argument in order to |
| 109 | +contact one of the nodes: |
| 110 | + |
| 111 | + * `rabbit-1` |
| 112 | + * `rabbit-2` |
| 113 | + * `rabbit-3` |
| 114 | + |
| 115 | +The names of the nodes can be looked up via |
| 116 | + |
| 117 | +``` shell |
| 118 | +epmd -names |
| 119 | +``` |
| 120 | + |
| 121 | +``` shell |
| 122 | +# Run from repository root. |
| 123 | +# Makes CLI tools talk to node rabbit-2 |
| 124 | +sbin/rabbitmq-diagnostics cluster_status -n rabbit-2 |
| 125 | + |
| 126 | +# Run from repository root. |
| 127 | +# Makes CLI tools talk to node rabbit-1 |
| 128 | +sbin/rabbitmq-diagnostics status -n rabbit-1 |
| 129 | +``` |
| 130 | + |
| 131 | +To stop a previously started cluster: |
| 132 | + |
| 133 | +``` shell |
| 134 | +# Run from repository root. |
| 135 | +# Stops a three node cluster started earlier |
| 136 | +gmake stop-cluster NODES=3 |
| 137 | +``` |
| 138 | + |
| 139 | + |
| 140 | +## Working on Management UI with BrowserSync |
| 141 | + |
| 142 | +When working on management UI code, besides starting the node with |
| 143 | + |
| 144 | +``` shell |
| 145 | +# starts a node with the management plugin enabled |
| 146 | +gmake run-broker RABBITMQ_PLUGINS=rabbitmq_management |
| 147 | +``` |
| 148 | + |
| 149 | +(or any other set of plugins), it is highly recommended to use [BrowserSync](https://browsersync.io/#install) |
| 150 | +to shorten the edit/feedback cycle for JS files, CSS, and so on. |
| 151 | + |
| 152 | +First, install BrowserSync using NPM: |
| 153 | + |
| 154 | +``` shell |
| 155 | +npm install -g browser-sync |
| 156 | +``` |
| 157 | + |
| 158 | +Assuming a node running locally with HTTP API on port `15672`, start |
| 159 | +a BrowserSync proxy like so: |
| 160 | + |
| 161 | +``` shell |
| 162 | +cd deps/rabbitmq_management/priv/www |
| 163 | + |
| 164 | +browser-sync start --proxy localhost:15672 --serverStatic . --files . |
| 165 | +``` |
| 166 | + |
| 167 | +BrowserSync will automatically open a browser window for you to use. The window |
| 168 | +will automatically refresh when one of the static (templates, JS, CSS) files change. |
| 169 | + |
| 170 | +All HTTP requests that BrowserSync does not know how to handle will be proxied to |
| 171 | +the HTTP API at `localhost:15672`. |
| 172 | + |
| 173 | + |
| 174 | +## Formatting the RabbitMQ CLI |
| 175 | + |
| 176 | +The RabbitMQ CLI uses the standard [Elixir code formatter](https://hexdocs.pm/mix/main/Mix.Tasks.Format.html). To ensure correct code formatting of the CLI: |
| 177 | + |
| 178 | +``` |
| 179 | +cd deps/rabbitmq_cli |
| 180 | +mix format |
| 181 | +``` |
| 182 | + |
| 183 | +Running `make` will validate the CLI formatting and issue any necessary warnings. Alternatively, run the format checker in the `deps/rabbitmq_cli` directory: |
| 184 | + |
| 185 | +``` |
| 186 | +mix format --check-formatted |
| 187 | +``` |
| 188 | + |
| 189 | +## Code of Conduct |
| 190 | + |
| 191 | +See [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md). |
| 192 | + |
| 193 | +## Contributor Agreement |
| 194 | + |
| 195 | +If you want to contribute a non-trivial change, please submit a signed copy of our |
| 196 | +[Contributor Agreement](https://cla.pivotal.io/) around the time |
| 197 | +you submit your pull request. This will make it much easier (in some cases, possible) |
| 198 | +for the RabbitMQ team at Pivotal to merge your contribution. |
| 199 | + |
| 200 | +## Where to Ask Questions |
| 201 | + |
| 202 | +If something isn't clear, feel free to ask on [GitHub Discussions](https://github.com/rabbitmq/rabbitmq-server/discussions) |
| 203 | +and [community Discord server](https://rabbitmq.com/discord). |
0 commit comments