1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

feature #849: Add OCCI PUT compute tests

This commit is contained in:
Daniel Molina 2011-10-17 18:40:19 +02:00
parent f1272b23d8
commit 612dc31489
15 changed files with 107 additions and 9 deletions

View File

@ -31,7 +31,7 @@ describe "Quota testing" do
<TEMPLATE>
<CPU>2</CPU>
<MEMORY>128</MEMORY>
<TEMPLATE>
</TEMPLATE>
EOT
vm_base64 = Base64::encode64(vm_template)
@ -41,7 +41,7 @@ describe "Quota testing" do
image_template = <<-EOT
<TEMPLATE>
<PATH>/etc/hosts</PATH>
<TEMPLATE>
</TEMPLATE>
EOT
image_base64 = Base64::encode64(image_template)
@ -52,7 +52,7 @@ describe "Quota testing" do
<TEMPLATE>
<CPU>2</CPU>
<MEMORY>128</MEMORY>
<TEMPLATE>
</TEMPLATE>
EOT
temp_base64 = Base64::encode64(temp_template)

View File

@ -0,0 +1 @@
<COMPUTE href="http://localhost:4567/compute/0"><ID>0</ID><CPU>1</CPU><MEMORY>512</MEMORY><NAME>one-0</NAME><STATE>ACTIVE</STATE><DISK id="0"><STORAGE href="http://localhost:4567/storage/0" name="first_image"/><TYPE>DISK</TYPE><TARGET>hda</TARGET></DISK><DISK id="1"><STORAGE href="http://localhost:4567/storage/1" name="second_image"/><TYPE>DISK</TYPE><TARGET>hde</TARGET></DISK></COMPUTE>

View File

@ -0,0 +1 @@
<COMPUTE href="http://localhost:4567/compute/0"><ID>0</ID><CPU>1</CPU><MEMORY>512</MEMORY><NAME>one-0</NAME><STATE>SUSPENDED</STATE><DISK id="0"><STORAGE href="http://localhost:4567/storage/0" name="first_image"/><SAVE_AS name="save_as1"/><TYPE>DISK</TYPE><TARGET>hda</TARGET></DISK><DISK id="1"><STORAGE href="http://localhost:4567/storage/1" name="second_image"/><TYPE>DISK</TYPE><TARGET>hde</TARGET></DISK></COMPUTE>

View File

@ -0,0 +1 @@
<COMPUTE href="http://localhost:4567/compute/0"><ID>0</ID><CPU>1</CPU><MEMORY>512</MEMORY><NAME>one-0</NAME><STATE>ACTIVE</STATE><DISK id="0"><STORAGE href="http://localhost:4567/storage/0" name="first_image"/><SAVE_AS name="save_as1"/><TYPE>DISK</TYPE><TARGET>hda</TARGET></DISK><DISK id="1"><STORAGE href="http://localhost:4567/storage/1" name="second_image"/><TYPE>DISK</TYPE><TARGET>hde</TARGET></DISK></COMPUTE>

View File

@ -0,0 +1 @@
<COMPUTE href="http://localhost:4567/compute/0"><ID>0</ID><CPU>1</CPU><MEMORY>512</MEMORY><NAME>one-0</NAME><STATE>ACTIVE</STATE><DISK id="0"><STORAGE href="http://localhost:4567/storage/0" name="first_image"/><TYPE>DISK</TYPE><TARGET>hda</TARGET></DISK><DISK id="1"><SAVE_AS name="save_as2"/><STORAGE href="http://localhost:4567/storage/1" name="second_image"/><TYPE>DISK</TYPE><TARGET>hde</TARGET></DISK></COMPUTE>

View File

@ -0,0 +1 @@
<COMPUTE href="http://localhost:4567/compute/0"><ID>0</ID><CPU>1</CPU><MEMORY>512</MEMORY><NAME>one-0</NAME><STATE>ACTIVE</STATE><DISK id="0"><STORAGE href="http://localhost:4567/storage/0" name="first_image"/><SAVE_AS name="save_as1"/><TYPE>DISK</TYPE><TARGET>hda</TARGET></DISK><DISK id="1"><STORAGE href="http://localhost:4567/storage/1" name="second_image"/><SAVE_AS name="save_as2"/><TYPE>DISK</TYPE><TARGET>hde</TARGET></DISK></COMPUTE>

View File

