deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject svn commit: r1207788 - in /deltacloud/trunk/server: ./ tests/cimi/features/ tests/cimi/features/step_definitions/ tests/cimi/features/support/
Date Tue, 29 Nov 2011 08:39:32 GMT
Author: mfojtik
Date: Tue Nov 29 08:39:31 2011
New Revision: 1207788

URL: http://svn.apache.org/viewvc?rev=1207788&view=rev
Log:
CIMI: Added Cucumber features for MachineImage

Added:
    deltacloud/trunk/server/tests/cimi/features/machine_images.feature
    deltacloud/trunk/server/tests/cimi/features/step_definitions/common_steps.rb   (with props)
    deltacloud/trunk/server/tests/cimi/features/step_definitions/machine_images_steps.rb 
 (with props)
Modified:
    deltacloud/trunk/server/Rakefile
    deltacloud/trunk/server/tests/cimi/features/machines.feature
    deltacloud/trunk/server/tests/cimi/features/step_definitions/machines_steps.rb
    deltacloud/trunk/server/tests/cimi/features/support/env.rb

Modified: deltacloud/trunk/server/Rakefile
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/Rakefile?rev=1207788&r1=1207787&r2=1207788&view=diff
==============================================================================
--- deltacloud/trunk/server/Rakefile (original)
+++ deltacloud/trunk/server/Rakefile Tue Nov 29 08:39:31 2011
@@ -55,6 +55,10 @@ begin
       t.cucumber_opts = "tests/cimi/features/machines.feature --format pretty"
       t.rcov = false
     end
+    Cucumber::Rake::Task.new(:machine_images) do |t|
+      t.cucumber_opts = "tests/cimi/features/machine_images.feature --format pretty"
+      t.rcov = false
+    end
   end
 rescue LoadError
 end

Added: deltacloud/trunk/server/tests/cimi/features/machine_images.feature
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/tests/cimi/features/machine_images.feature?rev=1207788&view=auto
==============================================================================
--- deltacloud/trunk/server/tests/cimi/features/machine_images.feature (added)
+++ deltacloud/trunk/server/tests/cimi/features/machine_images.feature Tue Nov 29 08:39:31
2011
@@ -0,0 +1,20 @@
+Feature: Managing Machines Images
+  In order to interact with the provider
+  We must first be provided a URL to the main entry point (CEP).
+
+Scenario: Listing Machine Images collection
+    Given Cloud Entry Point URL is provided
+    And client retrieve the Cloud Entry Point
+    When client lists Machine Images collection
+    Then client should get list of all Machine Images
+
+Scenario: Querying Machine Image
+    Given Cloud Entry Point URL is provided
+    And client retrieve the Cloud Entry Point
+    When client query for 'img1' Machine Image entity
+    Then client should verify that this Machine Image exists
+    And client should verify that this Machine Image has set
+      | *image_location | mock://img1 |
+      | description     | Fedora 10   |
+      | name            | img1        |
+      | uri             | http://example.org/cimi/machine_images/img1 |

Modified: deltacloud/trunk/server/tests/cimi/features/machines.feature
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/tests/cimi/features/machines.feature?rev=1207788&r1=1207787&r2=1207788&view=diff
==============================================================================
--- deltacloud/trunk/server/tests/cimi/features/machines.feature (original)
+++ deltacloud/trunk/server/tests/cimi/features/machines.feature Tue Nov 29 08:39:31 2011
@@ -17,19 +17,25 @@ Feature: Managing Machines
   Scenario: Querying created Machine
     Given Cloud Entry Point URL is provided
     And client retrieve the Cloud Entry Point
-    When client query for 'sampleMachine1' Machine
-    And client should verify that this machine exists
+    When client query for 'sampleMachine1' Machine entity
+    Then client should verify that this machine exists
+    And client should verify that this Machine has set
+      | name        | sampleMachine1            ||
+      | description | sampleMachine1Description ||
+      | cpu         | 1                         ||
+      | memory      | quantity                  | 1740  |
+      | state       | RUNNING                   ||
 
   Scenario: Stopping Machine
     Given Cloud Entry Point URL is provided
     And client retrieve the Cloud Entry Point
