[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Ovirt-devel] [Patch] VM Creation Test



Attached in this patch is an interface test used to run through and
verify the vm creation process, as well as updates to the test fixtures
to support it. Also included is a small fix to storage_volume.rb for a
bug which I discovered, where upon retrieval of the storage pool list
when creating a new vm, the include_vm variable (created /  passed in
via the vm controller only when the vm id specified by the interface is
not null, as it is when we're creating (eg. not updating) a vm) is null
and thus an exception is being thrown. I've been attempting to figure
out how to proceed with the start vm test, but I am still a bit confused
about how to satisfy the storage requirements for a vm I want to start.
With this patch, all the resources / quotas requirements are satisfied,
and the new vm is created, but this is perpretually in the 'pending'
state, and I'm not sure how to start / instruct taskomatic to change
this. Furthermore I don't see a newly created vm on node 3, and am still
unsure about the correct storage pool / volume parameters to set in the
test fixtures in order to set the vm's storage to something it can
access. Any help / pointers would be appreciated.

The selenium test that is included should also serve as a good guide for
anyone else wanting to write interface tests of your own. A tutorial on
how to do this is still on my list of things to do, but this guide shows
all the basics, eg clicking on links, filling in input, waiting for
elements to load, verifying page contents, etc. The complete selenium
ruby API is available here
http://release.openqa.org/selenium-remote-control/0.9.2/doc/ruby/  and
the selenium reference  here http://selenium-core.openqa.org/reference.html

   -Mo
>From e9dcdf727945ace17fbcaf1331471c465dbbdc26 Mon Sep 17 00:00:00 2001
From: Mohammed Morsi <mmorsi redhat com>
Date: Tue, 19 Aug 2008 16:04:41 -0400
Subject: [PATCH] vm creation test, bug fix to storage volume model, fixture improvements / changes

---
 wui/src/app/models/storage_volume.rb      |    2 +-
 wui/src/test/fixtures/quotas.yml          |    4 +-
 wui/src/test/fixtures/storage_pools.yml   |    9 ++++
 wui/src/test/functional/interface_test.rb |   62 ++++++++++++++++++++++++++++-
 4 files changed, 73 insertions(+), 4 deletions(-)

diff --git a/wui/src/app/models/storage_volume.rb b/wui/src/app/models/storage_volume.rb
index ccc5839..4044a13 100644
--- a/wui/src/app/models/storage_volume.rb
+++ b/wui/src/app/models/storage_volume.rb
@@ -53,7 +53,7 @@ class StorageVolume < ActiveRecord::Base
   def self.find_for_vm(include_vm, vm_pool)
     if vm_pool
       condition =  "(vms.id is null and storage_pools.hardware_pool_id=#{vm_pool.get_hardware_pool.id})"
-      condition += " or vms.id=#{include_vm.id}" if (include_vm.id)
+      condition += " or vms.id=#{include_vm.id}" if (include_vm && include_vm.id)
       self.find(:all, :include => [:vms, :storage_pool], :conditions => condition)
     else
       return []
diff --git a/wui/src/test/fixtures/quotas.yml b/wui/src/test/fixtures/quotas.yml
index 2d56ea0..cb6e914 100644
--- a/wui/src/test/fixtures/quotas.yml
+++ b/wui/src/test/fixtures/quotas.yml
@@ -1,10 +1,10 @@
 # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
 one:
   id: 1
-  total_vcpus: 8
+  total_vcpus: 30
   total_vmemory: 2097152
   total_vnics: 3
-  total_storage: 500
+  total_storage: 104857600
   total_vms: 2
   pool_id: 1
 two:
diff --git a/wui/src/test/fixtures/storage_pools.yml b/wui/src/test/fixtures/storage_pools.yml
index 34159ce..0610333 100644
--- a/wui/src/test/fixtures/storage_pools.yml
+++ b/wui/src/test/fixtures/storage_pools.yml
@@ -9,36 +9,44 @@ two:
   id: 2
   hardware_pool_id: 4
   type: 'NfsStoragePool'
+  ip_addr: '127.0.0.1'
   export_path: '/tmp/foopath'
 three:
   id: 3
   hardware_pool_id: 4
   type: 'NfsStoragePool'
+  ip_addr: '192.168.50.1'
   export_path: '/tmp/barpath'
 four:
   id: 4
   hardware_pool_id: 9
   type: 'IscsiStoragePool'
   port: 121
+  ip_addr: '192.168.50.1'
   target: 'rubarb'
+  hardware_pool_id: 1
 five:
   id: 5
   hardware_pool_id: 9
   type: 'NfsStoragePool'
+  ip_addr: '192.168.50.2'
   export_path: '/tmp/thepath'
 six:
   id: 6
   hardware_pool_id: 9
   type: 'NfsStoragePool'
+  ip_addr: '192.168.50.3'
   export_path: '/tmp/anotherpath'
 seven:
   id: 7
   hardware_pool_id: 9
   type: 'NfsStoragePool'
+  ip_addr: '192.168.50.4'
   export_path: '/tmp/apath'
 eight:
   id: 8
   hardware_pool_id: 6
+  ip_addr: '192.168.50.2'
   type: 'IscsiStoragePool'
   port: 531
   target: 'bartarget'
@@ -52,5 +60,6 @@ ten:
   id: 10
   hardware_pool_id: 6
   type: 'IscsiStoragePool'
+  ip_addr: '192.168.50.3'
   port: 539
   target: 'stayontarget'
diff --git a/wui/src/test/functional/interface_test.rb b/wui/src/test/functional/interface_test.rb
index 6563b44..e62b55d 100644
--- a/wui/src/test/functional/interface_test.rb
+++ b/wui/src/test/functional/interface_test.rb
@@ -32,10 +32,70 @@ if File.exists? File.dirname(__FILE__) + '/../selenium.rb'
          def test_ovirt
             @browser.open("http://192.168.50.2/ovirt/";)
             assert_equal("Dashboard", @browser.get_title())
-	    @browser.close
          end
 
+	 def test_view_pool
+         @browser.open("http://192.168.50.2/ovirt/";)
+         @browser.wait_for_condition(
+              "selenium.isElementPresent(\"//div[ id='side']/ul/li/span/a\")",
+              10000)
+         @browser.click(
+              "//div[ id='side']/ul/li/span/a")  # click 'master pool' link
+         @browser.wait_for_condition(
+              "selenium.isElementPresent(\"//div[ class='summary_title']\")",
+               10000)
+
+         # verify the title of the pool
+	     assert_equal("master pool",
+                      @browser.get_text("//div[ class='summary_title']"))
+	 end
+
+     def test_create_vm
+        @browser.open("http://192.168.50.2/ovirt/";)
+        @browser.wait_for_condition(
+              "selenium.isElementPresent(\"//div[ id='side']/ul/li/ul/li[1]/span/a\")",
+               10000)
+        # click on 'foobar' vm resource pool  link:
+        @browser.click "//div[ id='side']/ul/li/ul/li[1]/span/a"
+        @browser.wait_for_condition(
+              "selenium.isElementPresent(\"//li[ id='nav_vmpool']/a\")",
+              10000)
+        # click on virtual machines tab
+        @browser.click "//li[ id='nav_vmpool']/a"
+        @browser.wait_for_condition(
+               "selenium.isElementPresent(\"//div[ id='toolbar_nav']/ul/li[1]/a\")",
+               10000)
+        # click on 'add virtual machine'
+        @browser.click "//div[ id='toolbar_nav']/ul/li[1]/a"
+
+        # retrieve current # of vms
+        num_vms = @browser.get_xpath_count "//table[ id='vms_grid']/tbody/tr"
+
+        # fill in required fields
+        @browser.wait_for_condition(
+               "selenium.isElementPresent(\"//input[ id='vm_description']\")",
+               10000)
+        @browser.type("//input[ id='vm_description']", "selenium-test-vm")
+        @browser.type("//input[ id='vm_num_vcpus_allocated']", "3")
+        @browser.type("//input[ id='vm_memory_allocated_in_mb']", "1024")
+        # select 1st storage pool
+        @browser.click("//table[ id='storage_volumes_grid']/tbody/tr/td/div/input")
+        @browser.wait_for_condition(
+               "selenium.isElementPresent(\"//form[ id='vm_form']/div[2]/div[2]/div[2]/a\")",
+               10000)
+        # click the button
+        @browser.click "//form[ id='vm_form']/div[2]/div[2]/div[2]/a"
+
+        @browser.wait_for_condition(
+             "selenium.isElementPresent(\"//table[ id='vms_grid']/tbody/tr[" + (num_vms.to_i + 1).to_s + "]\")",
+              20000)
+        # verify title of newly created vm
+        assert_equal("selenium-test-vm",
+           @browser.get_text("//table[ id='vms_grid']/tbody/tr[" + (num_vms.to_i + 1).to_s + "]/td[2]/div"))
+     end
+
          def teardown
+            @browser.close
             @browser.stop
          end
  end
-- 
1.5.4.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]