deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject [7/41] Revamp RHEV-M driver tests and rerecord them
Date Mon, 11 Mar 2013 21:36:15 GMT
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/861156f8/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
index ee4c144..fd90b07 100644
--- 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
@@ -1,326 +1,46 @@
---- 
-http_interactions: 
-- request: 
+---
+http_interactions:
+- request:
     method: get
-    uri: https://admin%40internal:redhat@dell-per610-02.lab.eng.brq.redhat.com/api/templates/fe9dcb11-a035-4d80-89b4-a4092a892505
-    body: 
-      string: ""
-    headers: 
-      Content-Type: 
-      - application/xml
-      Accept: 
-      - application/xml
-      Accept-Encoding: 
-      - gzip, deflate
-  response: 
-    status: 
-      code: 200
-      message: OK
-    headers: 
-      Set-Cookie: 
-      - JSESSIONID=KRgJA8U+Dyfy2CrhDYcE68Mb; Path=/api; Secure
-      Content-Type: 
-      - application/xml
-      Pragma: 
-      - No-cache
-      Expires: 
-      - Thu, 01 Jan 1970 01:00:00 CET
-      Date: 
-      - Fri, 09 Nov 2012 08:56:05 GMT
-      Content-Length: 
-      - "1574"
-      Connection: 
-      - close
-      Cache-Control: 
-      - no-cache
-    body: 
-      string: |
-        <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-        <template href="/api/templates/fe9dcb11-a035-4d80-89b4-a4092a892505" id="fe9dcb11-a035-4d80-89b4-a4092a892505">
-            <actions>
-                <link href="/api/templates/fe9dcb11-a035-4d80-89b4-a4092a892505/export"
rel="export"/>
-            </actions>
-            <name>e55f531b-500d-4f7b-aff3-39cd9edda6f7</name>
-            <description>Template by iwhd</description>
-            <link href="/api/templates/fe9dcb11-a035-4d80-89b4-a4092a892505/disks" rel="disks"/>
-            <link href="/api/templates/fe9dcb11-a035-4d80-89b4-a4092a892505/nics" rel="nics"/>
-            <link href="/api/templates/fe9dcb11-a035-4d80-89b4-a4092a892505/cdroms" rel="cdroms"/>
-            <link href="/api/templates/fe9dcb11-a035-4d80-89b4-a4092a892505/permissions"
rel="permissions"/>
-            <type>server</type>
-            <status>
-                <state>ok</state>
-            </status>
-            <memory>536870912</memory>
-            <cpu>
-                <topology sockets="1" cores="1"/>
-            </cpu>
-            <os type="other_linux">
-                <boot dev="cdrom"/>
-                <boot dev="hd"/>
-            </os>
-            <cluster href="/api/clusters/99408929-82cf-4dc7-a532-9d998063fa95" id="99408929-82cf-4dc7-a532-9d998063fa95"/>
-            <creation_time>2012-09-24T13:07:37.000+02:00</creation_time>
-            <origin>rhev</origin>
-            <high_availability>
-                <enabled>false</enabled>
-                <priority>0</priority>
-            </high_availability>
-            <display>
-                <type>vnc</type>
-                <monitors>1</monitors>
-                <allow_override>false</allow_override>
-            </display>
-            <stateless>false</stateless>
-            <usb>
-                <enabled>false</enabled>
-            </usb>
-        </template>
-
-    http_version: 
-  recorded_at: Fri, 09 Nov 2012 08:56:06 GMT
-- request: 
-    method: delete
-    uri: https://admin%40internal:redhat@dell-per610-02.lab.eng.brq.redhat.com/api/templates/fe9dcb11-a035-4d80-89b4-a4092a892505
-    body: 
-      string: ""
-    headers: 
-      Accept: 
-      - application/xml
-      Accept-Encoding: 
-      - gzip, deflate
-  response: 
-    status: 
-      code: 400
-      message: Bad Request
-    headers: 
-      Content-Type: 
-      - application/xml
-      Date: 
-      - Fri, 09 Nov 2012 08:56:05 GMT
-      Content-Length: 
-      - "217"
-      Connection: 
-      - close
-    body: 
-      string: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><fault><reason>Operation
Failed</reason><detail>[Cannot delete Template. Template is being used by the
following VMs: rhevm1-jprovazn-09-rhevm1.]</detail></fault>"
-    http_version: 
-  recorded_at: Fri, 09 Nov 2012 08:56:06 GMT
-- request: 
-    method: get
-    uri: https://admin%40internal:redhat@dell-per610-02.lab.eng.brq.redhat.com/api/templates/5472e759-dee1-4e90-a2bf-79b61a601e80
-    body: 
-      string: ""
-    headers: 
-      Content-Type: 
-      - application/xml
-      Accept: 
-      - application/xml
-      Accept-Encoding: 
+    uri: https://fakeuser:fakepassword@rhevm.example.com/api/templates/5472e759-dee1-4e90-a2bf-79b61a601e80
+    body:
+      encoding: US-ASCII
+      string: ''
+    headers:
+      Accept:
+      - application/xml
+      Accept-Encoding:
       - gzip, deflate
