Skip to content

Commit

Permalink
Add tests for barclamp-ceph
Browse files Browse the repository at this point in the history
  • Loading branch information
mmnelemane committed Sep 21, 2015
1 parent 86cfc8e commit 3adfcc3
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 0 deletions.
33 changes: 33 additions & 0 deletions features/barclamp_ceph.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@ceph
Feature: Tests Ceph barclamp deployment
As an actor
I want to perform various validations
In order to verify the feature functionality

Background:
Given the chef role "ceph-mon" exists on admin node
And the chef role "ceph-mds" exists on admin node
And the chef role "ceph-osd" exists on admin node
And the chef role "ceph-radosgw" exists on admin node
And the chef role "ceph-calamari" exists on admin node
And the "ceph" cookbook exists on the admin node

Scenario: Ceph deployment and functioning
Given the barclamp proposal for "ceph" is deployed
When the node with "ceph-mon" role has been detected successfully
And the node with "ceph-osd" role has been detected successfully
And the node with "ceph-radosgw" role has been detected successfully
And the package "ceph" is installed in the controller node
And the package "ceph-radosgw" is installed in the controller node
Then I can check that the overall health of the ceph cluster is OK
And I can get the CRUSH tree of the ceph cluster
And I can check the status of the placement groups
And I can check if data, metadata and rbd have pools allocated
And I can create a block device "cucumber_rbd" in the data pool
And I can retreive the block device image information or resize it
And I can remove the block device "cucumber_rbd" in the data pool
And I can create a radosgw-admin user "cucumber_test"
And I can remove radosgw-admin user "cucumber_test"
And I can create an object "cucumber_obj" in the "data" pool and see the object in the list
And I can download the object "cucumber_obj" into the file system
And I can delete the object "cucumber_obj" from the data pool
108 changes: 108 additions & 0 deletions features/step_definitions/barclamp_ceph/ceph_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
Given(/^the barclamp proposal for "([^"]*)" is deployed$/) do |package_name|
json_response = JSON.parse(admin_node.exec!("crowbar ceph show default").output)
expect(json_response["attributes"]["ceph"]["config"]["osds_in_total"]).not_to be < 2
end

When(/^the node with "([^"]*)" role has been detected successfully$/) do |service_name|
@node_list = Hash.new
json_response = JSON.parse(admin_node.exec!("crowbar ceph show default").output)
@node_list[service_name] = json_response["deployment"]["ceph"]["elements"][service_name]
expect(json_response["deployment"]["ceph"]["elements"][service_name]).not_to be_empty
end

And(/^the package "([^"]*)" is installed in the controller node$/) do |package_name|
control_node.rpm_q(package_name)
end

Then(/^I can check that the overall health of the ceph cluster is OK$/) do
json_response = JSON.parse(control_node.exec!("ceph status -f json-pretty").output)
expect(json_response["health"]["overall_status"]).to eq("HEALTH_OK")
end

And(/^I can get the CRUSH tree of the ceph cluster$/) do
json_response = JSON.parse(control_node.exec!("ceph osd tree -f json-pretty").output)
expect(json_response).not_to be_empty
end

And(/^I can check the status of the placement groups$/) do
response = control_node.exec!("ceph pg stat --concise").output
expect(response).not_to be_empty
end

And(/^I can check if data, metadata and rbd have pools allocated$/) do
json_response = JSON.parse(control_node.exec!("ceph osd lspools -f json-pretty").output)
data_exists = metadata_exists = rbd_exists = rgw_exists = false
json_response.each do |pool_record|
if pool_record["poolname"] == "data"
data_exists = true
end
if pool_record["poolname"] == "metadata"
metadata_exists = true
end
if pool_record["poolname"] == "rbd"
rbd_exists = true
end
if pool_record["poolname"] == ".rgw"
rgw_exists = true
end
end
expect(data_exists && metadata_exists && rbd_exists && rgw_exists).to eq(true)
end

And(/^I can create a block device "([^"]*)" in the data pool$/) do |rbd_name|
control_node.exec!("rbd create #{rbd_name} --size 1024 --pool data")
response = control_node.exec!("rbd ls --pool data").output
obj_list = response.split(/\n/)
expect(obj_list).to include(rbd_name)
end

And(/^I can retreive the block device image information or resize it$/) do
rbd_info = control_node.exec!("rbd info cucumber_rbd --pool data").output
resize_output = control_node.exec!("rbd resize --size 2048 cucumber_rbd --pool data").output
rbd_info = control_node.exec!("rbd info cucumber_rbd --pool data").output
s_expect = "size 2048 MB"
s1 = "size 1024 MB"
rbd_info.lines.each do |line|
if line.match(/size/)
s1 = line.match(/size 2048 MB/)[0].to_s
end
end
expect(s1).to eq(s_expect)
end

And(/^I can remove the block device "([^"]*)" in the data pool$/) do |rbd_name|
control_node.exec!("rbd rm #{rbd_name} --pool data")
response = control_node.exec!("rbd ls --pool data").output
obj_list = response.split(/\n/)
expect(obj_list).not_to include(rbd_name)
end

And(/^I can create a radosgw-admin user "([^"]*)"$/) do |rgw_username|
json_response = JSON.parse(control_node.exec!("radosgw-admin user create --display-name=\"cucumber test\" --uid=cucumber").output)
expect(json_response["user_id"]).to eq("cucumber")
end

And(/^I can remove radosgw-admin user "([^"]*)"$/) do |rgw_username|
control_node.exec!("radosgw-admin user rm --uid=cucumber")
end

And(/^I can create an object "([^"]*)" in the "([^"]*)" pool and see the object in the list$/) do |obj_name, pool_name|
control_node.exec!("rados create #{obj_name} --pool #{pool_name}")
response = control_node.exec!("rados ls --pool #{pool_name}").output
obj_list = response.split(/\n/)
expect(obj_list).to include(obj_name)
end

And(/^I can download the object "([^"]*)" into the file system$/) do |obj_name|
control_node.exec!("rados get #{obj_name} cucumber.obj --pool data")
response = control_node.exec!("ls cucumber.obj").output
obj_list = response.split(/\n/)
expect(obj_list).to include("cucumber.obj")
end

And(/^I can delete the object "([^"]*)" from the data pool$/) do |obj_name|
control_node.exec!("rados rm #{obj_name} --pool data")
response = control_node.exec!("rados ls --pool data").output
obj_list = response.split(/\n/)
expect(obj_list).not_to include(obj_name)
end
2 changes: 2 additions & 0 deletions tasks/features.rake
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ namespace :features do
invoke_task "features:barclamps"
invoke_task "feature:users"
invoke_task "feature:images"
invoke_task "feature:barclamps"
end

desc "Run barclamp tests"
task :barclamps do
invoke_task "feature_barclamp:ceph"
invoke_task "feature:barclamp:database"
end
end
11 changes: 11 additions & 0 deletions tasks/features/barclamp_ceph.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace :feature do
feature_name "Tests Ceph barclamp deployment"

namespace :barclamp do
desc "Barclamp Ceph feature"
feature_task :ceph, tags: :@ceph

desc "Verification of Ceph Deployment"
feature_task :all
end
end

0 comments on commit 3adfcc3

Please sign in to comment.