deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [50/50] [abbrv] Core: Added initial RHEV-M unit tests
Date Mon, 30 Jul 2012 14:29:18 GMT
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: ! '<html><head><title>JBoss Web/2.1.11.GA - Error report</title><style><!--H1
+        {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
+        H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}
+        H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}
+        BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;}
+        B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;}
+        P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A
+        {color : black;}A.name {color : black;}HR {color : #525D76;}--></style>
</head><body><h1>HTTP
+        Status 404 - </h1><HR size="1" noshade="noshade"><p><b>type</b>
Status report</p><p><b>message</b>
+        <u></u></p><p><b>description</b> <u>The
requested resource () is not available.</u></p><HR
+        size="1" noshade="noshade"><h3>JBoss Web/2.1.11.GA</h3></body></html>'
+    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: ! "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<template
+        id=\"a90de8a2-0619-4625-b72e-db0ff65ef927\" href=\"/api/templates/a90de8a2-0619-4625-b72e-db0ff65ef927\">\n
+        \   <name>6fd96121-1c8c-4bb6-8dbd-e33c470d7769</name>\n    <description>Template
+        by iwhd</description>\n    <actions>\n        <link rel=\"export\"
href=\"/api/templates/a90de8a2-0619-4625-b72e-db0ff65ef927/export\"/>\n
+        \   </actions>\n    <link rel=\"disks\" href=\"/api/templates/a90de8a2-0619-4625-b72e-db0ff65ef927/disks\"/>\n
+        \   <link rel=\"nics\" href=\"/api/templates/a90de8a2-0619-4625-b72e-db0ff65ef927/nics\"/>\n
+        \   <link rel=\"cdroms\" href=\"/api/templates/a90de8a2-0619-4625-b72e-db0ff65ef927/cdroms\"/>\n
+        \   <link rel=\"snapshots\" href=\"/api/templates/a90de8a2-0619-4625-b72e-db0ff65ef927/snapshots\"/>\n
+        \   <link rel=\"tags\" href=\"/api/templates/a90de8a2-0619-4625-b72e-db0ff65ef927/tags\"/>\n
+        \   <link rel=\"permissions\" href=\"/api/templates/a90de8a2-0619-4625-b72e-db0ff65ef927/permissions\"/>\n
+        \   <link rel=\"statistics\" href=\"/api/templates/a90de8a2-0619-4625-b72e-db0ff65ef927/statistics\"/>\n
+        \   <type>server</type>\n    <status>\n        <state>ok</state>\n
   </status>\n
+        \   <memory>536870912</memory>\n    <cpu>\n        <topology
cores=\"1\" sockets=\"1\"/>\n
+        \   </cpu>\n    <os type=\"other_linux\">\n        <boot dev=\"cdrom\"/>\n
+        \       <boot dev=\"hd\"/>\n    </os>\n    <cluster id=\"3c8af388-cff6-11e0-9267-52540013f702\"
+        href=\"/api/clusters/3c8af388-cff6-11e0-9267-52540013f702\"/>\n    <creation_time>2012-01-17T12:33:41.000+01:00</creation_time>\n
+        \   <origin>rhev</origin>\n    <high_availability>\n        <enabled>false</enabled>\n
+        \       <priority>0</priority>\n    </high_availability>\n    <display>\n
+        \       <type>vnc</type>\n        <monitors>1</monitors>\n
   </display>\n
+        \   <stateless>false</stateless>\n    <usb>\n        <enabled>true</enabled>\n
+        \   </usb>\n</template>\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: ! "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<template
+        id=\"a90de8a2-0619-4625-b72e-db0ff65ef927\" href=\"/api/templates/a90de8a2-0619-4625-b72e-db0ff65ef927\">\n
+        \   <name>6fd96121-1c8c-4bb6-8dbd-e33c470d7769</name>\n    <description>Template
+        by iwhd</description>\n    <actions>\n        <link rel=\"export\"
href=\"/api/templates/a90de8a2-0619-4625-b72e-db0ff65ef927/export\"/>\n
+        \   </actions>\n    <link rel=\"disks\" href=\"/api/templates/a90de8a2-0619-4625-b72e-db0ff65ef927/disks\"/>\n
+        \   <link rel=\"nics\" href=\"/api/templates/a90de8a2-0619-4625-b72e-db0ff65ef927/nics\"/>\n
+        \   <link rel=\"cdroms\" href=\"/api/templates/a90de8a2-0619-4625-b72e-db0ff65ef927/cdroms\"/>\n
+        \   <link rel=\"snapshots\" href=\"/api/templates/a90de8a2-0619-4625-b72e-db0ff65ef927/snapshots\"/>\n
+        \   <link rel=\"tags\" href=\"/api/templates/a90de8a2-0619-4625-b72e-db0ff65ef927/tags\"/>\n
+        \   <link rel=\"permissions\" href=\"/api/templates/a90de8a2-0619-4625-b72e-db0ff65ef927/permissions\"/>\n
+        \   <link rel=\"statistics\" href=\"/api/templates/a90de8a2-0619-4625-b72e-db0ff65ef927/statistics\"/>\n
+        \   <type>server</type>\n    <status>\n        <state>locked</state>\n
   </status>\n
+        \   <memory>536870912</memory>\n    <cpu>\n        <topology
cores=\"1\" sockets=\"1\"/>\n
+        \   </cpu>\n    <os type=\"other_linux\">\n        <boot dev=\"cdrom\"/>\n
+        \       <boot dev=\"hd\"/>\n    </os>\n    <cluster id=\"3c8af388-cff6-11e0-9267-52540013f702\"
+        href=\"/api/clusters/3c8af388-cff6-11e0-9267-52540013f702\"/>\n    <creation_time>2012-01-17T12:33:41.000+01:00</creation_time>\n
+        \   <origin>rhev</origin>\n    <high_availability>\n        <enabled>false</enabled>\n
+        \       <priority>0</priority>\n    </high_availability>\n    <display>\n
+        \       <type>vnc</type>\n        <monitors>1</monitors>\n
   </display>\n
+        \   <stateless>false</stateless>\n    <usb>\n        <enabled>true</enabled>\n
+        \   </usb>\n</template>\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: ! '<html><head><title>JBoss Web/2.1.11.GA - Error report</title><style><!--H1
+        {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
+        H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}
+        H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}
+        BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;}
+        B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;}
+        P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A
+        {color : black;}A.name {color : black;}HR {color : #525D76;}--></style>
</head><body><h1>HTTP
+        Status 404 - </h1><HR size="1" noshade="noshade"><p><b>type</b>
Status report</p><p><b>message</b>
+        <u></u></p><p><b>description</b> <u>The
requested resource () is not available.</u></p><HR
+        size="1" noshade="noshade"><h3>JBoss Web/2.1.11.GA</h3></body></html>'
+    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
+


Mime
View raw message