Initial definitions import test

This commit is contained in:
Michael Klishin 2017-09-27 12:21:39 +03:00
parent f1e4255cb9
commit 504da8c360
3 changed files with 232 additions and 0 deletions

View File

@ -0,0 +1,84 @@
%% 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.
%%
%% Copyright (c) 2016 Pivotal Software, Inc. All rights reserved.
%%
%% This test suite covers the definitions import function
%% outside of the context of HTTP API (e.g. when definitions are
%% imported on boot).
-module(definitions_import_SUITE).
-include_lib("common_test/include/ct.hrl").
-include_lib("rabbit_common/include/rabbit.hrl").
-compile(export_all).
all() ->
[
{group, non_parallel_tests}
].
groups() ->
[
{non_parallel_tests, [], [
import_case1
]}
].
%% -------------------------------------------------------------------
%% Test suite setup/teardown.
%% -------------------------------------------------------------------
init_per_suite(Config) ->
rabbit_ct_helpers:log_environment(),
inets:start(),
Config1 = rabbit_ct_helpers:set_config(Config, [
{rmq_nodename_suffix, ?MODULE}
]),
rabbit_ct_helpers:run_setup_steps(Config1,
rabbit_ct_broker_helpers:setup_steps() ++
rabbit_ct_client_helpers:setup_steps()).
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).
%%
%% Tests
%%
import_case1(Config) ->
import_case(Config, "case1").
import_case(Config, CaseName) ->
CasePath = filename:join(?config(data_dir, Config), CaseName ++ ".json"),
rabbit_ct_broker_helpers:rpc(Config, 0, ?MODULE, run_import_case, [CasePath]),
ok.
run_import_case(Path) ->
{ok, Body} = file:read_file(Path),
ct:pal("Successfully loaded a definition to import from ~p~n", [Path]),
rabbit_mgmt_wm_definitions:apply_defs(Body, ?INTERNAL_USER,
fun () -> ct:pal("Import case ~p succeeded~n", [Path]) end,
fun (E) -> ct:pal("Import case ~p failed: ~p~n", [Path, E]) end).

View File

@ -0,0 +1,99 @@
{
"rabbit_version": "3.6.9",
"users": [
{
"name": "project_admin",
"password_hash": "A0EX\/2hiwrIDKFS+nEqwbCGcVxwEkDBFF3mBfkNW53KFFk64",
"hashing_algorithm": "rabbit_password_hashing_sha256",
"tags": ""
}
],
"vhosts": [
{
"name": "\/"
}
],
"permissions": [
{
"user": "project_admin",
"vhost": "\/",
"configure": ".*",
"write": ".*",
"read": ".*"
}
],
"policies": [
{
"vhost": "\/",
"name": "nd-ns",
"pattern": "^project-nd-ns-",
"apply-to": "queues",
"definition": {
"expires": 120000,
"max-length": 10000
},
"priority": 1
},
{
"vhost": "\/",
"name": "nd-s",
"pattern": "^project-nd-s-",
"apply-to": "queues",
"definition": {
"expires": 1800000,
"max-length": 50000
},
"priority": 1
},
{
"vhost": "\/",
"name": "d-ns",
"pattern": "^project-d-ns-",
"apply-to": "queues",
"definition": {
"ha-mode": "exactly",
"ha-params": 3,
"ha-sync-mode": "automatic",
"expires": 604800000,
"ha-sync-batch-size": 100,
"queue-mode": "lazy"
},
"priority": 1
},
{
"vhost": "\/",
"name": "d-s",
"pattern": "^project-d-s-",
"apply-to": "queues",
"definition": {
"ha-mode": "exactly",
"ha-params": 3,
"ha-sync-mode": "automatic",
"expires": 604800000,
"queue-master-locator": "min-masters",
"ha-sync-batch-size": 100,
"queue-mode": "lazy"
},
"priority": 1
}
],
"queues": [
],
"exchanges": [
{
"name": "project.topic.default",
"vhost": "\/",
"type": "topic",
"durable": true,
"auto_delete": false,
"internal": false,
"arguments": {
}
}
],
"bindings": [
]
}

View File

@ -0,0 +1,49 @@
{
"rabbit_version": "3.7.0-rc.1",
"users": [
{
"name": "guest",
"password_hash": "A0EX\/2hiwrIDKFS+nEqwbCGcVxwEkDBFF3mBfkNW53KFFk64",
"hashing_algorithm": "rabbit_password_hashing_sha256",
"tags": "administrator"
}
],
"vhosts": [
{
"name": "\/"
}
],
"permissions": [
{
"user": "guest",
"vhost": "\/",
"configure": ".*",
"write": ".*",
"read": ".*"
}
],
"topic_permissions": [
],
"parameters": [
],
"global_parameters": [
{
"name": "cluster_name",
"value": "rabbit@mercurio"
}
],
"policies": [
],
"queues": [
],
"exchanges": [
],
"bindings": [
]
}