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

[Ovirt-devel] [PATCH] vm creation / start / stop tests via selenium



---
 autobuild.sh                              |    5 +-
 wui/src/test/fixtures/cpus.yml            |   68 ++++++++++++++++----
 wui/src/test/fixtures/hosts.yml           |   10 +++
 wui/src/test/fixtures/nics.yml            |   13 +++-
 wui/src/test/fixtures/quotas.yml          |    8 +-
 wui/src/test/fixtures/storage_pools.yml   |    9 +++
 wui/src/test/functional/interface_test.rb |   98 +++++++++++++++++++++++++++-
 wui/src/test/unit/cpu_test.rb             |    2 +
 8 files changed, 189 insertions(+), 24 deletions(-)

diff --git a/autobuild.sh b/autobuild.sh
index 6c95cb1..95395d0 100755
--- a/autobuild.sh
+++ b/autobuild.sh
@@ -80,7 +80,10 @@ fi
 echo "Running the wui tests"
 $ssh_cmd \
   "sed -i \"s/#RAILS_ENV=production/RAILS_ENV=test/g\" /etc/sysconfig/ovirt-rails && \
-   service ovirt-mongrel-rails restart && service httpd restart && \
+   sed -i \"s/development/test/\" /usr/share/ovirt-wui/dutils/active_record_env.rb && \
+   service ovirt-taskomatic restart && \
+   service ovirt-mongrel-rails restart && \
+   service httpd restart && \
    curl -i http://management.priv.ovirt.org/ovirt/ | \
        grep 'HTTP/1.1 200 OK' && \
    cd /usr/share/ovirt-wui && rake test" > "$RESULTS" 2>&1 \
diff --git a/wui/src/test/fixtures/cpus.yml b/wui/src/test/fixtures/cpus.yml
index 5586303..995b433 100644
--- a/wui/src/test/fixtures/cpus.yml
+++ b/wui/src/test/fixtures/cpus.yml
@@ -1,21 +1,65 @@
 # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
 
 one:
+  id: 1
+  host_id: 10
   cpu_number: 1
   core_number: 1
-  cpu_id_level: 1
-  vendor: 1
-  family: 1
-  model: 1
-  family: MyString
-  flags: MyString
+  number_of_cores: 2
+  vendor: 'intel'
 
 two:
+  id: 2
+  host_id: 10
   cpu_number: 1
+  core_number: 2
+  number_of_cores: 2
+  vendor: 'intel'
+
+three:
+  id: 3
+  host_id: 10
+  cpu_number: 2
+  core_number: 1
+  number_of_cores: 4
+  vendor: 'intel'
+
+four:
+  id: 4
+  host_id: 10
+  cpu_number: 2
+  core_number: 2
+  number_of_cores: 4
+  vendor: 'intel'
+
+five:
+  id: 5
+  host_id: 10
+  cpu_number: 2
+  core_number: 3
+  number_of_cores: 4
+  vendor: 'intel'
+
+six:
+  id: 6
+  host_id: 10
+  cpu_number: 2
+  core_number: 4
+  number_of_cores: 4
+  vendor: 'intel'
+
+seven:
+  id: 7
+  host_id: 10
+  cpu_number: 3
+  core_number: 1
+  number_of_cores: 1
+  vendor: 'intel'
+
+seven:
+  id: 8
+  host_id: 10
+  cpu_number: 4
   core_number: 1
-  cpu_id_level: 1
-  vendor: 1
-  family: 1
-  model: 1
-  family: MyString
-  flags: MyString
+  number_of_cores: 1
+  vendor: 'intel'
diff --git a/wui/src/test/fixtures/hosts.yml b/wui/src/test/fixtures/hosts.yml
index f10a756..a4e1fc6 100644
--- a/wui/src/test/fixtures/hosts.yml
+++ b/wui/src/test/fixtures/hosts.yml
@@ -79,3 +79,13 @@ nine:
  is_disabled: 0
  hypervisor_type: 'kvm'
  hardware_pool_id: 3
+ten:
+ id: 10
+ uuid: '75f8d5f3-faf0-4308-9f20-e4b03d013a27'
+ hostname: 'node3.priv.ovirt.org'
+ arch: 'x86_64'
+ memory: 4194304
+ is_disabled: 0
+ hypervisor_type: 'kvm'
+ hardware_pool_id: 1
+ state: "available"
diff --git a/wui/src/test/fixtures/nics.yml b/wui/src/test/fixtures/nics.yml
index 008cfb7..db57e55 100644
--- a/wui/src/test/fixtures/nics.yml
+++ b/wui/src/test/fixtures/nics.yml
@@ -5,18 +5,25 @@ one:
   ip_addr: '1.2.3.4'
   usage_type: '1'
   bandwidth: 100
-  host_id: 1
+  host_id: 10
 two:
   id: 2
   mac: 'AA:BB:CC:DD:EE:FF'
   ip_addr: '2.3.4.5'
   usage_type: '2'
   bandwidth: 1000
