From d367efc7dbda08eb71bd349c42fb778aad9001c4 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Fri, 2 Mar 2012 13:37:02 +0100 Subject: [PATCH 1/4] Feature #1109: Add SelfService support in ozones Add self service end point when creating a zone. Show self service public link when showing VDC information. (cherry picked from commit f44bb4940efaaa10486afe79c89935068b28a545) --- .../Server/public/js/plugins/vdcs-tab.js | 12 ++++++--- .../Server/public/js/plugins/zones-tab.js | 27 ++++++++++++++++--- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/ozones/Server/public/js/plugins/vdcs-tab.js b/src/ozones/Server/public/js/plugins/vdcs-tab.js index d03b75c7f8..4a4f8cbb1f 100644 --- a/src/ozones/Server/public/js/plugins/vdcs-tab.js +++ b/src/ozones/Server/public/js/plugins/vdcs-tab.js @@ -282,12 +282,14 @@ function updateVDCInfo(req,vdc_json){ var zone_host = ""; var zone_port = ""; var sun_link = ""; + var self_link = ""; var zone_match = zone_endpoint.match(/^https?:\/\/([\w.-]+):(\d+)\/([\W\w]+)$/); if (zone_match){ zone_host = zone_match[1]; zone_port = zone_match[2]; sun_link = "http://" + zone_host +"/sunstone_"+ vdc.NAME+"/"; + self_link = "http://" + zone_host +"/self_"+ vdc.NAME+"/"; }; var info_tab = { @@ -330,6 +332,10 @@ function updateVDCInfo(req,vdc_json){ Sunstone public link\ '+(sun_link.length? ''+sun_link+'' : "")+'\ \ + \ + SelfService public link\ + '+(self_link.length? ''+self_link+'' : "")+'\ + \ \ ONE_XMLPRC (to export for CLI access)\ \ @@ -501,12 +507,10 @@ function setupCreateVDCDialog(){ "ZONEID" : zoneid, "VDCADMINNAME" : vdcadminname, "VDCADMINPASS" : vdcadminpass, - "FORCE" : force + "FORCE" : force, + "HOSTS" : hosts } }; - if (hosts.length){ - vdc_json["VDC"]["HOSTS"]=hosts; - }; Sunstone.runAction("VDC.create",vdc_json); dialog.dialog('close'); diff --git a/src/ozones/Server/public/js/plugins/zones-tab.js b/src/ozones/Server/public/js/plugins/zones-tab.js index 4fbb8daeb4..d7430e75ad 100644 --- a/src/ozones/Server/public/js/plugins/zones-tab.js +++ b/src/ozones/Server/public/js/plugins/zones-tab.js @@ -53,6 +53,12 @@ var create_zone_tmpl = /\ \
\ + \ + ://\ + :\ + /\ + \ +
\ \ \
\ @@ -310,8 +316,12 @@ function updateZoneInfo(req,zone_json){ '+zone.ENDPOINT+'\ \ \ - Sunstone endpoint\ -'+ (zone.SUNSENDPOINT.length? ''+zone.SUNSENDPOINT+'' : "") +'\ + Sunstone endpoint\ + '+ (zone.SUNSENDPOINT.length? ''+zone.SUNSENDPOINT+'' : "") +'\ + \ + \ + SelfService endpoint\ + '+ (zone.SELFENDPOINT.length? ''+zone.SELFENDPOINT+'' : "") +'\ \ \ #VDCs\ @@ -557,11 +567,17 @@ function setupCreateZoneDialog(){ var endpoint_port = $('#endpoint_port',this).val(); var onename = $('#onename',this).val(); var onepass = $('#onepass',this).val(); + var se = $('#sunsendpoint',this).val(); var se_ptc = $('#sunsendpoint_ptc',this).val(); var se_port = $('#sunsendpoint_port',this).val(); var se_path = $('#sunsendpoint_path',this).val(); + var ss = $('#selfsendpoint',this).val(); + var ss_ptc = $('#selfsendpoint_ptc',this).val(); + var ss_port = $('#selfsendpoint_port',this).val(); + var ss_path = $('#selfsendpoint_path',this).val(); + if (!name.length || !endpoint.length || !onename.length || !onepass.length){ notifyError("Please fill in all fields"); @@ -575,13 +591,18 @@ function setupCreateZoneDialog(){ se = se_ptc + "://" + se + ":" + se_port + "/" + se_path; + if (ss.length) + ss = ss_ptc + "://" + ss + ":" + ss_port + + "/" + ss_path; + var zone_json = { "ZONE": { "NAME": name, "ENDPOINT": endpoint, "ONENAME": onename, "ONEPASS": onepass, - "SUNSENDPOINT" : se + "SUNSENDPOINT" : se, + "SELFENDPOINT" : ss, } }; From dbddd4519d446a3581de9958d5e2679a031bd469 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Wed, 29 Feb 2012 14:33:59 +0100 Subject: [PATCH 2/4] Feature #938: Update zona unit tests They now work with latest master status. Pending: add new tests. (cherry picked from commit cd3978ea9cd7e15eda082e0b2521c18475f5d79e) --- src/ozones/test/etc/oned.conf.a | 57 +++++++++++++ src/ozones/test/etc/oned.conf.b | 57 +++++++++---- src/ozones/test/spec/VDCManagement_spec.rb | 95 ++++++++++++---------- src/ozones/test/templates/vdcC.template | 2 +- src/ozones/test/templates/zoneA.template | 4 +- src/ozones/test/templates/zoneB.template | 2 +- src/ozones/test/test.sh | 9 +- 7 files changed, 155 insertions(+), 71 deletions(-) create mode 100644 src/ozones/test/etc/oned.conf.a diff --git a/src/ozones/test/etc/oned.conf.a b/src/ozones/test/etc/oned.conf.a new file mode 100644 index 0000000000..4b63ff1534 --- /dev/null +++ b/src/ozones/test/etc/oned.conf.a @@ -0,0 +1,57 @@ +HOST_MONITORING_INTERVAL = 600 +#HOST_PER_INTERVAL = 15 + +VM_POLLING_INTERVAL = 600 +#VM_PER_INTERVAL = 5 + +#VM_DIR=/srv/cloud/one/var + +SCRIPTS_REMOTE_DIR=/var/tmp/one + +PORT = 2666 + +DB = [ backend = "sqlite" ] + +VNC_BASE_PORT = 5900 + +DEBUG_LEVEL = 3 + +NETWORK_SIZE = 254 + +MAC_PREFIX = "02:00" + +DEFAULT_IMAGE_TYPE = "OS" +DEFAULT_DEVICE_PREFIX = "hd" + + +IM_MAD = [ name="im_dummy", executable="one_im_dummy"] + +VM_MAD = [ name="vmm_dummy", executable="one_vmm_dummy", type="xml" ] + +TM_MAD = [ + name = "tm_dummy", + executable = "one_tm", + arguments = "tm_dummy/tm_dummy.conf" ] + +IMAGE_MAD = [ + executable = "one_image", + arguments = "fs -t 15" ] + +HM_MAD = [ + executable = "one_hm" ] + +AUTH_MAD = [ + executable = "one_auth_mad", + arguments = "--authn ssh,x509,ldap,server_cipher,server_x509" +# arguments = "--authz quota --authn ssh,x509,ldap,server_cipher,server_x509" +] + +SESSION_EXPIRATION_TIME = 900 + +VM_RESTRICTED_ATTR = "CONTEXT/FILES" +VM_RESTRICTED_ATTR = "DISK/SOURCE" +VM_RESTRICTED_ATTR = "NIC/MAC" +VM_RESTRICTED_ATTR = "NIC/VLAN_ID" +VM_RESTRICTED_ATTR = "RANK" + +IMAGE_RESTRICTED_ATTR = "SOURCE" diff --git a/src/ozones/test/etc/oned.conf.b b/src/ozones/test/etc/oned.conf.b index c7f90b798d..589cf164ba 100644 --- a/src/ozones/test/etc/oned.conf.b +++ b/src/ozones/test/etc/oned.conf.b @@ -1,30 +1,57 @@ -#******************************************************************************* -# OpenNebula Configuration file -#******************************************************************************* - -# General - HOST_MONITORING_INTERVAL = 600 +#HOST_PER_INTERVAL = 15 + VM_POLLING_INTERVAL = 600 +#VM_PER_INTERVAL = 5 + +#VM_DIR=/srv/cloud/one/var + SCRIPTS_REMOTE_DIR=/var/tmp/one -PORT=2637 + +PORT = 2667 + DB = [ backend = "sqlite" ] + VNC_BASE_PORT = 5900 -DEBUG_LEVEL=3 + +DEBUG_LEVEL = 3 + NETWORK_SIZE = 254 + MAC_PREFIX = "02:00" + DEFAULT_IMAGE_TYPE = "OS" DEFAULT_DEVICE_PREFIX = "hd" -# Dummy IM_MAD = [ name="im_dummy", executable="one_im_dummy"] -VM_MAD = [ name="vmm_dummy",executable="one_vmm_dummy", type="xml" ] -TM_MAD = [ name="tm_dummy", executable="one_tm", arguments ="tm_dummy/tm_dummy.conf" ] -# Image -IMAGE_MAD = [ executable = "one_image", arguments = "fs -t 15" ] +VM_MAD = [ name="vmm_dummy", executable="one_vmm_dummy", type="xml" ] -# Hook -HM_MAD = [ executable = "one_hm" ] +TM_MAD = [ + name = "tm_dummy", + executable = "one_tm", + arguments = "tm_dummy/tm_dummy.conf" ] +IMAGE_MAD = [ + executable = "one_image", + arguments = "fs -t 15" ] + +HM_MAD = [ + executable = "one_hm" ] + +AUTH_MAD = [ + executable = "one_auth_mad", + arguments = "--authn ssh,x509,ldap,server_cipher,server_x509" +# arguments = "--authz quota --authn ssh,x509,ldap,server_cipher,server_x509" +] + +SESSION_EXPIRATION_TIME = 900 + +VM_RESTRICTED_ATTR = "CONTEXT/FILES" +VM_RESTRICTED_ATTR = "DISK/SOURCE" +VM_RESTRICTED_ATTR = "NIC/MAC" +VM_RESTRICTED_ATTR = "NIC/VLAN_ID" +VM_RESTRICTED_ATTR = "RANK" + +IMAGE_RESTRICTED_ATTR = "SOURCE" diff --git a/src/ozones/test/spec/VDCManagement_spec.rb b/src/ozones/test/spec/VDCManagement_spec.rb index 03b8c32c82..832fd8a37d 100644 --- a/src/ozones/test/spec/VDCManagement_spec.rb +++ b/src/ozones/test/spec/VDCManagement_spec.rb @@ -33,85 +33,90 @@ module OZones describe "oZones server regarding VDCs" do before(:all) do - @zonehelper = + @zonehelper = ZonesHelper.new("zone", "ozonesadmin","ozonespassword") - @vdchelper = - VDCHelper.new("vdc", "ozonesadmin","ozonespassword") - + @vdchelper = + VDCHelper.new("vdc", "ozonesadmin","ozonespassword") + @clientA = OpenNebula::Client.new(File.read( - File.dirname(__FILE__)+"/../etc/one_auth_a"), - "http://localhost:2636/RPC2") - + File.dirname(__FILE__)+"/../etc/one_auth_a"), + "http://localhost:2666/RPC2") + @clientB = OpenNebula::Client.new(File.read( - File.dirname(__FILE__)+"/../etc/one_auth_b"), - "http://localhost:2637/RPC2") - + File.dirname(__FILE__)+"/../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") - hostA.allocate("hostA2","im_dummy","vmm_dummy","tm_dummy") - hostA.allocate("hostA3","im_dummy","vmm_dummy","tm_dummy") - hostA.allocate("hostA4","im_dummy","vmm_dummy","tm_dummy") - + hostA.allocate("hostA1","im_dummy","vmm_dummy","tm_dummy","dummy") + hostA.allocate("hostA2","im_dummy","vmm_dummy","tm_dummy","dummy") + hostA.allocate("hostA3","im_dummy","vmm_dummy","tm_dummy","dummy") + hostA.allocate("hostA4","im_dummy","vmm_dummy","tm_dummy","dummy") + hostB=OpenNebula::Host.new(OpenNebula::Host.build_xml, @clientB) - hostB.allocate("hostB1","im_dummy","vmm_dummy","tm_dummy") - hostB.allocate("hostB2","im_dummy","vmm_dummy","tm_dummy") - hostB.allocate("hostB3","im_dummy","vmm_dummy","tm_dummy") + hostB.allocate("hostB1","im_dummy","vmm_dummy","tm_dummy","dummy") + hostB.allocate("hostB2","im_dummy","vmm_dummy","tm_dummy","dummy") + hostB.allocate("hostB3","im_dummy","vmm_dummy","tm_dummy","dummy") 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) - end - + "/../templates/zoneB.template")[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")[0].should eql(0) - + "/../templates/vdcA.template", + {:force => false})[0].should eql(0) + upool = OpenNebula::UserPool.new(@clientA) upool.info userExist=false - upool.each{|user| + upool.each{|user| if user['NAME'] == "vdcadminA" userExist=true end } - + userExist.should eql(true) - + gpool = OpenNebula::GroupPool.new(@clientA) gpool.info groupExist=false - gpool.each{|group| + gpool.each{|group| if group['NAME'] == "vdcA" groupExist=true end - } - + } + groupExist.should eql(true) - + apool = OpenNebula::AclPool.new(@clientA) apool.info # TODO check ACLs end - - it "should be able to create a couple of VDCs" do + + it "should be able to create a couple of VDCs" do @vdchelper.create_resource(File.dirname(__FILE__)+ - "/../templates/vdcB.template")[0].should eql(0) + "/../templates/vdcB.template", + {:force => false})[0].should eql(0) @vdchelper.create_resource(File.dirname(__FILE__)+ - "/../templates/vdcC.template")[0].should eql(0) - end - - it "should fail when creating an existing VDC" do + "/../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")[0].should eql(-1) - end - - it "should fail when creating a VDC upon a non existing zone" do + "/../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")[0].should eql(-1) - end - + "/../templates/vdc.no.zone.template", + {:force => false})[0].should eql(-1) + end + end end diff --git a/src/ozones/test/templates/vdcC.template b/src/ozones/test/templates/vdcC.template index 31fbb6c4a0..47c2b9148b 100644 --- a/src/ozones/test/templates/vdcC.template +++ b/src/ozones/test/templates/vdcC.template @@ -2,4 +2,4 @@ NAME=vdcC VDCADMINNAME=vdcadminC VDCADMINPASS=vdcpassC ZONEID=1 -HOSTS=3 \ No newline at end of file +HOSTS=4 diff --git a/src/ozones/test/templates/zoneA.template b/src/ozones/test/templates/zoneA.template index 35b6adfb5f..bd92fcb475 100644 --- a/src/ozones/test/templates/zoneA.template +++ b/src/ozones/test/templates/zoneA.template @@ -1,5 +1,5 @@ NAME=zoneA ONENAME=oneadminA ONEPASS=opennebulaA -ENDPOINT=http://localhost:2636/RPC2 -SUNSENDPOINT=http://localhost:9869 \ No newline at end of file +ENDPOINT=http://localhost:2666/RPC2 +SUNSENDPOINT=http://localhost:9869 diff --git a/src/ozones/test/templates/zoneB.template b/src/ozones/test/templates/zoneB.template index 3eb7b9348b..9aa9cdda36 100644 --- a/src/ozones/test/templates/zoneB.template +++ b/src/ozones/test/templates/zoneB.template @@ -1,4 +1,4 @@ NAME=zoneB ONENAME=oneadminB ONEPASS=opennebulaB -ENDPOINT=http://localhost:2637/RPC2 \ No newline at end of file +ENDPOINT=http://localhost:2667/RPC2 diff --git a/src/ozones/test/test.sh b/src/ozones/test/test.sh index 963032dcf2..a1822faffc 100755 --- a/src/ozones/test/test.sh +++ b/src/ozones/test/test.sh @@ -35,8 +35,7 @@ for j in `ls ./spec/*_spec.rb` ; do OZONES_AUTH=$PWD/etc/ozones_auth ONE_LOCATION=$ONE_LOCATION_A oneA/bin/ozones-server start sleep 5 - - ONE_LOCATION=$ONE_LOCATION_A spec $j -f s + ONE_LOCATION=$ONE_LOCATION_A rspec $j -f s CODE=$? if [ $CODE != 0 ] ; then @@ -62,8 +61,4 @@ if (($CODE == 0)); then # Delete directories rm -rf oneA rm -rf oneB -fi - - - - +fi \ No newline at end of file From a9bf2f05dc1a16c0c423b78c99fcf96fd1e15d10 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Mon, 5 Mar 2012 11:32:36 +0100 Subject: [PATCH 3/4] Ozones: enable raw JSON output from CLI commands (cherry picked from commit e4b34a7e4e175da871b796396d054bf36ae2de7f) --- src/ozones/Client/bin/onevdc | 5 ++- src/ozones/Client/bin/onezone | 44 ++++++++++++++-------- src/ozones/Client/lib/cli/ozones_helper.rb | 34 ++++++++++++++--- 3 files changed, 60 insertions(+), 23 deletions(-) diff --git a/src/ozones/Client/bin/onevdc b/src/ozones/Client/bin/onevdc index b584c7fb6f..1fb688a2b2 100755 --- a/src/ozones/Client/bin/onevdc +++ b/src/ozones/Client/bin/onevdc @@ -61,11 +61,12 @@ cmd=CommandParser::CmdParser.new(ARGV) do helper.create_resource(args[0], options) end - command :show, 'Show information of a particular VDC', :vdcid do + command :show, 'Show information of a particular VDC', :vdcid, + :options => OZonesHelper::JSON do helper.show_resource(args[0],options) end - command :list, 'Lists VDCs in the pool' do + command :list, 'Lists VDCs in the pool', :options => OZonesHelper::JSON do helper.list_pool(options) end diff --git a/src/ozones/Client/bin/onezone b/src/ozones/Client/bin/onezone index af922e7bcb..5eae35012e 100755 --- a/src/ozones/Client/bin/onezone +++ b/src/ozones/Client/bin/onezone @@ -71,8 +71,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do onezone show 4 host EOT - command :show, show_desc, :zoneid, [:resource, nil] do - zone=helper.show_resource(args[0],options)[1] + command :show, show_desc, :zoneid, [:resource, nil], + :options => OZonesHelper::JSON do + zone = helper.show_resource(args[0],options)[1] + + #manually print here + if options[:json] + puts zone + end + + if !args[1] then next 0 end case args[1] when "host" @@ -87,35 +95,41 @@ cmd=CommandParser::CmdParser.new(ARGV) do aux_helper = OneTemplateHelper.new when "user" aux_helper = OneUserHelper.new - else - puts "\n:!: Pool #{args[1]} doesn't exist or is not supported\n\n" - next 0 + else + puts "\n:!: Pool #{args[1]} doesn't exist or is not supported\n\n" + next 0 end - pool_hash_data = helper.get_resource_pool("zone", zone[:ID], args[1]) + pool_hash_data = helper.get_resource_pool("zone", args[0], args[1], + options) - if pool_hash_data[0] != 0 - puts "\nError retrieving information for pool #{args[1]}. Reason: " + pool_hash_data[1] + "\n\n" + if pool_hash_data[0] != 0 + puts "\nError retrieving information for pool #{args[1]}. Reason: " + pool_hash_data[1] + "\n\n" next 0 - end + end - if !pool_hash_data[1] - next 0 + if !pool_hash_data[1] + next 0 + end + + if options[:json] + puts pool_hash_data[1] + next 0 end if pool_hash_data[1].is_a?(Hash) pool_hash_data[1]=[Hash.transform_keys_to_strings(pool_hash_data[1])] - else - pool_hash_data[1].each{|hash| hash.replace(Hash.transform_keys_to_strings(hash))} + else + pool_hash_data[1].each{|hash| hash.replace(Hash.transform_keys_to_strings(hash))} end table = aux_helper.format_pool(options) - table.show(pool_hash_data[1]) + table.show(pool_hash_data[1]) 0 end - command :list, 'Lists Zones in the pool' do + command :list, 'Lists Zones in the pool', :options=>OZonesHelper::JSON do helper.list_pool(options) end diff --git a/src/ozones/Client/lib/cli/ozones_helper.rb b/src/ozones/Client/lib/cli/ozones_helper.rb index 6ce320b5e8..cf13653354 100644 --- a/src/ozones/Client/lib/cli/ozones_helper.rb +++ b/src/ozones/Client/lib/cli/ozones_helper.rb @@ -18,6 +18,15 @@ require 'zona' module OZonesHelper + #Specific ozones CLI options + + JSON={ + :name => "json", + :short => "-j", + :large => "--json", + :description => "Show the resource in JSON format" + } + class OZHelper def initialize(user=nil, pass=nil, endpoint_str=nil, timeout=nil, debug_flag=true) @@ -45,8 +54,13 @@ module OZonesHelper if Zona::is_error?(rc) [-1, rc.message] else - pool=Zona::OZonesJSON.parse_json(rc.body, kind.upcase + "_POOL") - format_pool(pool, options) + if options[:json] + [0, rc.body] + else + resource_str = kind.upcase + "_POOL" + pool=Zona::OZonesJSON.parse_json(rc.body, resource_str) + format_pool(pool, options) + end end end @@ -56,18 +70,26 @@ module OZonesHelper if Zona::is_error?(rc) [-1, rc.message] else - resource=Zona::OZonesJSON.parse_json(rc.body, kind.upcase) - format_resource(resource, options) + if options[:json] + [0, rc.body] + else + resource=Zona::OZonesJSON.parse_json(rc.body, kind.upcase) + format_resource(resource, options) + end end end - def get_resource_pool(kind, id, pool) + def get_resource_pool(kind, id, pool, options) rc = @client.get_resource_pool(kind, id, pool) if Zona::is_error?(rc) [-1, rc.message] else - [0 , Zona::OZonesJSON.parse_json(rc.body, pool.upcase+"_POOL")[pool.upcase.to_sym]] + if options[:json] + [0, rc.body] + else + [0 , Zona::OZonesJSON.parse_json(rc.body, pool.upcase+"_POOL")[pool.upcase.to_sym]] + end end end From 28e841c73942b719819aec83dd81454c3b2372b5 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Tue, 6 Mar 2012 12:17:01 +0100 Subject: [PATCH 4/4] Feature #938: Move tests from ozones/Server/test to ozones/test (cherry picked from commit f2e86d4b487ac4ceb20e57c35790eca10e1c1501) --- src/ozones/Server/test/Rakefile | 9 -- .../Server/test/examples/pool/vdcpool0.json | 18 --- .../test/examples/pool/vdcpool1deleted.json | 12 -- .../Server/test/examples/pool/zonepool0.json | 22 --- .../test/examples/pool/zonepool1deleted.json | 14 -- src/ozones/Server/test/examples/vdc/vdc0.json | 8 -- .../Server/test/examples/vdc/vdc0.template | 5 - .../Server/test/examples/vdc/vdc1.template | 5 - .../test/examples/vdc/vdc2nozone.template | 3 - .../Server/test/examples/zone/zone0.json | 23 --- .../Server/test/examples/zone/zone0.template | 4 - .../Server/test/examples/zone/zone1.template | 4 - src/ozones/Server/test/spec/pools_spec.rb | 133 ------------------ src/ozones/Server/test/test.sh | 46 ------ src/ozones/test/examples/pool/vdcpool0.json | 36 +++++ .../test/examples/pool/vdcpool_deleted.json | 26 ++++ src/ozones/test/examples/pool/zonepool0.json | 26 ++++ .../test/examples/pool/zonepool_deleted.json | 16 +++ src/ozones/test/examples/vdc/vdc0.json | 12 ++ src/ozones/test/examples/zone/zone0.json | 14 ++ src/ozones/test/spec/VDCManagement_spec.rb | 58 +++++--- src/ozones/test/spec/ZoneManagement_spec.rb | 81 ++++++++--- src/ozones/test/test.sh | 7 - 23 files changed, 228 insertions(+), 354 deletions(-) delete mode 100644 src/ozones/Server/test/Rakefile delete mode 100644 src/ozones/Server/test/examples/pool/vdcpool0.json delete mode 100644 src/ozones/Server/test/examples/pool/vdcpool1deleted.json delete mode 100644 src/ozones/Server/test/examples/pool/zonepool0.json delete mode 100644 src/ozones/Server/test/examples/pool/zonepool1deleted.json delete mode 100644 src/ozones/Server/test/examples/vdc/vdc0.json delete mode 100644 src/ozones/Server/test/examples/vdc/vdc0.template delete mode 100644 src/ozones/Server/test/examples/vdc/vdc1.template delete mode 100644 src/ozones/Server/test/examples/vdc/vdc2nozone.template delete mode 100644 src/ozones/Server/test/examples/zone/zone0.json delete mode 100644 src/ozones/Server/test/examples/zone/zone0.template delete mode 100644 src/ozones/Server/test/examples/zone/zone1.template delete mode 100644 src/ozones/Server/test/spec/pools_spec.rb delete mode 100755 src/ozones/Server/test/test.sh create mode 100644 src/ozones/test/examples/pool/vdcpool0.json create mode 100644 src/ozones/test/examples/pool/vdcpool_deleted.json create mode 100644 src/ozones/test/examples/pool/zonepool0.json create mode 100644 src/ozones/test/examples/pool/zonepool_deleted.json create mode 100644 src/ozones/test/examples/vdc/vdc0.json create mode 100644 src/ozones/test/examples/zone/zone0.json 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