Return-Path: X-Original-To: apmail-deltacloud-commits-archive@www.apache.org Delivered-To: apmail-deltacloud-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D6DEDD435 for ; Mon, 30 Jul 2012 14:29:18 +0000 (UTC) Received: (qmail 1468 invoked by uid 500); 30 Jul 2012 14:29:18 -0000 Delivered-To: apmail-deltacloud-commits-archive@deltacloud.apache.org Received: (qmail 1423 invoked by uid 500); 30 Jul 2012 14:29:18 -0000 Mailing-List: contact commits-help@deltacloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@deltacloud.apache.org Delivered-To: mailing list commits@deltacloud.apache.org Received: (qmail 1076 invoked by uid 99); 30 Jul 2012 14:29:18 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Jul 2012 14:29:18 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 477291A0A3; Mon, 30 Jul 2012 14:29:18 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mfojtik@apache.org To: commits@deltacloud.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [50/50] [abbrv] Core: Added initial RHEV-M unit tests Message-Id: <20120730142918.477291A0A3@tyr.zones.apache.org> Date: Mon, 30 Jul 2012 14:29:18 +0000 (UTC) http://git-wip-us.apache.org/repos/asf/deltacloud/blob/02bb895d/server/tests/drivers/rhevm/fixtures/test_0006_must_support_destroying_images.yml ---------------------------------------------------------------------- diff --git a/server/tests/drivers/rhevm/fixtures/test_0006_must_support_destroying_images.yml b/server/tests/drivers/rhevm/fixtures/test_0006_must_support_destroying_images.yml new file mode 100644 index 0000000..207154a --- /dev/null +++ b/server/tests/drivers/rhevm/fixtures/test_0006_must_support_destroying_images.yml @@ -0,0 +1,246 @@ +--- +http_interactions: +- request: + method: get + uri: https://vdcadmin%40rhev.lab.eng.brq.redhat.com:123456@rhev30-dc.lab.eng.brq.redhat.com:8443/api/templates/354455c9-d075-46f7-bf41-7df48d0fe925 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/xml + Accept-Encoding: + - gzip, deflate + Content-Type: + - application/xml + User-Agent: + - Ruby + response: + status: + code: 404 + message: Not Found + headers: + Server: + - Apache-Coyote/1.1 + Content-Type: + - text/html;charset=utf-8 + Content-Length: + - '950' + Date: + - Wed, 25 Jul 2012 11:51:54 GMT + body: + encoding: US-ASCII + string: ! 'JBoss Web/2.1.11.GA - Error report

HTTP + Status 404 -


type Status report

message +

description The requested resource () is not available.


JBoss Web/2.1.11.GA

