Hi,
I updated all Cucumber features to reflect recent changes in API and added a couple of new tests to achieve better coverage. Also I removed configuration for Cucumber tests, because I plan to do a 'auto-learning' tests for drivers, which will be shipped separately.
Last thing I added is a jUnit output in Cucumber for better integration with Hudson. Also I deleted obsolete XML converter (we are using pure HAML for generating XML output now).
Sadly, there are two issues which blows up after I completed all features:
1) When you stop/reboot/start instance, XML which is returned has blank <id/> 2) We are missing JSON output for hardware_profiles and instance states
-- Michal
--- server/lib/converters/xml_converter.rb | 133 -------------------- server/lib/deltacloud/helpers/conversion_helper.rb | 1 - 2 files changed, 0 insertions(+), 134 deletions(-) delete mode 100644 server/lib/converters/xml_converter.rb
diff --git a/server/lib/converters/xml_converter.rb b/server/lib/converters/xml_converter.rb deleted file mode 100644 index 82a499d..0000000 --- a/server/lib/converters/xml_converter.rb +++ /dev/null @@ -1,133 +0,0 @@ -# -# Copyright (C) 2009 Red Hat, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -module Converters - - ( ALIASES = { - :owner=>nil, - :volume=>:storage_volume, - } ) unless defined?( ALIASES ) - - def self.url_type(type) - type = type.to_sym - return ALIASES[type] if ( ALIASES.keys.include?( type ) ) - type - end - - def self.tag_name(type) - tag_name = type.to_s - tag_name.gsub( /_/, '-' ) - end - - class XMLConverter - def initialize(link_builder, type) - @link_builder = link_builder - @type = type - end - - def convert(obj, builder=nil) - builder ||= Builder::XmlMarkup.new( :indent=>2 ) - if ( obj.is_a?( Array ) ) - builder.__send__( @type.to_s.pluralize.gsub( /_/, '-' ).to_sym ) do - obj.each do |e| - convert( e, builder ) - end - end - else - case ( obj ) - when Image - builder.image( :href=>@link_builder.send( :image_url, obj.id ) ) { - builder.id( obj.id ) - builder.owner_id( obj.owner_id ) - builder.name( obj.name ) - builder.description( obj.description ) - builder.architecture( obj.architecture ) - } - when Realm - builder.realm( :href=>@link_builder.send( :realm_url, obj.id ) ) { - builder.id( obj.id ) - builder.name( obj.name ) - builder.state( obj.state ) - if ( obj.limit == :unlimited ) - builder.limit() - else - builder.limit( obj.limit ) - end - } - when Instance - builder.instance( :href=>@link_builder.send( :instance_url, obj.id ) ) { - builder.id( obj.id ) - builder.name( obj.name ) - builder.owner_id( obj.owner_id ) - builder.image( :href=>@link_builder.send( :image_url, obj.image_id ) ) - builder.__send__( 'hardware-profile', :href=>@link_builder.send( :hardware_profile_url, obj.instance_profile.name) ) do - builder.id( obj.instance_profile.name ) - obj.instance_profile.overrides.each do |p, v| - u = ::Deltacloud::HardwareProfile::unit(p) - builder.property( :kind=>:fixed, :name=>p, :unit=>u, :value=>v ) - end - end - builder.realm( :href=>@link_builder.send( :realm_url, obj.realm_id ) ) if obj.realm_id - builder.state( obj.state ) - builder.actions { - if ( obj.actions ) - obj.actions.each do |action| - builder.link( :rel=>action, :href=>@link_builder.send( "#{action}_instance_url", obj.id ) ) - end - end - } - builder.__send__( 'public-addresses' ) { - obj.public_addresses.each do |address| - builder.address( address ) - end - } - builder.__send__( 'private-addresses' ) { - obj.private_addresses.each do |address| - builder.address( address ) - end - } - } - when StorageVolume - builder.__send__('storage-volume', :href=>@link_builder.send( :storage_volume_url, obj.id )) { - builder.id( obj.id ) - builder.created( obj.created ) - builder.state( obj.state ) - builder.capacity( obj.capacity ) - builder.device( obj.device ) - if ( obj.instance_id ) - builder.instance( :href=>@link_builder.send( :instance_url, obj.instance_id ) ) - else - builder.instance() - end - } - when StorageSnapshot - builder.__send__('storage-snapshot', :href=>@link_builder.send( :storage_snapshot_url, obj.id )) { - builder.id( obj.id ) - builder.created( obj.created ) - builder.state( obj.state ) - if ( obj.storage_volume_id ) - builder.__send__('storage-volume', :href=>@link_builder.send( :storage_volume_url, obj.storage_volume_id ) ) - else - builder.__send( 'storage-volume' ) - end - } - end - end - return builder.target! - end - end -end diff --git a/server/lib/deltacloud/helpers/conversion_helper.rb b/server/lib/deltacloud/helpers/conversion_helper.rb index 052095d..3db3fff 100644 --- a/server/lib/deltacloud/helpers/conversion_helper.rb +++ b/server/lib/deltacloud/helpers/conversion_helper.rb @@ -17,7 +17,6 @@
require 'deltacloud/base_driver' -require 'converters/xml_converter'
module ConversionHelper
On Tue, 2010-05-11 at 14:02 +0200, mfojtik@redhat.com wrote:
server/lib/converters/xml_converter.rb | 133 -------------------- server/lib/deltacloud/helpers/conversion_helper.rb | 1 - 2 files changed, 0 insertions(+), 134 deletions(-) delete mode 100644 server/lib/converters/xml_converter.rb
ACK
--- server/features/99_rake.feature | 7 + server/features/api.feature | 53 ++- server/features/hardware_profiles.feature | 34 +- server/features/images.feature | 87 ++-- server/features/instance_states.feature | 41 ++- server/features/instances.feature | 237 ++++++--- server/features/realms.feature | 52 +- server/features/step_definitions/api_steps.rb | 112 +++- server/features/step_definitions/common_steps.rb | 115 ---- .../step_definitions/hardware_profiles_steps.rb | 20 +- server/features/step_definitions/images_steps.rb | 84 +++- .../step_definitions/instance_states_steps.rb | 35 ++- .../features/step_definitions/instances_steps.rb | 157 +++--- server/features/step_definitions/rake_steps.rb | 19 + server/features/step_definitions/realms_steps.rb | 4 - .../step_definitions/storage_snapshots_steps.rb | 23 - .../features/step_definitions/storage_volumes.rb | 4 - server/features/storage_snapshots.feature | 54 +- server/features/storage_volumes.feature | 61 ++- server/features/support/ec2/config.yaml | 26 - server/features/support/ec2/fixtures/flavors.yaml | 10 - server/features/support/ec2/fixtures/images.yaml | 29 - .../features/support/ec2/fixtures/instances.yaml | 554 -------------------- server/features/support/ec2/fixtures/realms.yaml | 10 - .../support/ec2/fixtures/storage_snapshot.yaml | 11 - .../support/ec2/fixtures/storage_volume.yaml | 18 - server/features/support/env.rb | 21 +- server/features/support/gogrid/config.yaml | 26 - .../features/support/gogrid/fixtures/flavors.yaml | 7 - .../features/support/gogrid/fixtures/images.yaml | 13 - .../support/gogrid/fixtures/instances.yaml | 42 -- server/features/support/gogrid/fixtures/ips.yaml | 11 - server/features/support/gogrid/servers.yaml | 4 - server/features/support/mock/config.yaml | 25 - 34 files changed, 696 insertions(+), 1310 deletions(-) create mode 100644 server/features/99_rake.feature delete mode 100644 server/features/step_definitions/common_steps.rb create mode 100644 server/features/step_definitions/rake_steps.rb delete mode 100644 server/features/step_definitions/realms_steps.rb delete mode 100644 server/features/step_definitions/storage_snapshots_steps.rb delete mode 100644 server/features/step_definitions/storage_volumes.rb delete mode 100644 server/features/support/ec2/config.yaml delete mode 100644 server/features/support/ec2/fixtures/flavors.yaml delete mode 100644 server/features/support/ec2/fixtures/images.yaml delete mode 100644 server/features/support/ec2/fixtures/instances.yaml delete mode 100644 server/features/support/ec2/fixtures/realms.yaml delete mode 100644 server/features/support/ec2/fixtures/storage_snapshot.yaml delete mode 100644 server/features/support/ec2/fixtures/storage_volume.yaml delete mode 100644 server/features/support/gogrid/config.yaml delete mode 100644 server/features/support/gogrid/fixtures/flavors.yaml delete mode 100644 server/features/support/gogrid/fixtures/images.yaml delete mode 100644 server/features/support/gogrid/fixtures/instances.yaml delete mode 100644 server/features/support/gogrid/fixtures/ips.yaml delete mode 100644 server/features/support/gogrid/servers.yaml delete mode 100644 server/features/support/mock/config.yaml
diff --git a/server/features/99_rake.feature b/server/features/99_rake.feature new file mode 100644 index 0000000..c4362c5 --- /dev/null +++ b/server/features/99_rake.feature @@ -0,0 +1,7 @@ +Feature: Running rake tasks + + Scenario: I want to build Deltacloud API gem + Given I have a clean /pkg directory + When I run a 'package' task + Then I should see a gem file inside pkg directory + And I should see a tgz file inside pkg directory diff --git a/server/features/api.feature b/server/features/api.feature index 49dabcb..8c4ddd2 100644 --- a/server/features/api.feature +++ b/server/features/api.feature @@ -1,23 +1,18 @@ -Feature: Working with API - In order to work with API +Feature: Accessing API entry points
- 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: - | realms | - | instances | - | images | - | instance_states | - | hardware_profiles | - | storage_snapshots | - | storage_volumes | + Scenario: API driver and version + Given URI /api exists + And authentification is not required for this URI + When client access this URI + Then client should get root element 'api' + And this element should have attribute 'driver' with value 'mock' + And this element should have attribute 'version' with value '1.0'
- 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 get valid HTML response - And I should see these entry points in page: + Scenario: List of entry points + Given URI /api exists + And authentification is not required for this URI + When client access this URI + Then client should get list of valid entry points: | realms | | instances | | images | @@ -25,6 +20,22 @@ 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 + And this URI should be available in XML, JSON, HTML format + + Scenario: Following entry points + Given URI /api exists + And authentification is not required for this URI + When client access this URI + Then client should get list of valid entry points + And each link should have 'rel' attribute with valid name + And each link should have 'href' attribute with valid URL + When client follow this attribute + Then client should get a valid response + + Scenario: Instance features + Given URI /api exists + And authentification is not required for this URI + When client access this URI + Then client should get list of features inside 'instances': + | hardware_profiles | + | user_name | diff --git a/server/features/hardware_profiles.feature b/server/features/hardware_profiles.feature index 9c1de72..f10bb13 100644 --- a/server/features/hardware_profiles.feature +++ b/server/features/hardware_profiles.feature @@ -1,23 +1,29 @@ -Feature: Working with hardware profiles - In order to work with hardware profiles - - Background: - Given I want to get XML +Feature: Accessing hardware profiles
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 + Given URI /api/hardware_profiles exists + And authentification is not required for this URI + When client access this URI + Then client should get root element 'hardware-profiles' + And this URI should be available in XML, HTML, JSON format
Scenario: I want to show hardware profile details - When I request for '<HARDWARE_PROFILE_ID>' hardware profile - Then I should get this hardware profile + Given URI /api/hardware_profiles exists + And authentification is not required for this URI + When client access this URI + Then client should get root element 'hardware-profiles' + When client want to show 'm1-large' hardware-profile + And client 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' + And this URI should be available in XML, HTML, JSON format
- 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>' + Scenario: Filtering images by architecture + Given URI /api/hardware_profiles exists + And authentification is required for this URI + When client access this URI with parameters: + | architecture | i386 | + Then client should get some hardware-profiles + And each hardware-profile should have 'architecture' attribute set to 'i386' diff --git a/server/features/images.feature b/server/features/images.feature index 56974a9..50c3570 100644 --- a/server/features/images.feature +++ b/server/features/images.feature @@ -1,38 +1,59 @@ -Feature: Working with images - In order to work with images +Feature: Listing and showing images
- Background: - Given I want to get XML + Scenario: Listing available images + Given URI /api/images exists + And authentification is required for this URI + When client access this URI + Then client should get root element 'images' + And this element contains some images + And each image should have: + | id | + | name | + | description | + | architecture | + | owner_id | + And each image should have 'href' attribute with valid URL + And this URI should be available in XML, JSON, HTML format
- Scenario: I want to get list of all images - When I follow images link in entry points - Then I in order to see list of images I need to be authorized - When I enter correct username and password - And I follow images link in entry points - Then I should see <IMAGE_COUNT> image inside images - And each link in images should point me to valid image + Scenario: Following image href attribute + Given URI /api/images exists + And authentification is required for this URI + When client access this URI + Then client should get root element 'images' + And this element contains some images + When client want to show first image + Then client should follow href attribute in image + And client should get valid response with requested image + And this image should have: + | id | + | name | + | description | + | architecture | + | owner_id | + And this URI should be available in XML, JSON, HTML format
- Scenario: I want to show image details - Given I am authorized to show image '<IMAGE_ID>' - When I request for '<IMAGE_ID>' image - Then I should get this image - And image should have valid href 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: Filtering images by owner_id + Given URI /api/images exists + And authentification is required for this URI + When client access this URI with parameters: + | owner_id | fedoraproject | + Then client should get some images + And each image should have 'owner_id' attribute set to 'fedoraproject'
- Scenario: I want filter images by owner_id - When I want images with '<IMAGE_OWNER>' owner_id - Then I should get only images with owner_id '<IMAGE_OWNER>' + Scenario: Filtering images by architecture + Given URI /api/images exists + And authentification is required for this URI + When client access this URI with parameters: + | architecture | i386 | + Then client should get some images + And each image should have 'architecture' attribute set to 'i386'
- Scenario: I want filter images by architecture - When I want images with '<IMAGE_ARCH>' architecture - Then I should get only images with architecture '<IMAGE_ARCH>' - - Scenario: I want filter images by architecture - When I want images with '<IMAGE_ARCH>' architecture - And images with '<IMAGE_OWNER>' owner_id - Then I should get only images with architecture '<IMAGE_ARCH>' - And this images should also have owner_id '<IMAGE_OWNER>' + Scenario: Filtering images by architecture and owner_id + Given URI /api/images exists + And authentification is required for this URI + When client access this URI with parameters: + | architecture | i386 | + | owner_id | fedoraproject | + Then client should get some images + And each image should have 'architecture' attribute set to 'i386' + And each image should have 'owner_id' attribute set to 'fedoraproject' diff --git a/server/features/instance_states.feature b/server/features/instance_states.feature index 80158a3..3008ef0 100644 --- a/server/features/instance_states.feature +++ b/server/features/instance_states.feature @@ -1,7 +1,36 @@ -Feature: Get possible instance states - In order to get possible instance states +Feature: Instance states and transitions
- Scenario: - Given I want to get XML - When I follow instance states link in entry points - Then I should see list of instance states + Scenario: Getting list of states + Given URI /api/instance_states exists + And authentification is not required for this URI + When client access this URI + Then client should get root element 'states' + And this element contains some states + And this URI should be available in XML, JSON, HTML format + + + Scenario: State names + Given URI /api/instance_states exists + And authentification is not required for this URI + When client access this URI + Then client should get root element 'states' + And states element contains some states + And each state should have 'name' attribute + And first state should have 'name' attribute set to 'start' + And last state should have 'name' attribute set to 'finish' + + Scenario: Transitions + Given URI /api/instance_states exists + And authentification is not required for this URI + When client access this URI + Then client should get root element 'states' + And states element contains some states + And some states should have transitions + And each transitions should have 'to' attribute + + Scenario: State diagram + Given URI /api/instance_states exists + And authentification is not required for this URI + When client access this URI + And client wants PNG format + Then client should get PNG image diff --git a/server/features/instances.feature b/server/features/instances.feature index f11aa21..1c63d45 100644 --- a/server/features/instances.feature +++ b/server/features/instances.feature @@ -1,99 +1,164 @@ Feature: Managing instances - In order to manage instances
- Background: - Given I want to get XML + Scenario: Listing current instances + Given URI /api/instances exists + And authentification is required for this URI + When client access this URI + Then client should get root element 'instances' + And this element contains some instances + And each instance should have: + | id | + | name | + | owner_id | + | image | + | realm | + | state | + | hardware-profile | + | actions | + | public-addresses | + | private-addresses | + And each instance should have 'href' attribute with valid URL + And this URI should be available in XML, JSON, HTML format
- Scenario: I want to get list of all instances - Given I am authorized to list instances - When I follow instances link in entry points - Then I should see some instance inside instances - And each link in instances should point me to valid instance + Scenario: Filtering instances by state + Given URI /api/instances exists + And authentification is required for this URI + When client access this URI with parameters: + | state | RUNNING | + Then client should get some instances + And each instance should have 'state' attribute set to 'RUNNING'
- Scenario: I want to create a new instance - Given I am authorized to create instance - When I request create new instance with: - | name | <INSTANCE_1_NAME> | - | image_id | <INSTANCE_IMAGE_ID> | - Then I should request this instance - 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>' + Scenario: Get details about first instance + Given URI /api/instances exists + And authentification is required for this URI + When client access this URI + Then client should get root element 'instances' + And this element contains some instances + When client want to show first instance + Then client follow href attribute in first instance + Then client should get this instance + And this instance should have: + | id | + | name | + | owner_id | + | image | + | realm | + | state | + | hardware-profile | + | actions | + | public-addresses | + | private-addresses |
- Scenario: I want to create a new instance using realm - Given I am authorized to create instance - When I request create new instance with: - | name | <INSTANCE_2_NAME> | - | image_id | <INSTANCE_IMAGE_ID> | - | realm | <INSTANCE_REALM> | - Then I should request this instance - 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>' + Scenario: Following image href in instance + Given URI /api/instances exists + And authentification is required for this URI + When client access this URI + Then client should get root element 'instances' + And this element contains some instances + When client follow image href attribute in first instance + Then client should get valid image
- Scenario: I want to show instance details - 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 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 - When instance state is RUNNING - Then instance should include link to 'reboot' action - And instance should include link to 'stop' action + Scenario: Following realm href in instance + Given URI /api/instances exists + And authentification is required for this URI + When client access this URI + Then client should get root element 'instances' + And this element contains some instances + When client follow realm href attribute in first instance + Then client should get valid realm
- Scenario: I want to get instance image - Given I am authorized to show instance '<INSTANCE_1_ID>' - Given I request for '<INSTANCE_1_ID>' instance - When I want to get details about instance image - Then I could follow image href attribute - And this attribute should point me to valid image + Scenario: Following hardware profile href in instance + Given URI /api/instances exists + And authentification is required for this URI + When client access this URI + Then client should get root element 'instances' + And this element contains some instances + When client follow hardware-profile href attribute in first instance + Then client should get valid hardware-profile
- Scenario: I want to get instance hardware profile - Given I am authorized to show instance '<INSTANCE_1_ID>' - Given I request for '<INSTANCE_1_ID>' instance - When I want to get details about instance hardware profile - Then I could follow hardware profile href attribute - And this attribute should point me to valid hardware profile + Scenario: Instance actions + Given URI /api/instances exists + And authentification is required for this URI + When client access this URI + Then client should get root element 'instances' + And this element contains some instances + And each instance should have actions + And each actions should have some links + And each link should have valid href attribute + And each link should have valid rel attribute
- Scenario: I want to get instance realm - Given I am authorized to show instance '<INSTANCE_1_ID>' - Given I request for '<INSTANCE_1_ID>' instance - When I want to get details about instance realm - Then I could follow realm href attribute - And this attribute should point me to valid realm + Scenario: Reboot instance + Given URI /api/instances exists + And authentification is required for this URI + When client access this URI + Then client should get root element 'instances' + And this element contains some instances + When client want to 'reboot' first instance + And client follow link in actions + Then client should get first instance + And this instance should be in 'RUNNING' state
- Scenario: I want to stop instance - 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' or 'STOPPING' + Scenario: Stop instance + Given URI /api/instances exists + And authentification is required for this URI + When client access this URI + Then client should get root element 'instances' + And this element contains some instances + When client want to 'stop' first instance + And client follow link in actions + Then client should get first instance + And this instance should be in 'STOPPED' state
- Scenario: I want to start instance - 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 - Then I could follow start action in actions - And this instance state should be 'RUNNING' + Scenario: Start instance + Given URI /api/instances exists + And authentification is required for this URI + When client access this URI + Then client should get root element 'instances' + And this element contains some instances + When client want to 'start' first instance + And client follow link in actions + Then client should get first instance + And this instance should be in 'RUNNING' state
- Scenario: I want to reboot instance - Given I am authorized to show instance '<INSTANCE_1_ID>' - Given I request for '<INSTANCE_1_ID>' instance - When I want to reboot this instance - Then I could follow reboot action in actions - And this instance state should be 'RUNNING' + Scenario: Basic instance creation + Given URI /api/instances exists + And authentification is required for this URI + When client want to create a new instance + Then client should choose first image + When client request for a new instance + Then new instance should be created + And this instance should have chosed image + And this instance should be in 'RUNNING' state + And this instance should have valid id + And this instance should have name
- Scenario: I want to destroy instance - 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 - Then I could follow stop action in actions - And this instance state should be 'STOPPED' + Scenario: Choosing hardware profile for instance + Given URI /api/instances exists + And authentification is required for this URI + When client want to create a new instance + Then client should choose first image + And client choose last hardware profile + When client request for a new instance + Then new instance should be created + And this instance should have chosed image + And this instance should be in 'RUNNING' state + And this instance should have valid id + And this instance should have last hardware profile + And this instance should have name + + Scenario: Create instance using HTML form + Given URI /api/instances/new exists in HTML format + And authentification is required for this URI + When client access this URI + Then client should get HTML form + + Scenario: Destroying created instance + Given URI /api/instances exists + And authentification is required for this URI + When client want to 'stop' created instance + And client follow link in actions + Then client should get created instance + And this instance should be in 'STOPPED' state + When client want to 'destroy' created instance + And client follow link in actions + And this instance should be destroyed diff --git a/server/features/realms.feature b/server/features/realms.feature index f2b040a..a89173b 100644 --- a/server/features/realms.feature +++ b/server/features/realms.feature @@ -1,25 +1,31 @@ -Feature: Working with realms - In order to work with realms +Feature: Accessing realms
- Background: - Given I want to get XML + Scenario: Getting list of available realms + Given URI /api/realms exists + And authentification is required for this URI + When client access this URI + Then client should get root element 'realms' + And this element contains some realms + And each realm should have: + | id | + | name | + | state | + | limit | + And each realm should have 'href' attribute with valid URL + And this URI should be available in XML, JSON, HTML format
- Scenario: I want to get list of all realms - When I follow realms link in entry points - Then I in order to see list of realms I need to be authorized - When I enter correct username and password - And I follow realms link in entry points - Then I should see <REALM_COUNT> realm inside realms - And each link in realms should point me to valid realm - - Scenario: I want to show realm details - When I request for '<REALM_ID>' realm - Then I should get this realm - And realm should have valid href 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 - Then I should get only realms with state '<REALM_STATE>' + Scenario: Following realm href attribute + Given URI /api/realms exists + And authentification is required for this URI + When client access this URI + Then client should get root element 'realms' + And this element contains some realms + When client want to show first realm + Then client should follow href attribute in realm + And client should get valid response with requested realm + And this realm should have: + | id | + | name | + | state | + | limit | + And this URI should be available in XML, JSON, HTML format diff --git a/server/features/step_definitions/api_steps.rb b/server/features/step_definitions/api_steps.rb index f82c438..9a30c3d 100644 --- a/server/features/step_definitions/api_steps.rb +++ b/server/features/step_definitions/api_steps.rb @@ -1,45 +1,103 @@ -When /^I request for entry points$/ do - get "/api", { } - last_response.status.should == 200 +Given /^URI ([\w/-_]+) exists$/ do |uri| + get uri, {} + last_response.status.should_not == 404 + last_response.status.should_not == 500 + @uri = uri end
-Then /^I should see these entry points:$/ do |table| - Nokogiri::XML(last_response.body).xpath('/api/link').each do |entry_point| - table.raw.flatten.include?(entry_point[:rel]).should == true +Given /^URI ([\w/-_]+) exists in (.+) format$/ do |uri, format| + @uri = "#{uri}.#{format.downcase}" + get @uri, {} + last_response.status.should_not == 404 + last_response.status.should_not == 500 +end + +Given /^authentification is not required for this URI$/ do + last_response.status.should_not == 401 +end + +When /^client access this URI$/ do + get @uri, {} + last_response.status.should_not == 404 +end + +Then /^client should get root element '(.+)'$/ do |element| + @last_element = output_xml.xpath('/'+element).first + @last_element.should_not be_nil + @last_element.name.should == element +end + +Then /^this element should have attribute '(.+)' with value '(.+)'$/ do |atr, val| + @last_element[atr.to_sym].should == val +end + +Then /^client should get list of valid entry points:$/ do |table| + @entry_points = table.raw.flatten.sort + links = [] + output_xml.xpath('/api/link').each do |entry_point| + links << entry_point['rel'] end + @entry_points.should == links.sort end
-Then /^I should get valid HTML response$/ do - Nokogiri::HTML(last_response.body).root.name.should == 'html' +Then /^this URI should be available in (.+) format$/ do |formats| + @no_header = true + formats.split(',').each do |format| + get "#{@uri}.#{format.strip.downcase}", {} + last_response.status.should == 200 + end + @no_header = false +end + +Then /^client should get list of valid entry points$/ do + links = [] + output_xml.xpath('/api/link').each do |entry_point| + links << entry_point['rel'] + end + @entry_points.should == links.sort 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] +Then /^each (\w+) should have '(.+)' attribute with valid (.+)$/ do |el, attr, t| + case el + when 'link': + path = '/api/link' + when 'image': + path = '/images/image' end - table.raw.flatten.each do |link| - @links.include?("/api/#{link}").should == true + output_xml.xpath(path).each do |entry_point| + @entry_points.include?(entry_point[attr]).should == true if t=='name' + if t=='URL' + entry_point[:href].should_not be_nil + end end + @last_attribute = attr end
-When /^I follow this entry points$/ do - @responses = [] - authorize CONFIG[:username], CONFIG[:password] - @links.each do |link| - get link, {} - @responses << last_response.status +Then /^each ([\w-]+) should have '(.+)' attribute set to '(.+)'$/ do |el, attr, v| + case el + when 'image': + path = "/image/images" + end + output_xml.xpath(path).each do |element| + element[attr].should == v end end
-Then /^I should get valid HTML response for each$/ do - @responses.uniq.should == [200] +When /^client follow this attribute$/ do + output_xml.xpath('/api/link').each do |entry_point| + get entry_point[@last_attribute], {} + end 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 +Then /^client should get a valid response$/ do + last_response.status.should_not == 500 +end + +Then /^client should get list of features inside '(.+)':$/ do |element,table| + features = table.raw.flatten.sort + instance_features = [] + output_xml.xpath('/api/link[@rel="'+element+'"]/feature').each do |feature| + instance_features << feature[:name] end + features.should == instance_features.sort end diff --git a/server/features/step_definitions/common_steps.rb b/server/features/step_definitions/common_steps.rb deleted file mode 100644 index 4b5fc17..0000000 --- a/server/features/step_definitions/common_steps.rb +++ /dev/null @@ -1,115 +0,0 @@ -require 'nokogiri' - -When /^I want to get (HTML|XML)$/ do |format| - 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 - -Then /^I should see ([\w<>_-]+) (.+) inside (.+)$/ do |count, model, collection| - collection.tr!(' ', '-') - model.tr!(' ', '-') - if count.eql?('some') - Nokogiri::XML(last_response.body).xpath("/#{collection}/#{model}").size.should_not == 0 - else - Nokogiri::XML(last_response.body).xpath("/#{collection}/#{model}").size.should == replace_variables(count).to_i - end -end - -When /^I request for '(.+)' (.+)$/ do |id, model| - get '/api/'+model.tr(' ', '_')+'s'+'/'+replace_variables(id), {} - last_response.status.should == 200 -end - -Then /^I should get this (.+)$/ do |model| - 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| - @tested_params = [] - replace_variables(value).should_not == nil - @tested_params << [parameter, replace_variables(value)] -end - -When /^images with '(.+)' (.+)$/ do |value, parameter| - 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) - @tested_params.collect { |param| params[:"#{param[0]}"] = param[1] } - get '/api/'+collection, params, {} - last_response.status.should == 200 - parameters = [] - Nokogiri::XML(last_response.body).xpath("/#{collection}/#{collection.gsub(/s$/, '')}").each do |m| - parameters << m.xpath("#{parameter}").text - end - 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) - @tested_params.collect { |param| params[:"#{param[0]}"] = param[1] } - get '/api/'+collection, params, {} - last_response.status.should == 200 - parameters = [] - Nokogiri::XML(last_response.body).xpath("/#{collection}/#{collection.gsub(/s$/, '')}").each do |m| - parameters << m.xpath("#{parameter}").text - end - 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| -end - -When /^I enter correct username and password$/ do - authorize CONFIG[:username], CONFIG[:password] -end - -Given /^I am authorized to show (.+) '(.+)'$/ do |model, id| - 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 include (.+) parameter$/ do |model, parameter| - Nokogiri::XML(last_response.body).xpath("/#{model.tr(' ', '-')}/#{parameter}").first.should_not == nil - unless ['device'].include?(parameter) - Nokogiri::XML(last_response.body).xpath("/#{model.tr(' ', '-')}/#{parameter}").text.should_not == "" - end -end - -Given /^I am authorized to (list) (.+)$/ do |operation, 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', {} - 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| - collection.tr!(' ', '_') - 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 -end diff --git a/server/features/step_definitions/hardware_profiles_steps.rb b/server/features/step_definitions/hardware_profiles_steps.rb index b2e64bf..db1828b 100644 --- a/server/features/step_definitions/hardware_profiles_steps.rb +++ b/server/features/step_definitions/hardware_profiles_steps.rb @@ -1,13 +1,10 @@ Then /^it should have a (\w+) attribute$/ do |name| - attr = Nokogiri::XML(last_response.body).xpath('/hardware-profile').first[name] + attr = output_xml.xpath('/hardware-profile').first[name] attr.should_not be_nil - if (name == 'href') - attr.should == "http://example.org/api/hardware_profiles/#%7BCONFIG%5B:hardware_profile_id%5..." - 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 = output_xml.xpath("/hardware-profile/property[@name = '#{name}']") props.size.should == 1 prop = props.first prop['kind'].should == kind @@ -26,16 +23,3 @@ Then /^it should have a (\w+) property '(.+)'$/ do |kind, name| 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 diff --git a/server/features/step_definitions/images_steps.rb b/server/features/step_definitions/images_steps.rb index aaa9008..fc01364 100644 --- a/server/features/step_definitions/images_steps.rb +++ b/server/features/step_definitions/images_steps.rb @@ -1,5 +1,83 @@ -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/#%7BCONFIG%5B:image_id%5D%7D" +Given /^authentification is required for this URI$/ do + authorize CONFIG[:username], CONFIG[:password] + get @uri, {} + last_response.status.should == 200 end
+Then /^this element contains some (.+)$/ do |items| + item = items.singularize + output_xml.xpath("/#{@last_element.name}/#{item}").size.should > 0 +end + +Then /^each ([\w-]+) should have:$/ do |item, table| + properties = table.raw.flatten.sort + output_xml.xpath("/#{@last_element.name}/#{item}").each do |element| + childrens = (element > '*').collect { |c| c.name } + childrens.sort.should == properties + end +end + +Then /^this ([\w-]+) should have:$/ do |item, table| + properties = table.raw.flatten.sort + output_xml.xpath("/#{item}").each do |element| + childrens = (element > '*').collect { |c| c.name } + childrens.sort.should == properties + end +end + +When /^client want to show first (.+)$/ do |element| + case element + when 'image': + path = '/images/image' + when 'instance': + path = '/instances/instance' + when 'realm': + path = '/realms/realm' + when 'hardware-profile' + path = '/hardware-profiles/hardware-profile' + when 'storage-volume': + path = '/storage-volumes/storage-volume' + when 'storage-snapshot': + path = '/storage-snapshots/storage-snapshot' + end + @element = output_xml.xpath(path).first + @element.should_not be_nil +end + +When /^client want to show '(.+)' (.+)$/ do |id, el| + @uri = "/api/#{el.pluralize.tr('-', '_')}/#{id}" + get @uri, {} + @element = output_xml.xpath("/#{el}").first + @element.should_not be_nil +end + +Then /^client follow (\w+) attribute in first (.+)$/ do |attr, el| + url = output_xml.xpath("/#{el.pluralize}/#{el}").first[:href] + url.should_not be_nil + get url, {} +end + +Then /^client should get this (.+)$/ do |el| + last_response.status.should == 200 +end + + +Then /^client should follow href attribute in (\w+)$/ do |element| + get @element[:href], {} +end + +Then /^client should get valid response with requested (\w+)$/ do |element| + last_response.status.should == 200 + output_xml.xpath('/'+element+'/id').first.text.should == @element.xpath('id').text +end + +When /^client access this URI with parameters:$/ do |table| + params = {} + table.raw.each { |i| params[i[0]]=i[1] } + get @uri, params +end + +Then /^client should get some ([\w-]+)$/ do |elements| + last_response.status.should == 200 + output_xml.xpath('/'+elements+'/'+elements.singularize).size.should > 0 +end diff --git a/server/features/step_definitions/instance_states_steps.rb b/server/features/step_definitions/instance_states_steps.rb index 50d55f4..a587e5d 100644 --- a/server/features/step_definitions/instance_states_steps.rb +++ b/server/features/step_definitions/instance_states_steps.rb @@ -1,3 +1,34 @@ -Then /^I should see list of instance states$/ do - Nokogiri::XML(last_response.body).root.name.should == 'states' +Then /^states element contains some states$/ do + output_xml.xpath('/states/state').size.should > 0 +end + +Then /^each state should have '(.+)' attribute$/ do |attr| + output_xml.xpath('/states/state').each do |state| + state[attr].should_not be_nil + end +end + +Then /^(\w+) state should have '(.+)' attribute set to '(\w+)'$/ do |pos, attr, value| + output_xml.xpath('/states/state').first[attr].should==value if pos=='first' + output_xml.xpath('/states/state').last[attr].should==value if pos=='last' +end + +Then /^some states should have transitions$/ do + @transitions = output_xml.xpath('/states/state/transition') + @transitions.size.should > 0 +end + +Then /^each transitions should have 'to' attribute$/ do + @transitions.each do |t| + t[:to].should_not be_nil + end +end + +When /^client wants (\w+) format$/ do |format| + get "#{@uri}.#{format.downcase}", {} +end + +Then /^client should get PNG image$/ do + last_response.status.should == 200 + last_response.headers['Content-Type'].should == 'image/png' end diff --git a/server/features/step_definitions/instances_steps.rb b/server/features/step_definitions/instances_steps.rb index c31682b..068f302 100644 --- a/server/features/step_definitions/instances_steps.rb +++ b/server/features/step_definitions/instances_steps.rb @@ -1,124 +1,121 @@ -Then /^instance state should be (.+)$/ do |state| - Nokogiri::XML(last_response.body).xpath("/instance/state").first.text.should == state +When /^client follow ([\w-]+) href attribute in first instance$/ do |element| + get output_xml.xpath('/instances/instance[1]/'+element).first[:href], {} end
-When /^instance state is (.+)$/ do |state| - Nokogiri::XML(last_response.body).xpath("/instance/state").first.text.should == state +Then /^client should get valid ([\w-]+)$/ do |element| + last_response.status.should == 200 + output_xml.xpath("/#{element}").first.should_not be_nil end
-Then /^instance should have one (public|private) address$/ do |type| - adr = Nokogiri::XML(last_response.body).xpath("/instance/#{type}-addresses/address").first - adr.text.to_s.should_not == nil - adr.text.to_s.should_not == '' +Then /^each instance should have actions$/ do + output_xml.xpath('/instances/instance').each do |instance| + instance.xpath('actions').first.should_not be_nil + end end
-Then /^instance should include link to '(.+)' action$/ do |action| - links = Nokogiri::XML(last_response.body).xpath("/instance/actions/link") - actions = [] - links.each do |link| - actions << link[:rel] +Then /^each actions should have some links$/ do + output_xml.xpath('/instances/instance').each do |instance| + instance.xpath('actions/link').first.should_not be_nil end - actions.include?(action).should == true end
-When /^I want to get details about instance (.+)$/ do |model| +Then /^each link should have valid (\w+) attribute$/ do |attr| + output_xml.xpath('/instances/instance').each do |instance| + instance.xpath('actions/link').first[attr].should_not be_nil + end end
-Then /^I could follow (image|realm|hardware profile) href attribute$/ do |model| - model.tr!(' ', '-') - 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 +When /^client want to '(\w+)' first instance$/ do |action| + @action = action + @instance = output_xml.xpath('/instances/instance[1]').first end
-Then /^this attribute should point me to valid (image|realm|hardware profile)$/ do |model| - model_tag = model.tr(' ', '-') - model.tr!(' ', '_') - attribute = Nokogiri::XML(last_response.body).xpath("/#{model_tag}").first - attribute.should_not == nil - attribute.name.should == model_tag +When /^client follow link in actions$/ do + unless @instance_url + l = output_xml.xpath("/instances/instance[1]/actions/link[@rel = '#{@action}']").first + else + l = @instance.xpath('actions/link[@rel="'+@action+'"]').first + end + l.should_not be_nil + unless @action=='destroy' + post l[:href], { :id => @instance.xpath('id').first.text } + else + delete l[:href], { :id => @instance.xpath('id').first.text } + end + last_response.status.should_not == 500 end
-When /^I want to (.+) this instance$/ do |action| +Then /^client should get first instance$/ do + output_xml.xpath('/instance/id').first.should_not be_nil + output_xml.xpath('/instance/id').first.text.should == @instance.xpath('id').first.text end
-Given /^I am authorized to create instance$/ do - last_response.status.should_not == 401 +Then /^this instance should be in '(.+)' state$/ do |state| + output_xml.xpath('/instance/state').first.text.should == state 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 +When /^client want to create a new instance$/ do +end + +Then /^client should choose first image$/ do + get '/api/images', {} + @image = output_xml.xpath('/images/image').first + @image.should_not be_nil end
-Then /^this instance state should be '(\w+)'$/ do |state| - Nokogiri::XML(last_response.body).xpath("/instance/state").first.text.should == state +When /^client request for a new instance$/ do + params = { + :image_id => @image.xpath('id').first.text + } + params[:hwp_id] = @hwp_id if @hwp_id + post "#{@uri}", params + last_response.status.should == 201 + @instance_url = last_response.headers['Location'] 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 +Then /^new instance should be created$/ do + get @instance_url, {} + last_response.status.should == 200 end
-When /^I request create new instance with:$/ do |table| - params = {} - table.raw.map { |a,b| params[:"#{a}"] = replace_variables(b) } - post '/api/instances', params - @instance_id = Nokogiri::XML(last_response.body).xpath("/instance/id").first.text - @instance_id.should_not == nil - CONFIG[:instance_1_id] = @instance_id unless CONFIG[:instance_1_id] +Then /^this instance should have chosed image$/ do + output_xml.xpath('/instance/image').first[:href].should == @image[:href] 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 +Then /^this instance should have valid id$/ do + output_xml.xpath('instance/id').first.should_not be_nil end
-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 +Then /^this instance should have name$/ do + output_xml.xpath('instance/name').first.should_not be_nil end
-Then /^this instance should be '(RUNNING|PENDING|STOPPED)' or '(RUNNING|PENDING|STOPPED)'$/ do |state, second_state| - get URI.encode('/api/instances/'+@instance_id), {} +When /^client want to '(\w+)' created instance$/ do |action| + get @instance_url, {} last_response.status.should == 200 - [state, second_state].include?(Nokogiri::XML(last_response.body).xpath("/instance/state").first.text).should == true + @action = action + @instance = output_xml.xpath('/instance') 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) +Then /^client should get created instance$/ do + get @instance_url 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) +When /^this instance should be destroyed$/ do + get @instance_url, {} + last_response.status.should == 404 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, {} +Then /^client should get HTML form$/ do last_response.status.should == 200 - Nokogiri::XML(last_response.body).xpath("/realm/id").first.text.should == replace_variables(realm) + (last_response.body.strip =~ /^<!DOCTYPE html/).should be_true 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 +When /^client choose last hardware profile$/ do + get '/api/hardware_profiles', {} + @hwp_id = output_xml.xpath('/hardware-profiles/hardware-profile/id').last.text 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 +Then /^this instance should have last hardware profile$/ do + output_xml.xpath('instance/hardware-profile/id').first.text.should == @hwp_id end diff --git a/server/features/step_definitions/rake_steps.rb b/server/features/step_definitions/rake_steps.rb new file mode 100644 index 0000000..c8ea3d9 --- /dev/null +++ b/server/features/step_definitions/rake_steps.rb @@ -0,0 +1,19 @@ +require 'fileutils' +require 'rake' +require 'find' + +Given /^I have a clean (.+) directory$/ do |dir| + FileUtils.rm_rf dir +end + +When /^I run a '(\w+)' task$/ do |task| + @rake = Rake::Application.new + Rake.application = @rake + load "Rakefile" + @task = Rake::Task[task] + @task.invoke +end + +Then /^I should see a (\w+) file inside (\w+) directory$/ do |ext, dir| + Dir["#{dir}/deltacloud-*.#{ext}"].size.should == 1 +end diff --git a/server/features/step_definitions/realms_steps.rb b/server/features/step_definitions/realms_steps.rb deleted file mode 100644 index 39938cc..0000000 --- a/server/features/step_definitions/realms_steps.rb +++ /dev/null @@ -1,4 +0,0 @@ -Then /^realm should have valid href parameter$/ do - href=Nokogiri::XML(last_response.body).xpath('/realm').first[:href] - href.should == "http://example.org/api/realms/#%7BCONFIG%5B:realm_id%5D%7D" -end diff --git a/server/features/step_definitions/storage_snapshots_steps.rb b/server/features/step_definitions/storage_snapshots_steps.rb deleted file mode 100644 index 2130868..0000000 --- a/server/features/step_definitions/storage_snapshots_steps.rb +++ /dev/null @@ -1,23 +0,0 @@ -Then /^storage snapshot should have valid href parameter$/ do - href=Nokogiri::XML(last_response.body).xpath('/storage-snapshot').first[:href] - href.should == "http://example.org/api/storage_snapshots/#%7BCONFIG%5B:storage_snapshot_id%5..." -end - -Then /^storage snapshot should have storage-volume with valid href attribute$/ do - href=Nokogiri::XML(last_response.body).xpath('/storage-snapshot/storage-volume').first[:href] - href.should == "http://example.org/api/storage_volumes/#%7BCONFIG%5B:storage_volume_id%5D%7D" -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 - 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).root.name.should == "storage-volume" -end diff --git a/server/features/step_definitions/storage_volumes.rb b/server/features/step_definitions/storage_volumes.rb deleted file mode 100644 index 23546b0..0000000 --- a/server/features/step_definitions/storage_volumes.rb +++ /dev/null @@ -1,4 +0,0 @@ -Then /^storage volume should have valid href parameter$/ do - href=Nokogiri::XML(last_response.body).xpath('/storage-volume').first[:href] - href.should == "http://example.org/api/storage_volumes/#%7BCONFIG%5B:storage_volume_id%5D%7D" -end diff --git a/server/features/storage_snapshots.feature b/server/features/storage_snapshots.feature index 3cbaea0..f6f38e5 100644 --- a/server/features/storage_snapshots.feature +++ b/server/features/storage_snapshots.feature @@ -1,29 +1,29 @@ -Feature: Working with storage snapshots - In order to work with storage snapshots +Feature: Accessing storage snapshots
- Background: - Given I want to get XML + Scenario: Listing available storage snapshots + Given URI /api/storage_snapshots exists + And authentification is required for this URI + When client access this URI + Then client should get root element 'storage-snapshots' + And this element contains some storage-snapshots + And each storage-volume should have: + | id | + | created | + | storage-volume | + And each image should have 'href' attribute with valid URL + And this URI should be available in XML, JSON, HTML format
- Scenario: I want to get list of all storage snapshots - Given I am authorized to list storage snapshots - When I follow storage snapshots link in entry points - Then I should see <STORAGE_SNAPSHOT_COUNT> storage snapshot inside storage snapshots - And each link in storage snapshots should point me to valid storage snapshot - - Scenario: I want to show storage snapshot details - Given I am authorized to show storage snapshot '<STORAGE_SNAPSHOT_ID>' - 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 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 - And this attribute should point me to valid storage volume - - Scenario: I want filter storage snapshots by state - Given I am authorized to list storage snapshots - When I want storage snapshots with '<STORAGE_SNAPSHOT_STATE>' state - Then I should get only realms with state '<STORAGE_SNAPSHOT_STATE>' + Scenario: Get details about first volume + Given URI /api/storage_snapshots exists + And authentification is required for this URI + When client access this URI + Then client should get root element 'storage-snapshots' + And this element contains some storage-snapshots + When client want to show first storage-snapshot + Then client follow href attribute in first storage-snapshot + Then client should get this storage-snapshot + And this storage-snapshot should have: + | id | + | created | + | state | + | storage-volume | diff --git a/server/features/storage_volumes.feature b/server/features/storage_volumes.feature index 32e289f..dfca4b0 100644 --- a/server/features/storage_volumes.feature +++ b/server/features/storage_volumes.feature @@ -1,32 +1,33 @@ -Feature: Working with storage volumes - In order to work with storage volumes +Feature: Accessing storage volumes
- Background: - Given I want to get XML + Scenario: Listing available storage volumes + Given URI /api/storage_volumes exists + And authentification is required for this URI + When client access this URI + Then client should get root element 'storage-volumes' + And this element contains some storage-volumes + And each storage-volume should have: + | id | + | created | + | capacity | + | device | + | instance | + And each image should have 'href' attribute with valid URL + And this URI should be available in XML, JSON, HTML format
- Scenario: I want to get list of all storage volumes - Given I am authorized to list storage volumes - When I follow storage volumes link in entry points - Then I should see <STORAGE_VOLUME_COUNT> storage volume inside storage volumes - And each link in storage volumes should point me to valid storage volume - - Scenario: I want to show storage volume details - 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 storage volume should have valid href 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 - - Scenario: I want filter storage volumes by state - Given I am authorized to list storage volumes - When I want storage volumes with '<STORAGE_VOLUME_STATE>' state - Then I should get only realms with state '<STORAGE_VOLUME_STATE>' + Scenario: Get details about first volume + Given URI /api/storage_volumes exists + And authentification is required for this URI + When client access this URI + Then client should get root element 'storage-volumes' + And this element contains some storage-volumes + When client want to show first storage-volume + Then client follow href attribute in first storage-volume + Then client should get this storage-volume + And this storage-volume should have: + | id | + | created | + | capacity | + | device | + | instance | + | state | diff --git a/server/features/support/ec2/config.yaml b/server/features/support/ec2/config.yaml deleted file mode 100644 index 6295e42..0000000 --- a/server/features/support/ec2/config.yaml +++ /dev/null @@ -1,26 +0,0 @@ ---- -:username: mockuser -:password: mockpassword -:storage_snapshot_id: snap-72a5401b -:driver_name: ec2 -:instances_count: 2 -:hardware_profile_arch: x86_64 -:storage_snapshot_state: AVAILABLE -:realm_id: us-east-1a -:instance_1_name: ami-e4b6538d -:image_owner: "522821470517" -:storage_snapshot_count: "2" -:realm_state: AVAILABLE -: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 -:storage_volume_state: AVAILABLE -:hardware_profile_id: m1-small -:instance_realm: us-east-1a -:image_count: 2 -:storage_volume_count: 2 -:hardware_profile_count: 5 diff --git a/server/features/support/ec2/fixtures/flavors.yaml b/server/features/support/ec2/fixtures/flavors.yaml deleted file mode 100644 index 7aed95f..0000000 --- a/server/features/support/ec2/fixtures/flavors.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- -- :region_name: us-east-1 - :zone_name: us-east-1a - :zone_state: available -- :region_name: us-east-1 - :zone_name: us-east-1b - :zone_state: available -- :region_name: us-west-1 - :zone_name: us-west-1a - :zone_state: available diff --git a/server/features/support/ec2/fixtures/images.yaml b/server/features/support/ec2/fixtures/images.yaml deleted file mode 100644 index 8d43e17..0000000 --- a/server/features/support/ec2/fixtures/images.yaml +++ /dev/null @@ -1,29 +0,0 @@ ---- -- :aws_owner: "522821470517" - :aws_image_type: machine - :aws_id: ami-e4b6538d - :aws_state: available - :aws_location: deltacloud-mock/testimage1 - :aws_is_public: true - :aws_architecture: i386 -- :aws_owner: "522821470517" - :aws_image_type: machine - :aws_id: ami-e4b6538e - :aws_state: available - :aws_location: deltacloud-mock/testimage2 - :aws_is_public: true - :aws_architecture: x86_64 -- :aws_owner: "522821470517" - :aws_image_type: kernel - :aws_id: aki-be3adfd7 - :aws_state: available - :aws_location: deltacloud-mock/testimage3 - :aws_is_public: true - :aws_architecture: x86_64 -- :aws_owner: "522821470517" - :aws_image_type: ramdisk - :aws_id: ari-ce34gad7 - :aws_state: available - :aws_location: deltacloud-mock/testimage4 - :aws_is_public: false - :aws_architecture: i386 diff --git a/server/features/support/ec2/fixtures/instances.yaml b/server/features/support/ec2/fixtures/instances.yaml deleted file mode 100644 index 6f41666..0000000 --- a/server/features/support/ec2/fixtures/instances.yaml +++ /dev/null @@ -1,554 +0,0 @@ ---- -- &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 - :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 -- *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 - :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_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 - :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" - :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_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 - :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_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 diff --git a/server/features/support/ec2/fixtures/realms.yaml b/server/features/support/ec2/fixtures/realms.yaml deleted file mode 100644 index 7aed95f..0000000 --- a/server/features/support/ec2/fixtures/realms.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- -- :region_name: us-east-1 - :zone_name: us-east-1a - :zone_state: available -- :region_name: us-east-1 - :zone_name: us-east-1b - :zone_state: available -- :region_name: us-west-1 - :zone_name: us-west-1a - :zone_state: available diff --git a/server/features/support/ec2/fixtures/storage_snapshot.yaml b/server/features/support/ec2/fixtures/storage_snapshot.yaml deleted file mode 100644 index a1e9156..0000000 --- a/server/features/support/ec2/fixtures/storage_snapshot.yaml +++ /dev/null @@ -1,11 +0,0 @@ ---- -- :aws_progress: 100% - :aws_status: completed - :aws_id: snap-72a5401b - :aws_volume_id: vol-60957009 - :aws_started_at: "2008-02-23T02:50:48.000Z" -- :aws_progress: 100% - :aws_status: completed - :aws_id: snap-75a5401c - :aws_volume_id: vol-5582673c - :aws_started_at: "2008-02-23T16:23:19.000Z" diff --git a/server/features/support/ec2/fixtures/storage_volume.yaml b/server/features/support/ec2/fixtures/storage_volume.yaml deleted file mode 100644 index d842c0d..0000000 --- a/server/features/support/ec2/fixtures/storage_volume.yaml +++ /dev/null @@ -1,18 +0,0 @@ ---- -- :aws_size: 94 - :aws_id: vol-60957009 - :zone: us-east-1a - :aws_device: /dev/sda - :aws_created_at: Wed Jun 18 08:19:20s UTC 2008 - :aws_attachment_status: attached - :aws_instance_id: i-123f1234 - :snapshot_id: i-123f1234 - :aws_attached_at: Wed Jun 18 08:19:28 UTC 2008 - :aws_status: in-use -- :aws_size: 500 - :aws_id: vol-58957031 - :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 diff --git a/server/features/support/env.rb b/server/features/support/env.rb index 39f4195..45430c3 100644 --- a/server/features/support/env.rb +++ b/server/features/support/env.rb @@ -1,34 +1,39 @@ require 'sinatra' require 'server' require 'rack/test' +require 'nokogiri'
SERVER_DIR = File::expand_path(File::join(File::dirname(__FILE__), "../..")) - Sinatra::Application.set :environment, :test Sinatra::Application.set :root, SERVER_DIR
ENV['API_DRIVER'] = "mock" unless ENV['API_DRIVER'] -CONFIG = YAML::load_file(File::join('features', 'support', ENV['API_DRIVER'], 'config.yaml')) + +CONFIG = { + :username => 'mockuser', + :password => 'mockpassword' +}
World do + def app @app = Rack::Builder.new do set :logging, true set :raise_errors, true run Sinatra::Application end - end + end
- def replace_variables(str) - CONFIG.keys.collect { |k| str.gsub!(/<#{k.to_s.upcase}>/, "#{CONFIG[k]}") } - return str + def output_xml + Nokogiri::XML(last_response.body) end
Before do - header 'Accept', 'application/xml' + unless @no_header + header 'Accept', 'application/xml' + end end
include Rack::Test::Methods - end
diff --git a/server/features/support/gogrid/config.yaml b/server/features/support/gogrid/config.yaml deleted file mode 100644 index b562ed8..0000000 --- a/server/features/support/gogrid/config.yaml +++ /dev/null @@ -1,26 +0,0 @@ ---- -:username: mockuser -:password: mockpassword -:storage_snapshot_id: snap-72a5401b -:driver_name: gogrid -:instances_count: 2 -:flavor_arch: i386 -:storage_snapshot_state: AVAILABLE -:realm_id: us -:instance_1_name: ami-e4b6538d -:image_owner: "mockuser" -:storage_snapshot_count: "2" -:realm_state: AVAILABLE -:instance_2_name: ami-e4b6538d -:image_arch: i386 -:storage_volume_id: vol-60957009 -:storage_volume_instance: i-123f1234 -:realm_count: 1 -:instance_image_id: 1 -:image_id: 1 -:storage_volume_state: AVAILABLE -:flavor_id: server-with-512mb-ram -:instance_realm: us -:image_count: 2 -:storage_volume_count: 0 -:flavor_count: 3 diff --git a/server/features/support/gogrid/fixtures/flavors.yaml b/server/features/support/gogrid/fixtures/flavors.yaml deleted file mode 100644 index 503fd6b..0000000 --- a/server/features/support/gogrid/fixtures/flavors.yaml +++ /dev/null @@ -1,7 +0,0 @@ ---- -- name: 512MB - description: Server with 512MB RAM -- name: 1GB - description: Server with 1GB RAM -- name: 2GB - description: Server with 2GB RAM diff --git a/server/features/support/gogrid/fixtures/images.yaml b/server/features/support/gogrid/fixtures/images.yaml deleted file mode 100644 index 1e00abc..0000000 --- a/server/features/support/gogrid/fixtures/images.yaml +++ /dev/null @@ -1,13 +0,0 @@ ---- -- id: 1 - name: w2k8_32_iis_php_mysql - description: Windows 2008 (32-bit) w/ IIS 7.0 + PHP 5.2 + MySQL 5.0 - friendlyName: Windows 2008 IIS -- id: 2 - name: GSI-95aa2817-7267-3325-ad01-1387a25f31ff - description: My second GSI - friendlyName: Test second GSI -- id: 3 - name: RHEL 5.1 (64-bit) - description: RHEL Linux 5.1 (64-bit) - friendlyName: RHEL diff --git a/server/features/support/gogrid/fixtures/instances.yaml b/server/features/support/gogrid/fixtures/instances.yaml deleted file mode 100644 index a64bc41..0000000 --- a/server/features/support/gogrid/fixtures/instances.yaml +++ /dev/null @@ -1,42 +0,0 @@ ---- -- name: Example Web Server - type: - description: This server has a public connection to the Internet. - id: 1 - name: Web Server - object: option - id: 5075 - description: Some more info here - ip: - id: 499 - ip: 111.111.111.111 - object: ip - public: true - state: - description: IP is reserved - id: 2 - name: Assigned - object: option - subnet: "111.111.111.110/255.255.255.240" - os: - description: Windows 2008 Server (32-bit) - id: 11 - name: Windows 2008 Server (32-bit) - object: option - ram: - description: Server with 2GB RAM - id: 7 - name: 2GB - object: option - image: - id: 1 - name: w2k8_32_iis_php_mysql - description: Windows 2008 (32-bit) w/ IIS 7.0 + PHP 5.2 + MySQL 5.0 - object: option - object: server - state: - description: 'null' - id: 3 - name: 'Off' - object: option - diff --git a/server/features/support/gogrid/fixtures/ips.yaml b/server/features/support/gogrid/fixtures/ips.yaml deleted file mode 100644 index cddc44b..0000000 --- a/server/features/support/gogrid/fixtures/ips.yaml +++ /dev/null @@ -1,11 +0,0 @@ ---- -- public: true - id: '138273' - ip: '216.121.60.160' - subnet: "216.121.60.160/255.255.255.240" - object: 'ip' -- public: true - id: '138273' - ip: '216.121.60.161' - subnet: "216.121.60.161/255.255.255.240" - object: 'ip' diff --git a/server/features/support/gogrid/servers.yaml b/server/features/support/gogrid/servers.yaml deleted file mode 100644 index 662b34c..0000000 --- a/server/features/support/gogrid/servers.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -- name: 'From API' - os: - name: RHEL diff --git a/server/features/support/mock/config.yaml b/server/features/support/mock/config.yaml deleted file mode 100644 index 6f282ff..0000000 --- a/server/features/support/mock/config.yaml +++ /dev/null @@ -1,25 +0,0 @@ ---- -:username: mockuser -:password: mockpassword -:storage_snapshot_id: snap2 -:driver_name: mock -:instances_count: 180 -:storage_snapshot_state: AVAILABLE -:realm_id: us -:instance_1_name: 1268827277 testing instance -:image_owner: fedoraproject -:storage_snapshot_count: "2" -:realm_state: AVAILABLE -:instance_2_name: 1268827278 testing instance -:image_arch: i386 -:storage_volume_id: vol2 -:realm_count: 2 -:instance_image_id: img2 -:image_id: img2 -:storage_volume_state: AVAILABLE -:hardware_profile_id: m1-large -:instance_realm: us -:image_count: 3 -:storage_volume_count: 2 -:hardware_profile_count: 4 -:hardware_profile_arch: x86_64
ACK with two minor nits: please make the first line of the commit message something shorter, and s/authentification/authentication/ (that's why people talk about 'login' ;)
David
--- server/Rakefile | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/server/Rakefile b/server/Rakefile index 2e37ff4..ae1bfbd 100644 --- a/server/Rakefile +++ b/server/Rakefile @@ -51,6 +51,11 @@ begin t.rcov = true t.rcov_opts << %[-o "tmp/coverage"] end + + Cucumber::Rake::Task.new(:junit) do |t| + t.cucumber_opts = "features --format junit --out tmp/junit" + end + rescue LoadError desc 'Cucumber rake task not available' task :features do
On 11/05/10 14:01 +0200, mfojtik@redhat.com wrote:
Hi,
I updated all Cucumber features to reflect recent changes in API and added a couple of new tests to achieve better coverage. Also I removed configuration for Cucumber tests, because I plan to do a 'auto-learning' tests for drivers, which will be shipped separately.
Last thing I added is a jUnit output in Cucumber for better integration with Hudson. Also I deleted obsolete XML converter (we are using pure HAML for generating XML output now).
Sadly, there are two issues which blows up after I completed all features:
- When you stop/reboot/start instance, XML which is returned has blank <id/>
- We are missing JSON output for hardware_profiles and instance states
I fixed commit message and pushed this into master. Enjoy testing :-)
PS: I'll look on 1) issue today.
-- Michal
deltacloud-devel@lists.fedorahosted.org