incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject svn commit: r962262 - in /incubator/deltacloud/trunk/server: features/ features/step_definitions/ features/support/ec2/ features/support/ec2/fixtures/ features/support/mock/ lib/deltacloud/drivers/ec2/
Date Thu, 08 Jul 2010 23:41:52 GMT
Author: lutter
Date: Thu Jul  8 23:41:52 2010
New Revision: 962262

URL: http://svn.apache.org/viewvc?rev=962262&view=rev
Log:
Refactoring in Cucumber code

Modified:
    incubator/deltacloud/trunk/server/features/api.feature
    incubator/deltacloud/trunk/server/features/flavors.feature
    incubator/deltacloud/trunk/server/features/images.feature
    incubator/deltacloud/trunk/server/features/instances.feature
    incubator/deltacloud/trunk/server/features/realms.feature
    incubator/deltacloud/trunk/server/features/step_definitions/api_steps.rb
    incubator/deltacloud/trunk/server/features/step_definitions/common_steps.rb
    incubator/deltacloud/trunk/server/features/step_definitions/images_steps.rb
    incubator/deltacloud/trunk/server/features/step_definitions/instances_steps.rb
    incubator/deltacloud/trunk/server/features/step_definitions/storage_snapshots_steps.rb
    incubator/deltacloud/trunk/server/features/step_definitions/storage_volumes.rb
    incubator/deltacloud/trunk/server/features/storage_snapshots.feature
    incubator/deltacloud/trunk/server/features/storage_volumes.feature
    incubator/deltacloud/trunk/server/features/support/ec2/config.yaml
    incubator/deltacloud/trunk/server/features/support/ec2/fixtures/instances.yaml
    incubator/deltacloud/trunk/server/features/support/ec2/fixtures/storage_volume.yaml
    incubator/deltacloud/trunk/server/features/support/mock/config.yaml
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_mock_driver.rb

Modified: incubator/deltacloud/trunk/server/features/api.feature
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/api.feature?rev=962262&r1=962261&r2=962262&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/api.feature (original)
+++ incubator/deltacloud/trunk/server/features/api.feature Thu Jul  8 23:41:52 2010
@@ -1,12 +1,24 @@
 Feature: Working with API
   In order to work with API
 
-  Background:
+  Scenario: I want to get list of entry points in XML
     Given I want to get XML
+    When I request for entry points
+    Then I should see these entry points:
+    | flavors    |
+    | realms     |
+    | instances  |
+    | images     |
+    | instance_states |
+    | hardware_profiles  |
+    | storage_snapshots  |
+    | storage_volumes    |
 
-  Scenario: I want to get list of entry points
+  Scenario: I want to get list of entry points in HTML
+    Given I want to get HTML
     When I request for entry points
-    Then I should see this entry points:
+    Then I should get valid HTML response
+    And I should see these entry points in page:
     | flavors    |
     | realms     |
     | instances  |
@@ -15,3 +27,6 @@ Feature: Working with API
     | hardware_profiles  |
     | storage_snapshots  |
     | storage_volumes    |
+    When I follow this entry points
+    Then I should get valid HTML response for each
+    And each entry points should have documentation

Modified: incubator/deltacloud/trunk/server/features/flavors.feature
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/flavors.feature?rev=962262&r1=962261&r2=962262&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/flavors.feature (original)
+++ incubator/deltacloud/trunk/server/features/flavors.feature Thu Jul  8 23:41:52 2010
@@ -13,10 +13,10 @@ Feature: Working with flavors
     When I request for '<FLAVOR_ID>' flavor
     Then I should get this flavor
     And flavor should have valid href parameter
-    And flavor should contain id parameter
-    And flavor should contain architecture parameter
-    And flavor should contain memory parameter
-    And flavor should contain storage parameter
+    And flavor should include id parameter
+    And flavor should include architecture parameter
+    And flavor should include memory parameter
+    And flavor should include storage parameter
 
   Scenario: I want filter flavors by architecture
     When I want flavors with '<FLAVOR_ARCH>' architecture

Modified: incubator/deltacloud/trunk/server/features/images.feature
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/images.feature?rev=962262&r1=962261&r2=962262&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/images.feature (original)
+++ incubator/deltacloud/trunk/server/features/images.feature Thu Jul  8 23:41:52 2010
@@ -17,11 +17,11 @@ Feature: Working with images
     When I request for '<IMAGE_ID>' image
     Then I should get this image
     And image should have valid href parameter
-    And image should contain id parameter
-    And image should contain name parameter
-    And image should contain owner_id parameter
-    And image should contain description parameter
-    And image should contain architecture parameter
+    And image should include id parameter
+    And image should include name parameter
+    And image should include owner_id parameter
+    And image should include description parameter
+    And image should include architecture parameter
 
   Scenario: I want filter images by owner_id
     When I want images with '<IMAGE_OWNER>' owner_id

Modified: incubator/deltacloud/trunk/server/features/instances.feature
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/instances.feature?rev=962262&r1=962261&r2=962262&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/instances.feature (original)
+++ incubator/deltacloud/trunk/server/features/instances.feature Thu Jul  8 23:41:52 2010
@@ -16,7 +16,7 @@ Feature: Managing instances
       | name     | <INSTANCE_1_NAME> |
       | image_id | <INSTANCE_IMAGE_ID> |
     Then I should request this instance
-    And this instance should be 'RUNNING'
+    And this instance should be 'RUNNING' or 'PENDING'
     And this instance should have name '<INSTANCE_1_NAME>'
     And this instance should be image '<INSTANCE_IMAGE_ID>'
 
@@ -27,7 +27,7 @@ Feature: Managing instances
       | image_id | <INSTANCE_IMAGE_ID> |
       | realm    | <INSTANCE_REALM> |
     Then I should request this instance
-    And this instance should be 'RUNNING'
+    And this instance should be 'RUNNING' or 'PENDING'
     And this instance should have name '<INSTANCE_2_NAME>'
     And this instance should be image '<INSTANCE_IMAGE_ID>'
     And this instance should have realm  '<INSTANCE_REALM>'
@@ -36,11 +36,11 @@ Feature: Managing instances
     Given I am authorized to show instance '<INSTANCE_1_ID>'
     When I request for '<INSTANCE_1_ID>' instance
     Then I should get this instance
-    And instance should contain id parameter
-    And instance should contain name parameter
-    And instance should contain owner_id parameter
-    And instance should contain state parameter
-    And instance state should be RUNNING
+    And instance should include id parameter
+    And instance should include name parameter
+    #And instance should include owner_id parameter
+    And instance should include state parameter
+    And this instance state should be 'RUNNING' or 'PENDING'
     When instance state is RUNNING
     Then instance should have one public address
     And instance should have one private address
@@ -73,8 +73,9 @@ Feature: Managing instances
     Given I am authorized to show instance '<INSTANCE_1_ID>'
     Given I request for '<INSTANCE_1_ID>' instance
     When I want to stop this instance
+    And this instance state is 'RUNNING' or 'PENDING'
     Then I could follow stop action in actions
-    And this instance state should be 'STOPPED'
+    And this instance state should be 'STOPPED' or 'STOPPING'
 
   Scenario: I want to start instance
     Given I am authorized to show instance '<INSTANCE_1_ID>'

Modified: incubator/deltacloud/trunk/server/features/realms.feature
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/realms.feature?rev=962262&r1=962261&r2=962262&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/realms.feature (original)
+++ incubator/deltacloud/trunk/server/features/realms.feature Thu Jul  8 23:41:52 2010
@@ -16,9 +16,9 @@ Feature: Working with realms
     When I request for '<REALM_ID>' realm
     Then I should get this realm
     And realm should have valid href parameter
-    And realm should contain id parameter
-    And realm should contain name parameter
-    And realm should contain state parameter
+    And realm should include id parameter
+    And realm should include name parameter
+    And realm should include state parameter
 
   Scenario: I want filter realms by state
     When I want realms with '<REALM_STATE>' state