-  response: 
-    status: 
-      code: 200
-      message: OK
-    headers: 
-      Set-Cookie: 
-      - JSESSIONID=bww6+N6Ah11Efz3lihkL4P-d; Path=/api; Secure
-      Content-Type: 
+      Content-Type:
       - application/xml
-      Pragma: 
-      - No-cache
-      Expires: 
-      - Thu, 01 Jan 1970 01:00:00 CET
-      Date: 
-      - Fri, 09 Nov 2012 08:57:44 GMT
-      Content-Length: 
-      - "1498"
-      Connection: 
-      - close
-      Cache-Control: 
-      - no-cache
-    body: 
-      string: |
-        <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-        <template href="/api/templates/5472e759-dee1-4e90-a2bf-79b61a601e80" id="5472e759-dee1-4e90-a2bf-79b61a601e80">
-            <actions>
-                <link href="/api/templates/5472e759-dee1-4e90-a2bf-79b61a601e80/export"
rel="export"/>
-            </actions>
-            <name>test</name>
-            <link href="/api/templates/5472e759-dee1-4e90-a2bf-79b61a601e80/disks" rel="disks"/>
-            <link href="/api/templates/5472e759-dee1-4e90-a2bf-79b61a601e80/nics" rel="nics"/>
-            <link href="/api/templates/5472e759-dee1-4e90-a2bf-79b61a601e80/cdroms" rel="cdroms"/>
-            <link href="/api/templates/5472e759-dee1-4e90-a2bf-79b61a601e80/permissions"
rel="permissions"/>
-            <type>server</type>
-            <status>
-                <state>ok</state>
-            </status>
-            <memory>536870912</memory>
-            <cpu>
-                <topology sockets="1" cores="1"/>
-            </cpu>
-            <os type="other_linux">
-                <boot dev="network"/>
-                <boot dev="hd"/>
-            </os>
-            <cluster href="/api/clusters/99408929-82cf-4dc7-a532-9d998063fa95" id="99408929-82cf-4dc7-a532-9d998063fa95"/>
-            <creation_time>2012-11-09T09:56:44.989+01:00</creation_time>
-            <origin>rhev</origin>
-            <high_availability>
-                <enabled>false</enabled>
-                <priority>1</priority>
-            </high_availability>
-            <display>
-                <type>spice</type>
-                <monitors>1</monitors>
-                <allow_override>false</allow_override>
-            </display>
-            <stateless>false</stateless>
-            <usb>
-                <enabled>false</enabled>
-            </usb>
-        </template>
-
-    http_version: 
-  recorded_at: Fri, 09 Nov 2012 08:57:45 GMT
-- request: 
-    method: delete
-    uri: https://admin%40internal:redhat@dell-per610-02.lab.eng.brq.redhat.com/api/templates/5472e759-dee1-4e90-a2bf-79b61a601e80
-    body: 
-      string: ""
-    headers: 
-      Accept: 
-      - application/xml
-      Accept-Encoding: 
-      - gzip, deflate
-  response: 
-    status: 
-      code: 200
-      message: OK
-    headers: 
-      Set-Cookie: 
-      - JSESSIONID=BiYhU+8Xzl4EId-87uK7xfQw; Path=/api; Secure
-      Content-Type: 
-      - text/plain; charset=UTF-8
-      Pragma: 
-      - No-cache
-      Expires: 
-      - Thu, 01 Jan 1970 01:00:00 CET
-      Date: 
-      - Fri, 09 Nov 2012 08:57:44 GMT
-      Content-Length: 
-      - "0"
-      Connection: 
-      - close
-      Cache-Control: 
-      - no-cache
-    body: 
-      string: ""
-    http_version: 
-  recorded_at: Fri, 09 Nov 2012 08:57:45 GMT
-- request: 
-    method: get
-    uri: https://admin%40internal:redhat@dell-per610-02.lab.eng.brq.redhat.com/api/templates/5472e759-dee1-4e90-a2bf-79b61a601e80
-    body: 
-      string: ""
-    headers: 
-      Content-Type: 
-      - application/xml
-      Accept: 
-      - application/xml
-      Accept-Encoding: 
-      - gzip, deflate
-  response: 
-    status: 
-      code: 200
-      message: OK
-    headers: 
-      Set-Cookie: 
-      - JSESSIONID=4jQAIdMVUkJAJ+TLw5qgGxWC; Path=/api; Secure
-      Content-Type: 
-      - application/xml
-      Pragma: 
-      - No-cache
-      Expires: 
-      - Thu, 01 Jan 1970 01:00:00 CET
-      Date: 
-      - Fri, 09 Nov 2012 08:57:44 GMT
-      Content-Length: 
-      - "1502"
-      Connection: 
-      - close
-      Cache-Control: 
-      - no-cache
-    body: 
-      string: |
-        <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-        <template href="/api/templates/5472e759-dee1-4e90-a2bf-79b61a601e80" id="5472e759-dee1-4e90-a2bf-79b61a601e80">
-            <actions>
-                <link href="/api/templates/5472e759-dee1-4e90-a2bf-79b61a601e80/export"
rel="export"/>
-            </actions>
-            <name>test</name>
-            <link href="/api/templates/5472e759-dee1-4e90-a2bf-79b61a601e80/disks" rel="disks"/>
-            <link href="/api/templates/5472e759-dee1-4e90-a2bf-79b61a601e80/nics" rel="nics"/>
-            <link href="/api/templates/5472e759-dee1-4e90-a2bf-79b61a601e80/cdroms" rel="cdroms"/>
-            <link href="/api/templates/5472e759-dee1-4e90-a2bf-79b61a601e80/permissions"
rel="permissions"/>
-            <type>server</type>
-            <status>
-                <state>locked</state>
-            </status>
-            <memory>536870912</memory>
-            <cpu>
-                <topology sockets="1" cores="1"/>
-            </cpu>
-            <os type="other_linux">
-                <boot dev="network"/>
-                <boot dev="hd"/>
-            </os>
-            <cluster href="/api/clusters/99408929-82cf-4dc7-a532-9d998063fa95" id="99408929-82cf-4dc7-a532-9d998063fa95"/>
-            <creation_time>2012-11-09T09:56:44.989+01:00</creation_time>
-            <origin>rhev</origin>
-            <high_availability>
-                <enabled>false</enabled>
-                <priority>1</priority>
-            </high_availability>
-            <display>
-                <type>spice</type>
-                <monitors>1</monitors>
-                <allow_override>false</allow_override>
-            </display>
-            <stateless>false</stateless>
-            <usb>
-                <enabled>false</enabled>
-            </usb>
-        </template>
-
-    http_version: 
-  recorded_at: Fri, 09 Nov 2012 08:57:46 GMT
-- request: 
-    method: get
-    uri: https://admin%40internal:redhat@dell-per610-02.lab.eng.brq.redhat.com/api/templates/5472e759-dee1-4e90-a2bf-79b61a601e80
-    body: 
-      string: ""
-    headers: 
-      Content-Type: 
-      - application/xml
-      Accept: 
-      - application/xml
-      Accept-Encoding: 
-      - gzip, deflate
-  response: 
-    status: 
+      User-Agent:
+      - Ruby
+  response:
+    status:
       code: 404
       message: Not Found
