Introduced integration tests
This commit is contained in:
parent
56732fe069
commit
f704f5c112
|
|
@ -0,0 +1,32 @@
|
||||||
|
-module(integration_test_util).
|
||||||
|
|
||||||
|
-include_lib("rabbitmq_server/include/rabbit_framing.hrl").
|
||||||
|
-include("amqp_client.hrl").
|
||||||
|
|
||||||
|
-export([rpc_client_test/1]).
|
||||||
|
|
||||||
|
rpc_client_test(Connection) ->
|
||||||
|
X = <<"x">>,
|
||||||
|
BindKey = <<"a.b.c.*">>,
|
||||||
|
RoutingKey = <<"a.b.c.d">>,
|
||||||
|
Realm = <<"/data">>,
|
||||||
|
BindKey = <<"a.b.c.*">>,
|
||||||
|
RoutingKey = <<"a.b.c.d">>,
|
||||||
|
Q = <<"a.b.c">>,
|
||||||
|
{ChannelPid, Ticket} = test_util:setup_channel(Connection, Realm),
|
||||||
|
BrokerConfig = #broker_config{channel_pid = ChannelPid, ticket = Ticket,
|
||||||
|
exchange = X, routing_key = RoutingKey,
|
||||||
|
queue = Q,
|
||||||
|
content_type = <<"application/x-hessian">>},
|
||||||
|
RpcHandlerState = #rpc_handler_state{broker_config = BrokerConfig,
|
||||||
|
server_name = test_util},
|
||||||
|
{ok, Consumer} = gen_event:start_link(),
|
||||||
|
gen_event:add_handler(Consumer, amqp_rpc_handler , [RpcHandlerState] ),
|
||||||
|
BasicConsume = #'basic.consume'{ticket = Ticket, queue = Q,
|
||||||
|
consumer_tag = <<"">>,
|
||||||
|
no_local = false, no_ack = true, exclusive = false, nowait = false},
|
||||||
|
#'basic.consume_ok'{consumer_tag = ConsumerTag} = amqp_channel:call(ChannelPid, BasicConsume, Consumer),
|
||||||
|
RpcClientPid = amqp_rpc_client:start(BrokerConfig),
|
||||||
|
Reply = amqp_rpc_client:call(RpcClientPid, <<"foo">>),
|
||||||
|
io:format("Reply from RPC was ~p~n", [Reply]),
|
||||||
|
test_util:teardown(Connection, ChannelPid).
|
||||||
|
|
@ -20,10 +20,6 @@ basic_ack_test() ->
|
||||||
Connection = amqp_connection:start("guest", "guest", "localhost"),
|
Connection = amqp_connection:start("guest", "guest", "localhost"),
|
||||||
test_util:basic_ack_test(Connection).
|
test_util:basic_ack_test(Connection).
|
||||||
|
|
||||||
rpc_client_test() ->
|
|
||||||
Connection = amqp_connection:start("guest", "guest", "localhost"),
|
|
||||||
test_util:rpc_client_test(Connection).
|
|
||||||
|
|
||||||
test_coverage() ->
|
test_coverage() ->
|
||||||
rabbit_misc:enable_cover(),
|
rabbit_misc:enable_cover(),
|
||||||
test(),
|
test(),
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
-module(network_integration_test).
|
||||||
|
|
||||||
|
-include_lib("eunit/include/eunit.hrl").
|
||||||
|
|
||||||
|
rpc_client_test() ->
|
||||||
|
Connection = amqp_connection:start("guest", "guest", "localhost"),
|
||||||
|
integration_test_util:rpc_client_test(Connection).
|
||||||
|
|
@ -104,32 +104,6 @@ basic_consume_test(Connection) ->
|
||||||
end,
|
end,
|
||||||
teardown(Connection, Channel).
|
teardown(Connection, Channel).
|
||||||
|
|
||||||
rpc_client_test(Connection) ->
|
|
||||||
X = <<"x">>,
|
|
||||||
BindKey = <<"a.b.c.*">>,
|
|
||||||
RoutingKey = <<"a.b.c.d">>,
|
|
||||||
Realm = <<"/data">>,
|
|
||||||
BindKey = <<"a.b.c.*">>,
|
|
||||||
RoutingKey = <<"a.b.c.d">>,
|
|
||||||
Q = <<"a.b.c">>,
|
|
||||||
{ChannelPid, Ticket} = setup_channel(Connection, Realm),
|
|
||||||
BrokerConfig = #broker_config{channel_pid = ChannelPid, ticket = Ticket,
|
|
||||||
exchange = X, routing_key = RoutingKey,
|
|
||||||
queue = Q,
|
|
||||||
content_type = <<"application/x-hessian">>},
|
|
||||||
RpcHandlerState = #rpc_handler_state{broker_config = BrokerConfig,
|
|
||||||
server_name = test_util},
|
|
||||||
{ok, Consumer} = gen_event:start_link(),
|
|
||||||
gen_event:add_handler(Consumer, amqp_rpc_handler , [RpcHandlerState] ),
|
|
||||||
BasicConsume = #'basic.consume'{ticket = Ticket, queue = Q,
|
|
||||||
consumer_tag = <<"">>,
|
|
||||||
no_local = false, no_ack = true, exclusive = false, nowait = false},
|
|
||||||
#'basic.consume_ok'{consumer_tag = ConsumerTag} = amqp_channel:call(ChannelPid, BasicConsume, Consumer),
|
|
||||||
RpcClientPid = amqp_rpc_client:start(BrokerConfig),
|
|
||||||
Reply = amqp_rpc_client:call(RpcClientPid, <<"foo">>),
|
|
||||||
io:format("Reply from RPC was ~p~n", [Reply]),
|
|
||||||
teardown(Connection, ChannelPid).
|
|
||||||
|
|
||||||
setup_publish(Connection) ->
|
setup_publish(Connection) ->
|
||||||
Realm = <<"/data">>,
|
Realm = <<"/data">>,
|
||||||
Q = <<"a.b.c">>,
|
Q = <<"a.b.c">>,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue