From: marios <[email protected]>
Signed-off-by: marios <[email protected]> --- .../features/step_definitions/volumes_steps.rb | 38 ++++++++++++++++++++ server/tests/cimi/features/volumes.feature | 14 +++++++ 2 files changed, 52 insertions(+), 0 deletions(-) diff --git a/server/tests/cimi/features/step_definitions/volumes_steps.rb b/server/tests/cimi/features/step_definitions/volumes_steps.rb index 922cb04..a5abc9d 100644 --- a/server/tests/cimi/features/step_definitions/volumes_steps.rb +++ b/server/tests/cimi/features/step_definitions/volumes_steps.rb @@ -63,6 +63,44 @@ Then /^client should verify that this Volume was created correctly$/ do |capacit @@retrieved_volume.capacity[:quantity].should == capacity.raw[0][1] end +When /^client specifies a running Machine using$/ do |machine| + @machine_id = machine.raw[0][1] + authorize 'mockuser', 'mockpassword' + header 'Content-Type', 'application/xml' + get "/cimi/machines/#{@machine_id}?format=xml" + last_response.status.should==200 + @@machine = Machine.from_xml(last_response.body) + @@machine.name.should == @machine_id + @@machine.state.should == "STARTED" +end + +When /^client specifies the new Volume with attachment point using$/ do |attach| + @builder = Nokogiri::XML::Builder.new do |xml| + xml.VolumeAttach { + xml.volume( :href => @@created_volume.uri, :attachmentPoint=>attach.raw[0][1]) + } + end +end + +Then /^client should be able to attach the new volume to the Machine$/ do + authorize 'mockuser', 'mockpassword' + header 'Content-Type', 'application/CIMI-Machine+xml' + put "/cimi/machines/#{@@machine.name}/attach_volume?format=xml", @builder.to_xml + last_response.status.should == 200 +end + +When /^client should be able to detach the volume$/ do + authorize 'mockuser', 'mockpassword' + header 'Content-Type', 'application/CIMI-Machine+xml' + @builder = Nokogiri::XML::Builder.new do |xml| + xml.VolumeDetach { + xml.volume(:href => @@created_volume.uri) + } + end + put "/cimi/machines/#{@@machine.name}/detach_volume", @builder.to_xml + last_response.status.should == 200 +end + When /^client deletes the newly created Volume$/ do authorize 'mockuser', 'mockpassword' delete "/cimi/volumes/#{@@created_volume.name}" diff --git a/server/tests/cimi/features/volumes.feature b/server/tests/cimi/features/volumes.feature index c8d5282..7835e2a 100644 --- a/server/tests/cimi/features/volumes.feature +++ b/server/tests/cimi/features/volumes.feature @@ -25,6 +25,20 @@ Scenario: Query the newly created Volume Then client should verify that this Volume was created correctly | capacity | 2 | +Scenario: Attach the newly created Volume to a Machine + Given Cloud Entry Point URL is provided + And client retrieve the Cloud Entry Point + When client specifies a running Machine using + | name | inst0 | + And client specifies the new Volume with attachment point using + | attachment_point | /dev/sdc | + Then client should be able to attach the new volume to the Machine + +Scenario: Detach the newly created Volume from the Machine + Given Cloud Entry Point URL is provided + And client retrieve the Cloud Entry Point + Then client should be able to detach the volume + Scenario: Delete the newly created Volume Given Cloud Entry Point URL is provided And client retrieve the Cloud Entry Point -- 1.7.6.4