-    headers: 
-      Content-Type: 
+    headers:
+      Date:
+      - Thu, 07 Mar 2013 22:03:53 GMT
+      Content-Type:
       - text/html;charset=utf-8
-      Date: 
-      - Fri, 09 Nov 2012 08:57:55 GMT
-      Content-Length: 
-      - "976"
-      Connection: 
+      Content-Length:
+      - '976'
+      Connection:
       - close
-    body: 
-      string: "<html><head><title>JBoss Web/7.0.16..Final-redhat-1 - 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/7.0.16..Final-redhat-1</h3></body></htm
 l>"
+    body:
+      encoding: US-ASCII
+      string: ! '<html><head><title>JBoss Web/7.0.16..Final-redhat-1 -
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/7.0.16..Final-redhat-1</h3></body></html>'
     http_version: 
-  recorded_at: Fri, 09 Nov 2012 08:57:56 GMT
-recorded_with: VCR 2.2.5
+  recorded_at: Thu, 07 Mar 2013 22:03:53 GMT
+recorded_with: VCR 2.4.0

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/861156f8/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
index 7241667..e60cc4d 100644
--- a/server/tests/drivers/rhevm/images_test.rb
+++ b/server/tests/drivers/rhevm/images_test.rb
@@ -6,7 +6,10 @@ require_relative 'common'
 describe 'RhevmDriver Images' do
 
   before do
