deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject svn commit: r1207923 - in /deltacloud/trunk/server/tests/cimi/features: machines.feature step_definitions/machines_steps.rb support/env.rb
Date Tue, 29 Nov 2011 15:33:12 GMT
Author: mfojtik
Date: Tue Nov 29 15:33:11 2011
New Revision: 1207923

URL: http://svn.apache.org/viewvc?rev=1207923&view=rev
Log:
CIMI: Added delete operation Cucumber scenario for Machine entity and couple other minor fixed
there

Modified:
    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/tests/cimi/features/machines.feature
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/tests/cimi/features/machines.feature?rev=1207923&r1=1207922&r2=1207923&view=diff
==============================================================================
--- deltacloud/trunk/server/tests/cimi/features/machines.feature (original)
+++ deltacloud/trunk/server/tests/cimi/features/machines.feature Tue Nov 29 15:33:11 2011
@@ -2,7 +2,7 @@ Feature: Managing Machines
   In order to interact with the provider
   We must first be provided a URL to the main entry point (CEP).
 
-  Scenario: Create a New Machine
+  Scenario: Create a New Machine entity
     Given Cloud Entry Point URL is provided
     And client retrieve the Cloud Entry Point
     When client specifies a Machine Image
@@ -14,28 +14,33 @@ Feature: Managing Machines
       | description | sampleMachine1Description |
     Then client should be able to create this Machine
 
-  Scenario: Querying created Machine
+  Scenario: Querying created Machine entity
     Given Cloud Entry Point URL is provided
     And client retrieve the Cloud Entry Point
-    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                   ||
+    When client query for created Machine entity
+    Then client should verify that this Machine exists
+    And client should verify that this Machine has been created properly
+      | cpu         | 1                         |
+      | memory      | 1740.8                    |
+      | state       | STARTED                   |
 
-  Scenario: Stopping Machine
+  Scenario: Stopping created Machine entity
     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 for 'sampleMachine1' Machine entity
+    When client executes stop operation on created Machine
+    Then client query for created Machine entity
     And client should verify that this machine is stopped
 
-  Scenario: Starting Machine
+  Scenario: Starting created Machine entity
     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 for 'sampleMachine1' Machine entity
+    When client executes start operation on created Machine
+    Then client query for created Machine entity
     And client should verify that this machine is started
+
+  Scenario: Deleting created Machine entity
+    Given Cloud Entry Point URL is provided
+    And client retrieve the Cloud Entry Point
+    When client executes delete operation on created Machine
+    Then client query for created Machine entity
+    And client should verify that this machine is deleted

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=1207923&r1=1207922&r2=1207923&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 15:33:11 2011
@@ -21,9 +21,10 @@ end
 When /^client specifies a new Machine using$/ do |machine|
   @machine_image.should_not be_nil
   @machine_configuration.should_not be_nil
+  @new_machine_name = machine.raw[0][1]
   @builder = Nokogiri::XML::Builder.new do |xml|
     xml.Machine(:xmlns => CMWG_NAMESPACE) {
-      xml.name machine.raw[0][1]
+      xml.name @new_machine_name
       xml.description machine.raw[1][1]
       xml.MachineTemplate {
         xml.MachineConfig( :href => @machine_configuration.uri )
@@ -34,23 +35,59 @@ When /^client specifies a new Machine us
 end
 
 Then /^client should be able to create this Machine$/ do
-  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
+  header 'Content-Type', 'application/xml'
+  post '/cimi/machines', @builder.to_xml
   last_response.status.should == 201
+  set_new_machine(CIMI::Model::Machine.from_xml(last_response.body))
 end
 
-Then /^client should be able to query this Machine$/ do
-  get "/cimi/machines/%s" % (@new_machine/'')
+Then /^client query for created Machine entity$/ do
+  authorize 'mockuser', 'mockpassword'
+  header 'Content-Type', 'application/xml'
+  get "/cimi/machines/%s" % new_machine.name
+  if @delete_operation
+    last_response.status.should == 404
+  else
+    last_response.status.should == 200
+    @machine = CIMI::Model::Machine.from_xml(last_response.body)
+    @machine.name.should == new_machine.name
+  end
+
 end
 
-When /^client executes (\w+) operation on Machine '(\w+)'$/ do |operation, machine_id|
-  pending # express the regexp above with the code you wish you had
+Then /^client should verify that this Machine has been created properly$/ do |attrs|
+  attrs.rows_hash.each do |key, value|
+    if key == 'memory'
+      @machine.memory['quantity'].to_s.should == value
+    else
+      @machine.send(key.intern).to_s.should == value
+    end
+  end
+end
+
+When /^client executes (\w+) operation on created Machine$/ do |operation|
+  builder = Nokogiri::XML::Builder.new do |xml|
+    xml.Action(:xmlns => CMWG_NAMESPACE) {
+      xml.action "http://www.dmtf.org/cimi/action/#{operation}"
+    }
+  end
+  authorize 'mockuser', 'mockpassword'
+  header 'Content-Type', 'application/xml'
+  if operation == 'delete'
+    delete "/cimi/machines/%s/delete" % new_machine.name
+    last_response.status.should == 200
+    last_response.body.should be_empty
+    @delete_operation = true
+  else
+    post "/cimi/machines/%s/%s" % [new_machine.name, operation], builder.to_xml
+    last_response.status.should == 202
+    last_response.body.should be_empty
+  end
 end
 
 Then /^client should verify that this machine is (\w+)$/ do |status|
-  pending # express the regexp above with the code you wish you had
+  unless @delete_operation
+    @machine.state.should == status.upcase
+  end
 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=1207923&r1=1207922&r2=1207923&view=diff
==============================================================================
--- deltacloud/trunk/server/tests/cimi/features/support/env.rb (original)
+++ deltacloud/trunk/server/tests/cimi/features/support/env.rb Tue Nov 29 15:33:11 2011
@@ -16,6 +16,14 @@ def last_xml_response
   Nokogiri::XML(last_response.body)
 end
 
+def new_machine
+  @@new_machine
+end
+
+def set_new_machine(machine)
+  @@new_machine = machine
+end
+
 class String
 
   def to_class_name



Mime
View raw message