diff --git a/src/ozones/Server/test/Rakefile b/src/ozones/Server/test/Rakefile deleted file mode 100644 index 1cc32ded2d..0000000000 --- a/src/ozones/Server/test/Rakefile +++ /dev/null @@ -1,9 +0,0 @@ -require 'rake' -require 'spec/rake/spectask' - -desc "Run all tests with RCov" -Spec::Rake::SpecTask.new('test_with_rcov') do |t| - t.spec_files = FileList['spec/*_spec.rb'] - t.rcov = true - t.rcov_opts = ['--exclude', '/Library'] -end \ No newline at end of file diff --git a/src/ozones/Server/test/examples/pool/vdcpool0.json b/src/ozones/Server/test/examples/pool/vdcpool0.json deleted file mode 100644 index 568adf4dd9..0000000000 --- a/src/ozones/Server/test/examples/pool/vdcpool0.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "vdcpool": { - "vdc": [ - { - "hosts": "testhostvdc0n0,testhostvdc0n1,testhostvdc0n2", - "zones_id": 1, - "name": "testvdc0", - "id": 1 - }, - { - "hosts": "testhostvdc1n0", - "zones_id": 1, - "name": "testvdc1", - "id": 2 - } - ] - } -} \ No newline at end of file diff --git a/src/ozones/Server/test/examples/pool/vdcpool1deleted.json b/src/ozones/Server/test/examples/pool/vdcpool1deleted.json deleted file mode 100644 index 4f0d258aa9..0000000000 --- a/src/ozones/Server/test/examples/pool/vdcpool1deleted.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "vdcpool": { - "vdc": [ - { - "hosts": "testhostvdc0n0,testhostvdc0n1,testhostvdc0n2", - "zones_id": 1, - "name": "testvdc0", - "id": 1 - } - ] - } -} \ No newline at end of file diff --git a/src/ozones/Server/test/examples/pool/zonepool0.json b/src/ozones/Server/test/examples/pool/zonepool0.json deleted file mode 100644 index 05b79f2255..0000000000 --- a/src/ozones/Server/test/examples/pool/zonepool0.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "zonepool": { - "zone": [ - { - "onename": "oneadmin", - "onepass": "opennebula", - "endpoint": "http://localhost:2633/RPC2", - "numbervdcs": 2, - "name": "testzone0", - "id": 1 - }, - { - "onename": "testname", - "onepass": "testpass", - "endpoint": "http://remoteserver:2633/RPC2", - "numbervdcs": 0, - "name": "testzone1", - "id": 2 - } - ] - } -} \ No newline at end of file diff --git a/src/ozones/Server/test/examples/pool/zonepool1deleted.json b/src/ozones/Server/test/examples/pool/zonepool1deleted.json deleted file mode 100644 index dbd66dca25..0000000000 --- a/src/ozones/Server/test/examples/pool/zonepool1deleted.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "zonepool": { - "zone": [ - { - "onename": "oneadmin", - "onepass": "opennebula", - "endpoint": "http://localhost:2633/RPC2", - "numbervdcs": 2, - "name": "testzone0", - "id": 1 - } - ] - } -} \ No newline at end of file diff --git a/src/ozones/Server/test/examples/vdc/vdc0.json b/src/ozones/Server/test/examples/vdc/vdc0.json deleted file mode 100644 index 6deb95903d..0000000000 --- a/src/ozones/Server/test/examples/vdc/vdc0.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "vdc": { - "hosts": "5,7,9", - "zones_id": 1, - "name": "testvdc0", - "id": 1 - } -} \ No newline at end of file diff --git a/src/ozones/Server/test/examples/vdc/vdc0.template b/src/ozones/Server/test/examples/vdc/vdc0.template deleted file mode 100644 index b2e7e3d4f3..0000000000 --- a/src/ozones/Server/test/examples/vdc/vdc0.template +++ /dev/null @@ -1,5 +0,0 @@ -NAME=testvdc0 -ZONEID=1 -HOSTS=5,7,9 -VDCADMINNAME=adminname -VDCADMINPASS=adminpass diff --git a/src/ozones/Server/test/examples/vdc/vdc1.template b/src/ozones/Server/test/examples/vdc/vdc1.template deleted file mode 100644 index 4566505bbb..0000000000 --- a/src/ozones/Server/test/examples/vdc/vdc1.template +++ /dev/null @@ -1,5 +0,0 @@ -NAME=testvdc1 -HOSTS=8 -ZONEID=1 -VDCADMINNAME=othername -VDCADMINPASS=otherpass \ No newline at end of file diff --git a/src/ozones/Server/test/examples/vdc/vdc2nozone.template b/src/ozones/Server/test/examples/vdc/vdc2nozone.template deleted file mode 100644 index 946c43c46c..0000000000 --- a/src/ozones/Server/test/examples/vdc/vdc2nozone.template +++ /dev/null @@ -1,3 +0,0 @@ -NAME=testvdcnozone -HOSTS=3,7 -ZONEID=5 \ No newline at end of file diff --git a/src/ozones/Server/test/examples/zone/zone0.json b/src/ozones/Server/test/examples/zone/zone0.json deleted file mode 100644 index 3577998a60..0000000000 --- a/src/ozones/Server/test/examples/zone/zone0.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "zone": { - "onename": "oneadmin", - "onepass": "opennebula", - "endpoint": "http://localhost:2633/RPC2", - "name": "testzone0", - "id": 1, - "vdcs": [ - { - "hosts": "testhostvdc0n0,testhostvdc0n1,testhostvdc0n2", - "zones_id": 1, - "name": "testvdc0", - "id": 1 - }, - { - "hosts": "testhostvdc1n0", - "zones_id": 1, - "name": "testvdc1", - "id": 2 - } - ] - } -} \ No newline at end of file diff --git a/src/ozones/Server/test/examples/zone/zone0.template b/src/ozones/Server/test/examples/zone/zone0.template deleted file mode 100644 index acad3af06e..0000000000 --- a/src/ozones/Server/test/examples/zone/zone0.template +++ /dev/null @@ -1,4 +0,0 @@ -NAME=testzone0 -ENDPOINT=http://localhost:2633/RPC2 -ONENAME=oneadmin -ONEPASS=opennebula \ No newline at end of file diff --git a/src/ozones/Server/test/examples/zone/zone1.template b/src/ozones/Server/test/examples/zone/zone1.template deleted file mode 100644 index 4c1459667c..0000000000 --- a/src/ozones/Server/test/examples/zone/zone1.template +++ /dev/null @@ -1,4 +0,0 @@ -NAME=testzone1 -ENDPOINT=http://remoteserver:2633/RPC2 -ONENAME=testname -ONEPASS=testpass \ No newline at end of file diff --git a/src/ozones/Server/test/spec/pools_spec.rb b/src/ozones/Server/test/spec/pools_spec.rb deleted file mode 100644 index 4fd7667c7c..0000000000 --- a/src/ozones/Server/test/spec/pools_spec.rb +++ /dev/null @@ -1,133 +0,0 @@ -# -------------------------------------------------------------------------- # -# Copyright 2002-2012, 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. # -#--------------------------------------------------------------------------- # - -# Load libraries -require 'rubygems' -require 'spec' -require 'json' -require File.dirname(__FILE__) + "/../../../Client/lib/OZonesClient.rb" - -EXAMPLES_PATH = File.dirname(__FILE__) + "/../examples/" - -describe 'OZones Pool' do - before(:all) do - @client_launched = true - - begin - @ozones_client = OZonesClient::Client.new("http://localhost:6121") - rescue Exception => e - @client_launched = false - end - - @client_launched.should == true - - rc = @ozones_client.post_resource( - "zone",EXAMPLES_PATH + '/zone/zone0.template') - rc.class.should_not eql(OZonesClient::Error) - - rc = @ozones_client.post_resource( - "zone",EXAMPLES_PATH + '/zone/zone1.template') - rc.class.should_not eql(OZonesClient::Error) - - rc = @ozones_client.post_resource( - "vdc",EXAMPLES_PATH + '/vdc/vdc0.template') - rc.class.should_not eql(OZonesClient::Error) - - rc = @ozones_client.post_resource( - "vdc",EXAMPLES_PATH + '/vdc/vdc1.template') - rc.class.should_not eql(OZonesClient::Error) - - end - - it "should be able to retrieve the zone pool" do - zonepool = @ozones_client.get_pool("zone") - zonepool.class.should eql(Net::HTTPOK) - zonepool.body.should eql( - File.read(EXAMPLES_PATH+'/pool/zonepool0.json')) - end - - it "should be able to retrieve the vdc pool" do - vdcpool = @ozones_client.get_pool("vdc") - vdcpool.class.should eql(Net::HTTPOK) - vdcpool.body.should eql( - File.read(EXAMPLES_PATH+'/pool/vdcpool0.json')) - end - - it "should be able to retrieve a particular zone" do - zone0 = @ozones_client.get_resource("zone",1) - zone0.class.should eql(Net::HTTPOK) - zone0.body.should eql( - File.read(EXAMPLES_PATH+'/zone/zone0.json')) - end - - it "should be able to retrieve a particular vdc" do - vdc0 = @ozones_client.get_resource("vdc",1) - vdc0.class.should eql(Net::HTTPOK) - vdc0.body.should eql( - File.read(EXAMPLES_PATH+'/vdc/vdc0.json')) - end - - it "should fail on zone recreation (with the same name)" do - rc = @ozones_client.post_resource( - "zone",EXAMPLES_PATH + '/zone/zone0.template') - rc.class.should eql(OZonesClient::Error) - end - - it "should fail on vdc recreation (with the same name)" do - rc = @ozones_client.post_resource( - "vdc",EXAMPLES_PATH + '/vdc/vdc0.template') - rc.class.should eql(OZonesClient::Error) - end - - it "should fail on vdc creation with no existing zone" do - rc = @ozones_client.post_resource( - "vdc",EXAMPLES_PATH + - '/vdc/vdc2nozone.template') - rc.class.should eql(OZonesClient::Error) - end - - it "should allow deleting a zone" do - rc = @ozones_client.delete_resource("zone",2) - rc.class.should eql(Net::HTTPOK) - # Zone pool shouldn't account for the deleted zone - zonepool = @ozones_client.get_pool("zone") - zonepool.class.should eql(Net::HTTPOK) - zonepool.body.should eql( - File.read(EXAMPLES_PATH+ - '/pool/zonepool1deleted.json')) - end - - it "should allow deleting a vdc" do - rc = @ozones_client.delete_resource("vdc",2) - rc.class.should eql(Net::HTTPOK) - # Zone pool shouldn't account for the deleted zone - vdcpool = @ozones_client.get_pool("vdc") - vdcpool.class.should eql(Net::HTTPOK) - vdcpool.body.should eql( - File.read(EXAMPLES_PATH+ - '/pool/vdcpool1deleted.json')) - end - - it "should fail on non existing zone deletion" do - rc = @ozones_client.delete_resource("zone",5) - rc.class.should eql(OZonesClient::Error) - end - - it "should fail on non existing vdc deletion" do - rc = @ozones_client.delete_resource("vdc",5) - rc.class.should eql(OZonesClient::Error) - end -end diff --git a/src/ozones/Server/test/test.sh b/src/ozones/Server/test/test.sh deleted file mode 100755 index 98fa138442..0000000000 --- a/src/ozones/Server/test/test.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash - -# -------------------------------------------------------------------------- # -# Copyright 2002-2012, 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. # -#--------------------------------------------------------------------------- # - - -VAR_LOCATION="$PWD/var" -OZONES_LOCATION="$PWD/../" - -mkdir -p $VAR_LOCATION - -if [ "$(ls -A $VAR_LOCATION)" ]; then - echo "$VAR_LOCATION is not empty." - exit -1 -fi - -rm -rf coverage_server - -rcov --exclude /Library --exclude /Users/tinova/.gem -o coverage_server `which rackup` -- $OZONES_LOCATION/config.ru -s thin -p 6121 -o localhost &> server.log & -RCOVPID=$! -sleep 5 - -rake test_with_rcov -CODE=$? - -kill $RCOVPID -sleep 2s; - -if [ $CODE != 0 ] ; then - exit 1 -fi - -find $VAR_LOCATION -mindepth 1 -delete diff --git a/src/ozones/test/examples/pool/vdcpool0.json b/src/ozones/test/examples/pool/vdcpool0.json new file mode 100644 index 0000000000..1401a09b5b --- /dev/null +++ b/src/ozones/test/examples/pool/vdcpool0.json @@ -0,0 +1,36 @@ +{ + "VDC_POOL": { + "VDC": [ + { + "ID": 1, + "ACLS": "2,3,4,5,6,7", + "HOSTS": "1,2,3", + "NAME": "vdcA", + "ZONES_ID": 1, + "GROUP_ID": 100, + "VDCADMINNAME": "vdcadminA", + "VDCADMIN_ID": 2 + }, + { + "ID": 2, + "ACLS": "2,3,4,5", + "HOSTS": "1", + "NAME": "vdcB", + "ZONES_ID": 2, + "GROUP_ID": 100, + "VDCADMINNAME": "vdcadminB", + "VDCADMIN_ID": 2 + }, + { + "ID": 3, + "ACLS": "8,9,10,11", + "HOSTS": "4", + "NAME": "vdcC", + "ZONES_ID": 1, + "GROUP_ID": 101, + "VDCADMINNAME": "vdcadminC", + "VDCADMIN_ID": 3 + } + ] + } +} \ No newline at end of file diff --git a/src/ozones/test/examples/pool/vdcpool_deleted.json b/src/ozones/test/examples/pool/vdcpool_deleted.json new file mode 100644 index 0000000000..bd6fd87e84 --- /dev/null +++ b/src/ozones/test/examples/pool/vdcpool_deleted.json @@ -0,0 +1,26 @@ +{ + "VDC_POOL": { + "VDC": [ + { + "ID": 1, + "ACLS": "2,3,4,5,6,7", + "HOSTS": "1,2,3", + "NAME": "vdcA", + "ZONES_ID": 1, + "GROUP_ID": 100, + "VDCADMINNAME": "vdcadminA", + "VDCADMIN_ID": 2 + }, + { + "ID": 2, + "ACLS": "2,3,4,5", + "HOSTS": "1", + "NAME": "vdcB", + "ZONES_ID": 2, + "GROUP_ID": 100, + "VDCADMINNAME": "vdcadminB", + "VDCADMIN_ID": 2 + } + ] + } +} \ No newline at end of file diff --git a/src/ozones/test/examples/pool/zonepool0.json b/src/ozones/test/examples/pool/zonepool0.json new file mode 100644 index 0000000000..1eaf1751fa --- /dev/null +++ b/src/ozones/test/examples/pool/zonepool0.json @@ -0,0 +1,26 @@ +{ + "ZONE_POOL": { + "ZONE": [ + { + "ID": 1, + "ENDPOINT": "http://localhost:2666/RPC2", + "NUMBERVDCS": 0, + "SUNSENDPOINT": "http://localhost:9869", + "NAME": "zoneA", + "SELFENDPOINT": null, + "ONENAME": "oneadminA", + "ONEPASS": "OkqWM2aSqbM/nlrdHGv3OA==" + }, + { + "ID": 2, + "ENDPOINT": "http://localhost:2667/RPC2", + "NUMBERVDCS": 0, + "SUNSENDPOINT": null, + "NAME": "zoneB", + "SELFENDPOINT": null, + "ONENAME": "oneadminB", + "ONEPASS": "8Si8vlo2P3qn5/SNxkMkDg==" + } + ] + } +} \ No newline at end of file diff --git a/src/ozones/test/examples/pool/zonepool_deleted.json b/src/ozones/test/examples/pool/zonepool_deleted.json new file mode 100644 index 0000000000..6ec991ee16 --- /dev/null +++ b/src/ozones/test/examples/pool/zonepool_deleted.json @@ -0,0 +1,16 @@ +{ + "ZONE_POOL": { + "ZONE": [ + { + "ID": 1, + "ENDPOINT": "http://localhost:2666/RPC2", + "NUMBERVDCS": 0, + "SUNSENDPOINT": "http://localhost:9869", + "NAME": "zoneA", + "SELFENDPOINT": null, + "ONENAME": "oneadminA", + "ONEPASS": "OkqWM2aSqbM/nlrdHGv3OA==" + } + ] + } +} \ No newline at end of file diff --git a/src/ozones/test/examples/vdc/vdc0.json b/src/ozones/test/examples/vdc/vdc0.json new file mode 100644 index 0000000000..b716f24472 --- /dev/null +++ b/src/ozones/test/examples/vdc/vdc0.json @@ -0,0 +1,12 @@ +{ + "VDC": { + "ID": 1, + "ACLS": "2,3,4,5,6,7", + "HOSTS": "1,2,3", + "NAME": "vdcA", + "ZONES_ID": 1, + "GROUP_ID": 100, + "VDCADMINNAME": "vdcadminA", + "VDCADMIN_ID": 2 + } +} \ No newline at end of file diff --git a/src/ozones/test/examples/zone/zone0.json b/src/ozones/test/examples/zone/zone0.json new file mode 100644 index 0000000000..6b8d182e36 --- /dev/null +++ b/src/ozones/test/examples/zone/zone0.json @@ -0,0 +1,14 @@ +{ + "ZONE": { + "ID": 1, + "ENDPOINT": "http://localhost:2666/RPC2", + "SUNSENDPOINT": "http://localhost:9869", + "VDCS": [ + + ], + "NAME": "zoneA", + "SELFENDPOINT": null, + "ONENAME": "oneadminA", + "ONEPASS": "OkqWM2aSqbM/nlrdHGv3OA==" + } +} \ No newline at end of file diff --git a/src/ozones/test/spec/VDCManagement_spec.rb b/src/ozones/test/spec/VDCManagement_spec.rb index 832fd8a37d..35be54b574 100644 --- a/src/ozones/test/spec/VDCManagement_spec.rb +++ b/src/ozones/test/spec/VDCManagement_spec.rb @@ -29,6 +29,8 @@ require 'command_parser' require 'ozones_helper/zones_helper.rb' require 'ozones_helper/vdc_helper.rb' +TESTS_PATH = File.dirname(__FILE__)+"/../" + module OZones describe "oZones server regarding VDCs" do @@ -39,12 +41,12 @@ module OZones VDCHelper.new("vdc", "ozonesadmin","ozonespassword") @clientA = OpenNebula::Client.new(File.read( - File.dirname(__FILE__)+"/../etc/one_auth_a"), + TESTS_PATH+"etc/one_auth_a"), "http://localhost:2666/RPC2") @clientB = OpenNebula::Client.new(File.read( - File.dirname(__FILE__)+"/../etc/one_auth_b"), - "http://localhost:2667/RPC2") + TESTS_PATH+"etc/one_auth_b"), + "http://localhost:2667/RPC2") hostA=OpenNebula::Host.new(OpenNebula::Host.build_xml, @clientA) hostA.allocate("hostA1","im_dummy","vmm_dummy","tm_dummy","dummy") @@ -59,15 +61,14 @@ module OZones end it "should be able to create a couple of zones" do - @zonehelper.create_resource(File.dirname(__FILE__)+ - "/../templates/zoneA.template")[0].should eql(0) - @zonehelper.create_resource(File.dirname(__FILE__)+ - "/../templates/zoneB.template")[0].should eql(0) + rc = @zonehelper.create_resource(TESTS_PATH+"templates/zoneA.template") + rc[0].should eql(0) + rc = @zonehelper.create_resource(TESTS_PATH+"templates/zoneB.template") + rc[0].should eql(0) end - it "should be able to create one vdc with the apropiate ONE resources" do - @vdchelper.create_resource(File.dirname(__FILE__)+ - "/../templates/vdcA.template", + it "should be able to create one vdc with apropiate ONE resources" do + @vdchelper.create_resource(TESTS_PATH+"templates/vdcA.template", {:force => false})[0].should eql(0) upool = OpenNebula::UserPool.new(@clientA) @@ -98,25 +99,46 @@ module OZones end it "should be able to create a couple of VDCs" do - @vdchelper.create_resource(File.dirname(__FILE__)+ - "/../templates/vdcB.template", + @vdchelper.create_resource(TESTS_PATH+"templates/vdcB.template", {:force => false})[0].should eql(0) - @vdchelper.create_resource(File.dirname(__FILE__)+ - "/../templates/vdcC.template", + @vdchelper.create_resource(TESTS_PATH+"templates/vdcC.template", {:force => false})[0].should eql(0) end it "should fail when creating an existing VDC" do - @vdchelper.create_resource(File.dirname(__FILE__)+ - "/../templates/vdcA.template", + @vdchelper.create_resource(TESTS_PATH+"templates/vdcA.template", {:force => false})[0].should eql(-1) end it "should fail when creating a VDC upon a non existing zone" do - @vdchelper.create_resource(File.dirname(__FILE__)+ - "/../templates/vdc.no.zone.template", + @vdchelper.create_resource(TESTS_PATH+"templates/vdc.no.zone.template", {:force => false})[0].should eql(-1) end + it "should be able to retrieve the vdc pool" do + vdcpool = @vdchelper.list_pool({:json => true}) + vdcpool[0].should eql(0) + vdcpool[1].should eql(File.read(TESTS_PATH+"examples/pool/vdcpool0.json")) + end + + it "should be able to retrieve a particular vdc" do + vdc = @vdchelper.show_resource(1, {:json => true}) + vdc[0].should eql(0) + vdc[1].should eql(File.read(TESTS_PATH+"examples/vdc/vdc0.json")) + end + + it "should allow deleting a vdc" do + rc = @vdchelper.delete_resource(3, {}) + rc[0].should eql(0) + rc = @vdchelper.list_pool({:json => true}) + rc[0].should eql(0) + rc[1].should eql(File.read(TESTS_PATH+ + "examples/pool/vdcpool_deleted.json")) + end + + it "should fail on non-existing vdc deletion" do + rc = @vdchelper.delete_resource(7, {}) + rc[0].should eql(-1) + end end end diff --git a/src/ozones/test/spec/ZoneManagement_spec.rb b/src/ozones/test/spec/ZoneManagement_spec.rb index cf18a2d1ed..e60e5caf11 100644 --- a/src/ozones/test/spec/ZoneManagement_spec.rb +++ b/src/ozones/test/spec/ZoneManagement_spec.rb @@ -28,36 +28,71 @@ $: << RUBY_LIB_LOCATION+"/cli" require 'command_parser' require 'ozones_helper/zones_helper.rb' +TESTS_PATH = File.dirname(__FILE__)+"/../" + module OZones describe "oZones server regarding zones" do before(:all) do - @helper = ZonesHelper.new("zone", "ozonesadmin","ozonespassword") - @badhelper = ZonesHelper.new("zone", "wronguser","wrongpassword") + @helper = ZonesHelper.new("zone", "ozonesadmin","ozonespassword") + @badhelper = ZonesHelper.new("zone", "wronguser","wrongpassword") end - + it "should be able to create a couple of zones" do - @helper.create_resource(File.dirname(__FILE__)+ - "/../templates/zoneA.template")[0].should eql(0) - @helper.create_resource(File.dirname(__FILE__)+ - "/../templates/zoneB.template")[0].should eql(0) - end - + rc = @helper.create_resource(TESTS_PATH+"templates/zoneA.template") + rc[0].should eql(0) + + @helper.create_resource(TESTS_PATH+"templates/zoneB.template") + rc[0].should eql(0) + end + it "should fail with wrong zones templates" do - @helper.create_resource(File.dirname(__FILE__)+ - "/../templates/zone.wrong.credentials.template")[0].should eql(-1) - @helper.create_resource(File.dirname(__FILE__)+ - "/../templates/zone.wrong.endpoint.template")[0].should eql(-1) - end - + templ_path = "templates/zone.wrong.credentials.template" + rc = @helper.create_resource(TESTS_PATH+templ_path) + rc[0].should eql(-1) + + templ_path = "templates/zone.wrong.endpoint.template" + rc = @helper.create_resource(TESTS_PATH+templ_path) + rc[0].should eql(-1) + end + it "should fail when creating zones with existing name" do - @helper.create_resource(File.dirname(__FILE__)+ - "/../templates/zoneA.template")[0].should eql(-1) - end - + rc = @helper.create_resource(TESTS_PATH+"templates/zoneA.template") + rc[0].should eql(-1) + end + it "should refuse unauthorized requests" do - @badhelper.create_resource(File.dirname(__FILE__)+ - "/../templates/zoneA.template")[0].should eql(-1) - end + rc = @badhelper.create_resource(TESTS_PATH+ + "templates/zoneA.template") + rc[0].should eql(-1) + end + + it "should be able to retrieve the zone pool" do + zonepool = @helper.list_pool({:json => true}) + zonepool[0].should eql(0) + zonepool[1].should eql(File.read(TESTS_PATH+ + "examples/pool/zonepool0.json")) + end + + it "should be able to retrieve a particular zone" do + zone = @helper.show_resource(1,{:json => true}) + zone[0].should eql(0) + zone[1].should eql(File.read(TESTS_PATH+"examples/zone/zone0.json")) + end + + it "should allow deleting a zone" do + rc = @helper.delete_resource(2, {}) + rc[0].should eql(0) + rc = @helper.list_pool({:json => true}) + rc[0].should eql(0) + rc[1].should eql(File.read(TESTS_PATH+ + "examples/pool/zonepool_deleted.json")) + end + + it "should fail on non existing zone deletion" do + rc = @helper.delete_resource(7, {}) + rc[0].should eql(-1) + end + end -end \ No newline at end of file +end diff --git a/src/ozones/test/test.sh b/src/ozones/test/test.sh index a1822faffc..d6de0d2f42 100755 --- a/src/ozones/test/test.sh +++ b/src/ozones/test/test.sh @@ -51,13 +51,6 @@ for j in `ls ./spec/*_spec.rb` ; do done if (($CODE == 0)); then - # Terminate ONEs - ONE_LOCATION=$ONE_LOCATION_A oneA/bin/one stop - ONE_LOCATION=$ONE_LOCATION_B oneB/bin/one stop - - # Stop oZones - ONE_LOCATION=$ONE_LOCATION_A oneA/bin/ozones-server stop - # Delete directories rm -rf oneA rm -rf oneB