-    @driver = Deltacloud::new(:rhevm, credentials)
+    prefs = Deltacloud::Test::config.preferences(:rhevm)
+    @template_id = prefs["template"]
+
+    @driver = Deltacloud::Test::config.driver(:rhevm)
     VCR.insert_cassette __name__
   end
 
@@ -26,12 +29,14 @@ describe 'RhevmDriver Images' do
   end
 
   it 'must allow to filter images' do
-    @driver.images(:id => '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5').wont_be_empty
-    @driver.images(:id => '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5').must_be_kind_of Array
-    @driver.images(:id => '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5').size.must_equal 1
-    @driver.images(:id => '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5').first.id.must_equal
'5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5'
-    @driver.images(:owner_id => 'admin@internal').each do |img|
-      img.owner_id.must_equal 'admin@internal'
+    imgs = @driver.images(:id => @template_id)
+    imgs.wont_be_empty
+    imgs.must_be_kind_of Array
+    imgs.size.must_equal 1
+    imgs.first.id.must_equal @template_id
+    owner_id = imgs.first.owner_id
+    @driver.images(:owner_id => owner_id).each do |img|
+      img.owner_id.must_equal owner_id
     end
     @driver.images(:id => 'ami-aaaaaaaa').must_be_empty
     @driver.images(:id => 'unknown').must_be_empty
@@ -42,9 +47,10 @@ describe 'RhevmDriver Images' do
     # of YAML under Ruby 1.8.
     #
     if RUBY_VERSION =~ /^1\.9/
-      @driver.image(:id => '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5').wont_be_nil
-      @driver.image(:id => '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5').must_be_kind_of Image
-      @driver.image(:id => '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5').id.must_equal '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5'
+      img = @driver.image(:id => @template_id)
+      img.wont_be_nil
+      img.must_be_kind_of Image
+      img.id.must_equal @template_id
       @driver.image(:id => 'ami-aaaaaaaa').must_be_nil
       @driver.image(:id => 'unknown').must_be_nil
     end
@@ -52,7 +58,7 @@ describe 'RhevmDriver Images' do
 
   it 'must throw proper exception when destroying used image' do
     if RUBY_VERSION =~ /^1\.9/
-      image = @driver.image(:id => '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5')
+      image = @driver.image(:id => @template_id)
       image.wont_be_nil
       image.state.must_equal 'OK'
       Proc.new {
@@ -62,6 +68,8 @@ describe 'RhevmDriver Images' do
   end
 
   it 'must support destroying images' do
+    skip "Depends on hardcoded image"
+    # FIXME: we need to create a new image here, and then destroy it
     image = @driver.image(:id => '5472e759-dee1-4e90-a2bf-79b61a601e80')
     image.wont_be_nil
     image.state.must_equal 'OK'

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/861156f8/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
index 382cd4a..b6b09e9 100644
--- a/server/tests/drivers/rhevm/instance_test.rb
+++ b/server/tests/drivers/rhevm/instance_test.rb
@@ -3,16 +3,15 @@ require 'require_relative' if RUBY_VERSION < '1.9'
 
 require_relative 'common.rb'
 
-TST_REALM    = 'b91b0346-4ba3-11e2-a3ac-0050568c6b2d'
-TST_INSTANCE = '28c7428b-834a-46b6-8d21-bf350e00e3d7'
-TST_IMAGE    = '3cd2891a-9a0f-44c8-8dec-6280efa278e3'
-
 describe 'RhevmDriver Instances' do
 
   before do
-    # Read credentials from ${HOME/.deltacloud/config
-    @driver = Deltacloud::Test::config.driver(:rhevm,
-      provider="https://10.16.120.71/api;b9bb11c2-f397-4f41-a57b-7ac15a894779")
+    prefs = Deltacloud::Test::config.preferences(:rhevm)
+    @dc_id = prefs["datacenter"]
+    @vm_id = prefs["vm"]
+    @template_id = prefs["template"]
+
+    @driver = Deltacloud::Test::config.driver(:rhevm)
     VCR.insert_cassette __name__
   end
 
@@ -32,26 +31,27 @@ describe 'RhevmDriver Instances' do
   end
 
   it 'must allow to filter instances' do
-    @driver.instances(:id =>TST_INSTANCE).wont_be_empty
-    @driver.instances(:id =>TST_INSTANCE).must_be_kind_of Array
-    @driver.instances(:id =>TST_INSTANCE).size.must_equal 1
-    @driver.instances(:id => TST_INSTANCE).first.id.must_equal TST_INSTANCE
+    insts = @driver.instances(:id =>@vm_id)
+    insts.wont_be_empty
+    insts.must_be_kind_of Array
+    insts.size.must_equal 1
+    insts.first.id.must_equal @vm_id
     @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 => TST_INSTANCE).wont_be_nil
