2017-01-03 00:31:59 +08:00
|
|
|
%% The contents of this file are subject to the Mozilla Public License
|
|
|
|
|
%% Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
|
%% compliance with the License. You may obtain a copy of the License at
|
|
|
|
|
%% http://www.mozilla.org/MPL/
|
|
|
|
|
%%
|
|
|
|
|
%% Software distributed under the License is distributed on an "AS IS"
|
|
|
|
|
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
|
|
|
%% License for the specific language governing rights and limitations
|
|
|
|
|
%% under the License.
|
|
|
|
|
%%
|
|
|
|
|
%% The Original Code is RabbitMQ.
|
|
|
|
|
%%
|
|
|
|
|
%% The Initial Developer of the Original Code is GoPivotal, Inc.
|
|
|
|
|
%% Copyright (c) 2017 Pivotal Software, Inc. All rights reserved.
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
|
|
-module(system_SUITE).
|
|
|
|
|
|
|
|
|
|
-include_lib("common_test/include/ct.hrl").
|
2017-01-09 20:17:52 +08:00
|
|
|
-include_lib("eunit/include/eunit.hrl").
|
2017-01-03 00:31:59 +08:00
|
|
|
|
2017-01-11 23:07:14 +08:00
|
|
|
-include_lib("amqp10_common/include/amqp10_framing.hrl").
|
|
|
|
|
|
2017-01-03 00:31:59 +08:00
|
|
|
-include("amqp10_client.hrl").
|
|
|
|
|
|
|
|
|
|
-compile(export_all).
|
|
|
|
|
|
|
|
|
|
-define(UNAUTHORIZED_USER, <<"test_user_no_perm">>).
|
|
|
|
|
|
|
|
|
|
%% The latch constant defines how many processes are spawned in order
|
|
|
|
|
%% to run certain functionality in parallel. It follows the standard
|
|
|
|
|
%% countdown latch pattern.
|
|
|
|
|
-define(LATCH, 100).
|
|
|
|
|
|
|
|
|
|
%% The wait constant defines how long a consumer waits before it
|
|
|
|
|
%% unsubscribes
|
|
|
|
|
-define(WAIT, 200).
|
|
|
|
|
|
|
|
|
|
%% How to long wait for a process to die after an expected failure
|
|
|
|
|
-define(PROCESS_EXIT_TIMEOUT, 5000).
|
|
|
|
|
|
|
|
|
|
all() ->
|
|
|
|
|
[
|
2017-01-09 20:17:52 +08:00
|
|
|
{group, rabbitmq},
|
|
|
|
|
{group, activemq}
|
2017-01-03 00:31:59 +08:00
|
|
|
].
|
|
|
|
|
|
|
|
|
|
groups() ->
|
|
|
|
|
[
|
2017-01-09 20:17:52 +08:00
|
|
|
{rabbitmq, [], [basic_get]},
|
|
|
|
|
{activemq, [], [basic_get]}
|
2017-01-03 00:31:59 +08:00
|
|
|
].
|
|
|
|
|
|
|
|
|
|
%% -------------------------------------------------------------------
|
|
|
|
|
%% Testsuite setup/teardown.
|
|
|
|
|
%% -------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
init_per_suite(Config) ->
|
|
|
|
|
rabbit_ct_helpers:log_environment(),
|
2017-01-09 20:17:52 +08:00
|
|
|
rabbit_ct_helpers:run_setup_steps(Config,
|
2017-01-03 00:31:59 +08:00
|
|
|
[
|
|
|
|
|
fun start_amqp10_client_app/1
|
|
|
|
|
]).
|
|
|
|
|
|
|
|
|
|
end_per_suite(Config) ->
|
2017-01-09 20:17:52 +08:00
|
|
|
rabbit_ct_helpers:run_teardown_steps(Config,
|
2017-01-03 00:31:59 +08:00
|
|
|
[
|
|
|
|
|
fun stop_amqp10_client_app/1
|
2017-01-09 20:17:52 +08:00
|
|
|
]).
|
2017-01-03 00:31:59 +08:00
|
|
|
|
|
|
|
|
start_amqp10_client_app(Config) ->
|
2017-01-11 23:07:14 +08:00
|
|
|
?assertMatch({ok, _}, application:ensure_all_started(amqp10_client)),
|
2017-01-03 00:31:59 +08:00
|
|
|
Config.
|
|
|
|
|
|
|
|
|
|
stop_amqp10_client_app(Config) ->
|
2017-01-11 23:07:14 +08:00
|
|
|
ok = application:stop(amqp10_client),
|
2017-01-03 00:31:59 +08:00
|
|
|
Config.
|
|
|
|
|
|
|
|
|
|
%% -------------------------------------------------------------------
|
|
|
|
|
%% Groups.
|
|
|
|
|
%% -------------------------------------------------------------------
|
|
|
|
|
|
2017-01-09 20:17:52 +08:00
|
|
|
init_per_group(rabbitmq, Config) ->
|
|
|
|
|
rabbit_ct_helpers:run_steps(
|
|
|
|
|
Config,
|
|
|
|
|
rabbit_ct_broker_helpers:setup_steps());
|
|
|
|
|
init_per_group(activemq, Config) ->
|
|
|
|
|
rabbit_ct_helpers:run_steps(
|
|
|
|
|
Config,
|
|
|
|
|
activemq_ct_helpers:setup_steps()).
|
|
|
|
|
|
|
|
|
|
end_per_group(rabbitmq, Config) ->
|
|
|
|
|
rabbit_ct_helpers:run_steps(
|
|
|
|
|
Config,
|
|
|
|
|
rabbit_ct_broker_helpers:teardown_steps());
|
|
|
|
|
end_per_group(activemq, Config) ->
|
|
|
|
|
rabbit_ct_helpers:run_steps(
|
|
|
|
|
Config,
|
|
|
|
|
activemq_ct_helpers:teardown_steps()).
|
2017-01-03 00:31:59 +08:00
|
|
|
|
|
|
|
|
%% -------------------------------------------------------------------
|
|
|
|
|
%% Test cases.
|
|
|
|
|
%% -------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
init_per_testcase(_, Config) ->
|
|
|
|
|
Config.
|
|
|
|
|
|
|
|
|
|
end_per_testcase(_, Config) ->
|
|
|
|
|
Config.
|
|
|
|
|
|
|
|
|
|
%% -------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
basic_get(Config) ->
|
|
|
|
|
Hostname = ?config(rmq_hostname, Config),
|
|
|
|
|
Port = rabbit_ct_broker_helpers:get_node_config(Config, 0, tcp_port_amqp),
|
2017-01-09 20:17:52 +08:00
|
|
|
ct:pal("Opening connection to ~s:~b", [Hostname, Port]),
|
2017-01-03 00:31:59 +08:00
|
|
|
{ok, Connection} = amqp10_client_connection:open(Hostname, Port),
|
|
|
|
|
{ok, Session} = amqp10_client_session:'begin'(Connection),
|
2017-01-09 17:25:58 +08:00
|
|
|
{ok, Sender} = amqp10_client_link:sender(Session, <<"banana-sender">>, <<"test">>),
|
2017-01-11 23:27:26 +08:00
|
|
|
Msg = amqp10_msg:new(<<"my-tag">>, <<"banana">>, true),
|
|
|
|
|
ok = amqp10_client_link:send(Sender, Msg),
|
|
|
|
|
{ok, Receiver} = amqp10_client_link:receiver(Session, <<"banana-receiver2">>, <<"test">>),
|
|
|
|
|
{amqp_msg, OutMsg} = amqp10_client_link:get(Receiver),
|
2017-01-03 00:31:59 +08:00
|
|
|
ok = amqp10_client_session:'end'(Session),
|
2017-01-11 23:27:26 +08:00
|
|
|
ok = amqp10_client_connection:close(Connection),
|
|
|
|
|
?assertEqual([<<"banana">>], amqp10_msg:body(OutMsg)).
|