forked from rabbitmq/rabbitmq-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rabbitmq.bzl
153 lines (140 loc) · 4.66 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
load(
"@bazel-erlang//:bazel_erlang_lib.bzl",
"DEFAULT_ERLC_OPTS",
"DEFAULT_TEST_ERLC_OPTS",
"erlang_lib",
"test_erlang_lib",
)
load("@bazel-erlang//:ct_sharded.bzl", "ct_suite")
load("//:rabbitmq_home.bzl", "rabbitmq_home")
load("//:rabbitmq_run.bzl", "rabbitmq_run")
RABBITMQ_ERLC_OPTS = DEFAULT_ERLC_OPTS
RABBITMQ_TEST_ERLC_OPTS = DEFAULT_TEST_ERLC_OPTS + [
"+nowarn_export_all",
]
RABBITMQ_DIALYZER_OPTS = [
"-Werror_handling",
"-Wunmatched_returns",
]
APP_VERSION = "3.10.0"
LABELS_WITH_TEST_VERSIONS = [
"//deps/amqp10_common:bazel_erlang_lib",
"//deps/rabbit_common:bazel_erlang_lib",
"//deps/rabbit:bazel_erlang_lib",
"//deps/rabbit/apps/rabbitmq_prelaunch:bazel_erlang_lib",
]
def with_test_versions(deps):
r = []
for d in deps:
if d in LABELS_WITH_TEST_VERSIONS:
r.append(d.replace(":bazel_erlang_lib", ":test_bazel_erlang_lib"))
else:
r.append(d)
return r
def rabbitmq_lib(
app_name = "",
app_version = APP_VERSION,
app_description = "",
app_module = "",
app_registered = [],
app_env = "[]",
extra_apps = [],
erlc_opts = RABBITMQ_ERLC_OPTS,
test_erlc_opts = RABBITMQ_TEST_ERLC_OPTS,
first_srcs = [],
build_deps = [],
deps = [],
runtime_deps = []):
erlang_lib(
app_name = app_name,
app_version = app_version,
app_description = app_description,
app_module = app_module,
app_registered = app_registered,
app_env = app_env,
extra_apps = extra_apps,
erlc_opts = erlc_opts,
first_srcs = first_srcs,
build_deps = build_deps,
deps = deps,
runtime_deps = runtime_deps,
)
test_erlang_lib(
app_name = app_name,
app_version = app_version,
app_description = app_description,
app_module = app_module,
app_registered = app_registered,
app_env = app_env,
extra_apps = extra_apps,
erlc_opts = test_erlc_opts,
first_srcs = first_srcs,
build_deps = with_test_versions(build_deps),
deps = with_test_versions(deps),
runtime_deps = with_test_versions(runtime_deps),
)
def rabbitmq_suite(erlc_opts = [], test_env = {}, **kwargs):
ct_suite(
erlc_opts = RABBITMQ_TEST_ERLC_OPTS + erlc_opts,
test_env = dict({
"RABBITMQ_CT_SKIP_AS_ERROR": "true",
}.items() + test_env.items()),
**kwargs
)
return kwargs["name"]
def broker_for_integration_suites():
rabbitmq_home(
name = "broker-for-tests-home",
plugins = [
"//deps/rabbit:bazel_erlang_lib",
":bazel_erlang_lib",
],
)
rabbitmq_run(
name = "rabbitmq-for-tests-run",
home = ":broker-for-tests-home",
)
def rabbitmq_integration_suite(
package,
data = [],
erlc_opts = [],
test_env = {},
tools = [],
deps = [],
runtime_deps = [],
**kwargs):
ct_suite(
erlc_opts = RABBITMQ_TEST_ERLC_OPTS + erlc_opts,
data = [
"@rabbitmq_ct_helpers//tools/tls-certs:Makefile",
"@rabbitmq_ct_helpers//tools/tls-certs:openssl.cnf.in",
] + data,
test_env = dict({
"SKIP_MAKE_TEST_DIST": "true",
"RABBITMQ_CT_SKIP_AS_ERROR": "true",
"RABBITMQ_RUN": "$TEST_SRCDIR/$TEST_WORKSPACE/{}/rabbitmq-for-tests-run".format(package),
"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),
}.items() + test_env.items()),
tools = [
":rabbitmq-for-tests-run",
] + tools,
runtime_deps = [
"//deps/rabbitmq_cli:elixir_as_bazel_erlang_lib",
"//deps/rabbitmq_cli:rabbitmqctl",
"@rabbitmq_ct_client_helpers//:bazel_erlang_lib",
] + runtime_deps,
deps = [
"//deps/amqp_client:bazel_erlang_lib",
"//deps/rabbit_common:bazel_erlang_lib",
"@rabbitmq_ct_helpers//:bazel_erlang_lib",
] + deps,
**kwargs
)
return kwargs["name"]
def assert_suites(suite_names, suite_files):
for f in suite_files:
sn = f.rpartition("/")[-1].replace(".erl", "")
if not sn in suite_names:
fail("A bazel rule has not been defined for {} (expected {} in {}".format(f, sn, suite_names))