-    @driver.instance(:id => TST_INSTANCE).wont_be_nil
-    @driver.instance(:id => TST_INSTANCE).must_be_kind_of Instance
-    @driver.instance(:id => TST_INSTANCE).id.must_equal TST_INSTANCE
+    inst = @driver.instance(:id => @vm_id)
+    inst.wont_be_nil
+    inst.must_be_kind_of Instance
+    inst.id.must_equal @vm_id
     @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(TST_IMAGE,
-                                       :realm_id => TST_REALM,
+    instance = @driver.create_instance(@template_id,
+                                       :realm_id => @dc_id,
                                        :hwp_id => 'SERVER',
                                        :hwp_memory => '1024',
                                        :user_data => 'test user data'
@@ -59,23 +59,25 @@ describe 'RhevmDriver Instances' do
     instance = instance.wait_for!(@driver, record_retries('', :timeout => 60)) { |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 TST_REALM
-    @driver.instance(:id => instance.id).image_id.must_equal TST_IMAGE
-    @driver.instance(:id => instance.id).state.must_equal 'STOPPED'
-    @driver.instance(:id => instance.id).actions.must_include :start
+
+    inst = @driver.instance(:id => instance.id)
+    inst.wont_be_nil
+    inst.id.must_equal instance.id
+    inst.name.wont_be_nil
+    inst.instance_profile.name.must_equal 'SERVER'
+    inst.instance_profile.memory.must_equal 1024
+    inst.realm_id.must_equal @dc_id
+    inst.image_id.must_equal @template_id
+    inst.state.must_equal 'STOPPED'
+    inst.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(TST_IMAGE,
-                                       :realm_id => TST_REALM,
+    instance = @driver.create_instance(@template_id,
+                                       :realm_id => @dc_id,
                                        :hwp_id => 'SERVER',
                                        :hwp_memory => '1024',
                                        :user_data => 'test user data'
@@ -84,25 +86,33 @@ describe 'RhevmDriver Instances' do
     skip "Skip this test due to RHEVm bug: https://bugzilla.redhat.com/show_bug.cgi?id=910741"
     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 TST_REALM
-    @driver.instance(:id => instance.id).image_id.must_equal TST_IMAGE
-    @driver.instance(:id => instance.id).state.must_equal 'STOPPED'
-    @driver.instance(:id => instance.id).actions.must_include :start
+
+    inst = @driver.instance(:id => instance.id)
+    inst.wont_be_nil
+    inst.id.must_equal instance.id
+    inst.name.wont_be_nil
+    inst.instance_profile.name.must_equal 'SERVER'
+    inst.instance_profile.memory.must_equal 1024
+    inst.realm_id.must_equal @dc_id
+    inst.image_id.must_equal @template_id
+    inst.state.must_equal 'STOPPED'
+    inst.actions.must_include :start
+
     @driver.start_instance(instance.id)
     instance = instance.wait_for!(@driver, record_retries('start', :timeout => 60)) {
|i| i.is_running? }
-    @driver.instance(:id => instance.id).state.must_equal 'RUNNING'
-    @driver.instance(:id => instance.id).actions.must_include :stop
+
+    inst = @driver.instance(:id => instance.id)
+    inst.state.must_equal 'RUNNING'
+    inst.actions.must_include :stop
+
     Proc.new do
       @driver.destroy_instance(instance.id)
     end.must_raise Deltacloud::Exceptions::BackendError, 'Cannot remove VM. VM is running.'
+
     @driver.stop_instance(instance.id)
     instance = instance.wait_for!(@driver, record_retries('stop', :timeout => 60)) { |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', :timeout => 60)) { |i| i.nil?
}
   end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/861156f8/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
index bde6621..5a1e45a 100644
--- a/server/tests/drivers/rhevm/provider_test.rb
+++ b/server/tests/drivers/rhevm/provider_test.rb
@@ -6,7 +6,8 @@ require_relative 'common.rb'
 describe 'RHEV-M provider test' do
 
   before do
-    @driver = Deltacloud::new(:rhevm, credentials)
+    @config = Deltacloud::Test::config
+    @driver = @config.driver(:rhevm)
     VCR.insert_cassette __name__
   end
 
@@ -15,7 +16,9 @@ describe 'RHEV-M provider test' do
   end
 
   it 'must throw error when using wrong provider' do
-    wrong_driver = Deltacloud::new(:rhevm, credentials.merge(:provider => 'unknown'))
+    creds = @config.credentials(:rhevm).merge(:provider => 'unknown')
+    creds[:provider] = 'unknown'
+    wrong_driver = Deltacloud::new(:rhevm, creds)
     Proc.new {
       wrong_driver.realms
     }.must_raise Deltacloud::Exceptions::BackendError
@@ -30,12 +33,15 @@ describe 'RHEV-M provider test' do
   end
 
   it 'must switch realms when switching between different clusters' do
-
-    provider1 = @driver.provider(:id => '9df72b84-0234-11e2-9b87-9386d9b09d4a')
+    provs = @driver.providers
+    if provs.size < 2
+      skip "We need at least two providers (clusters)"
+    end
+    provider1 = provs[0]
     provider1.wont_be_nil
     provider1.url.wont_be_empty
 
-    provider2 = @driver.provider(:id => '9df72b84-0234-11e2-9b87-9386d9b09d4a')
+    provider2 = provs[1]
     provider2.wont_be_nil
     provider2.url.wont_be_empty
 

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/861156f8/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
index 577605d..d830ce1 100644
--- a/server/tests/drivers/rhevm/realms_test.rb
+++ b/server/tests/drivers/rhevm/realms_test.rb
@@ -6,7 +6,10 @@ require_relative 'common.rb'
 describe 'RhevmDriver Realms' do
 
   before do
-    @driver = Deltacloud::new(:rhevm, credentials)
+    prefs = Deltacloud::Test::config.preferences(:rhevm)
+    @dc_id = prefs["datacenter"]
+
+    @driver = Deltacloud::Test::config.driver(:rhevm)
     VCR.insert_cassette __name__
   end
 
@@ -21,21 +24,24 @@ describe 'RhevmDriver Realms' do
   end
 
   it 'must return list of realms' do
-    @driver.realms.wont_be_empty
-    @driver.realms.first.must_be_kind_of Realm
+    realms = @driver.realms
+    realms.wont_be_empty
+    realms.first.must_be_kind_of Realm
   end
 
   it 'must allow to filter realms' do
-    @driver.realms(:id => '99408929-82cf-4dc7-a532-9d998063fa95').wont_be_empty
-    @driver.realms(:id => '99408929-82cf-4dc7-a532-9d998063fa95').must_be_kind_of Array
-    @driver.realms(:id => '99408929-82cf-4dc7-a532-9d998063fa95').size.must_equal 1
-    @driver.realms(:id => '99408929-82cf-4dc7-a532-9d998063fa95').first.id.must_equal
'99408929-82cf-4dc7-a532-9d998063fa95'
+    realms = @driver.realms(:id => @dc_id)
+    realms.wont_be_empty
+    realms.must_be_kind_of Array
+    realms.size.must_equal 1
+    realms.first.id.must_equal @dc_id
     @driver.realms(:id => 'unknown').must_be_empty
   end
 
   it 'must allow to retrieve single realm' do
-    @driver.realm(:id => '99408929-82cf-4dc7-a532-9d998063fa95').wont_be_nil
-    @driver.realm(:id => '99408929-82cf-4dc7-a532-9d998063fa95').must_be_kind_of Realm
+    realm = @driver.realm(:id => @dc_id)
+    realm.wont_be_nil
+    realm.must_be_kind_of Realm
     @driver.realm(:id => 'unknown').must_be_nil
   end
 


Mime
View raw message