Skip to content

Commit 8b3039a

Browse files
committed
Add tests for barclamp-ceph
1 parent 4c149d5 commit 8b3039a

File tree

4 files changed

+184
-1
lines changed

4 files changed

+184
-1
lines changed

features/barclamp_ceph.feature

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
@ceph
2+
Feature: Tests Ceph barclamp deployment
3+
As an administrator
4+
I want to make sure the ceph cluster is deployed successfully
5+
In order to be used by the cloud for block/object storage
6+
7+
Background:
8+
Given the chef role "ceph-mon" exists on admin node
9+
And the chef role "ceph-mds" exists on admin node
10+
And the chef role "ceph-osd" exists on admin node
11+
And the chef role "ceph-radosgw" exists on admin node
12+
And the chef role "ceph-calamari" exists on admin node
13+
And the "ceph" cookbook exists on the admin node
14+
15+
@rbd
16+
Scenario: Tests for Ceph Block Device deployment
17+
Given the barclamp proposal for ceph is deployed
18+
When the node with ceph-mon role has been detected successfully
19+
And the node with ceph-osd role has been detected successfully
20+
And the package ceph is installed in the controller node
21+
Then I can check that the overall health of the ceph cluster is OK
22+
And I can get the CRUSH tree of the ceph cluster
23+
And I can check the status of the placement groups
24+
And I can check if data, metadata and rbd have pools allocated
25+
And I can create a block device "cucumber_rbd" in the data pool
26+
And I can retreive the block device image information or resize it
27+
And I can remove the block device "cucumber_rbd" in the data pool
28+
29+
@radosgw
30+
Scenario: Tests for Ceph Rados Gateway deployment
31+
Given the node with ceph-radosgw role has been detected successfully
32+
And the package ceph-radosgw is installed in the controller node
33+
Then I can create a radosgw-admin user "cucumber_test"
34+
And I can remove radosgw-admin user "cucumber_test"
35+
And I can create an object "cucumber_obj" in the "data" pool and see the object in the list
36+
And I can download the object "cucumber_obj" into the file system
37+
And I can delete the object "cucumber_obj" from the data pool
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
Given(/^the barclamp proposal for ceph is deployed$/) do
2+
json_response = JSON.parse(admin_node.exec!("crowbar ceph show default").output)
3+
expect(json_response["attributes"]["ceph"]["config"]["osds_in_total"]).not_to be < 2
4+
end
5+
6+
When(/^the node with ceph-mon role has been detected successfully$/) do
7+
@node_list = Hash.new
8+
json_response = JSON.parse(admin_node.exec!("crowbar ceph show default").output)
9+
@node_list["ceph-mon"] = json_response["deployment"]["ceph"]["elements"]["ceph-mon"]
10+
expect(@node_list["ceph-mon"]).not_to be_empty
11+
end
12+
13+
And(/^the node with ceph-osd role has been detected successfully$/) do
14+
json_response = JSON.parse(admin_node.exec!("crowbar ceph show default").output)
15+
@node_list["ceph-osd"] = json_response["deployment"]["ceph"]["elements"]["ceph-osd"]
16+
expect(@node_list["ceph-osd"]).not_to be_empty
17+
end
18+
19+
And(/^the package ceph is installed in the controller node$/) do
20+
node = nodes.find(fqdn: @node_list["ceph-mon"][0])
21+
node.exec!("rpm -q ceph")
22+
end
23+
24+
Then(/^I can check that the overall health of the ceph cluster is OK$/) do
25+
json_response = JSON.parse(control_node.exec!("ceph status -f json-pretty").output)
26+
expect(json_response["health"]["overall_status"]).to eq("HEALTH_OK")
27+
end
28+
29+
And(/^I can get the CRUSH tree of the ceph cluster$/) do
30+
json_response = JSON.parse(control_node.exec!("ceph osd tree -f json-pretty").output)
31+
expect(json_response).not_to be_empty
32+
end
33+
34+
And(/^I can check the status of the placement groups$/) do
35+
response = control_node.exec!("ceph pg stat --concise").output
36+
expect(response).not_to be_empty
37+
end
38+
39+
And(/^I can check if data, metadata and rbd have pools allocated$/) do
40+
json_response = JSON.parse(control_node.exec!("ceph osd lspools -f json-pretty").output)
41+
data_exists = metadata_exists = rbd_exists = rgw_exists = false
42+
json_response.each do |pool_record|
43+
if pool_record["poolname"] == "data"
44+
data_exists = true
45+
end
46+
if pool_record["poolname"] == "metadata"
47+
metadata_exists = true
48+
end
49+
if pool_record["poolname"] == "rbd"
50+
rbd_exists = true
51+
end
52+
if pool_record["poolname"] == ".rgw"
53+
rgw_exists = true
54+
end
55+
end
56+
expect(data_exists && metadata_exists && rbd_exists && rgw_exists).to eq(true)
57+
end
58+
59+
And(/^I can create a block device "([^"]*)" in the data pool$/) do |rbd_name|
60+
control_node.exec!("rbd create #{rbd_name} --size 1024 --pool data")
61+
response = control_node.exec!("rbd ls --pool data").output
62+
obj_list = response.split(/\n/)
63+
expect(obj_list).to include(rbd_name)
64+
end
65+
66+
And(/^I can retreive the block device image information or resize it$/) do
67+
rbd_info = control_node.exec!("rbd info cucumber_rbd --pool data").output
68+
resize_output = control_node.exec!("rbd resize --size 2048 cucumber_rbd --pool data").output
69+
rbd_info = control_node.exec!("rbd info cucumber_rbd --pool data").output
70+
s_expect = "size 2048 MB"
71+
s1 = "size 1024 MB"
72+
rbd_info.lines.each do |line|
73+
if line.match(/size/)
74+
s1 = line.match(/size 2048 MB/)[0].to_s
75+
end
76+
end
77+
expect(s1).to eq(s_expect)
78+
end
79+
80+
And(/^I can remove the block device "([^"]*)" in the data pool$/) do |rbd_name|
81+
control_node.exec!("rbd rm #{rbd_name} --pool data")
82+
response = control_node.exec!("rbd ls --pool data").output
83+
obj_list = response.split(/\n/)
84+
expect(obj_list).not_to include(rbd_name)
85+
end
86+
87+
Given(/^the node with ceph-radosgw role has been detected successfully$/) do
88+
json_response = JSON.parse(admin_node.exec!("crowbar ceph show default").output)
89+
@node_list["ceph-radosgw"] = json_response["deployment"]["ceph"]["elements"]["ceph-radosgw"]
90+
expect(@node_list["ceph-radosgw"]).not_to be_empty
91+
end
92+
93+
And(/^the package ceph-radosgw is installed in the controller node$/) do
94+
node = nodes.find(fqdn: @node_list["ceph-radosgw"][0])
95+
node.exec!("rpm -q ceph-radosgw")
96+
end
97+
98+
Then(/^I can create a radosgw-admin user "([^"]*)"$/) do |rgw_username|
99+
json_response = JSON.parse(control_node.exec!("radosgw-admin user create --display-name=\"cucumber test\" --uid=cucumber").output)
100+
expect(json_response["user_id"]).to eq("cucumber")
101+
end
102+
103+
And(/^I can remove radosgw-admin user "([^"]*)"$/) do |rgw_username|
104+
control_node.exec!("radosgw-admin user rm --uid=cucumber")
105+
end
106+
107+
And(/^I can create an object "([^"]*)" in the "([^"]*)" pool and see the object in the list$/) do |obj_name, pool_name|
108+
control_node.exec!("rados create #{obj_name} --pool #{pool_name}")
109+
response = control_node.exec!("rados ls --pool #{pool_name}").output
110+
obj_list = response.split(/\n/)
111+
expect(obj_list).to include(obj_name)
112+
end
113+
114+
And(/^I can download the object "([^"]*)" into the file system$/) do |obj_name|
115+
control_node.exec!("rados get #{obj_name} cucumber.obj --pool data")
116+
response = control_node.exec!("ls cucumber.obj").output
117+
obj_list = response.split(/\n/)
118+
expect(obj_list).to include("cucumber.obj")
119+
end
120+
121+
And(/^I can delete the object "([^"]*)" from the data pool$/) do |obj_name|
122+
control_node.exec!("rados rm #{obj_name} --pool data")
123+
response = control_node.exec!("rados ls --pool data").output
124+
obj_list = response.split(/\n/)
125+
expect(obj_list).not_to include(obj_name)
126+
end

tasks/features.rake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ 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:ceph"
15+
invoke_task "feature:barclamp:database"
1416
end
1517
end

tasks/features/barclamp_ceph.rake

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace :feature do
2+
feature_name "Tests Ceph barclamp deployment"
3+
4+
namespace :barclamp do
5+
desc "Barclamp Ceph feature"
6+
namespace :ceph do
7+
desc "Test Ceph block device deployment"
8+
feature_task :rbd, tags: :@ceph
9+
10+
desc "Test Ceph RadowGW deployment"
11+
feature_task :radosgw, tags: :@radosgw
12+
13+
feature_task :all
14+
end
15+
desc "Verification of Ceph Deployment"
16+
task :ceph => "ceph:all"
17+
end
18+
end

0 commit comments

Comments
 (0)