deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject svn commit: r1214357 - in /deltacloud/trunk/server: Rakefile tests/cimi/features/step_definitions/volumes_steps.rb tests/cimi/features/volumes.feature
Date Wed, 14 Dec 2011 17:24:05 GMT
Author: marios
Date: Wed Dec 14 17:24:05 2011
New Revision: 1214357

URL: http://svn.apache.org/viewvc?rev=1214357&view=rev
Log:
Adds cucumber scenario and steps for CIMI::Volumes

Added:
    deltacloud/trunk/server/tests/cimi/features/step_definitions/volumes_steps.rb
    deltacloud/trunk/server/tests/cimi/features/volumes.feature
Modified:
    deltacloud/trunk/server/Rakefile

Modified: deltacloud/trunk/server/Rakefile
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/Rakefile?rev=1214357&r1=1214356&r2=1214357&view=diff
==============================================================================
--- deltacloud/trunk/server/Rakefile (original)
+++ deltacloud/trunk/server/Rakefile Wed Dec 14 17:24:05 2011
@@ -63,6 +63,10 @@ begin
       t.cucumber_opts = "tests/cimi/features/machine_images.feature --format pretty"
       t.rcov = false
     end
+    Cucumber::Rake::Task.new(:volumes) do |t|
+      t.cucumber_opts = "tests/cimi/features/volumes.feature --format pretty"
+      t.rcov = false
+   end
   end
 rescue LoadError
 end

Added: deltacloud/trunk/server/tests/cimi/features/step_definitions/volumes_steps.rb
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/tests/cimi/features/step_definitions/volumes_steps.rb?rev=1214357&view=auto
==============================================================================
--- deltacloud/trunk/server/tests/cimi/features/step_definitions/volumes_steps.rb (added)
+++ deltacloud/trunk/server/tests/cimi/features/step_definitions/volumes_steps.rb Wed Dec
14 17:24:05 2011
@@ -0,0 +1,77 @@
+When /^client specifies a Volume Configuration$/ do |volume_config|
+  header 'Accept', 'application/xml'
+  authorize 'mockuser', 'mockpassword'
+  get volume_config.raw[0][1]
+  last_response.status.should==200
+  @volume_config = CIMI::Model::VolumeConfiguration.from_xml(last_response.body)
+  @volume_config.class.should == CIMI::Model::VolumeConfiguration
+  @volume_config.attribute_values[:capacity].quantity.should == "2"
+  @volume_config.uri.should == volume_config.raw[0][1]
+end
+
+When /^client specifies a new Volume using$/ do |volume|
+  @volume_config.should_not be_nil
+  volume_name = volume.raw[0][1]
+  volume_description = volume.raw[1][1]
+  @builder = Nokogiri::XML::Builder.new do |xml|
+    xml.Volume(:xmlns => CMWG_NAMESPACE) {
+      xml.name volume_name
+      xml.description volume_description
+      xml.volumeTemplate {
+        xml.volumeConfig( :href => @volume_config.uri )
+      }
+    }
+  end
+end
+
+Then /^client should be able to create this Volume$/ do
+  authorize 'mockuser', 'mockpassword'
+  header 'Content-Type', 'application/xml'
+  post '/cimi/volumes', @builder.to_xml
+  last_response.status.should == 200
+  @@created_volume = CIMI::Model::Volume.from_xml(last_response.body)
+end
+
+When /^client GET the Volumes Collection$/ do
+  authorize 'mockuser', 'mockpassword'
+  header 'Content-Type', 'application/xml'
+  get "/cimi/volumes"
+  last_response.status.should == 200
+  @@volume_collection = VolumeCollection.from_xml(last_response.body)
+end
+
+Then /^client should get a list of volumes$/ do
+  @@volume_collection.uri.end_with?("/cimi/volumes").should == true
+  @@volume_collection.attribute_values.has_key?(:volumes).should == true
+end
+
+Then /^list of volumes should contain newly created volume$/ do
+  volumes = @@volume_collection.attribute_values[:volumes].map{|v| v.href.split("/").last}
+  volumes.include?(@@created_volume.name).should == true
+end
+
+When /^client GET the newly created Volume in json format$/ do
+  authorize 'mockuser', 'mockpassword'
+  get "/cimi/volumes/#{@@created_volume.name}?format=json"
+  last_response.status.should == 200
+  @@retrieved_volume = CIMI::Model::Volume.from_json(last_response.body)
+end
+
+Then /^client should verify that this Volume was created correctly$/ do |capacity|
+  @@retrieved_volume.name.should == @@created_volume.name
+  @@retrieved_volume.uri.should == @@created_volume.uri
+  @@retrieved_volume.capacity[:quantity].should == capacity.raw[0][1]
+end
+
+When /^client deletes the newly created Volume$/ do
+  authorize 'mockuser', 'mockpassword'
+  delete "/cimi/volumes/#{@@created_volume.name}"
+  last_response.status.should == 200
+end
+
+Then /^client should verify the volume was deleted$/ do
+  authorize 'mockuser', 'mockpassword'
+  get "/cimi/volumes/#{@@created_volume.name}"
+  last_response.status.should == 404
+end
+

Added: deltacloud/trunk/server/tests/cimi/features/volumes.feature
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/tests/cimi/features/volumes.feature?rev=1214357&view=auto
==============================================================================
--- deltacloud/trunk/server/tests/cimi/features/volumes.feature (added)
+++ deltacloud/trunk/server/tests/cimi/features/volumes.feature Wed Dec 14 17:24:05 2011
@@ -0,0 +1,32 @@
+Feature: CIMI Volumes Collection
+  The URI of the Volumes collection is given in the Cloud Entry Point.
+
+Scenario: Create a new Volume entity
+  Given Cloud Entry Point URL is provided
+  And client retrieve the Cloud Entry Point
+  When client specifies a Volume Configuration
+    | volumeConfig | http://example.com/cimi/volume_configurations/2 |
+  And client specifies a new Volume using
+    | name | cucumber_volume |
+    | description | created in a cucumber scenario |
+  Then client should be able to create this Volume
+
+Scenario: Query the Volume collection
+  Given Cloud Entry Point URL is provided
+  And client retrieve the Cloud Entry Point
+  When client GET the Volumes Collection
+  Then client should get a list of volumes
+  And list of volumes should contain newly created volume
+
+Scenario: Query the newly created Volume
+  Given Cloud Entry Point URL is provided
+  And client retrieve the Cloud Entry Point
+  When client GET the newly created Volume in json format
+  Then client should verify that this Volume was created correctly
+    | capacity | 2 |
+
+Scenario: Delete the newly created Volume
+  Given Cloud Entry Point URL is provided
+  And client retrieve the Cloud Entry Point
+  When client deletes the newly created Volume
+  Then client should verify the volume was deleted



Mime
View raw message