From 3adfcc33d0e11331315bf95710440e1539c305d6 Mon Sep 17 00:00:00 2001 From: Madhu Mohan Nelemane Date: Fri, 18 Sep 2015 11:31:37 +0200 Subject: [PATCH] Add tests for barclamp-ceph --- features/barclamp_ceph.feature | 33 ++++++ .../barclamp_ceph/ceph_steps.rb | 108 ++++++++++++++++++ tasks/features.rake | 2 + tasks/features/barclamp_ceph.rake | 11 ++ 4 files changed, 154 insertions(+) create mode 100644 features/barclamp_ceph.feature create mode 100644 features/step_definitions/barclamp_ceph/ceph_steps.rb create mode 100644 tasks/features/barclamp_ceph.rake diff --git a/features/barclamp_ceph.feature b/features/barclamp_ceph.feature new file mode 100644 index 0000000..bfc38d1 --- /dev/null +++ b/features/barclamp_ceph.feature @@ -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 diff --git a/features/step_definitions/barclamp_ceph/ceph_steps.rb b/features/step_definitions/barclamp_ceph/ceph_steps.rb new file mode 100644 index 0000000..919a289 --- /dev/null +++ b/features/step_definitions/barclamp_ceph/ceph_steps.rb @@ -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 diff --git a/tasks/features.rake b/tasks/features.rake index 9e88d46..248dedc 100644 --- a/tasks/features.rake +++ b/tasks/features.rake @@ -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 diff --git a/tasks/features/barclamp_ceph.rake b/tasks/features/barclamp_ceph.rake new file mode 100644 index 0000000..672a8fc --- /dev/null +++ b/tasks/features/barclamp_ceph.rake @@ -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