You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by mf...@apache.org on 2011/02/25 14:17:55 UTC
svn commit: r1074512 - in /incubator/deltacloud/trunk/tests/sbc:
step_definitions/ support/ support/fixtures/
Author: mfojtik
Date: Fri Feb 25 13:17:54 2011
New Revision: 1074512
URL: http://svn.apache.org/viewvc?rev=1074512&view=rev
Log:
Cucumber step definitions for IBM SBC tests
Added:
incubator/deltacloud/trunk/tests/sbc/step_definitions/
incubator/deltacloud/trunk/tests/sbc/step_definitions/common_steps.rb
incubator/deltacloud/trunk/tests/sbc/step_definitions/images_steps.rb
incubator/deltacloud/trunk/tests/sbc/step_definitions/instances_steps.rb
incubator/deltacloud/trunk/tests/sbc/support/
incubator/deltacloud/trunk/tests/sbc/support/env.rb
incubator/deltacloud/trunk/tests/sbc/support/fixtures/
incubator/deltacloud/trunk/tests/sbc/support/fixtures/0d9cd0facc9d0b175788bf0967d00f4a.fixture
incubator/deltacloud/trunk/tests/sbc/support/fixtures/2186a78c8079ee4b675bc1d6e75675ab.fixture
incubator/deltacloud/trunk/tests/sbc/support/fixtures/291f0f35b96fa2b9e5cae3d1e5b89878.fixture
incubator/deltacloud/trunk/tests/sbc/support/fixtures/8f56d1e1fc0703e54eaedf61057b936a.fixture
incubator/deltacloud/trunk/tests/sbc/support/fixtures/f16b6558d39821a706056d936f3d6d90.fixture
incubator/deltacloud/trunk/tests/sbc/support/fixtures/ff671e15c30a18a501dd6d4e6db77c9e.fixture
Added: incubator/deltacloud/trunk/tests/sbc/step_definitions/common_steps.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/tests/sbc/step_definitions/common_steps.rb?rev=1074512&view=auto
==============================================================================
--- incubator/deltacloud/trunk/tests/sbc/step_definitions/common_steps.rb (added)
+++ incubator/deltacloud/trunk/tests/sbc/step_definitions/common_steps.rb Fri Feb 25 13:17:54 2011
@@ -0,0 +1,78 @@
+Given /^I enter ([A-Za-z_]+) collection$/ do |collection|
+ @current_collection = collection
+ @current_collection_url = "/api/%s" % collection.strip
+end
+
+Given /^I am authorized with my credentials$/ do
+ #unless CONFIG[:username] == 'sbc_test_username' && CONFIG[:password] == 'sbc_test_password'
+ puts 'going to authorize...'
+ authorize CONFIG[:username], CONFIG[:password]
+ #end
+ puts 'done doing authorize test'
+end
+
+When /^I request ([A-Z]+) response$/ do |format|
+ if format == 'HTML'
+ header 'Accept', 'text/html'
+ end
+ if format == 'XML'
+ header 'Accept', 'application/xml'
+ end
+ get @current_collection_url, {}
+ last_response.status == 200
+end
+
+Given /^result should be valid ([A-Z]+)$/ do |format|
+ if format == 'HTML'
+ last_response.body.should =~ /^\<\!DOCTYPE html PUBLIC/
+ else
+ last_response.body.should_not =~ /^\<\!DOCTYPE html PUBLIC/
+ end
+end
+
+Given /^result should contain (\d+) ([A-Za-z_]+)$/ do |count, collection|
+ (xml/"/#{collection}/#{collection.gsub(/s$/, '')}").size.should == count.to_i
+end
+
+Then /^result should contain one ([A-Za-z_]+)$/ do |item|
+ (xml/"/#{item}").size.should == 1
+end
+
+Given /^each ([A-Za-z_]+) should have properties set to$/ do |object, table|
+ table.raw.each do |property|
+ puts property[0]
+ (xml/"*/#{object}/#{property[0]}").size.should_not == 0
+ (xml/"*/#{object}/#{property[0]}").each do |element|
+ element.text.should == property[1]
+ end
+ end
+end
+
+Given /^the ([A-Za-z_]+) should have properties set to$/ do |object, table|
+ table.raw.each do |property|
+ (xml/"/#{object}/#{property[0]}").size.should_not == 0
+ (xml/"*/#{object}/#{property[0]}").each do |element|
+ element.text.should == property[1]
+ end
+ end
+end
+
+Given /^name of these ([A-Za-z_]+) should be$/ do |collection, table|
+ names = table.raw.flatten
+ (xml/"/#{collection}/#{collection.gsub(/s$/, '')}/name").each do |name|
+ names.delete(name.text)
+ end
+ names.should be_empty
+end
+
+Given /^I choose ([a-z_]+) with ([a-z_]+) ([\.0-9a-zA-Z_-]+)$/ do |collection, property, value|
+ @current_collection_url += "/%s" % value if property == 'id'
+end
+
+Then /^attribute ([a-z_]+) should be set to ([0-9A-Za-z_-]+)$/ do |property, value|
+ (xml/"/#{@current_collection.gsub(/s$/, '')}").first[property.to_sym].should == value
+end
+
+Then /^([a-z_]+) of this ([A-Za-z_]+) should be ([\.0-9a-zA-Z_-]+)$/ do |property, object, value|
+ (xml/"/#{object}/#{property}").text.strip.should == value.strip
+end
\ No newline at end of file
Added: incubator/deltacloud/trunk/tests/sbc/step_definitions/images_steps.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/tests/sbc/step_definitions/images_steps.rb?rev=1074512&view=auto
==============================================================================
--- incubator/deltacloud/trunk/tests/sbc/step_definitions/images_steps.rb (added)
+++ incubator/deltacloud/trunk/tests/sbc/step_definitions/images_steps.rb Fri Feb 25 13:17:54 2011
@@ -0,0 +1,7 @@
+Then /^([a-z]+) properties should be$/ do |type, table|
+ properties = table.raw.flatten
+ (xml/"hardware_profiles/hardware_profile/property[@kind='#{type}']").each do |name|
+ properties.delete(name[:name])
+ end
+ properties.should be_empty
+end
\ No newline at end of file
Added: incubator/deltacloud/trunk/tests/sbc/step_definitions/instances_steps.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/tests/sbc/step_definitions/instances_steps.rb?rev=1074512&view=auto
==============================================================================
--- incubator/deltacloud/trunk/tests/sbc/step_definitions/instances_steps.rb (added)
+++ incubator/deltacloud/trunk/tests/sbc/step_definitions/instances_steps.rb Fri Feb 25 13:17:54 2011
@@ -0,0 +1,26 @@
+Then /^instance should be in ([A-Z]+) state$/ do |state|
+ (xml/'instance/state').first.text.should == state
+end
+
+Then /^instance should have defined actions$/ do |table|
+ actions = table.raw.flatten
+ (xml/'instance/actions/link').each do |action|
+ actions.delete(action[:rel])
+ end
+ actions.should be_empty
+end
+
+Then /^I want to ([a-z]+) this instance$/ do |action|
+ get @current_collection_url
+end
+
+Then /^I follow ([a-z]+) link in actions$/ do |action|
+ link = (xml/"instance/actions/link[@rel='#{action}']").first
+ @instance_id = (xml/'instance').first[:id]
+ if link[:method].eql?('post')
+ post link[:href]
+ end
+ if link[:method].eql?('delete')
+ delete link[:href]
+ end
+end
\ No newline at end of file
Added: incubator/deltacloud/trunk/tests/sbc/support/env.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/tests/sbc/support/env.rb?rev=1074512&view=auto
==============================================================================
--- incubator/deltacloud/trunk/tests/sbc/support/env.rb (added)
+++ incubator/deltacloud/trunk/tests/sbc/support/env.rb Fri Feb 25 13:17:54 2011
@@ -0,0 +1,62 @@
+SERVER_DIR = File::expand_path(File::join(File::dirname(__FILE__), "../../../server"))
+Dir.chdir(SERVER_DIR)
+
+require 'rubygems'
+require 'nokogiri'
+require '../server/server'
+require 'rack/test'
+
+Sinatra::Application.set :environment, :test
+Sinatra::Application.set :root, SERVER_DIR
+
+CONFIG = {
+ :username => 'sbc_test_username',
+ :password => 'sbc_test_password'
+}
+
+ENV['RACK_ENV'] = 'test'
+
+
+World do
+
+ include Rack::Test::Methods
+
+ module Rack
+ module Test
+ class Session
+ def headers
+ @headers
+ end
+ end
+ end
+ class MockSession
+ def set_last_response(response)
+ @last_response = response
+ end
+ end
+ end
+
+ def app
+ @app = Rack::Builder.new do
+ set :environment => :development
+ set :loggining => true
+ set :raise_errors => true
+ set :show_exceptions => true
+ run Sinatra::Application
+ end
+ end
+
+ def xml
+ Nokogiri::XML(last_response.body)
+ end
+
+
+
+ Before do
+ unless @no_header
+ header 'Accept', 'application/xml;q=9'
+ end
+ end
+
+end
+
Added: incubator/deltacloud/trunk/tests/sbc/support/fixtures/0d9cd0facc9d0b175788bf0967d00f4a.fixture
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/tests/sbc/support/fixtures/0d9cd0facc9d0b175788bf0967d00f4a.fixture?rev=1074512&view=auto
==============================================================================
--- incubator/deltacloud/trunk/tests/sbc/support/fixtures/0d9cd0facc9d0b175788bf0967d00f4a.fixture (added)
+++ incubator/deltacloud/trunk/tests/sbc/support/fixtures/0d9cd0facc9d0b175788bf0967d00f4a.fixture Fri Feb 25 13:17:54 2011
@@ -0,0 +1 @@
+["/locations","get",{"body":"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><ns2:DescribeLocationsResponse xmlns:ns2=\"http://www.ibm.com/xmlns/b2b/cloud/api/2010-03-31\"><Location><ID>41</ID><Name>RTP</Name><Description>RTP usrdtsa0a1ccxra</Description><Location>RTP</Location><Capabilities><Capability id=\"oss.storage.format\"><Entry key=\"EXT3\"><Value>ext3</Value></Entry><Entry key=\"RAW\"><Value>raw</Value></Entry></Capability><Capability id=\"oss.instance.spec.i386\"/><Capability id=\"oss.instance.spec.x86_64\"/><Capability id=\"oss.storage.availabilityarea\"/></Capabilities><State>1</State></Location><Location><ID>61</ID><Name>EHN</Name><Description></Description><Location>EHN</Location><Capabilities><Capability id=\"oss.storage.format\"><Entry key=\"EXT3\"><Value>ext3</Value></Entry><Entry key=\"RAW\"><Value>raw</Value></Entry></Capability><Capability id=\"oss.instance.spec.i386\"/><Capability id=\"oss.instance.spec.x86_64\"/><Capability id=\"oss.storag
e.availabilityarea\"/></Capabilities><State>1</State></Location><Location><ID>82</ID><Name>us-co-dc1</Name><Description>BLD main DC</Description><Location>us-co-dc1</Location><Capabilities><Capability id=\"oss.storage.format\"><Entry key=\"EXT3\"><Value>ext3</Value></Entry><Entry key=\"RAW\"><Value>raw</Value></Entry></Capability><Capability id=\"oss.instance.spec.i386\"/><Capability id=\"oss.instance.spec.x86_64\"/><Capability id=\"oss.storage.availabilityarea\"/></Capabilities><State>1</State></Location><Location><ID>101</ID><Name>ca-on-dc1</Name><Description>Data Center 1 at Ontario, Canada </Description><Location>ca-on-dc1</Location><Capabilities><Capability id=\"oss.storage.format\"><Entry key=\"EXT3\"><Value>ext3</Value></Entry><Entry key=\"RAW\"><Value>raw</Value></Entry></Capability><Capability id=\"oss.instance.spec.i386\"/><Capability id=\"oss.instance.spec.x86_64\"/><Capability id=\"oss.storage.availabilityarea\"/></Capabilities><State>1</State></Location></ns2:De
scribeLocationsResponse>","Content-Type":"text/xml;charset=UTF-8","status":"200"}]
Added: incubator/deltacloud/trunk/tests/sbc/support/fixtures/2186a78c8079ee4b675bc1d6e75675ab.fixture
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/tests/sbc/support/fixtures/2186a78c8079ee4b675bc1d6e75675ab.fixture?rev=1074512&view=auto
==============================================================================
--- incubator/deltacloud/trunk/tests/sbc/support/fixtures/2186a78c8079ee4b675bc1d6e75675ab.fixture (added)
+++ incubator/deltacloud/trunk/tests/sbc/support/fixtures/2186a78c8079ee4b675bc1d6e75675ab.fixture Fri Feb 25 13:17:54 2011
@@ -0,0 +1 @@
+["/offerings/image/20006009","get",{"body":"{\"name\":\"IBM Mashup Center V2.0 - BYOL\",\"manifest\":\"https://www-147.ibm.com/cloud/enterprise/ram.ws/RAMSecure/artifact/{06BFD9D7-FCB6-531F-97EA-527C3AE77A99}/1.0/parameters.xml\",\"state\":1,\"visibility\":\"PUBLIC\",\"owner\":\"SYSTEM\",\"platform\":\"SUSE Linux Enterprise Server/11\",\"createdTime\":1273834388000,\"location\":\"41\",\"supportedInstanceTypes\":[{\"label\":\"Bronze 32 bit\",\"price\":{\"rate\":0.17,\"unitOfMeasure\":\"UHR \",\"countryCode\":\"IBM\",\"effectiveDate\":-1,\"currencyCode\":\"USD\",\"pricePerQuantity\":1},\"id\":\"BRZ32.1/2048/60*175\"},{\"label\":\"Silver 32 bit\",\"price\":{\"rate\":0.265,\"unitOfMeasure\":\"UHR \",\"countryCode\":\"IBM\",\"effectiveDate\":-1,\"currencyCode\":\"USD\",\"pricePerQuantity\":1},\"id\":\"SLV32.2/4096/60*350\"},{\"label\":\"Gold 32 bit\",\"price\":{\"rate\":0.41,\"unitOfMeasure\":\"UHR \",\"countryCode\":\"IBM\",\"effectiveDate\":-1,\"currencyCode\":\"USD\",\"pric
ePerQuantity\":1},\"id\":\"GLD32.4/4096/60*350\"},{\"label\":\"Copper 32 bit\",\"price\":{\"rate\":0.15,\"unitOfMeasure\":\"UHR \",\"countryCode\":\"IBM\",\"effectiveDate\":-1,\"currencyCode\":\"USD\",\"pricePerQuantity\":1},\"id\":\"COP32.1/2048/60\"}],\"productCodes\":[\"YzvQJGlaSmS4Miel2XAFbw\"],\"documentation\":\"https://www-147.ibm.com/cloud/enterprise/ram.ws/RAMSecure/artifact/{06BFD9D7-FCB6-531F-97EA-527C3AE77A99}/1.0/GettingStarted.html\",\"id\":\"20006009\",\"description\":\"IBM Mashup Center V2.0 for SUSE Linux Enterprise Server 11.0 (32-bit) using bring your own license entitlement (PVU) PA part number E08ANLL\"}","Content-Type":"application/json","status":"200"}]
Added: incubator/deltacloud/trunk/tests/sbc/support/fixtures/291f0f35b96fa2b9e5cae3d1e5b89878.fixture
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/tests/sbc/support/fixtures/291f0f35b96fa2b9e5cae3d1e5b89878.fixture?rev=1074512&view=auto
==============================================================================
--- incubator/deltacloud/trunk/tests/sbc/support/fixtures/291f0f35b96fa2b9e5cae3d1e5b89878.fixture (added)
+++ incubator/deltacloud/trunk/tests/sbc/support/fixtures/291f0f35b96fa2b9e5cae3d1e5b89878.fixture Fri Feb 25 13:17:54 2011
@@ -0,0 +1 @@
+["/instances/48151","get",{"body":"{\"launchTime\":1297389062997,\"software\":[{\"version\":\"11\",\"type\":\"OS\",\"name\":\"SUSE Linux Enterprise Server\"}],\"primaryIP\":{\"hostname\":\"170.224.161.70 \",\"ip\":\"170.224.161.70 \",\"type\":0},\"requestId\":\"48451\",\"keyName\":\"woodser_key\",\"name\":\"EricTest1\",\"instanceType\":\"COP32.1/2048/60\",\"status\":5,\"owner\":\"woodser@us.ibm.com\",\"location\":\"41\",\"imageId\":\"20006009\",\"root-only\":\"true\",\"productCodes\":[],\"volumes\":[],\"requestName\":\"EricTest1\",\"id\":\"48151\",\"secondaryIP\":[],\"expirationTime\":1360386000000,\"diskSize\":\"60\"}","Content-Type":"application/json","status":"200"}]
Added: incubator/deltacloud/trunk/tests/sbc/support/fixtures/8f56d1e1fc0703e54eaedf61057b936a.fixture
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/tests/sbc/support/fixtures/8f56d1e1fc0703e54eaedf61057b936a.fixture?rev=1074512&view=auto
==============================================================================
--- incubator/deltacloud/trunk/tests/sbc/support/fixtures/8f56d1e1fc0703e54eaedf61057b936a.fixture (added)
+++ incubator/deltacloud/trunk/tests/sbc/support/fixtures/8f56d1e1fc0703e54eaedf61057b936a.fixture Fri Feb 25 13:17:54 2011
@@ -0,0 +1 @@
+["/instances","get",{"body":"{\"instances\":[{\"launchTime\":1297388803193,\"software\":[{\"version\":\"11\",\"type\":\"OS\",\"name\":\"SUSE Linux Enterprise Server\"}],\"primaryIP\":{\"hostname\":\"170.224.160.165 \",\"ip\":\"170.224.160.165 \",\"type\":0},\"requestId\":\"48450\",\"keyName\":\"woodser_key\",\"name\":\"EricTest2\",\"instanceType\":\"COP32.1/2048/60\",\"status\":5,\"owner\":\"woodser@us.ibm.com\",\"location\":\"41\",\"imageId\":\"20006009\",\"root-only\":\"true\",\"productCodes\":[],\"volumes\":[],\"requestName\":\"EricTest2\",\"id\":\"48150\",\"secondaryIP\":[],\"expirationTime\":1360386000000,\"diskSize\":\"60\"},{\"launchTime\":1297389062997,\"software\":[{\"version\":\"11\",\"type\":\"OS\",\"name\":\"SUSE Linux Enterprise Server\"}],\"primaryIP\":{\"hostname\":\"170.224.161.70 \",\"ip\":\"170.224.161.70 \",\"type\":0},\"requestId\":\"48451\",\"keyName\":\"woodser_key\",\"name\":\"EricTest1\",\"instanceType\":\"COP32.1/2048/60\",\"status\":5,\"owner\":\"
woodser@us.ibm.com\",\"location\":\"41\",\"imageId\":\"20006009\",\"root-only\":\"true\",\"productCodes\":[],\"volumes\":[],\"requestName\":\"EricTest1\",\"id\":\"48151\",\"secondaryIP\":[],\"expirationTime\":1360386000000,\"diskSize\":\"60\"},{\"launchTime\":1297178462706,\"software\":[{\"version\":\"2008 R1\",\"type\":\"OS\",\"name\":\"Windows\"}],\"primaryIP\":{\"hostname\":\"170.224.165.59 \",\"ip\":\"170.224.165.59 \",\"type\":0},\"requestId\":\"47684\",\"name\":\"Win2008\",\"instanceType\":\"COP32.1/2048/60\",\"status\":5,\"owner\":\"dug@us.ibm.com\",\"location\":\"41\",\"imageId\":\"20012834\",\"root-only\":\"true\",\"productCodes\":[],\"volumes\":[],\"requestName\":\"Win2008\",\"id\":\"47384\",\"secondaryIP\":[],\"expirationTime\":1360213200000,\"diskSize\":\"60\"}]}","Content-Type":"application/json","status":"200"}]
Added: incubator/deltacloud/trunk/tests/sbc/support/fixtures/f16b6558d39821a706056d936f3d6d90.fixture
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/tests/sbc/support/fixtures/f16b6558d39821a706056d936f3d6d90.fixture?rev=1074512&view=auto
==============================================================================
--- incubator/deltacloud/trunk/tests/sbc/support/fixtures/f16b6558d39821a706056d936f3d6d90.fixture (added)
+++ incubator/deltacloud/trunk/tests/sbc/support/fixtures/f16b6558d39821a706056d936f3d6d90.fixture Fri Feb 25 13:17:54 2011
@@ -0,0 +1 @@
[... 2 lines stripped ...]
Added: incubator/deltacloud/trunk/tests/sbc/support/fixtures/ff671e15c30a18a501dd6d4e6db77c9e.fixture
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/tests/sbc/support/fixtures/ff671e15c30a18a501dd6d4e6db77c9e.fixture?rev=1074512&view=auto
==============================================================================
--- incubator/deltacloud/trunk/tests/sbc/support/fixtures/ff671e15c30a18a501dd6d4e6db77c9e.fixture (added)
+++ incubator/deltacloud/trunk/tests/sbc/support/fixtures/ff671e15c30a18a501dd6d4e6db77c9e.fixture Fri Feb 25 13:17:54 2011
@@ -0,0 +1 @@
+["/instances/48151","get",{"body":"{\"launchTime\":1297389062997,\"software\":[{\"version\":\"11\",\"type\":\"OS\",\"name\":\"SUSE Linux Enterprise Server\"}],\"primaryIP\":{\"hostname\":\"170.224.161.70 \",\"ip\":\"170.224.161.70 \",\"type\":0},\"requestId\":\"48451\",\"keyName\":\"woodser_key\",\"name\":\"EricTest1\",\"instanceType\":\"COP32.1/2048/60\",\"status\":5,\"owner\":\"woodser@us.ibm.com\",\"location\":\"41\",\"imageId\":\"20006009\",\"root-only\":\"true\",\"productCodes\":[],\"volumes\":[],\"requestName\":\"EricTest1\",\"id\":\"48151\",\"secondaryIP\":[],\"expirationTime\":1360386000000,\"diskSize\":\"60\"}","Content-Type":"application/json","status":"200"}]