Skip to content

Commit c419e13

Browse files
author
Vladimir Moravec
committed
Merge pull request #25 from mmnelemane/test-rabbitmq
Add tests for RabbitMQ Messaging service
2 parents 4c149d5 + a9798e4 commit c419e13

File tree

4 files changed

+77
-1
lines changed

4 files changed

+77
-1
lines changed

features/barclamp_rabbitmq.feature

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@rabbitmq
2+
Feature: Test the AMQP Messaging service
3+
As an administrator
4+
I want to make sure the messaging service is deployed successfully
5+
6+
Background:
7+
Given the chef role "rabbitmq-server" exists on admin node
8+
And the "rabbitmq" cookbook exists on the admin node
9+
10+
Scenario: RabbitMQ Successful deployment
11+
Given the barclamp proposal is using rabbitmq as messaging backend
12+
When the node with rabbitmq-server role has been detected successfully
13+
Then I can check the status of rabbitmq-server using command line
14+
And I can add a new user and view the user in the users list
15+
And I can change the user's role to an adminstrator
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
Given(/^the barclamp proposal is using rabbitmq as messaging backend$/) do
2+
json_response = JSON.parse(admin_node.exec!("crowbar rabbitmq show default").output)
3+
expect(json_response["attributes"]["rabbitmq"]).not_to be_empty
4+
end
5+
6+
When(/^the node with rabbitmq-server role has been detected successfully$/) do
7+
@node_list = nodes.find(barclamp: "rabbitmq", element: "rabbitmq-server")
8+
expect(@node_list).not_to be_empty
9+
end
10+
11+
Then(/^I can check the status of rabbitmq-server using command line$/) do
12+
rabbitmq_status = @nodes.map do |node|
13+
node.exec!("rabbitmqctl status", capture_error: true)
14+
end
15+
expect(rabbitmq_status).to succeed_at_least_once
16+
end
17+
18+
And(/^I can add a new user and view the user in the users list$/) do
19+
@username = "cucumber_rabbit"
20+
@password = "cucumber_crowbar"
21+
results = @nodes.map do |node|
22+
user_list = node.exec!("rabbitmqctl list_users", capture_error: true)
23+
if user_list.success?
24+
if user_list.output.match(@username)
25+
node.exec!("rabbitmqctl delete_user #{@username}")
26+
end
27+
node.exec!("rabbitmqctl add_user #{@username} #{@password}")
28+
end
29+
user_list
30+
end
31+
expect(results).to succeed_at_least_once
32+
end
33+
34+
And(/^I can change the user's role to an adminstrator$/) do
35+
results = @nodes.map do |node|
36+
user_list = node.exec!("rabbitmqctl list_users", capture_error: true)
37+
if user_list.success? && user_list.output.match(@username)
38+
result = node.exec!("rabbitmqctl set_user_tags #{@username} administrator")
39+
if result.success?
40+
list_users = node.exec!("rabbitmqctl list_users")
41+
expect(list_users.output.gsub("\t", " ")).to match(/#{@username}\s\[administrator\]/)
42+
end
43+
result
44+
end
45+
user_list
46+
end
47+
expect(results).to succeed_at_least_once
48+
end
49+

tasks/features.rake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ namespace :features do
66
invoke_task "test:func:all"
77
invoke_task "feature:users"
88
invoke_task "feature:images"
9+
invoke_task "feature:barclamps"
910
end
1011

1112
desc "Run barclamp tests"
1213
task :barclamps do
13-
14+
invoke_task "feature:barclamp:rabbitmq"
1415
end
1516
end

tasks/features/barclamp_rabbitmq.rake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace :feature do
2+
namespace :barclamp do
3+
feature_name "Test the AMQP Messaging service"
4+
5+
desc "RabbitMQ Messaging service tests"
6+
feature_task :rabbitmq, tags: :@rabbitmq
7+
8+
desc "Functional tests for RabbitMQ"
9+
feature_task :all
10+
end
11+
end

0 commit comments

Comments
 (0)