-    When client executes stop operation on Machine 'sampleMAchine1'
-    Then client should be able to query this Machine
+    When client executes stop operation on Machine 'sampleMachine1'
+    Then client should be able to query for 'sampleMachine1' Machine entity
     And client should verify that this machine is stopped
 
   Scenario: Starting Machine
     Given Cloud Entry Point URL is provided
     And client retrieve the Cloud Entry Point
-    When client executes start operation on Machine 'sampleMAchine1'
-    Then client should be able to query this Machine
+    When client executes start operation on Machine 'sampleMachine1'
+    Then client should be able to query for 'sampleMachine1' Machine entity
     And client should verify that this machine is started

Added: deltacloud/trunk/server/tests/cimi/features/step_definitions/common_steps.rb
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/tests/cimi/features/step_definitions/common_steps.rb?rev=1207788&view=auto
==============================================================================
--- deltacloud/trunk/server/tests/cimi/features/step_definitions/common_steps.rb (added)
+++ deltacloud/trunk/server/tests/cimi/features/step_definitions/common_steps.rb Tue Nov 29
08:39:31 2011
@@ -0,0 +1,61 @@
+World(Rack::Test::Methods)
+
+Given /^Cloud Entry Point URL is provided$/ do
+  get '/cimi'
+  last_response.status.should == 301
+  last_response.location.should == "http://example.org/cimi/cloudEntryPoint"
+end
+
+Given /^client retrieve the Cloud Entry Point$/ do
+  get "/cimi/cloudEntryPoint"
+  header 'Accept', 'application/xml'
+  last_response.status.should == 200
+end
+
+When /^client lists ([\w ]+) collection$/ do |col_name|
+  authorize 'mockuser', 'mockpassword'
+  header 'Accept', 'application/xml'
+  get "/cimi/%s" % col_name.to_collection_uri
+  last_response.status.should == 200
+  puts last_response.body
+end
+
+Then /^client should get list of all ([\w ]+)$/ do |col_name|
+  root_name = "#{col_name.to_class_name}Collection"
+  last_xml_response.root.name.should == root_name
+  (last_xml_response/"#{root_name}/name").size.should == 1
+  (last_xml_response/"#{root_name}/name").first.text.should == 'default'
+  (last_xml_response/"#{root_name}/uri").size.should == 1
+  (last_xml_response/"#{root_name}/uri").first.text.should == last_request.url
+  (last_xml_response/"#{root_name}/#{col_name.to_class_name}").size.should == 3
+  (last_xml_response/"#{root_name}/#{col_name.to_class_name}").each do |machine_img|
+    machine_img[:href].should_not be_nil
+    machine_img[:href].should =~ /http:\/\/example\.org\/cimi\/#{col_name.to_collection_uri}\/img(\d)/
+  end
+end
+
+When /^client( should be able to)? query for '(\w+)' ([\w ]+) entity$/ do |s, entity_id,
entity_name|
+  authorize 'mockuser', 'mockpassword'
+  header 'Accept', 'application/xml'
+  get "/cimi/%s/%s" % [entity_name.to_entity_uri, entity_id]
+  last_response.status.should == 200
+  puts last_response.body
+  @entity_id = entity_id
+end
+
+Then /^client should verify that this ([\w ]+) exists$/ do |entity_name|
+  root_name = entity_name.to_class_name
+  last_xml_response.root.name.should == root_name
+  @entity = last_xml_response
+end
+
+Then /^client should verify that this ([\w ]+) has set$/ do |entity, attrs|
+  model = CIMI::Model.const_get(entity.to_entity_name).from_xml(last_response.body)
+  attrs.rows_hash.each do |key, value|
+    if key =~ /^\*/
+      model.send(key.gsub(/^\*/, '').intern).href.should == value
+    else
+      model.send(key.intern).to_s.should == value
+    end
+  end
+end

