deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject svn commit: r1207043 - in /deltacloud/trunk/server: ./ tests/cimi/features/ tests/cimi/features/step_definitions/ tests/cimi/features/support/
Date Mon, 28 Nov 2011 09:43:59 GMT
Author: mfojtik
Date: Mon Nov 28 09:43:58 2011
New Revision: 1207043

URL: http://svn.apache.org/viewvc?rev=1207043&view=rev
Log:
CIMI: Added Cucumber feature for Machine model

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

Modified: deltacloud/trunk/server/Rakefile
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/Rakefile?rev=1207043&r1=1207042&r2=1207043&view=diff
==============================================================================
--- deltacloud/trunk/server/Rakefile (original)
+++ deltacloud/trunk/server/Rakefile Mon Nov 28 09:43:58 2011
@@ -50,6 +50,12 @@ begin
       end
     end
   end
+  namespace :cimi do
+    Cucumber::Rake::Task.new(:machines) do |t|
+      t.cucumber_opts = "tests/cimi/features/machines.feature --format pretty"
+      t.rcov = false
+    end
+  end
 rescue LoadError
 end
 

Added: deltacloud/trunk/server/tests/cimi/features/machines.feature
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/tests/cimi/features/machines.feature?rev=1207043&view=auto
==============================================================================
--- deltacloud/trunk/server/tests/cimi/features/machines.feature (added)
+++ deltacloud/trunk/server/tests/cimi/features/machines.feature Mon Nov 28 09:43:58 2011
@@ -0,0 +1,35 @@
+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
+    Given Cloud Entry Point URL is provided
+    And client retrieve the Cloud Entry Point
+    When client specifies a Machine Image
+      | machineImage | http://example.com/cimi/machine_images/img1 |
+    And client specifies a Machine Configuration
+      |   machineConfig | http://example.com/cimi/machine_configurations/m1-small |
+    And client specifies a new Machine using
+      | name | sampleMachine1 |
+      | description | sampleMachine1Description |
+    Then client should be able to create this Machine
+
+  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
+
+  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
+    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
+    And client should verify that this machine is started

Added: 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=1207043&view=auto
==============================================================================
--- deltacloud/trunk/server/tests/cimi/features/step_definitions/machines_steps.rb (added)
+++ deltacloud/trunk/server/tests/cimi/features/step_definitions/machines_steps.rb Mon Nov
28 09:43:58 2011
@@ -0,0 +1,80 @@
+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'
+  get machine_image.raw[0][1]
+  last_response.status.should == 200
+  @machine_image = CIMI::Model::MachineImage.from_xml(last_response.body)
+  @machine_image.should_not be_nil
+  @machine_image.uri.should == machine_image.raw[0][1]
+end
+
+When /^client specifies a Machine Configuration$/ do |machine_conf|
+  header 'Accept', 'application/xml'
+  authorize 'mockuser', 'mockpassword'
+  get machine_conf.raw[0][1]
+  last_response.status.should == 200
+  @machine_configuration = CIMI::Model::MachineImage.from_xml(last_response.body)
+  @machine_configuration.should_not be_nil
+  @machine_configuration.uri.should == machine_conf.raw[0][1]
+end
+
+When /^client specifies a new Machine using$/ do |machine|
+  @machine_image.should_not be_nil
+  @machine_configuration.should_not be_nil
+  @builder = Nokogiri::XML::Builder.new do |xml|
+    xml.Machine(:xmlns => CMWG_NAMESPACE) {
+      xml.name machine.raw[0][1]
+      xml.description machine.raw[1][1]
+      xml.MachineTemplate {
+        xml.MachineConfig( :href => @machine_configuration.uri )
+        xml.MachineImage( :href => @machine_image.uri )
+      }
+    }
+  end
+end
+
+Then /^client should be able to create this Machine$/ do
+  pending "NOTE: There is an inconsistency between Primer and CIMI spec\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
+
+When /^client executes (\w+) operation on Machine '(\w+)'$/ do |operation, machine_id|
+  pending # express the regexp above with the code you wish you had
+end
+
+Then /^client should verify that this machine is (\w+)$/ do |status|
+  pending # express the regexp above with the code you wish you had
+end

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

Added: 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=1207043&view=auto
==============================================================================
--- deltacloud/trunk/server/tests/cimi/features/support/env.rb (added)
+++ deltacloud/trunk/server/tests/cimi/features/support/env.rb Mon Nov 28 09:43:58 2011
@@ -0,0 +1,21 @@
+require 'rubygems'
+require 'nokogiri'
+
+ENV['API_DRIVER'] = 'mock'
+ENV['API_FRONTEND'] = 'cimi'
+ENV.delete('API_VERBOSE')
+
+$top_srcdir = File.join(File.dirname(__FILE__), '..', '..', '..', '..')
+$:.unshift File.join($top_srcdir, 'lib')
+
+load File.join($top_srcdir, 'lib', 'cimi', 'server.rb')
+
+require 'rack/test'
+
+def last_xml_response
+  Nokogiri::XML(last_response.body)
+end
+
+def app
+  Sinatra::Application
+end

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



Mime
View raw message