@ -14,7 +14,9 @@
# limitations under the License. #
#--------------------------------------------------------------------------- #
FIXTURES_PATH = File.join(File.dirname(__FILE__),'../fixtures')
FIXTURES_PATH = File.join(File.dirname(__FILE__),'../fixtures')
TEMPLATES_PATH = File.join(File.dirname(__FILE__),'../templates')
$: << File.join(File.dirname(__FILE__), '..', '..', 'lib')
# Load the testing libraries

View File

@ -31,7 +31,7 @@ describe 'OCCI User tests' do
xml_body = last_response.body
user_collection = File.read(FIXTURES_PATH + '/user_collection.xml')
user_collection = File.read(FIXTURES_PATH + '/user/user_collection.xml')
xml_body.strip.should eql(user_collection.strip)
end
@ -52,7 +52,7 @@ describe 'OCCI User tests' do
xml_body = last_response.body
user = File.read(FIXTURES_PATH + '/user.xml')
user = File.read(FIXTURES_PATH + '/user/user.xml')
xml_body.strip.should eql(user.strip)
end

View File

@ -0,0 +1,77 @@
# -------------------------------------------------------------------------- #
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe 'OCCI User tests' do
# PREREQUISITES
# OpenNebula installed and running using dummy drivers
before(:all) do
# Starting the drivers
sleep 2
system("onehost create myhost im_dummy vmm_dummy tm_dummy").should == true
system("oneimage create #{TEMPLATES_PATH+"/image1.template"}").should == true
system("oneimage create #{TEMPLATES_PATH+"/image2.template"}").should == true
# Copying the images
sleep 1
system("onevm create #{TEMPLATES_PATH+"/vm.template"}").should == true
system("onevm deploy 0 0").should == true
end
it "should show the new compute" do
basic_authorize('oneadmin','4478db59d30855454ece114e8ccfa5563d21c9bd')
get '/compute/0'
last_response.body.should == File.read(FIXTURES_PATH+"/vm_save_as/newcompute.xml")
end
it "should get an error when trying to change the resource state and save a disk " do
basic_authorize('oneadmin','4478db59d30855454ece114e8ccfa5563d21c9bd')
body = File.read(FIXTURES_PATH+"/vm_save_as/save_a_disk_and_change_state.xml")
put '/compute/0', body
last_response.status.should == 403
end
it "should get an error when trying to save two disks" do
basic_authorize('oneadmin','4478db59d30855454ece114e8ccfa5563d21c9bd')
body = File.read(FIXTURES_PATH+"/vm_save_as/save_two_disks.xml")
put '/compute/0', body
last_response.status.should == 403
end
it "should save the first disk" do
basic_authorize('oneadmin','4478db59d30855454ece114e8ccfa5563d21c9bd')
body = File.read(FIXTURES_PATH+"/vm_save_as/save_first_disk.xml")
put '/compute/0', body
last_response.status.should == 202
end
it "should save the second disk" do
basic_authorize('oneadmin','4478db59d30855454ece114e8ccfa5563d21c9bd')
body = File.read(FIXTURES_PATH+"/vm_save_as/save_second_disk.xml")
put '/compute/0', body
last_response.status.should == 202
end
end

View File

@ -0,0 +1,2 @@
NAME = first_image
PATH = /etc/hosts

View File

@ -0,0 +1,3 @@
NAME = second_image
PATH = /etc/hosts
TYPE = DATABLOCK

View File

@ -0,0 +1,10 @@
CPU = 1
MEMORY = 512
DISK = [
IMAGE_ID = 0
]
DISK = [
IMAGE_ID = 1
]

View File

@ -22,7 +22,6 @@ if [ -z $ONE_LOCATION ]; then
fi
VAR_LOCATION="$ONE_LOCATION/var"
rm -rf $VAR_LOCATION/*
if [ "$(ls -A $VAR_LOCATION)" ]; then
echo "$VAR_LOCATION is not empty."
@ -30,6 +29,8 @@ if [ "$(ls -A $VAR_LOCATION)" ]; then
fi
for j in `ls ./spec/*_spec.rb` ; do
find $VAR_LOCATION -mindepth 1 ! \( -path "$VAR_LOCATION/remotes*" -o -path "$VAR_LOCATION/images" \) -delete
PID=$$
oned -f &
@ -45,6 +46,4 @@ for j in `ls ./spec/*_spec.rb` ; do
if [ $CODE != 0 ] ; then
exit 1
fi
find $VAR_LOCATION -mindepth 1 -delete
done