' + http_version: + recorded_at: Mon, 23 Jul 2012 12:21:00 GMT +- request: + method: get + uri: https://vdcadmin%40rhev.lab.eng.brq.redhat.com:123456@rhev30-dc.lab.eng.brq.redhat.com:8443/api/templates/a90de8a2-0619-4625-b72e-db0ff65ef927 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/xml + Accept-Encoding: + - gzip, deflate + Content-Type: + - application/xml + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Server: + - Apache-Coyote/1.1 + Pragma: + - No-cache + Cache-Control: + - no-cache + Expires: + - Thu, 01 Jan 1970 01:00:00 CET + X-Powered-By: + - Servlet 2.5; JBoss-5.0/JBossWeb-2.1 + Content-Type: + - application/xml + Content-Length: + - '1809' + Date: + - Wed, 25 Jul 2012 11:54:53 GMT + body: + encoding: US-ASCII + string: ! "\n\n" + http_version: + recorded_at: Wed, 25 Jul 2012 11:55:58 GMT +- request: + method: delete + uri: https://vdcadmin%40rhev.lab.eng.brq.redhat.com:123456@rhev30-dc.lab.eng.brq.redhat.com:8443/api/templates/a90de8a2-0619-4625-b72e-db0ff65ef927 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/xml + Accept-Encoding: + - gzip, deflate + User-Agent: + - Ruby + response: + status: + code: 204 + message: No Content + headers: + Server: + - Apache-Coyote/1.1 + Pragma: + - No-cache + Cache-Control: + - no-cache + Expires: + - Thu, 01 Jan 1970 01:00:00 CET + X-Powered-By: + - Servlet 2.5; JBoss-5.0/JBossWeb-2.1 + Date: + - Wed, 25 Jul 2012 11:54:53 GMT + body: + encoding: US-ASCII + string: '' + http_version: + recorded_at: Wed, 25 Jul 2012 11:55:58 GMT +- request: + method: get + uri: https://vdcadmin%40rhev.lab.eng.brq.redhat.com:123456@rhev30-dc.lab.eng.brq.redhat.com:8443/api/templates/a90de8a2-0619-4625-b72e-db0ff65ef927 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/xml + Accept-Encoding: + - gzip, deflate + Content-Type: + - application/xml + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Server: + - Apache-Coyote/1.1 + Pragma: + - No-cache + Cache-Control: + - no-cache + Expires: + - Thu, 01 Jan 1970 01:00:00 CET + X-Powered-By: + - Servlet 2.5; JBoss-5.0/JBossWeb-2.1 + Content-Type: + - application/xml + Content-Length: + - '1813' + Date: + - Wed, 25 Jul 2012 11:54:53 GMT + body: + encoding: US-ASCII + string: ! "\n\n" + http_version: + recorded_at: Wed, 25 Jul 2012 11:55:58 GMT +- request: + method: get + uri: https://vdcadmin%40rhev.lab.eng.brq.redhat.com:123456@rhev30-dc.lab.eng.brq.redhat.com:8443/api/templates/a90de8a2-0619-4625-b72e-db0ff65ef927 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/xml + Accept-Encoding: + - gzip, deflate + Content-Type: + - application/xml + User-Agent: + - Ruby + response: + status: + code: 404 + message: Not Found + headers: + Server: + - Apache-Coyote/1.1 + Content-Type: + - text/html;charset=utf-8 + Content-Length: + - '950' + Date: + - Wed, 25 Jul 2012 11:55:03 GMT + body: + encoding: US-ASCII + string: ! 'JBoss Web/2.1.11.GA - Error report

HTTP + Status 404 -


type Status report

message +

description The requested resource () is not available.


JBoss Web/2.1.11.GA

