Merge branch 'stable'
This commit is contained in:
commit
6952b4a906
|
|
@ -10,11 +10,18 @@ addons:
|
|||
otp_release:
|
||||
- "18.3"
|
||||
|
||||
# The checkout made by Travis is a "detached HEAD". We switch back
|
||||
# to a tag or a branch. This pleases our git_rmq fetch method in
|
||||
# rabbitmq-components.mk and the proper tag/branch is selected in
|
||||
# dependencies too.
|
||||
before_script: (test "$TRAVIS_TAG" && git checkout "$TRAVIS_TAG") || (test "$TRAVIS_BRANCH" && git checkout "$TRAVIS_BRANCH")
|
||||
# The checkout made by Travis is a "detached HEAD" and branches
|
||||
# information is missing. Our Erlang.mk's git_rmq fetch method relies on
|
||||
# it, so we need to restore it.
|
||||
#
|
||||
# We simply fetch master and, if it exists, stable branches. A branch is
|
||||
# created, pointing to the detached HEAD.
|
||||
before_script:
|
||||
- |
|
||||
git checkout -B "${TRAVIS_TAG:-${TRAVIS_BRANCH}}"
|
||||
git remote add upstream https://github.com/$TRAVIS_REPO_SLUG.git
|
||||
git fetch upstream stable:stable || :
|
||||
git fetch upstream master:master || :
|
||||
|
||||
script: make tests
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,20 @@
|
|||
PROJECT = rabbitmq_event_exchange
|
||||
|
||||
TEST_DEPS = amqp_client
|
||||
TEST_DEPS += amqp_client
|
||||
TEST_DEPS += rabbit
|
||||
|
||||
DEP_PLUGINS = rabbit_common/mk/rabbitmq-plugin.mk
|
||||
|
||||
# FIXME: Use erlang.mk patched for RabbitMQ, while waiting for PRs to be
|
||||
# reviewed and merged.
|
||||
|
||||
ERLANG_MK_REPO = https://github.com/rabbitmq/erlang.mk.git
|
||||
ERLANG_MK_COMMIT = rabbitmq-tmp
|
||||
|
||||
include rabbitmq-components.mk
|
||||
include erlang.mk
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# Testing.
|
||||
# --------------------------------------------------------------------
|
||||
TEST_DEPS := $(filter-out rabbitmq_test,$(TEST_DEPS))
|
||||
|
||||
WITH_BROKER_TEST_COMMANDS := \
|
||||
rabbit_exchange_type_event_test_all:all_tests()
|
||||
include erlang.mk
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
%% 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 Consistent Hash Exchange.
|
||||
%%
|
||||
%% The Initial Developer of the Original Code is GoPivotal, Inc.
|
||||
%% Copyright (c) 2007-2016 Pivotal Software, Inc. All rights reserved.
|
||||
%%
|
||||
|
||||
-module(rabbit_exchange_type_event_test_all).
|
||||
|
||||
-export([all_tests/0]).
|
||||
|
||||
all_tests() ->
|
||||
ok = eunit:test(tests(rabbit_exchange_type_event_unit_test, 60), [verbose]),
|
||||
ok = eunit:test(tests(rabbit_exchange_type_event_test, 60), [verbose]).
|
||||
|
||||
tests(Module, Timeout) ->
|
||||
{foreach, fun() -> ok end,
|
||||
[{timeout, Timeout, fun () -> Module:F() end} ||
|
||||
{F, _Arity} <- proplists:get_value(exports, Module:module_info()),
|
||||
string:right(atom_to_list(F), 5) =:= "_test"]}.
|
||||
|
|
@ -14,16 +14,59 @@
|
|||
%% Copyright (c) 2007-2016 Pivotal Software, Inc. All rights reserved.
|
||||
%%
|
||||
|
||||
-module(rabbit_exchange_type_event_test).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
-module(system_SUITE).
|
||||
-include_lib("common_test/include/ct.hrl").
|
||||
|
||||
-include_lib("amqp_client/include/amqp_client.hrl").
|
||||
-compile(export_all).
|
||||
|
||||
all() ->
|
||||
[
|
||||
queue_created,
|
||||
authentication
|
||||
].
|
||||
|
||||
%% -------------------------------------------------------------------
|
||||
%% Testsuite setup/teardown.
|
||||
%% -------------------------------------------------------------------
|
||||
|
||||
init_per_suite(Config) ->
|
||||
rabbit_ct_helpers:log_environment(),
|
||||
Config1 = rabbit_ct_helpers:set_config(Config, [
|
||||
{rmq_nodename_suffix, ?MODULE}
|
||||
]),
|
||||
Config2 = rabbit_ct_helpers:run_setup_steps(Config1,
|
||||
rabbit_ct_broker_helpers:setup_steps() ++
|
||||
rabbit_ct_client_helpers:setup_steps()),
|
||||
Config2.
|
||||
|
||||
end_per_suite(Config) ->
|
||||
rabbit_ct_helpers:run_teardown_steps(Config,
|
||||
rabbit_ct_client_helpers:teardown_steps() ++
|
||||
rabbit_ct_broker_helpers:teardown_steps()).
|
||||
|
||||
init_per_group(_, Config) ->
|
||||
Config.
|
||||
|
||||
end_per_group(_, Config) ->
|
||||
Config.
|
||||
|
||||
init_per_testcase(Testcase, Config) ->
|
||||
rabbit_ct_helpers:testcase_started(Config, Testcase).
|
||||
|
||||
end_per_testcase(Testcase, Config) ->
|
||||
rabbit_ct_helpers:testcase_finished(Config, Testcase).
|
||||
|
||||
|
||||
%% -------------------------------------------------------------------
|
||||
%% Testsuite cases
|
||||
%% -------------------------------------------------------------------
|
||||
|
||||
%% Only really tests that we're not completely broken.
|
||||
queue_created_test() ->
|
||||
queue_created(Config) ->
|
||||
Now = os:system_time(seconds),
|
||||
{ok, Conn} = amqp_connection:start(#amqp_params_network{}),
|
||||
{ok, Ch} = amqp_connection:open_channel(Conn),
|
||||
|
||||
Ch = rabbit_ct_client_helpers:open_channel(Config, 0),
|
||||
#'queue.declare_ok'{queue = Q} =
|
||||
amqp_channel:call(Ch, #'queue.declare'{exclusive = true}),
|
||||
amqp_channel:call(Ch, #'queue.bind'{queue = Q,
|
||||
|
|
@ -42,27 +85,25 @@ queue_created_test() ->
|
|||
{#'basic.deliver'{routing_key = Key},
|
||||
#amqp_msg{props = #'P_basic'{headers = Headers, timestamp = TS}}} ->
|
||||
%% timestamp is within the last 5 seconds
|
||||
?assert((TS - Now) =< 5),
|
||||
?assertMatch(<<"queue.created">>, Key),
|
||||
?assertMatch({longstr, Q2}, rabbit_misc:table_lookup(
|
||||
Headers, <<"name">>))
|
||||
true = ((TS - Now) =< 5),
|
||||
<<"queue.created">> = Key,
|
||||
{longstr, Q2} = rabbit_misc:table_lookup(Headers, <<"name">>)
|
||||
end,
|
||||
|
||||
amqp_connection:close(Conn),
|
||||
rabbit_ct_client_helpers:close_channel(Ch),
|
||||
ok.
|
||||
|
||||
|
||||
authentication_test() ->
|
||||
{ok, Conn} = amqp_connection:start(#amqp_params_network{}),
|
||||
{ok, Ch} = amqp_connection:open_channel(Conn),
|
||||
authentication(Config) ->
|
||||
Ch = rabbit_ct_client_helpers:open_channel(Config, 0),
|
||||
|
||||
#'queue.declare_ok'{queue = Q} =
|
||||
amqp_channel:call(Ch, #'queue.declare'{exclusive = true}),
|
||||
amqp_channel:call(Ch, #'queue.bind'{queue = Q,
|
||||
exchange = <<"amq.rabbitmq.event">>,
|
||||
routing_key = <<"user.#">>}),
|
||||
Conn2 = rabbit_ct_client_helpers:open_unmanaged_connection(Config, 0),
|
||||
|
||||
{ok, Conn2} = amqp_connection:start(#amqp_params_network{}),
|
||||
amqp_channel:subscribe(Ch, #'basic.consume'{queue = Q, no_ack = true},
|
||||
self()),
|
||||
receive
|
||||
|
|
@ -72,15 +113,11 @@ authentication_test() ->
|
|||
receive
|
||||
{#'basic.deliver'{routing_key = Key},
|
||||
#amqp_msg{props = #'P_basic'{headers = Headers}}} ->
|
||||
?assertMatch(<<"user.authentication.success">>, Key),
|
||||
?assertMatch(undefined, rabbit_misc:table_lookup(
|
||||
Headers, <<"vhost">>)),
|
||||
?assertMatch({longstr, _PeerHost}, rabbit_misc:table_lookup(
|
||||
Headers, <<"peer_host">>)),
|
||||
?assertMatch({bool, false}, rabbit_misc:table_lookup(
|
||||
Headers, <<"ssl">>))
|
||||
<<"user.authentication.success">> = Key,
|
||||
undefined = rabbit_misc:table_lookup(Headers, <<"vhost">>),
|
||||
{longstr, _PeerHost} = rabbit_misc:table_lookup(Headers, <<"peer_host">>),
|
||||
{bool, false} = rabbit_misc:table_lookup(Headers, <<"ssl">>)
|
||||
end,
|
||||
|
||||
amqp_connection:close(Conn),
|
||||
amqp_connection:close(Conn2),
|
||||
ok.
|
||||
|
|
@ -14,14 +14,17 @@
|
|||
%% Copyright (c) 2007-2016 Pivotal Software, Inc. All rights reserved.
|
||||
%%
|
||||
|
||||
-module(rabbit_exchange_type_event_unit_test).
|
||||
-module(unit_SUITE).
|
||||
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
-include_lib("common_test/include/ct.hrl").
|
||||
|
||||
encoding_test() ->
|
||||
T = fun (In, Exp) ->
|
||||
?assertEqual(rabbit_exchange_type_event:fmt_proplist(In), Exp)
|
||||
end,
|
||||
-compile(export_all).
|
||||
|
||||
all() -> [ encoding ].
|
||||
|
||||
encoding(_) ->
|
||||
T = fun (In, Exp) ->
|
||||
true = (rabbit_exchange_type_event:fmt_proplist(In) == Exp) end,
|
||||
T([{name, <<"test">>}],
|
||||
[{<<"name">>, longstr, <<"test">>}]),
|
||||
T([{name, rabbit_misc:r(<<"/">>, exchange, <<"test">>)}],
|
||||
Loading…
Reference in New Issue