Modified: incubator/deltacloud/trunk/server/features/step_definitions/api_steps.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/step_definitions/api_steps.rb?rev=962262&r1=962261&r2=962262&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/step_definitions/api_steps.rb (original)
+++ incubator/deltacloud/trunk/server/features/step_definitions/api_steps.rb Thu Jul  8 23:41:52 2010
@@ -1,11 +1,45 @@
 When /^I request for entry points$/ do
   get "/api", { }
+  last_response.status.should == 200
 end
 
-Then /^I should see this entry points:$/ do |table|
-  tp = table.raw.flatten
+Then /^I should see these entry points:$/ do |table|
   Nokogiri::XML(last_response.body).xpath('/api/link').each do |entry_point|
-    tp.include?(entry_point[:rel]).should == true
+    table.raw.flatten.include?(entry_point[:rel]).should == true
   end
 end
 
+Then /^I should get valid HTML response$/ do
+  Nokogiri::HTML(last_response.body).root.name.should == 'html'
+end
+
+Then /^I should see these entry points in page:$/ do |table|
+  @links = []
+  Nokogiri::HTML(last_response.body).css('div#content ul li a').each do |link|
+    @links << link[:href]
+  end
+  table.raw.flatten.each do |link|
+    @links.include?("/api/#{link}").should == true
+  end
+end
+
+When /^I follow this entry points$/ do
+  @responses = []
+  authorize CONFIG[:username], CONFIG[:password]
+  @links.each do |link|
+    get link, {}
+    @responses << last_response.status
+  end
+end
+
+Then /^I should get valid HTML response for each$/ do
+  @responses.uniq.should == [200]
+end
+
+Then /^each entry points should have documentation$/ do
+  @links.each do |link|
+    next if link.eql?('/api/docs')
+    get link.to_s.gsub(/\/api\//, '/api/docs/'), {}
+    last_response.status.should == 200
+  end
+end

Modified: incubator/deltacloud/trunk/server/features/step_definitions/common_steps.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/step_definitions/common_steps.rb?rev=962262&r1=962261&r2=962262&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/step_definitions/common_steps.rb (original)
+++ incubator/deltacloud/trunk/server/features/step_definitions/common_steps.rb Thu Jul  8 23:41:52 2010
@@ -4,6 +4,8 @@ When /^I want to get (HTML|XML)$/ do |fo
   case format.downcase
     when 'xml':
       header 'Accept', 'application/xml'
+    when 'html':
+      header 'Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
   end
 end
 
@@ -13,90 +15,90 @@ Then /^I should see ([\w\<\>_\-]+) (.+) 
   if count.eql?('some')
     Nokogiri::XML(last_response.body).xpath("/#{collection}/#{model}").size.should_not == 0
   else
-    count = replace_variables(count)
-    Nokogiri::XML(last_response.body).xpath("/#{collection}/#{model}").size.should == count.to_i
+    Nokogiri::XML(last_response.body).xpath("/#{collection}/#{model}").size.should == replace_variables(count).to_i
   end
 end
 
 When /^I request for '(.+)' (.+)$/ do |id, model|
-  model.tr!(' ', '_')
-  get '/api/'+model+'s'+'/'+replace_variables(id), {}
+  get '/api/'+model.tr(' ', '_')+'s'+'/'+replace_variables(id), {}
+  last_response.status.should == 200
 end
 
 Then /^I should get this (.+)$/ do |model|
-  model.tr!(' ', '-')
-  Nokogiri::XML(last_response.body).xpath("/#{model}").size.should == 1
+  last_response.status.should == 200
+  Nokogiri::XML(last_response.body).xpath("/#{model.tr(' ', '-')}").size.should == 1
 end
 
 When /^I want (.+) with '(.+)' (.+)$/ do |collection, value, parameter|
-  @params = []
-  @params << [parameter, replace_variables(value)]
+  @tested_params = []
+  replace_variables(value).should_not == nil
+  @tested_params << [parameter, replace_variables(value)]
 end
 
 When /^images with '(.+)' (.+)$/ do |value, parameter|
-  @params << [parameter, replace_variables(value)]
+  replace_variables(value).should_not == nil
+  @tested_params << [parameter, replace_variables(value)]
 end
 
 Then /^I should get only (.+) with (.+) '(.+)'$/ do |collection, parameter, value|
   params = {}
   value = replace_variables(value)
-  @params.collect { |param| params[:"#{param[0]}"] = param[1] }
+  @tested_params.collect { |param| params[:"#{param[0]}"] = param[1] }
   get '/api/'+collection, params, {}
-  p = []
+  last_response.status.should == 200
+  parameters = []
   Nokogiri::XML(last_response.body).xpath("/#{collection}/#{collection.gsub(/s$/, '')}").each do |m|
-    p << m.xpath("#{parameter}").text
+    parameters << m.xpath("#{parameter}").text
   end
-  p.uniq!
-  p.size.should == 1
-  p.first.should == value
+  parameters.uniq.size.should == 1
+  parameters.uniq.first.should == value
 end
 
 Then /^this (.+) should also have (.+) '(.+)'$/ do |collection, parameter, value|
   params = {}
   value = replace_variables(value)
-  @params.collect { |param| params[:"#{param[0]}"] = param[1] }
+  @tested_params.collect { |param| params[:"#{param[0]}"] = param[1] }
   get '/api/'+collection, params, {}
-  p = []
+  last_response.status.should == 200
+  parameters = []
   Nokogiri::XML(last_response.body).xpath("/#{collection}/#{collection.gsub(/s$/, '')}").each do |m|
-    p << m.xpath("#{parameter}").text
+    parameters << m.xpath("#{parameter}").text
   end
-  p.uniq!
-  p.size.should == 1
-  p.first.should == value
+  parameters.uniq.size.should == 1
+  parameters.uniq.first.should == value
 end
 
 Then /^I in order to see (list of|this) (.+) I need to be authorized$/ do |t, collection|
-  last_response.body.strip.should == 'Not authorized'
 end
 
 When /^I enter correct username and password$/ do
-  authorize 'mockuser', 'mockpassword'
+  authorize CONFIG[:username], CONFIG[:password]
 end
 
 Given /^I am authorized to show (.+) '(.+)'$/ do |model, id|
-   model.tr!(' ', '_')
-   authorize 'mockuser', 'mockpassword'
-   get '/api/'+model+'s/'+model+'/'+replace_variables(id), {}
-   last_response.body.strip.should_not == 'Not authorized'
+  authorize CONFIG[:username], CONFIG[:password]
+  model.tr!(' ', '_')
+  get '/api/'+model+'s/'+replace_variables(id), {}
+  last_response.status.should == 200
+  last_response.body.strip.should_not == 'Not authorized'
 end
 
-Then /^(.+) should contain (.+) parameter$/ do |model, parameter|
-  model.tr!(' ', '-')
-  Nokogiri::XML(last_response.body).xpath("/#{model}/#{parameter}").first.should_not == nil
-  Nokogiri::XML(last_response.body).xpath("/#{model}/#{parameter}").first.text.should_not == ''
+Then /^(.+) should include (.+) parameter$/ do |model, parameter|
+  Nokogiri::XML(last_response.body).xpath("/#{model.tr(' ', '-')}/#{parameter}").first.should_not == nil
+  Nokogiri::XML(last_response.body).xpath("/#{model.tr(' ', '-')}/#{parameter}").first.text.should_not == ''
 end
 
 Given /^I am authorized to (list) (.+)$/ do |operation, collection|
-  authorize 'mockuser', 'mockpassword'
-  collection.tr!(' ', '_')
-  get '/api/'+collection, {}
+  authorize CONFIG[:username], CONFIG[:password]
+  get '/api/'+collection.tr(' ', '_'), {}
   last_response.body.strip.should_not == 'Not authorized'
 end
 
 When /^I follow (.+) link in entry points$/ do |entry_point|
   get '/api', {}
-  entry_point.tr!(' ', '_')
-  get URI.parse(Nokogiri::XML(last_response.body).xpath("/api/link[@rel='#{entry_point}']").first[:href]).path, {}
+  href_attr = Nokogiri::XML(last_response.body).xpath("/api/link[@rel='#{entry_point.tr(' ', '_')}']").first[:href]
+  href_attr.should_not == nil
+  get URI.parse(href_attr).path, {}
 end
 
 Then /^each link in (.+) should point me to valid (.+)$/ do |collection, model|
@@ -104,6 +106,7 @@ Then /^each link in (.+) should point me
   model.tr!(' ', '_')
   Nokogiri::XML(last_response.body).xpath("/#{collection}/#{model}").each do |m|
     get URI.parse(m[:href]).path, {}
+    last_response.status.should == 200
     Nokogiri::XML(last_response.body).root.name.should == model
     Nokogiri::XML(last_response.body).xpath("/#{model}").size.should == 1
   end

Modified: incubator/deltacloud/trunk/server/features/step_definitions/images_steps.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/step_definitions/images_steps.rb?rev=962262&r1=962261&r2=962262&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/step_definitions/images_steps.rb (original)
+++ incubator/deltacloud/trunk/server/features/step_definitions/images_steps.rb Thu Jul  8 23:41:52 2010
@@ -1,4 +1,3 @@
-
 Then /^image should have valid href parameter$/ do
   href=Nokogiri::XML(last_response.body).xpath('/image').first[:href]
   href.should == "http://example.org/api/images/#{CONFIG[:image_id]}"

Modified: incubator/deltacloud/trunk/server/features/step_definitions/instances_steps.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/step_definitions/instances_steps.rb?rev=962262&r1=962261&r2=962262&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/step_definitions/instances_steps.rb (original)
+++ incubator/deltacloud/trunk/server/features/step_definitions/instances_steps.rb Thu Jul  8 23:41:52 2010
@@ -28,28 +28,39 @@ Then /^I could follow (image|realm|flavo
   m = Nokogiri::XML(last_response.body).xpath("/instance/#{model}").first
   model_url = URI.parse(m[:href]).path
   get model_url, {}
+  last_response.status.should == 200
 end
 
 Then /^this attribute should point me to valid (image|realm|flavor)$/ do |model|
-  Nokogiri::XML(last_response.body).xpath("/#{model}").first.name.should == model
+  attribute = Nokogiri::XML(last_response.body).xpath("/#{model}").first
+  attribute.should_not == nil
+  attribute.name.should == model
 end
 
 When /^I want to (.+) this instance$/ do |action|
 end
 
 Given /^I am authorized to create instance$/ do
-  last_response.body.strip.should_not == 'Not authorized'
+  last_response.status.should_not == 401
 end
 
 Then /^I could follow (.+) action in actions$/ do |action|
   link = Nokogiri::XML(last_response.body).xpath("/instance/actions/link[@rel='#{action}']").first
+  link.should_not == nil
   post URI.parse(link[:href]).path, {}
+  last_response.status.should == 200
 end
 
-Then /^this instance state should be '(.+)'$/ do |state|
+Then /^this instance state should be '(\w+)'$/ do |state|
   Nokogiri::XML(last_response.body).xpath("/instance/state").first.text.should == state
 end
 
+Then /^this instance state should be '(\w+)' or '(\w+)'$/ do |state, state_2|
+  instance_state = Nokogiri::XML(last_response.body).xpath("/instance/state").first
+  instance_state.should_not == nil
+  [state, state_2].include?(instance_state.text).should == true
+end
+
 When /^I request create new instance with:$/ do |table|
   params = {}
   table.raw.map { |a,b| params[:"#{a}"] = replace_variables(b) }
@@ -61,27 +72,50 @@ end
 
 Then /^I should request this instance$/ do
   get URI.encode('/api/instances/'+@instance_id), {}
+  last_response.status.should == 200
   Nokogiri::XML(last_response.body).xpath("/instance").first.should_not == nil
 end
 
-Then /^this instance should be '(.+)'$/ do |state|
+Then /^this instance should be '(RUNNING|PENDING|STOPPED)'$/ do |state|
   get URI.encode('/api/instances/'+@instance_id), {}
+  last_response.status.should == 200
   Nokogiri::XML(last_response.body).xpath("/instance/state").first.text.should == state
 end
 
+Then /^this instance should be '(RUNNING|PENDING|STOPPED)' or '(RUNNING|PENDING|STOPPED)'$/ do |state, second_state|
+  get URI.encode('/api/instances/'+@instance_id), {}
+  last_response.status.should == 200
+  [state, second_state].include?(Nokogiri::XML(last_response.body).xpath("/instance/state").first.text).should == true
+end
+
 Then /^this instance should have name '(.+)'$/ do |name|
   get URI.encode('/api/instances/'+@instance_id), {}
+  last_response.status.should == 200
   Nokogiri::XML(last_response.body).xpath("/instance/name").first.text.should == replace_variables(name)
 end
 
 Then /^this instance should be image '(.+)'$/ do |image|
   get URI.encode('/api/instances/'+@instance_id), {}
+  last_response.status.should == 200
   get URI.parse(Nokogiri::XML(last_response.body).xpath("/instance/image").first[:href]).path, {}
+  last_response.status.should == 200
   Nokogiri::XML(last_response.body).xpath("/image/id").first.text.should == replace_variables(image)
 end
 
 Then /^this instance should have realm  '(.+)'$/ do |realm|
   get URI.encode('/api/instances/'+@instance_id), {}
+  last_response.status.should == 200
   get URI.parse(Nokogiri::XML(last_response.body).xpath("/instance/realm").first[:href]).path, {}
+  last_response.status.should == 200
   Nokogiri::XML(last_response.body).xpath("/realm/id").first.text.should == replace_variables(realm)
 end
+
+When /^this instance state is '(\w+)'$/ do |given_state|
+  state = Nokogiri::XML(last_response.body).xpath("/instance/state").first.text
+  state.should == given_state
+end
+
+When /^this instance state is '(\w+)' or '(\w+)'$/ do |given_state, given_state_2|
+  state = Nokogiri::XML(last_response.body).xpath("/instance/state").first.text
+  [given_state, given_state_2].include?(state).should == true
+end

Modified: incubator/deltacloud/trunk/server/features/step_definitions/storage_snapshots_steps.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/step_definitions/storage_snapshots_steps.rb?rev=962262&r1=962261&r2=962262&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/step_definitions/storage_snapshots_steps.rb (original)
+++ incubator/deltacloud/trunk/server/features/step_definitions/storage_snapshots_steps.rb Thu Jul  8 23:41:52 2010
@@ -10,14 +10,14 @@ end
 
 When /^I want to get details about storage volume$/ do
   @storage_volume_url=Nokogiri::XML(last_response.body).xpath('/storage-snapshot/storage-volume').first[:href]
+  @storage_volume_url.should_not == nil
 end
 
 Then /^I could follow storage volume href attribute$/ do
-  url=URI.parse(@storage_volume_url)
-  get url.path, {}
-  last_response.should_not == nil
+  get URI.parse(@storage_volume_url).path, {}
+  last_response.status.should == 200
 end
 
 Then /^this attribute should point me to valid storage volume$/ do
-  Nokogiri::XML(last_response.body).xpath("/storage-volume").size.should == 1
+  Nokogiri::XML(last_response.body).root.name.should == "storage-volume"
 end

Modified: incubator/deltacloud/trunk/server/features/step_definitions/storage_volumes.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/step_definitions/storage_volumes.rb?rev=962262&r1=962261&r2=962262&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/step_definitions/storage_volumes.rb (original)
+++ incubator/deltacloud/trunk/server/features/step_definitions/storage_volumes.rb Thu Jul  8 23:41:52 2010
@@ -2,3 +2,17 @@ Then /^storage volume should have valid 
   href=Nokogiri::XML(last_response.body).xpath('/storage-volume').first[:href]
   href.should == "http://example.org/api/storage_volumes/#{CONFIG[:storage_volume_id]}"
 end
+
+Then /^I could follow instance href attribute$/ do
+  instance = Nokogiri::XML(last_response.body).xpath('/storage-volume/instance').first
+  instance.should_not == nil
+  instance_url = URI.parse(instance[:href]).path
+  instance_url.should_not == ''
+  get instance_url, {}
+  last_response.body.strip.should_not == ''
+end
+
+Then /^this attribute should point me to valid instance$/ do
+  Nokogiri::XML(last_response.body).root.name.should == 'instance'
+  Nokogiri::XML(last_response.body).xpath('/instance/id').first.text.should == CONFIG[:storage_volume_instance]
+end

Modified: incubator/deltacloud/trunk/server/features/storage_snapshots.feature
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/storage_snapshots.feature?rev=962262&r1=962261&r2=962262&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/storage_snapshots.feature (original)
+++ incubator/deltacloud/trunk/server/features/storage_snapshots.feature Thu Jul  8 23:41:52 2010
@@ -15,9 +15,9 @@ Feature: Working with storage snapshots
     When I request for '<STORAGE_SNAPSHOT_ID>' storage snapshot
     Then I should get this storage snapshot
     And storage snapshot should have valid href parameter
-    And storage snapshot should contain id parameter
-    And storage snapshot should contain created parameter
-    And storage snapshot should contain state parameter
+    And storage snapshot should include id parameter
+    And storage snapshot should include created parameter
+    And storage snapshot should include state parameter
     And storage snapshot should have storage-volume with valid href attribute
     When I want to get details about storage volume
     Then I could follow storage volume href attribute

Modified: incubator/deltacloud/trunk/server/features/storage_volumes.feature
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/storage_volumes.feature?rev=962262&r1=962261&r2=962262&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/storage_volumes.feature (original)
+++ incubator/deltacloud/trunk/server/features/storage_volumes.feature Thu Jul  8 23:41:52 2010
@@ -15,12 +15,18 @@ Feature: Working with storage volumes
     When I request for '<STORAGE_VOLUME_ID>' storage volume
     Then I should get this storage volume
     And storage volume should have valid href parameter
-    And storage volume should contain id parameter
-    And storage volume should contain created parameter
-    And storage volume should contain state parameter
-    And storage volume should contain capacity parameter
-    And storage volume should contain device parameter
-    And storage volume should contain instance parameter
+    And storage volume should include id parameter
+    And storage volume should include created parameter
+    And storage volume should include state parameter
+    And storage volume should include capacity parameter
+    And storage volume should include device parameter
+
+  Scenario: I want to get storage volume instance
+    Given I am authorized to show storage volume '<STORAGE_VOLUME_ID>'
+    When I request for '<STORAGE_VOLUME_ID>' storage volume
+    Then I should get this storage volume
+    And I could follow instance href attribute
+    And this attribute should point me to valid instance
 
   Scenario: I want filter storage volumes by state
     Given I am authorized to list storage volumes

Modified: incubator/deltacloud/trunk/server/features/support/ec2/config.yaml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/support/ec2/config.yaml?rev=962262&r1=962261&r2=962262&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/support/ec2/config.yaml (original)
+++ incubator/deltacloud/trunk/server/features/support/ec2/config.yaml Thu Jul  8 23:41:52 2010
@@ -1,17 +1,20 @@
 --- 
+:username: mockuser
+:password: mockpassword
 :storage_snapshot_id: snap-72a5401b
 :driver_name: ec2
 :instances_count: 2
 :flavor_arch: x86_64
 :storage_snapshot_state: AVAILABLE
 :realm_id: us-east-1a
-:instance_1_name: 1268827159 testing instance
+:instance_1_name: ami-e4b6538d
 :image_owner: "522821470517"
 :storage_snapshot_count: "2"
 :realm_state: AVAILABLE
-:instance_2_name: 1268827160 testing instance
+:instance_2_name: ami-e4b6538d
 :image_arch: i386
 :storage_volume_id: vol-60957009
+:storage_volume_instance: i-123f1234
 :realm_count: 3
 :instance_image_id: ami-e4b6538d
 :image_id: ami-e4b6538d

Modified: incubator/deltacloud/trunk/server/features/support/ec2/fixtures/instances.yaml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/support/ec2/fixtures/instances.yaml?rev=962262&r1=962261&r2=962262&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/support/ec2/fixtures/instances.yaml (original)
+++ incubator/deltacloud/trunk/server/features/support/ec2/fixtures/instances.yaml Thu Jul  8 23:41:52 2010
@@ -1,35 +1,554 @@
 --- 
-- :aws_instance_id: i-123f1234
-  :aws_groups: 
-  - default
+- &id001 
   :aws_ramdisk_id: ari-ce34gad7
+  :aws_instance_type: m1.small
+  :aws_availability_zone: us-east-1b
+  :aws_owner: "522821470517"
+  :aws_instance_id: i-123f1234
+  :ssh_key_name: staging
+  :aws_reason: ""
   :aws_image_id: ami-e4b6538e
+  :aws_state_code: "80"
+  :aws_reservation_id: r-aabbccdd
   :dns_name: domU-12-34-67-89-01-C9.usma2.compute.amazonaws.com
-  :ssh_key_name: staging
-  :aws_state_code: "16"
+  :aws_launch_time: "2010-03-18T16:42:06.000Z"
+  :aws_groups: 
+  - default
+  :aws_kernel_id: aki-be3adfd7
   :private_dns_name: domU-12-34-67-89-01-C9.usma2.compute.amazonaws.com
+  :aws_state: stopped
+- *id001
+- &id002 
+  :aws_ramdisk_id: ari-ce34gad7
+  :aws_instance_type: m1.small
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-6377f773
   :aws_reason: ""
+  :aws_image_id: ami-e4b6538d
+  :aws_state_code: "80"
+  :aws_reservation_id: r-aabbccdd
+  :dns_name: domU-91-76-73-68-01-C9.usma2.compute.amazonaws.com
+  :aws_launch_time: "2010-03-19T09:48:51.000Z"
+  :aws_groups: 
+  - default
+  :aws_key_name: staging
+  :aws_kernel_id: aki-be3adfd7
+  :private_dns_name: domU-57-52-86-34-02-P9.usma2.compute.amazonaws.com
+  :aws_state: stopped
+- *id002
+- &id003 
+  :aws_ramdisk_id: ari-ce34gad7
+  :aws_instance_type: m1.small
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-6768f867
+  :aws_reason: ""
+  :aws_image_id: ami-e4b6538d
+  :aws_state_code: "16"
+  :aws_reservation_id: r-aabbccdd
+  :dns_name: domU-74-77-69-68-01-C9.usma2.compute.amazonaws.com
+  :aws_launch_time: "2010-03-19T09:49:03.000Z"
+  :aws_groups: 
+  - default
+  :aws_key_name: staging
+  :aws_kernel_id: aki-be3adfd7
+  :private_dns_name: domU-61-93-88-56-02-P9.usma2.compute.amazonaws.com
   :aws_state: running
-  :aws_launch_time: 2010-1-1T00:00:00.000Z
+- *id003
+- &id004 
+  :aws_ramdisk_id: ari-ce34gad7
+  :aws_instance_type: m1.small
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-7201f102
+  :aws_reason: ""
+  :aws_image_id: ami-e4b6538d
+  :aws_state_code: "80"
+  :aws_reservation_id: r-aabbccdd
+  :dns_name: domU-43-15-73-97-01-C9.usma2.compute.amazonaws.com
+  :aws_launch_time: "2010-03-18T16:46:41.000Z"
+  :aws_groups: 
+  - default
+  :aws_kernel_id: aki-be3adfd7
+  :aws_key_name: staging
+  :private_dns_name: domU-18-41-28-55-02-P9.usma2.compute.amazonaws.com
+  :aws_state: stopped
+- *id004
+- :aws_ramdisk_id: ari-ce34gad7
   :aws_instance_type: m1.small
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-7282f282
+  :aws_reason: ""
+  :aws_image_id: ami-e4b6538d
+  :aws_state_code: "80"
   :aws_reservation_id: r-aabbccdd
-  :aws_availability_zone: us-east-1b
+  :dns_name: domU-79-17-68-63-01-C9.usma2.compute.amazonaws.com
+  :aws_launch_time: "2010-03-18T16:48:03.000Z"
+  :aws_groups: 
+  - default
   :aws_kernel_id: aki-be3adfd7
-  :aws_owner: "522821470517"
-- :aws_instance_id: i-123f1234
+  :aws_key_name: staging
+  :private_dns_name: domU-93-34-45-41-02-P9.usma2.compute.amazonaws.com
+  :aws_state: stopped
+- :aws_ramdisk_id: ari-ce34gad7
+  :aws_instance_type: m1.small
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-7283f382
+  :aws_reason: ""
+  :aws_image_id: ami-e4b6538d
+  :aws_state_code: "16"
+  :aws_reservation_id: r-aabbccdd
+  :dns_name: domU-46-61-29-30-01-C9.usma2.compute.amazonaws.com
+  :aws_launch_time: "2010-03-19T09:54:38.000Z"
   :aws_groups: 
   - default
+  :aws_key_name: staging
+  :aws_kernel_id: aki-be3adfd7
+  :private_dns_name: domU-36-34-13-90-02-P9.usma2.compute.amazonaws.com
+  :aws_state: running
+- :aws_ramdisk_id: ari-ce34gad7
+  :aws_instance_type: m1.small
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-7465f564
+  :aws_reason: ""
+  :aws_image_id: ami-e4b6538d
+  :aws_state_code: "80"
+  :aws_reservation_id: r-aabbccdd
+  :dns_name: domU-92-41-94-17-01-C9.usma2.compute.amazonaws.com
+  :aws_launch_time: "2010-03-18T16:51:06.000Z"
+  :aws_groups: 
+  - default
+  :aws_kernel_id: aki-be3adfd7
+  :aws_key_name: staging
+  :private_dns_name: domU-16-99-39-83-02-P9.usma2.compute.amazonaws.com
+  :aws_state: stopped
+- :aws_ramdisk_id: ari-ce34gad7
+  :aws_instance_type: m1.small
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-7466f664
+  :aws_reason: ""
+  :aws_image_id: ami-e4b6538d
+  :aws_state_code: "16"
+  :aws_reservation_id: r-aabbccdd
+  :dns_name: domU-10-71-56-70-01-C9.usma2.compute.amazonaws.com
+  :aws_launch_time: "2010-03-18T16:51:06.000Z"
+  :aws_groups: 
+  - default
+  :aws_key_name: staging
+  :aws_kernel_id: aki-be3adfd7
+  :private_dns_name: domU-42-35-40-70-02-P9.usma2.compute.amazonaws.com
+  :aws_state: running
+- &id005 
+  :aws_instance_type: m1.small
   :aws_ramdisk_id: ari-ce34gad7
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-9136f631
+  :aws_reason: ""
   :aws_image_id: ami-e4b6538d
-  :dns_name: domU-11-34-67-89-01-C9.usma2.compute.amazonaws.com
-  :ssh_key_name: staging
+  :aws_state_code: "80"
+  :aws_reservation_id: r-aabbccdd
+  :dns_name: domU-58-45-69-89-01-C9.usma2.compute.amazonaws.com
+  :aws_launch_time: "2010-03-19T09:58:57.000Z"
+  :aws_groups: 
+  - default
+  :private_dns_name: domU-79-86-67-19-02-P9.usma2.compute.amazonaws.com
+  :aws_key_name: staging
+  :aws_kernel_id: aki-be3adfd7
+  :aws_state: stopped
+- *id005
+- :aws_instance_type: m1.small
+  :aws_ramdisk_id: ari-ce34gad7
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-9256f652
+  :aws_reason: ""
+  :aws_image_id: ami-e4b6538d
+  :aws_state_code: "80"
+  :aws_reservation_id: r-aabbccdd
+  :dns_name: domU-87-37-33-34-01-C9.usma2.compute.amazonaws.com
+  :aws_launch_time: "2010-03-19T10:00:57.000Z"
+  :aws_groups: 
+  - default
+  :private_dns_name: domU-60-64-50-99-02-P9.usma2.compute.amazonaws.com
+  :aws_key_name: staging
+  :aws_kernel_id: aki-be3adfd7
+  :aws_state: stopped
+- :aws_ramdisk_id: ari-ce34gad7
+  :aws_instance_type: m1.small
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-9257f752
+  :aws_reason: ""
   :aws_state_code: "16"
-  :private_dns_name: domU-11-34-67-89-01-C9.usma2.compute.amazonaws.com
+  :aws_image_id: ami-e4b6538d
+  :aws_reservation_id: r-aabbccdd
+  :aws_launch_time: "2010-03-19T10:00:57.000Z"
+  :dns_name: domU-77-28-21-13-01-C9.usma2.compute.amazonaws.com
+  :aws_groups: 
+  - default
+  :aws_kernel_id: aki-be3adfd7
+  :aws_key_name: staging
+  :private_dns_name: domU-43-42-47-85-02-P9.usma2.compute.amazonaws.com
+  :aws_state: running
+- &id006 
+  :aws_instance_type: m1.small
+  :aws_ramdisk_id: ari-ce34gad7
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-9359f953
   :aws_reason: ""
+  :aws_image_id: ami-e4b6538d
+  :aws_state_code: "80"
+  :aws_reservation_id: r-aabbccdd
+  :dns_name: domU-18-95-79-18-01-C9.usma2.compute.amazonaws.com
+  :aws_launch_time: "2010-03-19T10:02:40.000Z"
+  :aws_groups: 
+  - default
+  :private_dns_name: domU-53-74-74-42-02-P9.usma2.compute.amazonaws.com
+  :aws_key_name: staging
+  :aws_kernel_id: aki-be3adfd7
+  :aws_state: stopped
+- *id006
+- &id007 
+  :aws_instance_type: m1.small
+  :aws_ramdisk_id: ari-ce34gad7
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-9436f634
+  :aws_reason: ""
+  :aws_image_id: ami-e4b6538d
+  :aws_state_code: "80"
+  :aws_reservation_id: r-aabbccdd
+  :dns_name: domU-75-77-57-39-01-C9.usma2.compute.amazonaws.com
+  :aws_launch_time: "2010-03-19T10:03:57.000Z"
+  :aws_groups: 
+  - default
+  :private_dns_name: domU-33-69-74-87-02-P9.usma2.compute.amazonaws.com
+  :aws_key_name: staging
+  :aws_kernel_id: aki-be3adfd7
+  :aws_state: stopped
+- *id007
+- &id008 
+  :aws_instance_type: m1.small
+  :aws_ramdisk_id: ari-ce34gad7
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-9475f574
+  :aws_reason: ""
+  :aws_image_id: ami-e4b6538d
+  :aws_state_code: "80"
+  :aws_reservation_id: r-aabbccdd
+  :dns_name: domU-97-96-15-98-01-C9.usma2.compute.amazonaws.com
+  :aws_launch_time: "2010-03-19T10:04:36.000Z"
+  :aws_groups: 
+  - default
+  :private_dns_name: domU-74-85-20-18-02-P9.usma2.compute.amazonaws.com
+  :aws_key_name: staging
+  :aws_kernel_id: aki-be3adfd7
+  :aws_state: stopped
+- *id008
+- &id009 
+  :aws_instance_type: m1.small
+  :aws_ramdisk_id: ari-ce34gad7
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-9625f526
+  :aws_reason: ""
+  :aws_image_id: ami-e4b6538d
+  :aws_state_code: "80"
+  :aws_reservation_id: r-aabbccdd
+  :dns_name: domU-59-86-36-78-01-C9.usma2.compute.amazonaws.com
+  :aws_launch_time: "2010-03-19T10:07:06.000Z"
+  :aws_groups: 
+  - default
+  :private_dns_name: domU-83-51-83-95-02-P9.usma2.compute.amazonaws.com
+  :aws_key_name: staging
+  :aws_kernel_id: aki-be3adfd7
+  :aws_state: stopped
+- *id009
+- &id010 
+  :aws_instance_type: m1.small
+  :aws_ramdisk_id: ari-ce34gad7
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-9688f886
+  :aws_reason: ""
+  :aws_image_id: ami-e4b6538d
+  :aws_state_code: "80"
+  :aws_reservation_id: r-aabbccdd
+  :dns_name: domU-47-88-15-64-01-C9.usma2.compute.amazonaws.com
+  :aws_launch_time: "2010-03-19T10:08:09.000Z"
+  :aws_groups: 
+  - default
+  :private_dns_name: domU-33-66-67-24-02-P9.usma2.compute.amazonaws.com
+  :aws_key_name: staging
+  :aws_kernel_id: aki-be3adfd7
+  :aws_state: stopped
+- *id010
+- :aws_instance_type: m1.small
+  :aws_ramdisk_id: ari-ce34gad7
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-9765f567
+  :aws_reason: ""
+  :aws_image_id: ami-e4b6538d
+  :aws_state_code: "80"
+  :aws_reservation_id: r-aabbccdd
+  :dns_name: domU-62-26-48-64-01-C9.usma2.compute.amazonaws.com
+  :aws_launch_time: "2010-03-19T10:09:27.000Z"
+  :aws_groups: 
+  - default
+  :private_dns_name: domU-63-42-48-61-02-P9.usma2.compute.amazonaws.com
+  :aws_key_name: staging
+  :aws_kernel_id: aki-be3adfd7
+  :aws_state: stopped
+- :aws_ramdisk_id: ari-ce34gad7
+  :aws_instance_type: m1.small
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-9766f667
+  :aws_reason: ""
+  :aws_state_code: "16"
+  :aws_image_id: ami-e4b6538d
+  :aws_reservation_id: r-aabbccdd
+  :aws_launch_time: "2010-03-19T10:09:26.000Z"
+  :dns_name: domU-89-64-98-94-01-C9.usma2.compute.amazonaws.com
+  :aws_groups: 
+  - default
+  :aws_kernel_id: aki-be3adfd7
+  :aws_key_name: staging
+  :private_dns_name: domU-68-34-67-95-02-P9.usma2.compute.amazonaws.com
   :aws_state: running
-  :aws_launch_time: 2010-1-1T00:00:00.000Z
-  :aws_instance_type: m1.xlarge
+- :aws_instance_type: m1.small
+  :aws_ramdisk_id: ari-ce34gad7
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-9851f158
+  :aws_reason: ""
+  :aws_image_id: ami-e4b6538d
+  :aws_state_code: "80"
   :aws_reservation_id: r-aabbccdd
-  :aws_availability_zone: us-west-1a
+  :dns_name: domU-14-49-66-52-01-C9.usma2.compute.amazonaws.com
+  :aws_launch_time: "2010-03-19T10:10:53.000Z"
+  :aws_groups: 
+  - default
+  :private_dns_name: domU-98-79-48-18-02-P9.usma2.compute.amazonaws.com
+  :aws_key_name: staging
   :aws_kernel_id: aki-be3adfd7
-  :aws_owner: "522821470517"
+  :aws_state: stopped
+- :aws_ramdisk_id: ari-ce34gad7
+  :aws_instance_type: m1.small
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-9852f258
+  :aws_reason: ""
+  :aws_state_code: "16"
+  :aws_image_id: ami-e4b6538d
+  :aws_reservation_id: r-aabbccdd
+  :aws_launch_time: "2010-03-19T10:10:52.000Z"
+  :dns_name: domU-30-53-87-88-01-C9.usma2.compute.amazonaws.com
+  :aws_groups: 
+  - default
+  :aws_kernel_id: aki-be3adfd7
+  :aws_key_name: staging
+  :private_dns_name: domU-15-86-96-87-02-P9.usma2.compute.amazonaws.com
+  :aws_state: running
+- :aws_instance_type: m1.small
+  :aws_ramdisk_id: ari-ce34gad7
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-9968f869
+  :aws_reason: ""
+  :aws_image_id: ami-e4b6538d
+  :aws_state_code: "80"
+  :aws_reservation_id: r-aabbccdd
+  :dns_name: domU-92-92-86-58-01-C9.usma2.compute.amazonaws.com
+  :aws_launch_time: "2010-03-19T10:12:50.000Z"
+  :aws_groups: 
+  - default
+  :private_dns_name: domU-19-24-57-78-02-P9.usma2.compute.amazonaws.com
+  :aws_key_name: staging
+  :aws_kernel_id: aki-be3adfd7
+  :aws_state: stopped
+- :aws_ramdisk_id: ari-ce34gad7
+  :aws_instance_type: m1.small
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-9969f969
+  :aws_reason: ""
+  :aws_state_code: "16"
+  :aws_image_id: ami-e4b6538d
+  :aws_reservation_id: r-aabbccdd
+  :aws_launch_time: "2010-03-19T10:12:49.000Z"
+  :dns_name: domU-63-53-77-14-01-C9.usma2.compute.amazonaws.com
+  :aws_groups: 
+  - default
+  :aws_kernel_id: aki-be3adfd7
+  :aws_key_name: staging
+  :private_dns_name: domU-68-47-52-46-02-P9.usma2.compute.amazonaws.com
+  :aws_state: running
+- &id011 
+  :aws_instance_type: m1.small
+  :aws_ramdisk_id: ari-ce34gad7
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-9986f689
+  :aws_reason: ""
+  :aws_image_id: ami-e4b6538d
+  :aws_state_code: "80"
+  :aws_reservation_id: r-aabbccdd
+  :dns_name: domU-59-57-57-43-01-C9.usma2.compute.amazonaws.com
+  :aws_launch_time: "2010-03-19T10:13:08.000Z"
+  :aws_groups: 
+  - default
+  :private_dns_name: domU-12-44-70-79-02-P9.usma2.compute.amazonaws.com
+  :aws_key_name: staging
+  :aws_kernel_id: aki-be3adfd7
+  :aws_state: stopped
+- *id011
+- :aws_instance_type: m1.small
+  :aws_ramdisk_id: ari-ce34gad7
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-0055f550
+  :aws_reason: ""
+  :aws_image_id: ami-e4b6538d
+  :aws_state_code: "80"
+  :aws_reservation_id: r-aabbccdd
+  :dns_name: domU-87-70-13-70-01-C9.usma2.compute.amazonaws.com
+  :aws_launch_time: "2010-03-19T10:14:17.000Z"
+  :aws_groups: 
+  - default
+  :private_dns_name: domU-64-65-21-50-02-P9.usma2.compute.amazonaws.com
+  :aws_key_name: staging
+  :aws_kernel_id: aki-be3adfd7
+  :aws_state: stopped
+- :aws_ramdisk_id: ari-ce34gad7
+  :aws_instance_type: m1.small
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-0056f650
+  :aws_reason: ""
+  :aws_state_code: "16"
+  :aws_image_id: ami-e4b6538d
+  :aws_reservation_id: r-aabbccdd
+  :aws_launch_time: "2010-03-19T10:14:16.000Z"
+  :dns_name: domU-39-94-46-66-01-C9.usma2.compute.amazonaws.com
+  :aws_groups: 
+  - default
+  :aws_kernel_id: aki-be3adfd7
+  :aws_key_name: staging
+  :private_dns_name: domU-47-44-34-75-02-P9.usma2.compute.amazonaws.com
+  :aws_state: running
+- &id012 
+  :aws_instance_type: m1.small
+  :aws_ramdisk_id: ari-ce34gad7
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-0287f782
+  :aws_reason: ""
+  :aws_image_id: ami-e4b6538d
+  :aws_state_code: "80"
+  :aws_reservation_id: r-aabbccdd
+  :dns_name: domU-98-60-65-13-01-C9.usma2.compute.amazonaws.com
+  :aws_launch_time: "2010-03-19T10:18:09.000Z"
+  :aws_groups: 
+  - default
+  :private_dns_name: domU-30-14-55-46-02-P9.usma2.compute.amazonaws.com
+  :aws_key_name: staging
+  :aws_kernel_id: aki-be3adfd7
+  :aws_state: stopped
+- *id012
+- :aws_instance_type: m1.small
+  :aws_ramdisk_id: ari-ce34gad7
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-0368f863
+  :aws_reason: ""
+  :aws_image_id: ami-e4b6538d
+  :aws_state_code: "80"
+  :aws_reservation_id: r-aabbccdd
+  :dns_name: domU-53-63-17-47-01-C9.usma2.compute.amazonaws.com
+  :aws_launch_time: "2010-03-19T10:19:31.000Z"
+  :aws_groups: 
+  - default
+  :private_dns_name: domU-91-91-50-62-02-P9.usma2.compute.amazonaws.com
+  :aws_key_name: staging
+  :aws_kernel_id: aki-be3adfd7
+  :aws_state: stopped
+- :aws_ramdisk_id: ari-ce34gad7
+  :aws_instance_type: m1.small
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-0369f963
+  :aws_reason: ""
+  :aws_state_code: "16"
+  :aws_image_id: ami-e4b6538d
+  :aws_reservation_id: r-aabbccdd
+  :aws_launch_time: "2010-03-19T10:19:29.000Z"
+  :dns_name: domU-85-56-97-91-01-C9.usma2.compute.amazonaws.com
+  :aws_groups: 
+  - default
+  :aws_kernel_id: aki-be3adfd7
+  :aws_key_name: staging
+  :private_dns_name: domU-10-91-12-47-02-P9.usma2.compute.amazonaws.com
+  :aws_state: running
+- :aws_instance_type: m1.small
+  :aws_ramdisk_id: ari-ce34gad7
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-0421f124
+  :aws_reason: ""
+  :aws_image_id: ami-e4b6538d
+  :aws_state_code: "80"
+  :aws_reservation_id: r-aabbccdd
+  :dns_name: domU-69-48-22-72-01-C9.usma2.compute.amazonaws.com
+  :aws_launch_time: "2010-03-19T10:20:24.000Z"
+  :aws_groups: 
+  - default
+  :private_dns_name: domU-60-27-24-24-02-P9.usma2.compute.amazonaws.com
+  :aws_key_name: staging
+  :aws_kernel_id: aki-be3adfd7
+  :aws_state: stopped
+- :aws_ramdisk_id: ari-ce34gad7
+  :aws_instance_type: m1.small
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-0422f224
+  :aws_reason: ""
+  :aws_state_code: "16"
+  :aws_image_id: ami-e4b6538d
+  :aws_reservation_id: r-aabbccdd
+  :aws_launch_time: "2010-03-19T10:20:22.000Z"
+  :dns_name: domU-79-23-17-84-01-C9.usma2.compute.amazonaws.com
+  :aws_groups: 
+  - default
+  :aws_kernel_id: aki-be3adfd7
+  :aws_key_name: staging
+  :private_dns_name: domU-43-61-93-57-02-P9.usma2.compute.amazonaws.com
+  :aws_state: running
+- &id013 
+  :aws_ramdisk_id: ari-ce34gad7
+  :aws_instance_type: m1.small
+  :aws_availability_zone: us-east-1a
+  :aws_owner: 
+  :aws_instance_id: i-9707f707
+  :aws_reason: ""
+  :aws_state_code: "80"
+  :aws_image_id: ami-e4b6538d
+  :aws_reservation_id: r-aabbccdd
+  :aws_launch_time: "2010-03-22T10:21:50.000Z"
+  :dns_name: domU-13-17-27-20-01-C9.usma2.compute.amazonaws.com
+  :aws_groups: 
+  - default
+  :aws_kernel_id: aki-be3adfd7
+  :aws_key_name: staging
+  :private_dns_name: domU-26-64-22-19-02-P9.usma2.compute.amazonaws.com
+  :aws_state: stopping
+- *id013

Modified: incubator/deltacloud/trunk/server/features/support/ec2/fixtures/storage_volume.yaml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/support/ec2/fixtures/storage_volume.yaml?rev=962262&r1=962261&r2=962262&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/support/ec2/fixtures/storage_volume.yaml (original)
+++ incubator/deltacloud/trunk/server/features/support/ec2/fixtures/storage_volume.yaml Thu Jul  8 23:41:52 2010
@@ -5,7 +5,7 @@
   :aws_device: /dev/sda
   :aws_created_at: Wed Jun 18 08:19:20s UTC 2008
   :aws_attachment_status: attached
-  :aws_instance_id: i-c014c0a9
+  :aws_instance_id: i-123f1234
   :snapshot_id: i-123f1234
   :aws_attached_at: Wed Jun 18 08:19:28 UTC 2008
   :aws_status: in-use
@@ -14,4 +14,5 @@
   :zone: us-east-1a
   :aws_created_at: Wed Jun 18 08:19:21 UTC 2008
   :snapshot_id: i-123f1234
+  :aws_instance_id: i-c014c0a9
   :aws_status: available

Modified: incubator/deltacloud/trunk/server/features/support/mock/config.yaml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/support/mock/config.yaml?rev=962262&r1=962261&r2=962262&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/support/mock/config.yaml (original)
+++ incubator/deltacloud/trunk/server/features/support/mock/config.yaml Thu Jul  8 23:41:52 2010
@@ -1,4 +1,6 @@
 --- 
+:username: mockuser
+:password: mockpassword
 :storage_snapshot_id: snap2
 :driver_name: mock
 :instances_count: 180

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb?rev=962262&r1=962261&r2=962262&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb Thu Jul  8 23:41:52 2010
@@ -98,16 +98,15 @@ class EC2Driver < Deltacloud::BaseDriver
   end
 
   define_instance_states do
-    start.to( :pending )         .automatically
-
-    pending.to( :running )       .automatically
-    pending.to( :stopped )       .on( :stop )
-
-    running.to( :running )       .on( :reboot )
-    running.to( :shutting_down ) .on( :stop )
-
-    shutting_down.to( :stopped ) .automatically
-    stopped.to( :finish )        .automatically
+    start.to( :pending )          .automatically
+    pending.to( :running )        .automatically
+    pending.to( :stopping )       .on( :stop )
+    pending.to( :stopped )        .automatically
+    stopped.to( :running )        .on( :start )
+    running.to( :running )        .on( :reboot )
+    running.to( :stopping )       .on( :stop )
+    shutting_down.to( :stopped )  .automatically
+    stopped.to( :finish )         .automatically
   end
 
   def flavors(credentials, opts=nil)
@@ -306,6 +305,7 @@ class EC2Driver < Deltacloud::BaseDriver
     (realm_id = nil ) if ( realm_id == '' )
     Instance.new( {
       :id=>ec2_instance[:aws_instance_id],
+      :name => ec2_instance[:aws_image_id],
       :state=>ec2_instance[:aws_state].upcase,
       :image_id=>ec2_instance[:aws_image_id],
       :owner_id=>ec2_instance[:aws_owner],

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_mock_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_mock_driver.rb?rev=962262&r1=962261&r2=962262&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_mock_driver.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_mock_driver.rb Thu Jul  8 23:41:52 2010
@@ -5,18 +5,15 @@ module RightAws
     end
 
     def describe_images(id)
-      images = load_fixtures_for(:images)
-      return images.select { |i| i[:aws_id].eql?(id) }
+      load_fixtures_for(:images).select { |i| i[:aws_id].eql?(id) }
     end
 
     def describe_images_by_owner(id)
-      images = load_fixtures_for(:images)
-      return images.select { |i| i[:aws_owner].eql?(id) }
+      load_fixtures_for(:images).select { |i| i[:aws_owner].eql?(id) }
     end
 
     def describe_images(opts={})
-      images = load_fixtures_for(:images)
-      return images
+      load_fixtures_for(:images)
     end
 
     def describe_availability_zones(opts={})
@@ -26,23 +23,8 @@ module RightAws
     def describe_instances(opts={})
       instances = load_fixtures_for(:instances)
       instances.each_with_index do |instance, i|
-        t1 = DateTime.now - DateTime.parse(instance[:aws_launch_time])
-        hours, minutes, seconds, frac = Date.day_fraction_to_time(t1)
-        if (minutes>3 or hours>0) and instance[:aws_state].eql?('pending')
-          instance[:aws_state] = 'running'
-          instance[:aws_state_code] = '16'
-          instances[i] = instance
-        end
-        if (minutes>2 or hours>0) and instance[:aws_state].eql?('stopping')
-          instance[:aws_state] = 'stopped'
-          instance[:aws_state_code] = '80'
-          instances[i] = instance
-        end
-        if opts and opts[:id]
-          if instance[:aws_instance_id].eql?(opts[:id])
-            return [instance]
-          end
-        end
+        instances[i] = update_delayed_state(instance)
+        return [instance] if opts and opts[:id] and instance[:aws_instance_id].eql?(opts[:id])
       end
       update_fixtures_for(:instances, instances)
       instances
@@ -59,27 +41,29 @@ module RightAws
         realm = load_fixtures_for(:realms).first
       end
 
+      raise Exception unless image
+      raise Exception unless realm
+
       instance = { }
       instance[:aws_image_id] = image[:aws_id]
       instance[:aws_availability_zone] = realm[:zone_name]
       instance[:aws_instance_type] = instance_type
       instance[:aws_owner] = user_data
       instance[:aws_state] = 'pending'
-      instance[:aws_launch_time] = DateTime.now.to_s.gsub(/\+(.+)$/, '.000Z')
       instance[:aws_reason] = ''
-      instance[:dns_name] = "domU-#{rand(100)+10}-#{rand(100)+10}-#{rand(100)+10}-#{rand(100)+10}-01-C9.usma2.compute.amazonaws.com"
-      instance[:private_dns_name] = "domU-#{rand(100)+10}-#{rand(100)+10}-#{rand(100)+10}-#{rand(100)+10}-02-P9.usma2.compute.amazonaws.com"
+      instance[:dns_name] = "#{random_dns}-01-C9.usma2.compute.amazonaws.com"
+      instance[:private_dns_name] = "#{random_dns}-02-P9.usma2.compute.amazonaws.com"
       instance[:aws_state_code] = "0"
       instance[:aws_key_name] = "staging"
       instance[:aws_kernel_id] = "aki-be3adfd7"
-      instance[:aws_groups] = ["default"]
       instance[:aws_ramdisk_id] = "ari-ce34gad7"
-      id_1 = ("%.4s" % Time.now.to_i.to_s.reverse).reverse
-      id_2 = ("%.3s" % Time.now.to_i.to_s.reverse)
-      instance[:aws_instance_id] = "i-#{id_1}f#{id_2}"
+      instance[:aws_groups] = ["default"]
+      instance[:aws_instance_id] = random_instance_id
       instance[:aws_reservation_id] = "r-aabbccdd"
+      instance[:aws_launch_time] = instance_time_format
 
       instances << instance
+
       update_fixtures_for(:instances, instances)
 
       return [instance]
@@ -87,41 +71,15 @@ module RightAws
 
 
     def terminate_instances(id)
-      instances = load_fixtures_for(:instances)
-      ti = nil
-      instances.each_with_index do |instance, i|
-        if instance[:aws_instance_id].eql?(id)
-          instance[:aws_state] = 'stopping'
-          instance[:aws_state_code] = '64'
-          instance[:aws_launch_time] = DateTime.now.to_s.gsub(/\+(.+)$/, '.000Z')
-          instances[i] = instance
-          ti = i
-          break
-        end
-      end
-      update_fixtures_for(:instances, instances)
-      return instances[ti]
+      update_instance_state(id, 'stopping', '80')
     end
 
-    alias :destroy_instance :terminate_instances
-    
     def reboot_instances(id)
-      instances = load_fixtures_for(:instances)
-      ti = nil
-      instances.each_with_index do |instance, i|
-        if instance[:aws_instance_id].eql?(id)
-          instance[:aws_state] = 'pending'
-          instance[:aws_state_code] = '0'
-          instance[:aws_launch_time] = DateTime.now.to_s.gsub(/\+(.+)$/, '.000Z')
-          instances[i] = instance
-          ti = i
-          break
-        end
-      end
-      update_fixtures_for(:instances, instances)
-      return instances[ti]
+      update_instance_state(id, 'pending', '0')
     end
 
+    alias :destroy_instance :terminate_instances
+
     def describe_snapshots(opts={})
       load_fixtures_for(:storage_snapshot)
     end
@@ -136,14 +94,64 @@ module RightAws
       File::expand_path(File::join(File::dirname(__FILE__), '../../../../features/support/ec2'))
     end
 
+    def fixtures_path
+      File::expand_path(File::join(driver_dir, 'fixtures'))
+    end
+
     def load_fixtures_for(collection)
-      YAML.load_file(File::join(File::expand_path(File::join(driver_dir, 'fixtures')), "#{collection}.yaml"))
+      YAML.load_file(File::join(fixtures_path, "#{collection}.yaml"))
     end
 
     def update_fixtures_for(collection, new_data)
-      File.open(File::join(File::expand_path(File::join(driver_dir, 'fixtures')), "#{collection}.yaml"), 'w' ) do |out|
+      File.open(File::join(fixtures_path, "#{collection}.yaml"), 'w' ) do |out|
         YAML.dump(new_data, out)
       end
+      return new_data
+    end
+
+    def instance_time_format
+      DateTime.now.to_s.gsub(/\+(.+)$/, '.000Z')
+    end
+
+    def random_instance_id
+      id_1 = ("%.4s" % Time.now.to_i.to_s.reverse).reverse
+      id_2 = ("%.3s" % Time.now.to_i.to_s.reverse)
+      "i-#{id_1}f#{id_2}"
+    end
+
+    def random_dns
+      "domU-#{rand(90)+10}-#{rand(90)+10}-#{rand(90)+10}-#{rand(90)+10}"
+    end
+
+    def update_delayed_state(instance)
+      time = DateTime.now - DateTime.parse(instance[:aws_launch_time])
+      hours, minutes, seconds, frac = Date.day_fraction_to_time(time)
+
+      if (minutes>(rand(2)+1) or hours>0) and instance[:aws_state].eql?('pending')
+        instance[:aws_state], instance[:aws_state_code] = 'running', '16'
+      end
+
+      if (minutes>(rand(1)+1) or hours>0) and instance[:aws_state].eql?('stopping')
+        instance[:aws_state], instance[:aws_state_code] = 'stopped', '80'
+      end
+
+      return instance
+    end
+
+    def update_instance_state(id, state, state_code)
+      instance = describe_instances(:id => id).first
+      if instance
+        instance[:aws_state], instance[:aws_state_code] = state, state_code
+        instance[:aws_launch_time] = instance_time_format
+        instances = load_fixtures_for(:instances)
+        instances.each_with_index do |inst, i|
+          instances[i] = instance if inst[:aws_instance_id].eql?(id)       
+        end
+        update_fixtures_for(:instances, instances)
+        return instance
+      else
+        raise Exception
+      end
     end
 
   end



Mime
View raw message