Return-Path: Delivered-To: apmail-incubator-deltacloud-dev-archive@minotaur.apache.org Received: (qmail 5714 invoked from network); 29 Nov 2010 13:17:36 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 29 Nov 2010 13:17:36 -0000 Received: (qmail 78743 invoked by uid 500); 29 Nov 2010 13:17:36 -0000 Delivered-To: apmail-incubator-deltacloud-dev-archive@incubator.apache.org Received: (qmail 78726 invoked by uid 500); 29 Nov 2010 13:17:36 -0000 Mailing-List: contact deltacloud-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: deltacloud-dev@incubator.apache.org Delivered-To: mailing list deltacloud-dev@incubator.apache.org Received: (qmail 78718 invoked by uid 99); 29 Nov 2010 13:17:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Nov 2010 13:17:36 +0000 X-ASF-Spam-Status: No, hits=-5.0 required=10.0 tests=RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of mfojtik@redhat.com designates 209.132.183.28 as permitted sender) Received: from [209.132.183.28] (HELO mx1.redhat.com) (209.132.183.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Nov 2010 13:17:28 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oATDH7qQ013376 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 29 Nov 2010 08:17:07 -0500 Received: from patashnik.brq.redhat.com (dhcp-2-138.brq.redhat.com [10.34.2.138]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oATDH0w6001104 for ; Mon, 29 Nov 2010 08:17:06 -0500 From: mfojtik@redhat.com To: deltacloud-dev@incubator.apache.org Subject: [PATCH core 5/6] Added storage_volume Cucumber features Date: Mon, 29 Nov 2010 14:16:57 +0100 Message-Id: <1291036618-21348-6-git-send-email-mfojtik@redhat.com> In-Reply-To: <1291036618-21348-1-git-send-email-mfojtik@redhat.com> References: <1291036618-21348-1-git-send-email-mfojtik@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-Virus-Checked: Checked by ClamAV on apache.org From: Michal Fojtik --- .../ec2/step_definitions/storage_volumes_steps.rb | 89 ++++++++++++++++++++ tests/ec2/storage_volumes.feature | 52 ++++++++++++ 2 files changed, 141 insertions(+), 0 deletions(-) create mode 100644 tests/ec2/step_definitions/storage_volumes_steps.rb create mode 100644 tests/ec2/storage_volumes.feature diff --git a/tests/ec2/step_definitions/storage_volumes_steps.rb b/tests/ec2/step_definitions/storage_volumes_steps.rb new file mode 100644 index 0000000..62b84f4 --- /dev/null +++ b/tests/ec2/step_definitions/storage_volumes_steps.rb @@ -0,0 +1,89 @@ +When /^client want create a new ([\w_]+)$/ do |object| +end + +When /^client want to list all storage_volumes$/ do +end + +When /^client want to attach storage volume to RUNNING instance$/ do + get "/api/instances", { :state => "RUNNING" } + @instance_id = (output_xml/"/instances/instance").first[:id] + get "/api/storage_volumes" + @storage_volume_id = (output_xml/"/storage_volumes/storage_volume").first[:id] +end + +Then /^client should POST on ([\w_\/\$]+) using$/ do |uri, table| + params = {} + uri.gsub!(/\$storage_volume_id/, @storage_volume_id) if @storage_volume_id + table.raw.each do |key, value| + if value =~ /\$(.*)/ + value = case $1.strip + when 'instance_id' then @instance_id + end + end + params[key.to_sym] = value.strip + end + post uri, params +end + +Then /^client should do a POST on ([\w_\/\$]+)$/ do |uri| + get "/api/storage_volumes" + @storage_volume_id = (output_xml/"/storage_volumes/storage_volume").first[:id] + uri.gsub!(/\$storage_volume_id/, @storage_volume_id) if @storage_volume_id +end + +Then /^client should GET on ([\w_\/]+)$/ do |uri| + get uri +end + +Then /^a new storage_volume should be created$/ do + last_response.status.should == 200 +end + +Then /^a list of ([\w_]+) should be returned$/ do |collection| + last_response.status.should == 200 + (output_xml/"/#{collection}").size.should_not == 0 +end + +Then /^this storage_volume should have (\w+) set to '(\w+)'$/ do |key, val| + (output_xml/"/storage_volume/#{key}").text.should == val +end + +Then /^this storage_volume should have (\w+) with valid date$/ do |key| + (output_xml/"/storage_volume/#{key}").text.class.should_not == nil +end + +Then /^each (\w+) should have (\w+) with valid date$/ do |object, key| + (output_xml/"/#{object}s/#{object}").each do |item| + (item/"#{key}").should_not == nil + end +end + +Then /^this storage_volume should have actions:$/ do |table| + table.raw.each do |key| + (output_xml/"/storage_volume/actions/link[@rel = '#{key}']").should_not == nil + end +end + +Then /^each (\w+) should have (\w+)$/ do |object, key| + (output_xml/"/#{object}s/#{object}").each do |item| + (item/"#{key}").should_not == nil + end +end + +Then /^storage_volume should be attached to this instance$/ do + get "/api/storage_volumes/#{@storage_volume_id}" + (output_xml/"/storage_volume/mount/instance").first['id'].should == @instance_id +end + +Then /^this storage_volume should have mounted instance with:$/ do |table| + table.raw.each do |key| + (output_xml/"/storage_volume/mount/#{key}").should_not == nil + end +end + +When /^client want to detach created storage volume$/ do +end + +Then /^storage_volume should be detached from$/ do + last_response.status.should == 200 +end diff --git a/tests/ec2/storage_volumes.feature b/tests/ec2/storage_volumes.feature new file mode 100644 index 0000000..e5d0585 --- /dev/null +++ b/tests/ec2/storage_volumes.feature @@ -0,0 +1,52 @@ +Feature: Managing storage volumes + + @prefix-create + Scenario: Create a new storage volume + Given URI /api/storage_volumes exists + And authentification is required for this URI + When client want create a new storage_volume + Then client should POST on /api/storage_volumes using + | capacity | 1 | + | realm_id | us-east-1a | + And a new storage_volume should be created + And this storage_volume should have capacity set to '1' + And this storage_volume should have created_at with valid date + And this storage_volume should have state set to 'CREATING' + And this storage_volume should have actions: + | attach | + | detach | + | destroy | + + @prefix-list + Scenario: Getting a list of all storage volumes + Given URI /api/storage_volumes exists + And authentification is required for this URI + When client want to list all storage_volumes + Then client should GET on /api/storage_volumes + And a list of storage_volumes should be returned + And each storage_volume should have id + And each storage_volume should have created_at with valid date + And each storage_volume should have state + And each storage_volume should have capacity + And each storage_volume should have actions + + @prefix-attach + Scenario: Attach storage volume to instance + Given URI /api/storage_volumes exists + And authentification is required for this URI + When client want to attach storage volume to RUNNING instance + Then client should POST on /api/storage_volumes/$storage_volume_id/attach using + | device | /dev/sdc | + | instance_id | $instance_id | + And storage_volume should be attached to this instance + And this storage_volume should have mounted instance with: + | instance | + | device | + + @prefix-detach + Scenario: Detach storage volume to instance + Given URI /api/storage_volumes exists + And authentification is required for this URI + When client want to detach created storage volume + Then client should do a POST on /api/storage_volumes/$storage_volume_id/detach + And storage_volume should be detached from -- 1.7.3.2