[Ovirt-devel] [Patch] Fixed Test Cases
Hugh O. Brock
hbrock at redhat.com
Tue Jul 1 21:31:18 UTC 2008
On Tue, Jul 01, 2008 at 05:06:26PM -0400, Mohammed Morsi wrote:
>
>> Very cool... can you make a real git patch and resend then?
>>
>> --Hugh
>>
> Attached (includes the latest fix). Also found that when developing on
> the oVirt appliance, switching the server to look at a oVirt copy you
> checked out instead of /usr/share/ovirt-wui is as simple as editing
> /etc/init.d/ovirt-mongrel-rails and changing the OVIRT_DIR at the top of
> the file and restarting the server. (you will also have to change
> config/ldap.yml in your ovirt checkout to point to the correct ldap
> server).
>
>
> -Mo
> >From d31b5cd66aa4833bfbb553e7384f1967b3d48570 Mon Sep 17 00:00:00 2001
> From: root <root at management.priv.ovirt.org>
> Date: Tue, 1 Jul 2008 20:49:44 +0000
> Subject: [PATCH] refixed test cases, all now run successfully again
>
> ---
> wui/src/app/controllers/hardware_controller.rb | 1 +
> wui/src/app/controllers/host_controller.rb | 5 +++++
> wui/src/config/database.yml | 3 +--
> wui/src/config/ldap.yml | 12 ++++++------
> wui/src/test/fixtures/hosts.yml | 10 +++++-----
> wui/src/test/fixtures/permissions.yml | 2 +-
> wui/src/test/fixtures/quotas.yml | 6 +++---
> wui/src/test/fixtures/vms.yml | 2 +-
> .../test/functional/permission_controller_test.rb | 5 ++---
> wui/src/test/functional/quota_controller_test.rb | 11 ++++-------
> .../test/functional/resources_controller_test.rb | 8 +++-----
> wui/src/test/functional/storage_controller_test.rb | 11 ++++-------
> wui/src/test/functional/vm_controller_test.rb | 11 ++++-------
> 13 files changed, 40 insertions(+), 47 deletions(-)
>
> diff --git a/wui/src/app/controllers/hardware_controller.rb b/wui/src/app/controllers/hardware_controller.rb
> index 9718d60..8c8f8c0 100644
> --- a/wui/src/app/controllers/hardware_controller.rb
> +++ b/wui/src/app/controllers/hardware_controller.rb
> @@ -35,6 +35,7 @@ class HardwareController < ApplicationController
> unless @can_view
> flash[:notice] = 'You do not have permission to view this hardware pool: redirecting to top level'
> redirect_to :controller => "dashboard"
> + return
> end
> if params[:ajax]
> render :layout => 'tabs-and-content'
> diff --git a/wui/src/app/controllers/host_controller.rb b/wui/src/app/controllers/host_controller.rb
> index 8eb26b9..2a72254 100644
> --- a/wui/src/app/controllers/host_controller.rb
> +++ b/wui/src/app/controllers/host_controller.rb
> @@ -27,6 +27,11 @@ class HostController < ApplicationController
> verify :method => :post, :only => [ :destroy, :create, :update ],
> :redirect_to => { :action => :list }
>
> + def list
> + @hosts = Host.find(:all) if @hosts.nil?
> + end
> +
> +
> def show
> set_perms(@perm_obj)
> unless @can_view
> diff --git a/wui/src/config/database.yml b/wui/src/config/database.yml
> index b87fa3e..c60ee8f 100644
> --- a/wui/src/config/database.yml
> +++ b/wui/src/config/database.yml
> @@ -34,8 +34,7 @@ development:
> test:
> adapter: postgresql
> database: ovirt_test
> - username: ovirt
> - password: v23zj59an
> + username: postgres
> host: localhost
>
> production:
> diff --git a/wui/src/config/ldap.yml b/wui/src/config/ldap.yml
> index 796c334..e1ef4e7 100644
> --- a/wui/src/config/ldap.yml
> +++ b/wui/src/config/ldap.yml
> @@ -1,14 +1,14 @@
> development:
> - host: ldap.for.your.domain.com
> + host: management.priv.ovirt.org
> port: 389
> - base: dc=domain,dc=com
> + base: dc=priv,dc=ovirt,dc=org
>
> test:
> - host: ldap.for.your.domain.com
> + host: management.priv.ovirt.org
> port: 389
> - base: dc=domain,dc=com
> + base: dc=priv,dc=ovirt,dc=org
>
> production:
> - host: ldap.for.your.domain.com
> + host: management.priv.ovirt.org
> port: 389
> - base: dc=domain,dc=com
> + base: dc=priv,dc=ovirt,dc=org
> diff --git a/wui/src/test/fixtures/hosts.yml b/wui/src/test/fixtures/hosts.yml
> index 966a829..3b93aea 100644
> --- a/wui/src/test/fixtures/hosts.yml
> +++ b/wui/src/test/fixtures/hosts.yml
> @@ -30,7 +30,7 @@ three:
> memory: 2048
> is_disabled: 0
> hypervisor_type: 'kvm'
> - hardware_pool_id: 2
> + hardware_pool_id: 3
> four:
> id: 4
> uuid: '520bbb34-6515-490e-9d07-0c8b14f76805'
> @@ -41,7 +41,7 @@ four:
> memory: 2048
> is_disabled: 1
> hypervisor_type: 'kvm'
> - hardware_pool_id: 2
> + hardware_pool_id: 3
> five:
> id: 5
> uuid: '2e422f66-324e-48d4-973f-0b91b33070f9'
> @@ -49,10 +49,10 @@ five:
> num_cpus: 32
> cpu_speed: 4096
> arch: 'xeon'
> - memory: 16384
> + memory: 1048576
> is_disabled: 0
> hypervisor_type: 'kvm'
> - hardware_pool_id: 2
> + hardware_pool_id: 3
> six:
> id: 6
> uuid: 'bb0ce7c7-f234-49ae-84b5-6f4fd8bddcaa'
> @@ -63,7 +63,7 @@ six:
> memory: 16384
> is_disabled: 0
> hypervisor_type: 'kvm'
> - hardware_pool_id: 2
> + hardware_pool_id: 3
> seven:
> id: 7
> uuid: '6ae3d22e-97e0-4d86-9712-5395b20a0f45'
> diff --git a/wui/src/test/fixtures/permissions.yml b/wui/src/test/fixtures/permissions.yml
> index eb99ee2..ded5865 100644
> --- a/wui/src/test/fixtures/permissions.yml
> +++ b/wui/src/test/fixtures/permissions.yml
> @@ -1,7 +1,7 @@
> one:
> id: 1
> user_role: 'Super Admin'
> - uid: 'admin'
> + uid: 'ovirtadmin'
> pool_id: 1
> two:
> id: 2
> diff --git a/wui/src/test/fixtures/quotas.yml b/wui/src/test/fixtures/quotas.yml
> index 089d688..2d56ea0 100644
> --- a/wui/src/test/fixtures/quotas.yml
> +++ b/wui/src/test/fixtures/quotas.yml
> @@ -2,7 +2,7 @@
> one:
> id: 1
> total_vcpus: 8
> - total_vmemory: 4096
> + total_vmemory: 2097152
> total_vnics: 3
> total_storage: 500
> total_vms: 2
> @@ -30,7 +30,7 @@ four:
> total_vnics:
> total_storage:
> total_vms: 2
> - pool_id: 4
> + pool_id: 6
> five:
> id: 5
> total_vcpus: 3
> @@ -58,7 +58,7 @@ seven:
> eight:
> id: 8
> total_vcpus: 20
> - total_vmemory: 200000
> + total_vmemory: 2097152
> total_vnics: 30
> total_storage: 1111111111
> total_vms: 20
> diff --git a/wui/src/test/fixtures/vms.yml b/wui/src/test/fixtures/vms.yml
> index 59c6311..ca783e6 100644
> --- a/wui/src/test/fixtures/vms.yml
> +++ b/wui/src/test/fixtures/vms.yml
> @@ -4,7 +4,7 @@ one:
> description: 'production httpd appliance'
> num_vcpus_allocated: 2
> num_vcpus_used: 2
> - memory_allocated: 2048
> + memory_allocated: 262144
> memory_used: 1024
> vnic_mac_addr: '23:51:90:A1:13:37'
> state: 'stopped'
> diff --git a/wui/src/test/functional/permission_controller_test.rb b/wui/src/test/functional/permission_controller_test.rb
> index 61ecf2a..45e7ec5 100644
> --- a/wui/src/test/functional/permission_controller_test.rb
> +++ b/wui/src/test/functional/permission_controller_test.rb
> @@ -56,10 +56,9 @@ class PermissionControllerTest < Test::Unit::TestCase
> def test_create
> num_permissions = Permission.count
>
> - post :create, :permission => { :user_role => 'Administrator', :uid => 'admin', :pool_id => 1}
> + post :create, :permission => { :user_role => 'Administrator', :uid => 'admin', :pool_id => 2}
>
> - assert_response :redirect
> - assert_redirected_to :controller => 'hardware', :action => 'show', :id => 1
> + assert_response :success
>
> assert_equal num_permissions + 1, Permission.count
> end
> diff --git a/wui/src/test/functional/quota_controller_test.rb b/wui/src/test/functional/quota_controller_test.rb
> index c609cf2..c87faef 100644
> --- a/wui/src/test/functional/quota_controller_test.rb
> +++ b/wui/src/test/functional/quota_controller_test.rb
> @@ -56,10 +56,9 @@ class QuotaControllerTest < Test::Unit::TestCase
> def test_create
> num_quotas = Quota.count
>
> - post :create, :quota => { :pool_id => 1 }
> + post :create, :quota => { :pool_id => 8 }
>
> - assert_response :redirect
> - assert_redirected_to :controller=> 'hardware', :action => 'show', :id => 1
> + assert_response :success
>
> assert_equal num_quotas + 1, Quota.count
> end
> @@ -76,8 +75,7 @@ class QuotaControllerTest < Test::Unit::TestCase
>
> def test_update
> post :update, :id => @first_id
> - assert_response :redirect
> - assert_redirected_to :action => 'show', :id => @first_id
> + assert_response :success
> end
>
> def test_destroy
> @@ -88,8 +86,7 @@ class QuotaControllerTest < Test::Unit::TestCase
> }
>
> post :destroy, :id => @first_id
> - assert_response :redirect
> - assert_redirected_to :controller => 'hardware', :action => 'show', :id => pool.id
> + assert_response :success
>
> assert_raise(ActiveRecord::RecordNotFound) {
> Quota.find(@first_id)
> diff --git a/wui/src/test/functional/resources_controller_test.rb b/wui/src/test/functional/resources_controller_test.rb
> index 8f0099c..fca7aad 100644
> --- a/wui/src/test/functional/resources_controller_test.rb
> +++ b/wui/src/test/functional/resources_controller_test.rb
> @@ -33,11 +33,10 @@ class ResourcesControllerTest < ActionController::TestCase
>
> def test_create
> assert_difference('VmResourcePool.count') do
> - post :create, :vm_resource_pool => { }, :parent_id => 1
> + post :create, :vm_resource_pool => { :name => 'foo_resource_pool' }, :parent_id => 1
> end
>
> - assert_response :redirect
> - assert_redirected_to :controller => 'hardware', :action => 'show', :id => 1
> + assert_response :success
> end
>
> def test_show
> @@ -63,8 +62,7 @@ class ResourcesControllerTest < ActionController::TestCase
> }
>
> post :destroy, :id => 2
> - assert_response :redirect
> - assert_redirected_to :controller => 'hardware', :action => 'show', :id => pool
> + assert_response :success
>
> assert_raise(ActiveRecord::RecordNotFound) {
> VmResourcePool.find(2)
> diff --git a/wui/src/test/functional/storage_controller_test.rb b/wui/src/test/functional/storage_controller_test.rb
> index 248058f..ff728b9 100644
> --- a/wui/src/test/functional/storage_controller_test.rb
> +++ b/wui/src/test/functional/storage_controller_test.rb
> @@ -72,10 +72,9 @@ class StorageControllerTest < Test::Unit::TestCase
> hw_pool = HardwarePool.get_default_pool
> num_storage_volumes = StoragePool.count
>
> - post :create, :storage_type => 'NFS', :storage_pool => { :hardware_pool => hw_pool, :ip_addr => '111.121.131.141'}
> + post :create, :storage_type => 'NFS', :storage_pool => { :hardware_pool => hw_pool, :ip_addr => '111.121.131.141', :export_path => '/tmp/path' }
>
> - assert_response :redirect
> - assert_redirected_to :controller => 'hardware', :action => 'show', :id => hw_pool.id
> + assert_response :success
>
> assert_equal num_storage_volumes + 1, StoragePool.count
> end
> @@ -92,8 +91,7 @@ class StorageControllerTest < Test::Unit::TestCase
>
> def test_update
> post :update, :id => @first_id
> - assert_response :redirect
> - assert_redirected_to :action => 'show', :id => @first_id
> + assert_response :success
> end
>
> def test_destroy
> @@ -104,8 +102,7 @@ class StorageControllerTest < Test::Unit::TestCase
> }
>
> post :destroy, :id => @first_id
> - assert_response :redirect
> - assert_redirected_to :controller => 'hardware', :action => 'show', :id => hw_pool_id
> + assert_response :success
>
> assert_raise(ActiveRecord::RecordNotFound) {
> StoragePool.find(@first_id)
> diff --git a/wui/src/test/functional/vm_controller_test.rb b/wui/src/test/functional/vm_controller_test.rb
> index aa33625..815321f 100644
> --- a/wui/src/test/functional/vm_controller_test.rb
> +++ b/wui/src/test/functional/vm_controller_test.rb
> @@ -56,10 +56,9 @@ class VmControllerTest < Test::Unit::TestCase
> def test_create
> num_vms = Vm.count
>
> - post :create, :vm_resource_pool_name => 'foobar', :hardware_pool_id => 1, :vm => { :uuid => 'f43b298c-1e65-46fa-965f-0f6fb9ffaa10', :description => 'descript', :num_vcpus_allocated => 4, :memory_allocated => 1024, :vnic_mac_addr => 'AA:BB:CC:DD:EE:FF' }
> + post :create, :vm_resource_pool_name => 'foobar', :hardware_pool_id => 1, :vm => { :uuid => 'f43b298c-1e65-46fa-965f-0f6fb9ffaa10', :description => 'descript', :num_vcpus_allocated => 4, :memory_allocated => 262144, :vnic_mac_addr => 'AA:BB:CC:DD:EE:FF' }
>
> - assert_response :redirect
> - assert_redirected_to :controller => 'resources', :action => 'show', :id => 12
> + assert_response :success
>
> assert_equal num_vms + 1, Vm.count
> end
> @@ -76,8 +75,7 @@ class VmControllerTest < Test::Unit::TestCase
>
> def test_update
> post :update, :id => @first_id, :vm => {}
> - assert_response :redirect
> - assert_redirected_to :action => 'show', :id => @first_id
> + assert_response :success
> end
>
> def test_destroy
> @@ -87,8 +85,7 @@ class VmControllerTest < Test::Unit::TestCase
> }
>
> post :destroy, :id => @first_id
> - assert_response :redirect
> - assert_redirected_to :controller=>'resources', :action => 'show', :id => pool
> + assert_response :success
>
> assert_raise(ActiveRecord::RecordNotFound) {
> Vm.find(@first_id)
This looks good to me with one caveat: Even for developer config, we
shouldn't ever have to edit an init script -- if a value in an init
script needs to change, we should put it in a config file under /etc
(right apevec?). Can you check with Alan and work out the right way to
do this? In general I think the idea of being able to repoint the
Mongrel server for development purposes is very cool.
With that fixed I will ACK.
Take care,
--Hugh
More information about the ovirt-devel
mailing list