Skip to content

Commit e217597

Browse files
committed
feat: introduce EMQX 6.0 compatibility
1 parent e0325b5 commit e217597

File tree

6 files changed

+29
-9
lines changed

6 files changed

+29
-9
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ up:
7777
down:
7878
docker compose down --volumes
7979

80+
.PHONY: emqx-logs
81+
emqx-logs:
82+
docker compose logs -f emqx
83+
8084
# bump-version-patch/minor/major
8185
.PHONY: bump-version-%
8286
bump-version-%:

docker-compose.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
emqx:
3-
image: emqx/emqx-enterprise:5.9.0
3+
image: emqx/emqx-enterprise:6.0.0
44
container_name: emqx
55
environment:
66
EMQX_LOG__CONSOLE__LEVEL: debug
@@ -128,6 +128,7 @@ services:
128128

129129
redis-cluster-node-1:
130130
image: redis:7.0
131+
container_name: redis-cluster-node-1
131132
command: redis-server --requirepass public --masterauth public --port 7001 --cluster-enabled yes --cluster-config-file nodes.conf --cluster-node-timeout 5000
132133
ports:
133134
- "7001:7001"
@@ -141,6 +142,7 @@ services:
141142

142143
redis-cluster-node-2:
143144
image: redis:7.0
145+
container_name: redis-cluster-node-2
144146
command: redis-server --requirepass public --masterauth public --port 7002 --cluster-enabled yes --cluster-config-file nodes.conf --cluster-node-timeout 5000
145147
ports:
146148
- "7002:7002"
@@ -154,6 +156,7 @@ services:
154156

155157
redis-cluster-node-3:
156158
image: redis:7.0
159+
container_name: redis-cluster-node-3
157160
command: redis-server --requirepass public --masterauth public --port 7003 --cluster-enabled yes --cluster-config-file nodes.conf --cluster-node-timeout 5000
158161
ports:
159162
- "7003:7003"
@@ -167,6 +170,7 @@ services:
167170

168171
redis-cluster-setup:
169172
image: redis:7.0
173+
container_name: redis-cluster-setup
170174
depends_on:
171175
redis-cluster-node-1:
172176
condition: service_healthy
@@ -180,6 +184,7 @@ services:
180184

181185
redis-master:
182186
image: redis:7.0
187+
container_name: redis-master
183188
command: redis-server --requirepass public --masterauth public --port 8001
184189
ports:
185190
- "8001:8001"
@@ -193,6 +198,7 @@ services:
193198

194199
redis-slave:
195200
image: redis:7.0
201+
container_name: redis-slave
196202
command: redis-server --requirepass public --masterauth public --port 8002 --replicaof redis-master 8001
197203
ports:
198204
- "8002:8002"
@@ -209,6 +215,7 @@ services:
209215

210216
redis-sentinel:
211217
image: redis:7.0
218+
container_name: redis-sentinel
212219
command: >
213220
bash -c "
214221
echo 'sentinel monitor mymaster redis-master 8001 1' > sentinel.conf

src/emqx_omp_mysql.erl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,8 @@ make_mysql_resource_config(#{<<"insert_message_sql">> := InsertMessageStatement}
423423
}
424424
},
425425

426-
ResourceOpts = emqx_omp_utils:make_resource_opts(RawConfig0),
426+
ResourceOpts0 = emqx_omp_utils:make_resource_opts(RawConfig0),
427+
ResourceOpts = ResourceOpts0#{spawn_buffer_workers => true},
427428

428429
{MysqlConfig, ResourceOpts}.
429430

@@ -437,7 +438,7 @@ init_default_schema(#{<<"init_default_schema">> := true} = ConfigRaw) ->
437438
{ok, _} = emqx_resource:create_local(
438439
?RESOURCE_ID_INIT,
439440
?RESOURCE_GROUP,
440-
emqx_bridge_mysql_connector,
441+
emqx_mysql,
441442
MysqlConfig,
442443
ResourceOpts
443444
),

src/emqx_omp_utils.erl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ make_resource_opts(RawConfig) ->
4545
%% nothing to remove yet.
4646
%% After some time, the message will be persisted in the database, and the client
4747
%% will receive it once more on reconnect.
48-
query_mode => sync
48+
query_mode => sync,
49+
owner_id => <<"omp">>
4950
}.
5051

5152
check_config(Schema, ConfigRaw) ->

test/emqx_omp_SUITE.erl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,11 @@ t_message_order(_Config) ->
264264
ok = emqtt:stop(ClientSub),
265265

266266
%% Check messages order
267-
?assertEqual(lists:seq(1, 200), Messages).
267+
Expected = lists:seq(1, 200),
268+
?assertEqual([], Expected -- Messages, "Not all messages were received"),
269+
?assertEqual([], Messages -- Expected, "Duplicate messages were received"),
270+
InvalidOrder = lists:filter(fun({A, B}) -> A =/= B end, lists:zip(Expected, Messages)),
271+
?assertEqual([], InvalidOrder, "Messages were received in the wrong order").
268272

269273
t_mysql_table_cleanup(Config) ->
270274
%% setup and cleanup

test/emqx_omp_test_helpers.erl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,16 @@ api_delete(Path) ->
7878

7979
make_request({get, Path}) ->
8080
ct:pal("GET ~s~n~n", [api_url(Path)]),
81-
hackney:request(get, api_url(Path), headers());
81+
hackney:request(get, api_url(Path), headers(), <<>>, hackney_options());
8282
make_request({post, Path, Body}) ->
8383
ct:pal("POST ~s~n~n~s~n~n", [api_url(Path), encode_json(Body)]),
84-
hackney:request(post, api_url(Path), headers(), encode_json(Body));
84+
hackney:request(post, api_url(Path), headers(), encode_json(Body), hackney_options());
8585
make_request({put, Path, Body}) ->
8686
ct:pal("PUT ~s~n~n~s~n~n", [api_url(Path), encode_json(Body)]),
87-
hackney:request(put, api_url(Path), headers(), encode_json(Body));
87+
hackney:request(put, api_url(Path), headers(), encode_json(Body), hackney_options());
8888
make_request({delete, Path}) ->
8989
ct:pal("DELETE ~s~n~n", [api_url(Path)]),
90-
hackney:request(delete, api_url(Path), headers()).
90+
hackney:request(delete, api_url(Path), headers(), <<>>, hackney_options()).
9191

9292
handle_result({ok, Code, _Headers, ClientRef}) when Code >= 200 andalso Code < 300 ->
9393
{ok, Json} = hackney:body(ClientRef),
@@ -152,3 +152,6 @@ decode_json(Body) ->
152152

153153
encode_json(Data) ->
154154
jiffy:encode(Data).
155+
156+
hackney_options() ->
157+
[{recv_timeout, 10000}, {connect_timeout, 5000}, {checkout_timeout, 5000}].

0 commit comments

Comments
 (0)