You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by lu...@apache.org on 2010/07/09 01:44:14 UTC
svn commit: r962297 - in /incubator/deltacloud/trunk/server/features:
hardware_profiles.feature step_definitions/hardware_profiles_steps.rb
support/mock/config.yaml
Author: lutter
Date: Thu Jul 8 23:44:14 2010
New Revision: 962297
URL: http://svn.apache.org/viewvc?rev=962297&view=rev
Log:
Hardware profiles: feature tests
Added:
incubator/deltacloud/trunk/server/features/hardware_profiles.feature
incubator/deltacloud/trunk/server/features/step_definitions/hardware_profiles_steps.rb
Modified:
incubator/deltacloud/trunk/server/features/support/mock/config.yaml
Added: incubator/deltacloud/trunk/server/features/hardware_profiles.feature
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/hardware_profiles.feature?rev=962297&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/features/hardware_profiles.feature (added)
+++ incubator/deltacloud/trunk/server/features/hardware_profiles.feature Thu Jul 8 23:44:14 2010
@@ -0,0 +1,23 @@
+Feature: Working with hardware profiles
+ In order to work with hardware profiles
+
+ Background:
+ Given I want to get XML
+
+ Scenario: I want to get list of all hardware profiles
+ When I follow hardware profiles link in entry points
+ Then I should see <HARDWARE_PROFILE_COUNT> hardware profile inside hardware profiles
+ And each link in hardware profiles should point me to valid hardware profile
+
+ Scenario: I want to show hardware profile details
+ When I request for '<HARDWARE_PROFILE_ID>' hardware profile
+ Then I should get this hardware profile
+ And it should have a href attribute
+ And hardware profile should include id parameter
+ And it should have a fixed property 'cpu'
+ And it should have a range property 'memory'
+ And it should have a enum property 'storage'
+
+ Scenario: I want filter hardware profiles by architecture
+ When I want hardware profiles with '<HARDWARE_PROFILE_ARCH>' architecture
+ Then the returned hardware profiles should have architecture '<HARDWARE_PROFILE_ARCH>'
Added: incubator/deltacloud/trunk/server/features/step_definitions/hardware_profiles_steps.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/step_definitions/hardware_profiles_steps.rb?rev=962297&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/features/step_definitions/hardware_profiles_steps.rb (added)
+++ incubator/deltacloud/trunk/server/features/step_definitions/hardware_profiles_steps.rb Thu Jul 8 23:44:14 2010
@@ -0,0 +1,41 @@
+Then /^it should have a (\w+) attribute$/ do |name|
+ attr = Nokogiri::XML(last_response.body).xpath('/hardware-profile').first[name]
+ attr.should_not be_nil
+ if (name == 'href')
+ attr.should == "http://example.org/api/hardware_profiles/#{CONFIG[:hardware_profile_id]}"
+ end
+end
+
+Then /^it should have a (\w+) property '(.+)'$/ do |kind, name|
+ props = Nokogiri::XML(last_response.body).xpath("/hardware-profile/property[@name = '#{name}']")
+ props.size.should == 1
+ prop = props.first
+ prop['kind'].should == kind
+ prop['unit'].should_not be_nil
+ if kind == 'range'
+ ranges = prop.xpath('range')
+ ranges.size.should == 1
+ range = ranges.first
+ range['first'].should_not be_nil
+ range['last'].should_not be_nil
+ end
+ if kind == 'enum'
+ enums = prop.xpath('enum')
+ enums.size.should == 1
+ enums.first.xpath('entry').size.should_not == 0
+ end
+end
+
+Then /^the returned hardware profiles should have (.+) '(.+)'$/ do |parameter, value|
+ params = {}
+ value = replace_variables(value)
+ @tested_params.collect { |param| params[:"#{param[0]}"] = param[1] }
+ get '/api/hardware_profiles', params, {}
+ last_response.status.should == 200
+ parameters = []
+ Nokogiri::XML(last_response.body).xpath("/hardware-profiles/hardware-profile/property[@name = '#{parameter}']").each do |elt|
+ parameters << elt['value']
+ end
+ parameters.uniq.size.should == 1
+ parameters.uniq.first.should == value
+end
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=962297&r1=962296&r2=962297&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:44:14 2010
@@ -1,4 +1,4 @@
----
+---
:username: mockuser
:password: mockpassword
:storage_snapshot_id: snap2
@@ -19,7 +19,10 @@
:image_id: img2
:storage_volume_state: AVAILABLE
:flavor_id: m1-small
+:hardware_profile_id: m1-large
:instance_realm: us
:image_count: 3
:storage_volume_count: 2
:flavor_count: 5
+:hardware_profile_count: 4
+:hardware_profile_arch: x86_64