Propchange: deltacloud/trunk/server/tests/cimi/features/step_definitions/common_steps.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Added: deltacloud/trunk/server/tests/cimi/features/step_definitions/machine_images_steps.rb
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/tests/cimi/features/step_definitions/machine_images_steps.rb?rev=1207788&view=auto
==============================================================================
    (empty)

Propchange: deltacloud/trunk/server/tests/cimi/features/step_definitions/machine_images_steps.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: deltacloud/trunk/server/tests/cimi/features/step_definitions/machines_steps.rb
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/tests/cimi/features/step_definitions/machines_steps.rb?rev=1207788&r1=1207787&r2=1207788&view=diff
==============================================================================
--- deltacloud/trunk/server/tests/cimi/features/step_definitions/machines_steps.rb (original)
+++ deltacloud/trunk/server/tests/cimi/features/step_definitions/machines_steps.rb Tue Nov
29 08:39:31 2011
@@ -1,17 +1,3 @@
-World(Rack::Test::Methods)
-
-Given /^Cloud Entry Point URL is provided$/ do
-  get '/cimi'
-  last_response.status.should == 301
-  last_response.location.should == "http://example.org/cimi/cloudEntryPoint"
-end
-
-Given /^client retrieve the Cloud Entry Point$/ do
-  get "/cimi/cloudEntryPoint"
-  header 'Accept', 'application/xml'
-  last_response.status.should == 200
-end
-
 When /^client specifies a Machine Image$/ do |machine_image|
   header 'Accept', 'application/xml'
   authorize 'mockuser', 'mockpassword'
@@ -48,25 +34,15 @@ When /^client specifies a new Machine us
 end
 
 Then /^client should be able to create this Machine$/ do
-  pending "NOTE: There is an inconsistency between Primer and CIMI spec\n"
+  pending "\nNOTE: There is an inconsistency between Primer and CIMI spec\n" +
+    "The Primer says that client should send just pointners MachineConf and MachineImg\n"+
+    "The CIMI says that full XML need to be provided in order to create a Machine\n\n"
   @machine = CIMI::Model::Machine.from_xml(@builder.to_xml)
   authorize 'mockuser', 'mockpassword'
   post '/cimi/machines', @machine
   last_response.status.should == 201
 end
 
-When /^client query for '(\w+)' Machine$/ do |machine_id|
-  header 'Accept', 'application/xml'
-  authorize 'mockuser', 'mockpassword'
-  get "/cimi/machines/%s" % machine_id
-end
-
-Then /^client should verify that this machine exists$/ do
-  last_xml_response.root.name == 'Machine'
-  last_response.status == 200
-  @new_machine = last_xml_response
-end
-
 Then /^client should be able to query this Machine$/ do
   get "/cimi/machines/%s" % (@new_machine/'')
 end

Modified: deltacloud/trunk/server/tests/cimi/features/support/env.rb
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/tests/cimi/features/support/env.rb?rev=1207788&r1=1207787&r2=1207788&view=diff
==============================================================================
--- deltacloud/trunk/server/tests/cimi/features/support/env.rb (original)
+++ deltacloud/trunk/server/tests/cimi/features/support/env.rb Tue Nov 29 08:39:31 2011
@@ -16,6 +16,26 @@ def last_xml_response
   Nokogiri::XML(last_response.body)
 end
 
+class String
+
+  def to_class_name
+    to_entity_name.singularize
+  end
+
+  def to_entity_name
+    self.tr(' ', '')
+  end
+
+  def to_collection_uri
+    self.tr(' ', '_').downcase
+  end
+
+  def to_entity_uri
+    to_collection_uri.pluralize
+  end
+
+end
+
 def app
   Sinatra::Application
 end



Mime
View raw message