Skip to content

Commit

Permalink
Use 1.0 instead of 0.9.1 client for 1.0 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ansd committed Mar 23, 2024
1 parent e21007f commit e6eef88
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 178 deletions.
2 changes: 1 addition & 1 deletion deps/rabbit/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ rabbitmq_integration_suite(
],
shard_count = 3,
runtime_deps = [
"//deps/amqp10_client:erlang_app",
"//deps/rabbitmq_amqp_client:erlang_app",
],
)

Expand Down
52 changes: 21 additions & 31 deletions deps/rabbit/src/rabbit_amqp_management.erl
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ handle_http_req(<<"DELETE">>,
fun (Q) ->
case rabbit_queue_type:purge(Q) of
{ok, NumMsgs} ->
RespPayload = {map, [{{utf8, <<"message_count">>}, {ulong, NumMsgs}}]},
RespPayload = {map, [{{utf8, <<"message_count">>},
{ulong, NumMsgs}}]},
{<<"200">>, RespPayload};
{error, not_supported} ->
throw(<<"400">>,
Expand All @@ -234,7 +235,8 @@ handle_http_req(<<"DELETE">>,
ok = check_resource_access(QName, configure, User),
try rabbit_amqqueue:delete_with(QName, ConnPid, false, false, Username, true) of
{ok, NumMsgs} ->
RespPayload = {map, [{{utf8, <<"message_count">>}, {ulong, NumMsgs}}]},
RespPayload = {map, [{{utf8, <<"message_count">>},
{ulong, NumMsgs}}]},
{<<"200">>, RespPayload}
catch exit:#amqp_error{explanation = Explanation} ->
throw(<<"400">>, Explanation, [])
Expand Down Expand Up @@ -343,15 +345,8 @@ decode_queue({map, KVList}) ->
({{utf8, <<"auto_delete">>}, V}, Acc)
when is_boolean(V) ->
Acc#{auto_delete => V};
({{utf8, <<"arguments">>}, {map, List}}, Acc) ->
Args = lists:map(fun({{utf8, Key = <<"x-", _/binary>>}, {utf8, Val}}) ->
{Key, longstr, Val};
(Arg) ->
throw(<<"400">>,
"unsupported queue argument ~tp",
[Arg])
end, List),
Acc#{arguments => Args};
({{utf8, <<"arguments">>}, Args}, Acc) ->
Acc#{arguments => args_amqp_to_amqpl(Args)};
(Prop, _Acc) ->
throw(<<"400">>, "bad queue property ~tp", [Prop])
end, #{}, KVList),
Expand Down Expand Up @@ -442,15 +437,8 @@ decode_exchange({map, KVList}) ->
({{utf8, <<"internal">>}, V}, Acc)
when is_boolean(V) ->
Acc#{internal => V};
({{utf8, <<"arguments">>}, {map, List}}, Acc) ->
Args = lists:map(fun({{utf8, Key = <<"x-", _/binary>>}, {utf8, Val}}) ->
{Key, longstr, Val};
(Arg) ->
throw(<<"400">>,
"unsupported exchange argument ~tp",
[Arg])
end, List),
Acc#{arguments => Args};
({{utf8, <<"arguments">>}, Args}, Acc) ->
Acc#{arguments => args_amqp_to_amqpl(Args)};
(Prop, _Acc) ->
throw(<<"400">>, "bad exchange property ~tp", [Prop])
end, #{}, KVList),
Expand All @@ -471,17 +459,8 @@ decode_binding({map, KVList}) ->
Acc#{destination_exchange => V};
({{utf8, <<"binding_key">>}, {utf8, V}}, Acc) ->
Acc#{binding_key => V};
({{utf8, <<"arguments">>}, {map, List}}, Acc) ->
Args = lists:map(fun({{T, Key}, TypeVal})
when T =:= utf8 orelse
T =:= symbol ->
mc_amqpl:to_091(Key, TypeVal);
(Arg) ->
throw(<<"400">>,
"unsupported binding argument ~tp",
[Arg])
end, List),
Acc#{arguments => Args};
({{utf8, <<"arguments">>}, Args}, Acc) ->
Acc#{arguments => args_amqp_to_amqpl(Args)};
(Field, _Acc) ->
throw(<<"400">>, "bad binding field ~tp", [Field])
end, #{}, KVList).
Expand Down Expand Up @@ -511,6 +490,17 @@ encode_bindings(Bindings) ->
end, Bindings),
{list, Bs}.

args_amqp_to_amqpl({map, KVList}) ->
lists:map(fun({{T, Key}, TypeVal})
when T =:= utf8 orelse
T =:= symbol ->
mc_amqpl:to_091(Key, TypeVal);
(Arg) ->
throw(<<"400">>,
"unsupported argument ~tp",
[Arg])
end, KVList).

args_amqpl_to_amqp(Args) ->
{map, [{{utf8, K}, mc_amqpl:from_091(T, V)} || {K, T, V} <- Args]}.

Expand Down
Loading

0 comments on commit e6eef88

Please sign in to comment.