' + http_version: + recorded_at: Wed, 25 Jul 2012 11:56:08 GMT +recorded_with: VCR 2.1.1 http://git-wip-us.apache.org/repos/asf/deltacloud/blob/02bb895d/server/tests/drivers/rhevm/images_test.rb ---------------------------------------------------------------------- diff --git a/server/tests/drivers/rhevm/images_test.rb b/server/tests/drivers/rhevm/images_test.rb new file mode 100644 index 0000000..28d18b1 --- /dev/null +++ b/server/tests/drivers/rhevm/images_test.rb @@ -0,0 +1,66 @@ +require 'minitest/autorun' + +require_relative File.join('..', '..', '..', 'lib', 'deltacloud', 'api.rb') +require_relative 'common.rb' + +describe 'RhevmDriver Images' do + + before do + @driver = Deltacloud::new(:rhevm, credentials) + VCR.insert_cassette __name__ + end + + after do + VCR.eject_cassette + end + + it 'must throw error when wrong credentials' do + Proc.new do + @driver.backend.images(OpenStruct.new(:user => 'unknown', :password => 'wrong')) + end.must_raise Deltacloud::ExceptionHandler::AuthenticationFailure, 'Authentication Failure' + end + + it 'must return list of images' do + @driver.images.wont_be_empty + @driver.images.first.must_be_kind_of Image + end + + it 'must allow to filter images' do + @driver.images(:id => 'dfa924b7-83e8-4a5c-9d5c-1270fd0c0872').wont_be_empty + @driver.images(:id => 'dfa924b7-83e8-4a5c-9d5c-1270fd0c0872').must_be_kind_of Array + @driver.images(:id => 'dfa924b7-83e8-4a5c-9d5c-1270fd0c0872').size.must_equal 1 + @driver.images(:id => 'dfa924b7-83e8-4a5c-9d5c-1270fd0c0872').first.id.must_equal 'dfa924b7-83e8-4a5c-9d5c-1270fd0c0872' + @driver.images(:owner_id => 'vdcadmin@rhev.lab.eng.brq.redhat.com').each do |img| + img.owner_id.must_equal 'vdcadmin@rhev.lab.eng.brq.redhat.com' + end + @driver.images(:id => 'ami-aaaaaaaa').must_be_empty + @driver.images(:id => 'unknown').must_be_empty + end + + it 'must allow to retrieve single image' do + @driver.image(:id => 'dfa924b7-83e8-4a5c-9d5c-1270fd0c0872').wont_be_nil + @driver.image(:id => 'dfa924b7-83e8-4a5c-9d5c-1270fd0c0872').must_be_kind_of Image + @driver.image(:id => 'dfa924b7-83e8-4a5c-9d5c-1270fd0c0872').id.must_equal 'dfa924b7-83e8-4a5c-9d5c-1270fd0c0872' + @driver.image(:id => 'ami-aaaaaaaa').must_be_nil + @driver.image(:id => 'unknown').must_be_nil + end + + it 'must throw proper exception when destroying used image' do + image = @driver.image(:id => 'dfa924b7-83e8-4a5c-9d5c-1270fd0c0872') + image.wont_be_nil + image.state.must_equal 'OK' + Proc.new { + @driver.destroy_image(image.id) + }.must_raise Deltacloud::ExceptionHandler::BackendError, 'Cannot delete Template. Template is being used by the following VMs: test1.' + end + + it 'must support destroying images' do + image = @driver.image(:id => 'a90de8a2-0619-4625-b72e-db0ff65ef927') + image.wont_be_nil + image.state.must_equal 'OK' + @driver.destroy_image(image.id) + image.wait_for!(@driver) { |img| img.nil? } + end + +end + http://git-wip-us.apache.org/repos/asf/deltacloud/blob/02bb895d/server/tests/drivers/rhevm/instance_test.rb ---------------------------------------------------------------------- diff --git a/server/tests/drivers/rhevm/instance_test.rb b/server/tests/drivers/rhevm/instance_test.rb new file mode 100644 index 0000000..bdcae83 --- /dev/null +++ b/server/tests/drivers/rhevm/instance_test.rb @@ -0,0 +1,104 @@ +require 'minitest/autorun' + +require_relative File.join('..', '..', '..', 'lib', 'deltacloud', 'api.rb') +require_relative 'common.rb' + +describe 'RhevmDriver Instances' do + + before do + @driver = Deltacloud::new(:rhevm, credentials) + VCR.insert_cassette __name__ + end + + after do + VCR.eject_cassette + end + + it 'must throw error when wrong credentials' do + Proc.new do + @driver.backend.images(OpenStruct.new(:user => 'unknown', :password => 'wrong')) + end.must_raise Deltacloud::ExceptionHandler::AuthenticationFailure, 'Authentication Failure' + end + + it 'must return list of instances' do + @driver.instances.wont_be_empty + @driver.instances.first.must_be_kind_of Instance + end + + it 'must allow to filter instances' do + @driver.instances(:id => 'c63758d9-3db6-47ca-8412-4f517946910e').wont_be_empty + @driver.instances(:id => 'c63758d9-3db6-47ca-8412-4f517946910e').must_be_kind_of Array + @driver.instances(:id => 'c63758d9-3db6-47ca-8412-4f517946910e').size.must_equal 1 + @driver.instances(:id => 'c63758d9-3db6-47ca-8412-4f517946910e').first.id.must_equal 'c63758d9-3db6-47ca-8412-4f517946910e' + @driver.instances(:owner_id => 'vdcadmin@rhev.lab.eng.brq.redhat.com').wont_be_empty + @driver.instances(:owner_id => 'vdcadmin@rhev.lab.eng.brq.redhat.com').each do |inst| + inst.owner_id.must_equal 'vdcadmin@rhev.lab.eng.brq.redhat.com' + end + @driver.instances(:id => 'i-00000000').must_be_empty + @driver.instances(:id => 'unknown').must_be_empty + end + + it 'must allow to retrieve single instance' do + @driver.instance(:id => 'c63758d9-3db6-47ca-8412-4f517946910e').wont_be_nil + @driver.instance(:id => 'c63758d9-3db6-47ca-8412-4f517946910e').must_be_kind_of Instance + @driver.instance(:id => 'c63758d9-3db6-47ca-8412-4f517946910e').id.must_equal 'c63758d9-3db6-47ca-8412-4f517946910e' + @driver.instance(:id => 'i-00000000').must_be_nil + @driver.instance(:id => 'unknown').must_be_nil + end + + it 'must allow to create a new instance and destroy it' do + instance = @driver.create_instance('dfa924b7-83e8-4a5c-9d5c-1270fd0c0872', + :realm_id => '3c8af388-cff6-11e0-9267-52540013f702', + :hwp_id => 'SERVER', + :hwp_memory => '1024', + :user_data => 'test user data' + ) + instance = instance.wait_for!(@driver, record_retries) { |i| i.is_stopped? } + instance.must_be_kind_of Instance + instance.is_running?.must_equal false + @driver.instance(:id => instance.id).wont_be_nil + @driver.instance(:id => instance.id).id.must_equal instance.id + @driver.instance(:id => instance.id).name.wont_be_nil + @driver.instance(:id => instance.id).instance_profile.name.must_equal 'SERVER' + @driver.instance(:id => instance.id).instance_profile.memory.must_equal 1024 + @driver.instance(:id => instance.id).realm_id.must_equal '3c8af388-cff6-11e0-9267-52540013f702' + @driver.instance(:id => instance.id).image_id.must_equal 'dfa924b7-83e8-4a5c-9d5c-1270fd0c0872' + @driver.instance(:id => instance.id).owner_id.must_equal 'vdcadmin@rhev.lab.eng.brq.redhat.com' + @driver.instance(:id => instance.id).state.must_equal 'STOPPED' + @driver.instance(:id => instance.id).actions.must_include :start + @driver.destroy_instance(instance.id) + instance.wait_for!(@driver, record_retries('destroy')) { |i| i.nil? } + end + + it 'must allow to create a new instance and make it running' do + instance = @driver.create_instance('5f411ae4-a3cf-48a8-8bca-d049ddd51f0b', + :realm_id => '3c8af388-cff6-11e0-9267-52540013f702', + :hwp_id => 'SERVER', + :hwp_memory => '1024', + :user_data => 'test user data' + ) + instance = instance.wait_for!(@driver, record_retries) { |i| i.is_stopped? } + instance.must_be_kind_of Instance + instance.is_running?.must_equal false + @driver.instance(:id => instance.id).wont_be_nil + @driver.instance(:id => instance.id).id.must_equal instance.id + @driver.instance(:id => instance.id).name.wont_be_nil + @driver.instance(:id => instance.id).instance_profile.name.must_equal 'SERVER' + @driver.instance(:id => instance.id).instance_profile.memory.must_equal 1024 + @driver.instance(:id => instance.id).realm_id.must_equal '3c8af388-cff6-11e0-9267-52540013f702' + @driver.instance(:id => instance.id).image_id.must_equal '5f411ae4-a3cf-48a8-8bca-d049ddd51f0b' + @driver.instance(:id => instance.id).owner_id.must_equal 'vdcadmin@rhev.lab.eng.brq.redhat.com' + @driver.instance(:id => instance.id).state.must_equal 'STOPPED' + @driver.instance(:id => instance.id).actions.must_include :start + @driver.start_instance(instance.id) + instance = instance.wait_for!(@driver, record_retries('start')) { |i| i.is_running? } + @driver.instance(:id => instance.id).state.must_equal 'RUNNING' + Proc.new { @driver.destroy_instance(instance.id) }.must_raise Deltacloud::ExceptionHandler::BackendError, 'Cannot remove VM. VM is running.' + @driver.stop_instance(instance.id) + instance = instance.wait_for!(@driver, record_retries('stop')) { |i| i.is_stopped? } + @driver.instance(:id => instance.id).state.must_equal 'STOPPED' + @driver.destroy_instance(instance.id) + instance.wait_for!(@driver, record_retries('destroy')) { |i| i.nil? } + end + +end http://git-wip-us.apache.org/repos/asf/deltacloud/blob/02bb895d/server/tests/drivers/rhevm/provider_test.rb ---------------------------------------------------------------------- diff --git a/server/tests/drivers/rhevm/provider_test.rb b/server/tests/drivers/rhevm/provider_test.rb new file mode 100644 index 0000000..086cef5 --- /dev/null +++ b/server/tests/drivers/rhevm/provider_test.rb @@ -0,0 +1,48 @@ +require 'minitest/autorun' + +require_relative File.join('..', '..', '..', 'lib', 'deltacloud', 'api.rb') +require_relative 'common.rb' + +describe 'RHEV-M provider test' do + + before do + @driver = Deltacloud::new(:rhevm, credentials) + VCR.insert_cassette __name__ + end + + after do + VCR.eject_cassette + end + + it 'must throw error when using wrong provider' do + wrong_driver = Deltacloud::new(:rhevm, credentials.merge(:provider => 'unknown')) + Proc.new { + wrong_driver.realms + }.must_raise Deltacloud::ExceptionHandler::BackendError + end + + it 'must support listing of available providers' do + @driver.providers.wont_be_empty + @driver.providers.each { |p| p.must_be_kind_of Provider } + @driver.providers.each { |p| p.name.wont_be_empty } + @driver.providers.each { |p| p.id.wont_be_empty } + @driver.providers.each { |p| p.url.wont_be_empty } + end + + it 'must switch realms when switching between different clusters' do + + provider1 = @driver.provider(:id => 'aa585157-a098-48c3-8b5b-70a32e88c263') + provider1.wont_be_nil + provider1.url.wont_be_empty + + provider2 = @driver.provider(:id => '645e425e-66fe-4ac9-8874-537bd10ef08d') + provider2.wont_be_nil + provider2.url.wont_be_empty + + drv1 = Deltacloud::new(:rhevm, credentials.merge(:provider => provider1.url)) + drv2 = Deltacloud::new(:rhevm, credentials.merge(:provider => provider2.url)) + + drv1.realms.map { |r| r.id }.wont_include drv2.realms.map { |r| r.id } + end + +end http://git-wip-us.apache.org/repos/asf/deltacloud/blob/02bb895d/server/tests/drivers/rhevm/realms_test.rb ---------------------------------------------------------------------- diff --git a/server/tests/drivers/rhevm/realms_test.rb b/server/tests/drivers/rhevm/realms_test.rb new file mode 100644 index 0000000..492d667 --- /dev/null +++ b/server/tests/drivers/rhevm/realms_test.rb @@ -0,0 +1,43 @@ +require 'minitest/autorun' + +require_relative File.join('..', '..', '..', 'lib', 'deltacloud', 'api.rb') +require_relative 'common.rb' + +describe 'RhevmDriver Realms' do + + before do + @driver = Deltacloud::new(:rhevm, credentials) + VCR.insert_cassette __name__ + end + + after do + VCR.eject_cassette + end + + it 'must throw error when wrong credentials' do + Proc.new do + @driver.backend.realms(OpenStruct.new(:user => 'unknown', :password => 'wrong')) + end.must_raise Deltacloud::ExceptionHandler::AuthenticationFailure, 'Authentication Failure' + end + + it 'must return list of realms' do + @driver.realms.wont_be_empty + @driver.realms.first.must_be_kind_of Realm + end + + it 'must allow to filter realms' do + @driver.realms(:id => '3c8af388-cff6-11e0-9267-52540013f702').wont_be_empty + @driver.realms(:id => '3c8af388-cff6-11e0-9267-52540013f702').must_be_kind_of Array + @driver.realms(:id => '3c8af388-cff6-11e0-9267-52540013f702').size.must_equal 1 + @driver.realms(:id => '3c8af388-cff6-11e0-9267-52540013f702').first.id.must_equal '3c8af388-cff6-11e0-9267-52540013f702' + @driver.realms(:id => 'unknown').must_be_empty + end + + it 'must allow to retrieve single realm' do + @driver.realm(:id => '3c8af388-cff6-11e0-9267-52540013f702').wont_be_nil + @driver.realm(:id => '3c8af388-cff6-11e0-9267-52540013f702').must_be_kind_of Realm + @driver.realm(:id => 'unknown').must_be_nil + end + +end +