-  host_id: 1
+  host_id: 10
 three:
   id: 3
   mac: '00:FF:11:EE:22:DD'
   ip_addr: '3.4.5.6'
   usage_type: '1'
   bandwidth: 10
-  host_id: 2
+  host_id: 10
+four:
+  id: 4
+  mac: '00:FF:11:EE:22:DD'
+  ip_addr: '3.4.5.6'
+  usage_type: '1'
+  bandwidth: 10
+  host_id: 10
diff --git a/wui/src/test/fixtures/quotas.yml b/wui/src/test/fixtures/quotas.yml
index 2d56ea0..757c934 100644
--- a/wui/src/test/fixtures/quotas.yml
+++ b/wui/src/test/fixtures/quotas.yml
@@ -1,11 +1,11 @@
 # 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_vms: 2
+  total_vnics: 20
+  total_storage: 104857600
+  total_vms: 20
   pool_id: 1
 two:
   id: 2
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..eadeb74 100644
--- a/wui/src/test/functional/interface_test.rb
+++ b/wui/src/test/functional/interface_test.rb
@@ -27,17 +27,107 @@ if File.exists? File.dirname(__FILE__) + '/../selenium.rb'
                            "*firefox /usr/lib64/firefox-3.0.1/firefox",
                            "http://192.168.50.2/ovirt/";, 15000)
             @browser.start
+            @browser.set_speed(1500) # ms delay between operations
          end
 
          def test_ovirt
             @browser.open("http://192.168.50.2/ovirt/";)
             assert_equal("Dashboard", @browser.get_title())
-	    @browser.close
          end
 
-         def teardown
-            @browser.stop
-         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_start_stop_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']", "zzz-selenium-test-vm")
+        @browser.type("//input[ id='vm_num_vcpus_allocated']", "1")
+        @browser.type("//input[ id='vm_memory_allocated_in_mb']", "256")
+        # 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("zzz-selenium-test-vm",
+           @browser.get_text("//table[ id='vms_grid']/tbody/tr[" + (num_vms.to_i + 1).to_s + "]/td[2]/div"))
+
+        # start it, click checkbox, 'start vm', confirmation button; reload tab, check result
+        @browser.click "//table[ id='vms_grid']/tbody/tr[" + (num_vms.to_i + 1).to_s + "]/td[1]/div/input"
+        @browser.click "//div[ id='toolbar_nav']/ul/li[2]/ul/li[1]"
+        @browser.wait_for_condition(
+             "selenium.isElementPresent(\"//div[ id='vm_action_results']/div[3]/div/div[2]/a\")",
+              10000)
+        @browser.click "//div[ id='vm_action_results']/div[3]/div/div[2]/a"
+        @browser.click "//div[ id='side']/ul/li/ul/li[1]/span/a"
+        @browser.wait_for_condition(
+             "selenium.isElementPresent(\"//table[ id='vms_grid']/tbody/tr[" + (num_vms.to_i + 1).to_s + "]/td[7]/div\")",
+              20000)
+        assert_equal("running",
+          @browser.get_text("//table[ id='vms_grid']/tbody/tr[" + (num_vms.to_i + 1).to_s + "]/td[7]/div"))
+
+        # stop / destroy vm
+        @browser.click "//table[ id='vms_grid']/tbody/tr[" + (num_vms.to_i + 1).to_s + "]/td[1]/div/input"
+        @browser.click "//div[ id='toolbar_nav']/ul/li[2]/ul/li[2]"
+        @browser.wait_for_condition(
+             "selenium.isElementPresent(\"//div[ id='vm_action_results']/div[3]/div/div[2]/a\")",
+              10000)
+        @browser.click "//div[ id='vm_action_results']/div[3]/div/div[2]/a"
+        @browser.click "//div[ id='side']/ul/li/ul/li[1]/span/a"
+        @browser.wait_for_condition(
+             "selenium.isElementPresent(\"//table[ id='vms_grid']/tbody/tr[" + (num_vms.to_i + 1).to_s + "]/td[7]/div\")",
+              20000)
+        assert_equal("stopped",
+          @browser.get_text("//table[ id='vms_grid']/tbody/tr[" + (num_vms.to_i + 1).to_s + "]/td[7]/div"))
+
+     end
+
+     def teardown
+       @browser.close
+       @browser.stop
+     end
  end
 
 end
diff --git a/wui/src/test/unit/cpu_test.rb b/wui/src/test/unit/cpu_test.rb
index 5b64ca7..9558525 100644
--- a/wui/src/test/unit/cpu_test.rb
+++ b/wui/src/test/unit/cpu_test.rb
@@ -1,6 +1,8 @@
 require File.dirname(__FILE__) + '/../test_helper'
 
 class CpuTest < ActiveSupport::TestCase
+  fixtures :cpus
+
   # Replace this with your real tests.
   def test_truth
     assert true
-- 
1.5.4.1


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