forked from rabbitmq/rabbitmq-server
-
Notifications
You must be signed in to change notification settings - Fork 1
/
rabbitmq.bzl
308 lines (285 loc) · 11 KB
/
rabbitmq.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
load(
"@rules_erlang//:erlang_app.bzl",
"DEFAULT_ERLC_OPTS",
"DEFAULT_TEST_ERLC_OPTS",
"erlang_app",
"test_erlang_app",
)
load(
"@rules_erlang//:ct.bzl",
"assert_suites2",
"ct_test",
)
load("//:rabbitmq_home.bzl", "rabbitmq_home")
load("//:rabbitmq_run.bzl", "rabbitmq_run")
def without(item, elements):
c = list(elements)
c.remove(item)
return c
STARTS_BACKGROUND_BROKER_TAG = "starts-background-broker"
MIXED_VERSION_CLUSTER_TAG = "mixed-version-cluster"
RABBITMQ_ERLC_OPTS = DEFAULT_ERLC_OPTS + [
"-DINSTR_MOD=gm",
]
RABBITMQ_TEST_ERLC_OPTS = DEFAULT_TEST_ERLC_OPTS + [
"+nowarn_export_all",
"-DINSTR_MOD=gm",
]
RABBITMQ_DIALYZER_OPTS = [
"-Werror_handling",
"-Wunmatched_returns",
"-Wunknown",
]
APP_VERSION = "4.0.0"
BROKER_VERSION_REQUIREMENTS_ANY = """
{broker_version_requirements, []}
"""
ALL_PLUGINS = [
"//deps/rabbit:erlang_app",
"//deps/rabbitmq_amqp1_0:erlang_app",
"//deps/rabbitmq_auth_backend_cache:erlang_app",
"//deps/rabbitmq_auth_backend_http:erlang_app",
"//deps/rabbitmq_auth_backend_ldap:erlang_app",
"//deps/rabbitmq_auth_backend_oauth2:erlang_app",
"//deps/rabbitmq_auth_mechanism_ssl:erlang_app",
"//deps/rabbitmq_consistent_hash_exchange:erlang_app",
"//deps/rabbitmq_event_exchange:erlang_app",
"//deps/rabbitmq_federation:erlang_app",
"//deps/rabbitmq_federation_management:erlang_app",
"//deps/rabbitmq_federation_prometheus:erlang_app",
"//deps/rabbitmq_jms_topic_exchange:erlang_app",
"//deps/rabbitmq_management:erlang_app",
"//deps/rabbitmq_mqtt:erlang_app",
"//deps/rabbitmq_peer_discovery_aws:erlang_app",
"//deps/rabbitmq_peer_discovery_consul:erlang_app",
"//deps/rabbitmq_peer_discovery_etcd:erlang_app",
"//deps/rabbitmq_peer_discovery_k8s:erlang_app",
"//deps/rabbitmq_prometheus:erlang_app",
"//deps/rabbitmq_random_exchange:erlang_app",
"//deps/rabbitmq_recent_history_exchange:erlang_app",
"//deps/rabbitmq_sharding:erlang_app",
"//deps/rabbitmq_shovel:erlang_app",
"//deps/rabbitmq_shovel_management:erlang_app",
"//deps/rabbitmq_shovel_prometheus:erlang_app",
"//deps/rabbitmq_stomp:erlang_app",
"//deps/rabbitmq_stream:erlang_app",
"//deps/rabbitmq_stream_management:erlang_app",
"//deps/rabbitmq_top:erlang_app",
"//deps/rabbitmq_tracing:erlang_app",
"//deps/rabbitmq_trust_store:erlang_app",
"//deps/rabbitmq_web_dispatch:erlang_app",
"//deps/rabbitmq_web_mqtt:erlang_app",
"//deps/rabbitmq_web_mqtt_examples:erlang_app",
"//deps/rabbitmq_web_stomp:erlang_app",
"//deps/rabbitmq_web_stomp_examples:erlang_app",
]
LABELS_WITH_TEST_VERSIONS = [
"//deps/amqp10_common:erlang_app",
"//deps/rabbit_common:erlang_app",
"//deps/rabbitmq_prelaunch:erlang_app",
"//deps/rabbit:erlang_app",
]
def all_plugins(rabbitmq_workspace = "@rabbitmq-server"):
return [
Label("{}{}".format(rabbitmq_workspace, p))
for p in ALL_PLUGINS
]
def with_test_versions(deps):
r = []
for d in deps:
if d in LABELS_WITH_TEST_VERSIONS:
r.append(d.replace(":erlang_app", ":test_erlang_app"))
else:
r.append(d)
return r
def rabbitmq_app(
name = "erlang_app",
app_name = "",
app_version = APP_VERSION,
app_description = "",
app_module = "",
app_registered = [],
app_env = "",
app_extra_keys = "",
extra_apps = [],
beam_files = [":beam_files"],
hdrs = None,
srcs = [":all_srcs"],
priv = [":priv"],
license_files = [":license_files"],
deps = [],
testonly = False):
if name != "erlang_app":
fail("name attr exists for compatibility only, and must be set to '\"erlang_app\"'")
if beam_files != [":beam_files"]:
fail("beam_files attr exists for compatibility only, and must be set to '[\":beam_files\"]'")
if hdrs != [":public_hdrs"]:
fail("hdrs attr exists for compatibility only, and must be set to '[\":public_hdrs\"]'")
erlang_app(
name = "erlang_app",
app_name = app_name,
app_version = app_version,
app_description = app_description,
app_module = app_module,
app_registered = app_registered,
app_env = app_env,
app_extra_keys = app_extra_keys,
extra_apps = extra_apps,
beam_files = beam_files,
hdrs = [":public_hdrs"],
srcs = srcs,
priv = priv,
license_files = license_files,
deps = deps,
testonly = testonly,
)
test_erlang_app(
name = "test_erlang_app",
app_name = app_name,
app_version = app_version,
app_description = app_description,
app_module = app_module,
app_registered = app_registered,
app_env = app_env,
app_extra_keys = app_extra_keys,
extra_apps = extra_apps,
beam_files = [":test_beam_files"],
hdrs = [":public_and_private_hdrs"],
srcs = srcs,
priv = priv,
license_files = license_files,
deps = with_test_versions(deps),
)
def rabbitmq_suite(
name = None,
suite_name = None,
data = [],
additional_beam = [],
test_env = {},
deps = [],
runtime_deps = [],
**kwargs):
app_name = native.package_name().rpartition("/")[-1]
# suite_name exists in the underying ct_test macro, but we don't
# want to use the arg in rabbitmq-server, for the sake of clarity
if suite_name != None:
fail("rabbitmq_suite cannot be called with a suite_name attr")
ct_test(
name = name,
app_name = app_name,
compiled_suites = [":{}_beam_files".format(name)] + additional_beam,
data = native.glob(["test/{}_data/**/*".format(name)]) + data,
test_env = dict({
"RABBITMQ_CT_SKIP_AS_ERROR": "true",
"LANG": "C.UTF-8",
"COVERDATA_TO_LCOV_APPS_DIRS": "deps:deps/rabbit/apps",
}.items() + test_env.items()),
deps = [":test_erlang_app"] + deps + runtime_deps,
ct_run_extra_args = ["-kernel net_ticktime 5"],
**kwargs
)
return name
def broker_for_integration_suites(extra_plugins = []):
rabbitmq_home(
name = "broker-for-tests-home",
plugins = [
"//deps/rabbit:test_erlang_app",
":test_erlang_app",
] + extra_plugins,
testonly = True,
)
rabbitmq_run(
name = "rabbitmq-for-tests-run",
home = ":broker-for-tests-home",
testonly = True,
)
def rabbitmq_integration_suite(
name = None,
suite_name = None,
tags = [],
data = [],
erlc_opts = [],
additional_beam = [],
test_env = {},
tools = [],
deps = [],
runtime_deps = [],
**kwargs):
app_name = native.package_name().rpartition("/")[-1]
# suite_name exists in the underying ct_test macro, but we don't
# want to use the arg in rabbitmq-server, for the sake of clarity
if suite_name != None:
fail("rabbitmq_integration_suite cannot be called with a suite_name attr")
assumed_deps = [
":test_erlang_app",
"//deps/rabbit_common:erlang_app",
"//deps/rabbitmq_ct_helpers:erlang_app",
"@rules_elixir//elixir",
"//deps/rabbitmq_cli:erlang_app",
"//deps/rabbitmq_ct_client_helpers:erlang_app",
]
package = native.package_name()
if package != "deps/amqp_client":
assumed_deps.append("//deps/amqp_client:erlang_app")
ct_test(
name = name,
app_name = app_name,
suite_name = name,
compiled_suites = [":{}_beam_files".format(name)] + additional_beam,
tags = tags + [STARTS_BACKGROUND_BROKER_TAG],
data = native.glob(["test/{}_data/**/*".format(name)]) + data,
test_env = dict({
"SKIP_MAKE_TEST_DIST": "true",
"RABBITMQ_CT_SKIP_AS_ERROR": "true",
"RABBITMQ_RUN": "$(location :rabbitmq-for-tests-run)",
"RABBITMQCTL": "$TEST_SRCDIR/$TEST_WORKSPACE/{}/broker-for-tests-home/sbin/rabbitmqctl".format(package),
"RABBITMQ_PLUGINS": "$TEST_SRCDIR/$TEST_WORKSPACE/{}/broker-for-tests-home/sbin/rabbitmq-plugins".format(package),
"RABBITMQ_QUEUES": "$TEST_SRCDIR/$TEST_WORKSPACE/{}/broker-for-tests-home/sbin/rabbitmq-queues".format(package),
"LANG": "C.UTF-8",
"COVERDATA_TO_LCOV_APPS_DIRS": "deps:deps/rabbit/apps",
}.items() + test_env.items()),
tools = [
":rabbitmq-for-tests-run",
] + tools,
deps = assumed_deps + deps + runtime_deps,
ct_run_extra_args = ["-kernel net_ticktime 5"],
**kwargs
)
ct_test(
name = name + "-mixed",
suite_name = name,
compiled_suites = [":{}_beam_files".format(name)] + additional_beam,
tags = tags + [STARTS_BACKGROUND_BROKER_TAG, MIXED_VERSION_CLUSTER_TAG],
data = native.glob(["test/{}_data/**/*".format(name)]) + data,
test_env = dict({
"SKIP_MAKE_TEST_DIST": "true",
# The feature flags listed below are required. This means they must be enabled in mixed-version testing
# before even starting the cluster because newer nodes don't have the corresponding compatibility/migration code.
"RABBITMQ_FEATURE_FLAGS":
# required starting from 3.11.0 in rabbit:
"quorum_queue,implicit_default_bindings,virtual_host_metadata,maintenance_mode_status,user_limits," +
# required starting from 3.12.0 in rabbit:
"feature_flags_v2,stream_queue,classic_queue_type_delivery_support,classic_mirrored_queue_version," +
"stream_single_active_consumer,direct_exchange_routing_v2,listener_records_in_ets,tracking_records_in_ets," +
# required starting from 3.12.0 in rabbitmq_management_agent:
# empty_basic_get_metric, drop_unroutable_metric
# required starting from 4.0 in rabbit:
"message_containers,stream_update_config_command,stream_filtering,stream_sac_coordinator_unblock_group,restart_streams",
"RABBITMQ_RUN": "$(location :rabbitmq-for-tests-run)",
"RABBITMQCTL": "$TEST_SRCDIR/$TEST_WORKSPACE/{}/broker-for-tests-home/sbin/rabbitmqctl".format(package),
"RABBITMQ_PLUGINS": "$TEST_SRCDIR/$TEST_WORKSPACE/{}/broker-for-tests-home/sbin/rabbitmq-plugins".format(package),
"RABBITMQ_QUEUES": "$TEST_SRCDIR/$TEST_WORKSPACE/{}/broker-for-tests-home/sbin/rabbitmq-queues".format(package),
"RABBITMQ_RUN_SECONDARY": "$(location @rabbitmq-server-generic-unix-4.0//:rabbitmq-run)",
"LANG": "C.UTF-8",
}.items() + test_env.items()),
tools = [
":rabbitmq-for-tests-run",
"@rabbitmq-server-generic-unix-4.0//:rabbitmq-run",
] + tools,
deps = assumed_deps + deps + runtime_deps,
ct_run_extra_args = ["-kernel net_ticktime 5"],
**kwargs
)
return name
def assert_suites(**kwargs):
assert_suites2(**kwargs)