Jason Guiditta
2008-Nov-17 20:16 UTC
[Ovirt-devel] [PATCH server] DB change to support larger numbers.
Since we store mem, storage, etc in KB, we need an 8 byte int. This patch change all tables with this type of data to support larger size. Signed-off-by: Jason Guiditta <jguiditt at redhat.com> --- src/db/migrate/029_update_integer_size.rb | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) create mode 100644 src/db/migrate/029_update_integer_size.rb diff --git a/src/db/migrate/029_update_integer_size.rb b/src/db/migrate/029_update_integer_size.rb new file mode 100644 index 0000000..5c67d48 --- /dev/null +++ b/src/db/migrate/029_update_integer_size.rb @@ -0,0 +1,22 @@ +class UpdateIntegerSize < ActiveRecord::Migration + def self.up + #Since we store mem, storage, etc in KB, we need an 8 byte int. + #Change all tables with this type of data to support larger size + + change_column :hosts, :memory, :integer, :limit => 8 + change_column :storage_volumes, :size, :integer, :limit => 8 + change_column :quotas, :total_vmemory, :integer, :limit => 8 + change_column :quotas, :total_storage, :integer, :limit => 8 + change_column :vms, :memory_allocated, :integer, :limit => 8 + change_column :vms, :memory_used, :integer, :limit => 8 + end + + def self.down + change_column :hosts, :memory, :integer, :limit => 4 + change_column :storage_volumes, :size, :integer, :limit => 4 + change_column :quotas, :total_vmemory, :integer, :limit => 4 + change_column :quotas, :total_storage, :integer, :limit => 4 + change_column :vms, :memory_allocated, :integer, :limit => 4 + change_column :vms, :memory_used, :integer, :limit => 4 + end +end -- 1.5.6.5
NOTE: This patch relies on previous one that changes int size of db tables. Redoing the test fixtures to take advantage of rails 2.1 'foxy fixtures'. This means very few ids, except for a couple special cases. This not only gets us closer to current rails standards, but makes the fixtures more readable and maintainable, which hopefully translates into making it less painful to write comprehensive tests for new code (and build out better tests for existing code). A side effect of this is that I have been trimming unneeded fixture entries and renaming many of the ones we are keeping so it is more clear what they are, as well as general cleanup of incorrect things like quotes where they shouldn't be. Signed-off-by: Jason Guiditta <jguiditt at redhat.com> --- src/test/fixtures/bondings.yml | 26 ++-- src/test/fixtures/bondings_nics.yml | 15 -- src/test/fixtures/cpus.yml | 44 ++--- src/test/fixtures/hosts.yml | 221 ++++++++++----------- src/test/fixtures/ip_addresses.yml | 40 +---- src/test/fixtures/networks.yml | 36 ++-- src/test/fixtures/nics.yml | 94 +++------ src/test/fixtures/permissions.yml | 200 ++++--------------- src/test/fixtures/pools.yml | 163 +++++++--------- src/test/fixtures/quotas.yml | 88 +++------ src/test/fixtures/storage_pools.yml | 81 ++------ src/test/fixtures/storage_volumes.yml | 82 ++++---- src/test/fixtures/tasks.yml | 115 +---------- src/test/fixtures/vms.yml | 174 +++++----------- src/test/functional/host_controller_test.rb | 36 ++-- src/test/functional/nic_controller_test.rb | 8 +- src/test/functional/permission_controller_test.rb | 42 +++-- src/test/functional/quota_controller_test.rb | 45 +++-- src/test/functional/resources_controller_test.rb | 42 +++-- src/test/functional/storage_controller_test.rb | 40 +++-- src/test/functional/task_controller_test.rb | 4 +- src/test/functional/vm_controller_test.rb | 41 +++-- src/test/unit/active_record_env_test.rb | 10 +- src/test/unit/host_browser_awaken_test.rb | 3 +- src/test/unit/ip_address_test.rb | 13 +- src/test/unit/permission_test.rb | 12 +- src/test/unit/pool_test.rb | 8 +- src/test/unit/storage_pool_test.rb | 5 +- src/test/unit/storage_volume_test.rb | 4 +- src/test/unit/task_test.rb | 11 +- src/test/unit/vm_test.rb | 4 + 31 files changed, 641 insertions(+), 1066 deletions(-) delete mode 100644 src/test/fixtures/bondings_nics.yml diff --git a/src/test/fixtures/bondings.yml b/src/test/fixtures/bondings.yml index ee1939d..40d856c 100644 --- a/src/test/fixtures/bondings.yml +++ b/src/test/fixtures/bondings.yml @@ -1,15 +1,17 @@ mailservers_managed_node_bonding: - name: Production Network - interface_name: mailbonding0 - bonding_type_id: <%= Fixtures.identify(:link_aggregation_bonding_type) %> - host_id: <%= Fixtures.identify(:mailservers_managed_node) %> - arp_ping_address: 172.31.0.100 - arp_interval: 0 - vlan_id: <%= Fixtures.identify(:dhcp_vlan_one) %> + name: Production Network + interface_name: mailbonding0 + bonding_type: link_aggregation_bonding_type + host: mailservers_managed_node + arp_ping_address: 172.31.0.100 + arp_interval: 0 + vlan: dhcp_vlan_one + nics: mailserver_nic_one, mailserver_nic_two mediaserver_managed_node_bonding: - name: Fileserver Network - interface_name: mediabonding0 - bonding_type_id: <%= Fixtures.identify(:link_aggregation_bonding_type) %> - host_id: <%= Fixtures.identify(:mediaserver_managed_node) %> - vlan_id: <%= Fixtures.identify(:dhcp_vlan_one) %> + name: Fileserver Network + interface_name: mediabonding0 + bonding_type: link_aggregation_bonding_type + host: mediaserver_managed_node + vlan: dhcp_vlan_one + nics: mediaserver_nic_one, mediaserver_nic_two diff --git a/src/test/fixtures/bondings_nics.yml b/src/test/fixtures/bondings_nics.yml deleted file mode 100644 index 607ff8b..0000000 --- a/src/test/fixtures/bondings_nics.yml +++ /dev/null @@ -1,15 +0,0 @@ -mailservers_managed_node_bonding_nic_1: - bonding_id: <%= Fixtures.identify(:mailservers_managed_node_bonding) %> - nic_id: <%= Fixtures.identify(:mailserver_nic_one) %> - -mailservers_managed_node_bonding_nic_2: - bonding_id: <%= Fixtures.identify(:mailservers_managed_node_bonding) %> - nic_id: <%= Fixtures.identify(:mailserver_nic_two) %> - -mediaservers_managed_node_bonding_nic_1: - bonding_id: <%= Fixtures.identify(:mediaserver_managed_node_bonding) %> - nic_id: <%= Fixtures.identify(:mediaserver_nic_one) %> - -mediaservers_managed_node_bonding_nic_2: - bonding_id: <%= Fixtures.identify(:mediaserver_managed_node_bonding) %> - nic_id: <%= Fixtures.identify(:mediaserver_nic_two) %> diff --git a/src/test/fixtures/cpus.yml b/src/test/fixtures/cpus.yml index 995b433..c49e574 100644 --- a/src/test/fixtures/cpus.yml +++ b/src/test/fixtures/cpus.yml @@ -1,65 +1,55 @@ -# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html - -one: - id: 1 - host_id: 10 +prod_corp_com_1: + host: prod_corp_com cpu_number: 1 core_number: 1 number_of_cores: 2 vendor: 'intel' -two: - id: 2 - host_id: 10 +prod_corp_com_2: + host: prod_corp_com cpu_number: 1 core_number: 2 number_of_cores: 2 vendor: 'intel' -three: - id: 3 - host_id: 10 +prod_corp_com_3: + host: prod_corp_com cpu_number: 2 core_number: 1 number_of_cores: 4 vendor: 'intel' -four: - id: 4 - host_id: 10 +prod_corp_com_4: + host: prod_corp_com cpu_number: 2 core_number: 2 number_of_cores: 4 vendor: 'intel' -five: - id: 5 - host_id: 10 +prod_corp_com_5: + host: prod_corp_com cpu_number: 2 core_number: 3 number_of_cores: 4 vendor: 'intel' -six: - id: 6 - host_id: 10 +buildserver_managed_node_1: + host: buildserver_managed_node cpu_number: 2 core_number: 4 number_of_cores: 4 vendor: 'intel' -seven: - id: 7 - host_id: 10 +buildserver_managed_node_2: + host: buildserver_managed_node cpu_number: 3 core_number: 1 number_of_cores: 1 vendor: 'intel' -seven: - id: 8 - host_id: 10 +buildserver_managed_node_3: + host: buildserver_managed_node cpu_number: 4 core_number: 1 number_of_cores: 1 - vendor: 'intel' + vendor: 'amd' diff --git a/src/test/fixtures/hosts.yml b/src/test/fixtures/hosts.yml index 28282c2..31e7580 100644 --- a/src/test/fixtures/hosts.yml +++ b/src/test/fixtures/hosts.yml @@ -1,137 +1,122 @@ -one: - id: 1 - uuid: '1148fdf8-961d-11dc-9387-001558c41534' - hostname: 'prod.corp.com' - arch: 'i686' +prod_corp_com: + uuid: 1148fdf8-961d-11dc-9387-001558c41534 + hostname: prod.corp.com + arch: i686 memory: 18384 is_disabled: 0 - hypervisor_type: 'xen' - hardware_pool_id: 3 -two: - id: 2 - uuid: '1f2a8694-961d-11dc-9387-001558c41534' - hostname: 'myworkstation.dev.corp.com' - arch: 'i386' + state: available + hypervisor_type: xen + hardware_pool: corp_com +workstation_corp_com: + uuid: 1f2a8694-961d-11dc-9387-001558c41534 + hostname: workstation.corp.com + arch: i386 memory: 2048 is_disabled: 0 - hypervisor_type: 'qemu' - hardware_pool_id: 4 -three: - id: 3 - uuid: '58a85f44-75fd-4934-805f-88e45b40d4b4' - hostname: 'macworkstation.foobar.com' - arch: 'mips' + hypervisor_type: qemu + hardware_pool: corp_com +macworkstation_qa_corp_com: + uuid: 58a85f44-75fd-4934-805f-88e45b40d4b4 + hostname: macworkstation.qa.corp.com + arch: mips memory: 2048 is_disabled: 0 - hypervisor_type: 'kvm' - hardware_pool_id: 3 -four: - id: 4 - uuid: '520bbb34-6515-490e-9d07-0c8b14f76805' - hostname: 'fedoraworkstation.foobar.com' - arch: 'i386' + hypervisor_type: kvm + hardware_pool: corp_com_qa +fedoraworkstation_qa_corp_com: + uuid: 520bbb34-6515-490e-9d07-0c8b14f76805 + hostname: fedoraworkstation.qa.corp.com + arch: i386 memory: 2048 is_disabled: 1 - hypervisor_type: 'kvm' - hardware_pool_id: 3 -five: - id: 5 - uuid: '2e422f66-324e-48d4-973f-0b91b33070f9' - hostname: 'pipeline.foobar.com' - arch: 'xeon' + hypervisor_type: kvm + hardware_pool: corp_com_qa +pipeline_qa_corp_com: + uuid: 2e422f66-324e-48d4-973f-0b91b33070f9 + hostname: pipeline.qa.corp.com + arch: xeon memory: 1048576 is_disabled: 0 - hypervisor_type: 'kvm' - hardware_pool_id: 3 -six: - id: 6 - uuid: 'bb0ce7c7-f234-49ae-84b5-6f4fd8bddcaa' - hostname: 'prod.foobar.com' - arch: 'xeon' + hypervisor_type: kvm + hardware_pool: corp_com_qa +app_qa_corp_com: + uuid: bb0ce7c7-f234-49ae-84b5-6f4fd8bddcaa + hostname: app.qa.corp.com + arch: xeon memory: 16384 is_disabled: 0 - hypervisor_type: 'kvm' - hardware_pool_id: 3 -seven: - id: 7 - uuid: '6ae3d22e-97e0-4d86-9712-5395b20a0f45' - hostname: 'mystation.dev.corp.com' - arch: 'i686' + hypervisor_type: kvm + hardware_pool: corp_com_qa +issue_qa_corp_com: + uuid: ec0d86de-657b-48f6-b7cc-e733a3f9a834 + hostname: issue.qa.corp.com + arch: x86 + memory: 4096 + is_disabled: 0 + hypervisor_type: kvm + hardware_pool: corp_com_qa +db_dev_corp_com: + uuid: 81c15560-dbf4-45f5-9b75-106cdbd63aeb + hostname: db.dev.corp.com + arch: x86 + memory: 4096 + is_disabled: 0 + hypervisor_type: kvm + hardware_pool: corp_com_dev +mystation_dev_corp_com: + uuid: 6ae3d22e-97e0-4d86-9712-5395b20a0f45 + hostname: mystation.dev.corp.com + arch: i686 memory: 2048 is_disabled: 0 - hypervisor_type: 'xen' - hardware_pool_id: 4 -eight: - id: 8 - uuid: 'ec0d86de-657b-48f6-b7cc-e733a3f9a834' - hostname: 'issue.qa.corp.com' - arch: 'x86' - memory: 4096 - is_disabled: 0 - hypervisor_type: 'kvm' - hardware_pool_id: 5 -nine: - id: 9 - uuid: '81c15560-dbf4-45f5-9b75-106cdbd63aeb' - hostname: 'somehost' - arch: 'x86' - memory: 4096 - 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" - + hypervisor_type: xen + hardware_pool: corp_com_dev +node3_priv_ovirt_org: + uuid: 75f8d5f3-faf0-4308-9f20-e4b03d013a27 + hostname: node3.priv.ovirt.org + arch: x86_64 + memory: 4194304 + is_disabled: 0 + hypervisor_type: kvm + hardware_pool: default + state: available mailservers_managed_node: - uuid: '182a8596-961d-11dc-9387-001558c41534' - hostname: 'mail.mynetwork.com' - arch: 'i386' - memory: 16384 - is_disabled: 0 - hypervisor_type: 'kvm' - hardware_pool_id: <%= Fixtures.identify(:prodops_pool) %> - + uuid: 182a8596-961d-11dc-9387-001558c41534 + hostname: mail.mynetwork.com + arch: i386 + memory: 16384 + is_disabled: 0 + hypervisor_type: kvm + hardware_pool: corp_com_prod fileserver_managed_node: - uuid: '928ad8172-9723-11dc-9387-001558c41534' - hostname: 'files.mynetwork.com' - arch: 'x86_64' - memory: 32768 - is_disabled: 0 - hypervisor_type: 'kvm' - hardware_pool_id: <%= Fixtures.identify(:prodops_pool) %> - + uuid: 928ad8172-9723-11dc-9387-001558c41534 + hostname: files.mynetwork.com + arch: x86_64 + memory: 32768 + is_disabled: 0 + hypervisor_type: kvm + hardware_pool: corp_com_prod ldapserver_managed_node: - uuid: '919ae372-9156-11dc-9387-001558c41534' - hostname: 'ldap.mynetwork.com' - arch: 'i386' - memory: 16384 - is_disabled: 0 - hypervisor_type: 'kvm' - hardware_pool_id: <%= Fixtures.identify(:prodops_pool) %> - + uuid: 919ae372-9156-11dc-9387-001558c41534 + hostname: ldap.mynetwork.com + arch: i386 + memory: 16384 + is_disabled: 0 + hypervisor_type: kvm + hardware_pool: corp_com_prod buildserver_managed_node: - uuid: '6293acd9-2784-11dc-9387-001558c41534' - hostname: 'build.mynetwork.com' - arch: 'x86_64' - memory: 65536 - is_disabled: 0 - hypervisor_type: 'kvm' - hardware_pool_id: <%= Fixtures.identify(:prodops_pool) %> - + uuid: 6293acd9-2784-11dc-9387-001558c41534 + hostname: build.mynetwork.com + arch: x86_64 + memory: 65536 + is_disabled: 0 + hypervisor_type: kvm + hardware_pool: corp_com_prod mediaserver_managed_node: - uuid: '6293acd9-2784-11dc-9387-001558c41534' - hostname: 'build.mynetwork.com' - arch: 'x86_64' - memory: 65536 - is_disabled: 0 - hypervisor_type: 'kvm' - hardware_pool_id: <%= Fixtures.identify(:prodops_pool) %> - + uuid: 6293acd9-2784-11dc-9387-001558c41534 + hostname: build.mynetwork.com + arch: x86_64 + memory: 65536 + is_disabled: 0 + hypervisor_type: kvm + hardware_pool: corp_com_prod diff --git a/src/test/fixtures/ip_addresses.yml b/src/test/fixtures/ip_addresses.yml index aed3811..b19e9e1 100644 --- a/src/test/fixtures/ip_addresses.yml +++ b/src/test/fixtures/ip_addresses.yml @@ -1,37 +1,5 @@ -ip_v4_one: - nic_id: <%= Fixtures.identify(:nic_one) %> - type: IpV4Address - address: 1.2.3.4 - netmask: 255.255.255.0 - gateway: 1.2.3.1 - broadcast: 1.2.3.255 - -ip_v4_two: - nic_id: <%= Fixtures.identify(:nic_two) %> - type: IpV4Address - address: 2.3.4.5 - netmask: 255.255.255.0 - gateway: 1.2.3.1 - broadcast: 2.3.4.255 - -ip_v4_three: - nic_id: <%= Fixtures.identify(:nic_three) %> - type: IpV4Address - address: 3.4.5.6 - netmask: 255.255.255.0 - gateway: 3.4.5.1 - broadcast: 3.4.5.255 - -ip_v4_four: - nic_id: <%= Fixtures.identify(:nic_four) %> - type: IpV4Address - address: 3.4.5.6 - netmask: 255.255.255.0 - gateway: 3.4.5.1 - broadcast: 3.4.5.255 - ip_v4_mailserver_nic_one: - nic_id: <%= Fixtures.identify(:mailserver_nic_one) %> + nic: mailserver_nic_one type: IpV4Address address: 172.31.0.15 netmask: 255.255.255.0 @@ -39,13 +7,13 @@ ip_v4_mailserver_nic_one: broadcast: 172.31.0.255 ip_v4_ldapserver_nic_one: - nic_id: <%= Fixtures.identify(:ldapserver_nic_one) %> + nic: ldapserver_nic_one type: IpV4Address address: 172.31.0.25 gateway: 172.31.0.1 ip_v4_buildserver_nic_one: - nic_id: <%= Fixtures.identify(:buildserver_nic_two) %> + nic: buildserver_nic_two type: IpV4Address address: 172.31.0.31 netmask: 255.255.255.0 @@ -53,7 +21,7 @@ ip_v4_buildserver_nic_one: broadcast: 172.31.0.255 ip_v4_mailservers_managed_node_bonding: - bonding_id: <%= Fixtures.identify(:mailservers_managed_node_bonding) %> + bonding: mailservers_managed_node_bonding type: IpV4Address address: 192.168.50.100 netmask: 255.255.255.0 diff --git a/src/test/fixtures/networks.yml b/src/test/fixtures/networks.yml index cb50c0c..1ea2c7c 100644 --- a/src/test/fixtures/networks.yml +++ b/src/test/fixtures/networks.yml @@ -1,33 +1,33 @@ static_vlan_one: - type: 'Vlan' - name: 'Static Vlan 1' - boot_type_id: <%= Fixtures.identify(:boot_type_static_ip) %> + type: Vlan + name: Static Vlan 1 + boot_type: boot_type_static_ip number: 1 dhcp_vlan_one: - type: 'Vlan' - name: 'DHCP Vlan 1' - boot_type_id: <%= Fixtures.identify(:boot_type_dhcp) %> + type: Vlan + name: DHCP Vlan 1 + boot_type: boot_type_dhcp number: 2 bootp_vlan_one: - type: 'Vlan' - name: 'BOOTP Vlan 1' - boot_type_id: <%= Fixtures.identify(:boot_type_bootp) %> + type: Vlan + name: BOOTP Vlan 1 + boot_type: boot_type_bootp number: 3 static_physical_network_one: - type: 'PhysicalNetwork' - name: 'Static Physical Network 1' - boot_type_id: <%= Fixtures.identify(:boot_type_static_ip) %> + type: PhysicalNetwork + name: Static Physical Network 1 + boot_type: boot_type_static_ip dhcp_physical_network_one: - type: 'PhysicalNetwork' - name: 'DHCP Physical Network 1' - boot_type_id: <%= Fixtures.identify(:boot_type_dhcp) %> + type: PhysicalNetwork + name: DHCP Physical Network 1 + boot_type: boot_type_dhcp bootp_physical_network_one: - type: 'PhysicalNetwork' - name: 'BOOTP Physical Network 1' - boot_type_id: <%= Fixtures.identify(:boot_type_bootp) %> + type: PhysicalNetwork + name: BOOTP Physical Network 1 + boot_type: boot_type_bootp diff --git a/src/test/fixtures/nics.yml b/src/test/fixtures/nics.yml index 7f65ef6..a7851ff 100644 --- a/src/test/fixtures/nics.yml +++ b/src/test/fixtures/nics.yml @@ -1,84 +1,56 @@ -nic_one: - id: 1 - mac: '00:11:22:33:44:55' - bandwidth: 100 - host_id: 10 - physical_network_id: <%= Fixtures.identify(:dhcp_physical_network_one) %> -nic_two: - id: 2 - mac: 'AA:BB:CC:DD:EE:FF' - usage_type: '2' - bandwidth: 1000 - host_id: 10 - physical_network_id: <%= Fixtures.identify(:dhcp_physical_network_one) %> -nic_three: - id: 3 - mac: '00:FF:11:EE:22:DD' - usage_type: '1' - bandwidth: 10 - host_id: 10 - physical_network_id: <%= Fixtures.identify(:dhcp_physical_network_one) %> -nic_four: - id: 4 - mac: '00:FF:11:EE:22:DD' - usage_type: '1' - bandwidth: 10 - host_id: 10 - physical_network_id: <%= Fixtures.identify(:dhcp_physical_network_one) %> - mailserver_nic_one: - mac: '00:11:22:33:44:55' - usage_type: '1' + mac: 00:11:22:33:44:55 + usage_type: 1 bandwidth: 100 - host_id: <%= Fixtures.identify(:mailservers_managed_node) %> - physical_network_id: <%= Fixtures.identify(:dhcp_physical_network_one) %> + host: mailservers_managed_node + physical_network: dhcp_physical_network_one mailserver_nic_two: - mac: '22:11:33:66:44:55' - usage_type: '1' + mac: 22:11:33:66:44:55 + usage_type: 1 bandwidth: 100 - host_id: <%= Fixtures.identify(:mailservers_managed_node) %> - physical_network_id: <%= Fixtures.identify(:dhcp_physical_network_one) %> + host: mailservers_managed_node + physical_network: dhcp_physical_network_one fileserver_nic_one: - mac: '00:99:00:99:13:07' - usage_type: '1' + mac: 00:99:00:99:13:07 + usage_type: 1 bandwidth: 100 - host_id: <%= Fixtures.identify(:fileserver_managed_node) %> - physical_network_id: <%= Fixtures.identify(:dhcp_physical_network_one) %> + host: fileserver_managed_node + physical_network: dhcp_physical_network_one ldapserver_nic_one: - mac: '00:03:02:00:09:06' - usage_type: '1' + mac: 00:03:02:00:09:06 + usage_type: 1 bandwidth: 100 - bridge: 'ovirtbr0' - host_id: <%= Fixtures.identify(:ldapserver_managed_node) %> - physical_network_id: <%= Fixtures.identify(:static_physical_network_one) %> + bridge: ovirtbr0 + host: ldapserver_managed_node + physical_network: static_physical_network_one buildserver_nic_one: - mac: '07:17:19:65:03:38' - usage_type: '1' + mac: 07:17:19:65:03:38 + usage_type: 1 bandwidth: 100 - host_id: <%= Fixtures.identify(:buildserver_managed_node) %> - physical_network_id: <%= Fixtures.identify(:dhcp_physical_network_one) %> + host: buildserver_managed_node + physical_network: dhcp_physical_network_one buildserver_nic_two: - mac: '07:17:19:65:03:39' - usage_type: '1' + mac: 07:17:19:65:03:39 + usage_type: 1 bandwidth: 100 - host_id: <%= Fixtures.identify(:buildserver_managed_node) %> - physical_network_id: <%= Fixtures.identify(:static_physical_network_one) %> + host: buildserver_managed_node + physical_network: static_physical_network_one mediaserver_nic_one: - mac: '07:17:19:65:03:32' - usage_type: '1' + mac: 07:17:19:65:03:32 + usage_type: 1 bandwidth: 100 - host_id: <%= Fixtures.identify(:mediaserver_managed_node) %> - physical_network_id: <%= Fixtures.identify(:dhcp_physical_network_one) %> + host: mediaserver_managed_node + physical_network: dhcp_physical_network_one mediaserver_nic_two: - mac: '07:17:19:65:03:31' - usage_type: '1' + mac: 07:17:19:65:03:31 + usage_type: 1 bandwidth: 100 - host_id: <%= Fixtures.identify(:mediaserver_managed_node) %> - physical_network_id: <%= Fixtures.identify(:dhcp_physical_network_one) %> + host: mediaserver_managed_node + physical_network: dhcp_physical_network_one diff --git a/src/test/fixtures/permissions.yml b/src/test/fixtures/permissions.yml index e86a42e..4fff79e 100644 --- a/src/test/fixtures/permissions.yml +++ b/src/test/fixtures/permissions.yml @@ -1,161 +1,39 @@ -one: - id: 1 - user_role: 'Super Admin' - uid: 'ovirtadmin' - pool_id: 1 -two: - id: 2 - user_role: 'Administrator' - uid: 'jadmin' - pool_id: 3 -three: - id: 3 - user_role: 'User' - uid: 'buser' - pool_id: 10 -four: - id: 4 - user_role: 'Monitor' - uid: 'auser' - pool_id: 10 -five: - id: 5 - user_role: 'Administrator' - uid: 'kadmin' - pool_id: 6 -six: - id: 6 - user_role: 'Monitor' - uid: 'auser' - pool_id: 6 -seven: - id: 7 - user_role: 'User' - uid: 'luser' - pool_id: 7 -eight: - id: 8 - user_role: 'User' - uid: 'muser' - pool_id: 7 -nine: - id: 9 - user_role: 'Monitor' - uid: 'iuser' - pool_id: 7 -ten: - id: 10 - user_role: 'Administrator' - uid: 'qadmin' - pool_id: 6 -eleven: - id: 11 - user_role: 'Monitor' - uid: 'iuser' - pool_id: 6 -twelve: - id: 12 - user_role: 'User' - uid: 'buser' - pool_id: 2 -thirteen: - id: 13 - user_role: 'User' - uid: 'yuser' - pool_id: 9 -fourteen: - id: 14 - user_role: 'Super Admin' - uid: 'ovirtadmin' - pool_id: 2 - inherited_from_id: 1 -fifteen: - id: 15 - user_role: 'Super Admin' - uid: 'ovirtadmin' - pool_id: 3 - inherited_from_id: 1 -sixteen: - id: 16 - user_role: 'Super Admin' - uid: 'ovirtadmin' - pool_id: 4 - inherited_from_id: 1 -seventeen: - id: 17 - user_role: 'Super Admin' - uid: 'ovirtadmin' - pool_id: 5 - inherited_from_id: 1 -eighteen: - id: 18 - user_role: 'Super Admin' - uid: 'ovirtadmin' - pool_id: 6 - inherited_from_id: 1 -nineteen: - id: 19 - user_role: 'Super Admin' - uid: 'ovirtadmin' - pool_id: 7 - inherited_from_id: 1 -twenty: - id: 20 - user_role: 'Super Admin' - uid: 'ovirtadmin' - pool_id: 8 - inherited_from_id: 1 -twentyone: - id: 21 - user_role: 'Super Admin' - uid: 'ovirtadmin' - pool_id: 9 - inherited_from_id: 1 -twentytwo: - id: 22 - user_role: 'Super Admin' - uid: 'ovirtadmin' - pool_id: 10 - inherited_from_id: 1 -twentythree: - id: 23 - user_role: 'Administrator' - uid: 'jadmin' - pool_id: 4 - inherited_from_id: 2 -twentyfour: - id: 24 - user_role: 'Administrator' - uid: 'jadmin' - pool_id: 5 - inherited_from_id: 2 -twentyfive: - id: 25 - user_role: 'Administrator' - uid: 'jadmin' - pool_id: 6 - inherited_from_id: 2 -twentysix: - id: 26 - user_role: 'Administrator' - uid: 'jadmin' - pool_id: 7 - inherited_from_id: 2 -twentyseven: - id: 27 - user_role: 'Administrator' - uid: 'jadmin' - pool_id: 8 - inherited_from_id: 2 -twentyeight: - id: 28 - user_role: 'Administrator' - uid: 'jadmin' - pool_id: 9 - inherited_from_id: 2 -twentynine: - id: 29 - user_role: 'Administrator' - uid: 'jadmin' - pool_id: 10 - inherited_from_id: 2 +ovirtadmin_root: + user_role: Super Admin + uid: ovirtadmin + pool: root_dir_pool +ovirtadmin_default: + user_role: Super Admin + uid: ovirtadmin + pool: default + inherited_from_id: <%= Fixtures.identify(:ovirtadmin_root) %> +ovirtadmin_hardware_pool: + user_role: Super Admin + uid: ovirtadmin + pool: hw_dir_pool + inherited_from_id: <%= Fixtures.identify(:ovirtadmin_root) %> +ovirtadmin_users_pool: + user_role: Super Admin + uid: ovirtadmin + pool: smart_dir_pool + inherited_from_id: <%= Fixtures.identify(:ovirtadmin_root) %> +ovirtadmin_corp_com_pool: + user_role: Super Admin + uid: ovirtadmin + pool: corp_com + inherited_from_id: <%= Fixtures.identify(:ovirtadmin_root) %> +ovirtadmin_corp_com_production_vmpool: + user_role: Super Admin + uid: ovirtadmin + pool: corp_com_production_vmpool + inherited_from_id: <%= Fixtures.identify(:ovirtadmin_root) %> +ovirtadmin_prodops_pool: + user_role: Super Admin #Monitor + uid: ovirtadmin + pool: corp_com_prod + inherited_from_id: <%= Fixtures.identify(:ovirtadmin_root) %> +ovirtadmin_corp_com_qa_pool: + user_role: Monitor + uid: ovirtadmin + pool: corp_com_qa + inherited_from_id: <%= Fixtures.identify(:ovirtadmin_root) %> \ No newline at end of file diff --git a/src/test/fixtures/pools.yml b/src/test/fixtures/pools.yml index 181a75b..1c810b3 100644 --- a/src/test/fixtures/pools.yml +++ b/src/test/fixtures/pools.yml @@ -1,100 +1,77 @@ -one: - id: 1 - name: 'default' - type: 'HardwarePool' - parent_id: 12 - created_at: '2008-02-13 15:42:43.417883' - updated_at: '2008-02-14 16:41:42.417883' - lft: 3 +root_dir_pool: + name: root + type: DirectoryPool + lft: 1 + rgt: 26 +hw_dir_pool: + name: hardware + type: DirectoryPool + parent_id: <%= Fixtures.identify(:root_dir_pool) %> + lft: 2 + rgt: 19 +smart_dir_pool: + name: users + type: DirectoryPool + parent_id: <%= Fixtures.identify(:root_dir_pool) %> + lft: 20 + rgt: 25 +ovirtadmin_dir_pool: + name: ovirtadmin + type: DirectoryPool + parent_id: <%= Fixtures.identify(:smart_dir_pool) %> + lft: 21 rgt: 24 -two: - id: 2 - name: 'foobar hosts' - type: 'VmResourcePool' - parent_id: 1 +default: + name: default + type: HardwarePool + parent_id: <%= Fixtures.identify(:hw_dir_pool) %> + lft: 3 + rgt: 18 +corp_com: + name: corp.com + type: HardwarePool + parent_id: <%= Fixtures.identify(:default) %> lft: 4 - rgt: 5 -three: - id: 3 - name: 'corp.com' - type: 'HardwarePool' - parent_id: 1 - lft: 6 - rgt: 23 -four: - id: 4 - name: 'corp.com dev' - type: 'HardwarePool' - parent_id: 3 - lft: 7 + rgt: 17 +corp_com_prod: + name: Production Operations + type: HardwarePool + parent_id: <%= Fixtures.identify(:corp_com) %> + lft: 5 rgt: 8 -five: - id: 5 - name: 'corp.com qa' - type: 'HardwarePool' - parent_id: 3 +corp_com_qa: + name: corp.com qa + type: HardwarePool + parent_id: <%= Fixtures.identify(:corp_com) %> lft: 9 - rgt: 20 -six: - id: 6 - name: 'corp.com production vms' - type: 'VmResourcePool' - parent_id: 3 - lft: 21 - rgt: 22 -seven: - id: 7 - name: 'foobar' - type: 'VmResourcePool' - parent_id: 5 + rgt: 12 +corp_com_dev: + name: corp.com dev + type: HardwarePool + parent_id: <%= Fixtures.identify(:corp_com) %> + lft: 13 + rgt: 16 +corp_com_production_vmpool: + name: corp.com production vmpool + type: VmResourcePool + parent_id: <%= Fixtures.identify(:corp_com_prod) %> + lft: 6 + rgt: 7 +corp_qa_vmpool: + name: corp.com qa vms + type: VmResourcePool + parent_id: <%= Fixtures.identify(:corp_com_qa) %> lft: 10 rgt: 11 -eight: - id: 8 - name: 'some foobar hardware' - type: 'HardwarePool' - parent_id: 5 - lft: 12 +corp_com_dev_vmpool: + name: corp.com dev vmpool + type: VmResourcePool + parent_id: <%= Fixtures.identify(:corp_com_dev) %> + lft: 14 rgt: 15 -nine: - id: 9 - name: 'some more foobar hardware' - type: 'HardwarePool' - parent_id: 8 - lft: 13 - rgt: 14 -ten: - id: 10 - name: 'yet another pool' - type: 'VmResourcePool' - parent_id: 5 - lft: 16 - rgt: 17 -prodops_pool: - id: 11 - name: 'Production Operations' - type: 'HardwarePool' - parent_id: 5 - lft: 18 - rgt: 19 -hw_dir_pool: - id: 12 - name: 'hardware' - type: 'DirectoryPool' - parent_id: 13 - lft: 2 - rgt: 25 -root_dir_pool: - id: 13 - name: 'root' - type: 'DirectoryPool' - lft: 1 - rgt: 28 -smart_dir_pool: - id: 14 - name: 'hardware' - type: 'DirectoryPool' - parent_id: 13 - lft: 26 - rgt: 27 - +qa_testing_smartpool: + name: qa testing + type: SmartPool + parent_id: <%= Fixtures.identify(:ovirtadmin_dir_pool) %> + lft: 22 + rgt: 23 diff --git a/src/test/fixtures/quotas.yml b/src/test/fixtures/quotas.yml index 037fd67..f953d3a 100644 --- a/src/test/fixtures/quotas.yml +++ b/src/test/fixtures/quotas.yml @@ -1,65 +1,35 @@ -# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html -one: - id: 1 +default_quota: total_vcpus: 30 - total_vmemory: 2097152 + total_vmemory: 204800000 total_vnics: 20 - total_storage: 104857600 + total_storage: 41943040000 total_vms: 20 - pool_id: 1 -two: - id: 2 + pool: default +corp_com_quota: total_vcpus: 32 - total_vmemory: 16765 + total_vmemory: 51200000 + total_vnics: 20 + total_storage: 10485760000 + total_vms: 32 + pool: corp_com +corp_com_dev_quota: + total_vcpus: 4 + total_vmemory: 12288000 total_vnics: 5 - total_storage: 1000000 - total_vms: 13 - pool_id: 3 -three: - id: 3 - total_vcpus: 2 - total_vmemory: - total_vnics: - total_storage: - total_vms: - pool_id: 4 -four: - id: 4 - total_vcpus: - total_vmemory: - total_vnics: - total_storage: - total_vms: 2 - pool_id: 6 -five: - id: 5 - total_vcpus: 3 - total_vmemory: 1024 - total_vnics: - total_storage: 150 - total_vms: - pool_id: 5 -six: - id: 6 + total_storage: 2621440000 + total_vms: 8 + pool: corp_com_dev +corp_com_qa_quota: total_vcpus: 4 - total_vmemory: 5096 - total_vnics: 3 - total_storage: 1024 - total_vms: 2 - pool_id: 5 -seven: - id: 7 - total_vcpus: - total_vmemory: - total_vnics: 1 - total_storage: 112233 - total_vms: - pool_id: 11 -eight: - id: 8 - total_vcpus: 20 - total_vmemory: 2097152 - total_vnics: 30 - total_storage: 1111111111 - total_vms: 20 - pool_id: 7 + total_vmemory: 12288000 + total_vnics: 5 + total_storage: 2621440000 + total_vms: 8 + pool: corp_com_qa +corp_com_prod_quota: + total_vcpus: 4 + total_vmemory: 12288000 + total_vnics: 5 + total_storage: 2621440000 + total_vms: 8 + pool: corp_com_prod diff --git a/src/test/fixtures/storage_pools.yml b/src/test/fixtures/storage_pools.yml index ac042a0..604b49c 100644 --- a/src/test/fixtures/storage_pools.yml +++ b/src/test/fixtures/storage_pools.yml @@ -1,65 +1,16 @@ -one: - id: 1 - hardware_pool_id: 3 - ip_addr: '127.0.0.1' - type: 'IscsiStoragePool' - port: 53 - target: 'footarget' -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: 9 - ip_addr: '192.168.50.2' - type: 'IscsiStoragePool' - port: 531 - target: 'bartarget' -nine: - id: 9 - hardware_pool_id: 9 - type: 'NfsStoragePool' - ip_addr: '1.2.3.4' - export_path: '/tmp/somepath' -ten: - id: 10 - hardware_pool_id: 9 - type: 'IscsiStoragePool' - ip_addr: '192.168.50.3' - port: 539 - target: 'stayontarget' +corp_com_ovirtpriv_storage: + hardware_pool: corp_com + ip_addr: 192.168.50.2 + type: IscsiStoragePool + port: 3260 + target: ovirtpriv:storage +corp_com_nfs_ovirtnfs: + hardware_pool: corp_com + type: NfsStoragePool + ip_addr: 192.168.50.2 + export_path: /ovirtnfs +corp_com_dev_nfs_ovirtnfs: + hardware_pool: corp_com_dev + type: NfsStoragePool + ip_addr: 192.168.50.3 + export_path: /devnfs diff --git a/src/test/fixtures/storage_volumes.yml b/src/test/fixtures/storage_volumes.yml index 1c49ace..82a1860 100644 --- a/src/test/fixtures/storage_volumes.yml +++ b/src/test/fixtures/storage_volumes.yml @@ -1,40 +1,42 @@ -# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html -one: - id: 1 - lun: 'abcd' - size: '10485760' - path: '/tmp/foobar' - storage_pool_id: 1 - type: 'IscsiStorageVolume' -two: - id: 2 - size: '20485760' - path: '/home/secretstuff' - storage_pool_id: 2 - type: 'NfsStorageVolume' - filename: 'secretstuff' -three: - id: 3 - lun: 'abcd' - size: '14221672' - path: - storage_pool_id: 1 - type: 'IscsiStorageVolume' -four: - id: 4 - lun: '49723e4d-32e6-469e-8019-913a3dc1bb5d' - size: '01223542' - storage_pool_id: 4 - type: 'IscsiStorageVolume' -five: - id: 5 - size: '42424242' - storage_pool_id: 2 - type: 'NfsStorageVolume' - filename: 'foobar' -six: - id: 6 - size: '007007' - storage_pool_id: 6 - type: 'NfsStorageVolume' - filename: 'barfoo' +ovirtpriv_storage_lun_1: + lun: lun-1 + size: 3145728 + path: /dev/disk/by-id/scsi-S_beaf321011 + storage_pool: corp_com_ovirtpriv_storage + type: IscsiStorageVolume + state: pending_setup +ovirtpriv_storage_lun_2: + lun: lun-2 + size: 3145728 + path: /dev/disk/by-id/scsi-S_beaf321012 + storage_pool: corp_com_ovirtpriv_storage + type: IscsiStorageVolume + state: pending_setup +ovirtpriv_storage_lun_3: + lun: lun-3 + size: 3145728 + path: /dev/disk/by-id/scsi-S_beaf321013 + storage_pool: corp_com_ovirtpriv_storage + type: IscsiStorageVolume + state: pending_setup +ovirt_nfs_disk_1: + size: 3145728 + path: /mnt/a3q49Sj4Sfmae1bV/disk1.dsk + storage_pool: corp_com_nfs_ovirtnfs + type: NfsStorageVolume + filename: disk1.dsk + state: pending_setup +ovirt_nfs_disk_2: + size: 3145728 + path: /mnt/a3q49Sj4Sfmae1bV/disk2.dsk + storage_pool: corp_com_nfs_ovirtnfs + type: NfsStorageVolume + filename: disk2.dsk + state: pending_setup +ovirt_nfs_disk_3: + size: 3145728 + path: /mnt/a3q49Sj4Sfmae1bV/disk3.dsk + storage_pool: corp_com_nfs_ovirtnfs + type: NfsStorageVolume + filename: disk3.dsk + state: pending_setup \ No newline at end of file diff --git a/src/test/fixtures/tasks.yml b/src/test/fixtures/tasks.yml index 404543c..7f1e0bf 100644 --- a/src/test/fixtures/tasks.yml +++ b/src/test/fixtures/tasks.yml @@ -1,110 +1,9 @@ -one: - id: 1 - user: 'admin' - action: 'create_vm' - state: 'queued' +shutdown_production_httpd_appliance_task: + user: ovirtadmin + action: shutdown_vm + state: running args: - created_at: '2008-02-13 15:42:43.417883' - time_started: - time_ended: + created_at: 2008-02-13 15:42:43.417883 message: - type: 'VmTask' - task_target_type: 'Vm' - task_target_id: 5 -two: - id: 2 - user: 'admin' - action: 'refresh_pool' - state: 'queued' - created_at: '2008-01-13 15:40:13.417883' - type: 'StorageTask' - task_target_type: 'StoragePool' - task_target_id: 1 -three: - id: 3 - user: 'luser' - action: 'start_vm' - state: 'finished' - created_at: '2002-12-14 05:12:23.417883' - time_started: '2002-12-14 05:12:23.417884' - time_ended: '2002-12-14 05:12:23.417885' - message: 'finished!' - type: 'VmTask' - task_target_type: 'Vm' - task_target_id: 7 -four: - id: 4 - user: 'buser' - action: 'pause_vm' - state: 'running' - created_at: '2015-11-23 15:12:43.417883' - time_started: '2015-11-23 15:12:43.417885' - type: 'VmTask' - task_target_type: 'Vm' - task_target_id: 2 -five: - id: 5 - user: 'admin' - action: 'pause_vm' - state: 'running' - created_at: '2015-11-23 15:12:43.417883' - time_started: '2015-11-23 15:12:43.417885' - type: 'VmTask' - task_target_type: 'Vm' - task_target_id: 3 -six: - id: 6 - user: 'buser' - action: 'clear_vms' - state: 'canceled' - created_at: '2001-01-03 01:01:01.417883' - time_started: '2001-01-03 01:05:01.417885' - time_ended: '2001-01-03 01:05:19.417885' - message: 'task cancelled' - type: 'HostTask' - task_target_type: 'Host' - task_target_id: 9 -seven: - id: 7 - user: 'yuser' - action: 'refresh_pool' - state: 'failed' - created_at: '2001-05-10 13:47:53.417883' - time_started: '2001-05-10 13:49:12.417885' - time_ended: '2001-01-10 13:49:15.417885' - message: 'task failed, insufficient permissions' - type: 'StorageTask' - task_target_type: 'StoragePool' - task_target_id: 4 -eight: - id: 8 - user: 'yuser' - action: 'refresh_pool' - state: 'finished' - created_at: '2001-05-10 13:51:53.417883' - time_started: '2001-05-10 13:53:12.417885' - time_ended: '2001-01-10 14:04:15.417885' - message: 'completed' - type: 'StorageTask' - task_target_type: 'StoragePool' - task_target_id: 4 -nine: - id: 9 - user: 'kadmin' - action: 'save_vm' - state: 'paused' - created_at: '2008-04-20 04:00:00.417883' - time_started: '2008-04-20 20:00:00.417885' - message: 'paused' - type: 'VmTask' - task_target_type: 'Vm' - task_target_id: 12 -ten: - id: 10 - user: 'kadmin' - action: 'shutdown_vm' - state: 'queued' - created_at: '2008-04-20 20:05:30.417883' - type: 'VmTask' - task_target_type: 'Vm' - task_target_id: 12 + type: VmTask + task_target: production_httpd_vm (Vm) diff --git a/src/test/fixtures/vms.yml b/src/test/fixtures/vms.yml index ca783e6..ca0d63f 100644 --- a/src/test/fixtures/vms.yml +++ b/src/test/fixtures/vms.yml @@ -1,168 +1,104 @@ -one: - id: 1 - uuid: 'dd2573c3-b97d-493d-bedf-6a8369c965e9' - description: 'production httpd appliance' +production_httpd_vm: + uuid: dd2573c3-b97d-493d-bedf-6a8369c965e9 + description: production httpd appliance num_vcpus_allocated: 2 num_vcpus_used: 2 memory_allocated: 262144 - memory_used: 1024 - vnic_mac_addr: '23:51:90:A1:13:37' - state: 'stopped' + memory_used: 131072 + vnic_mac_addr: 23:51:90:A1:13:37 + state: stopped needs_restart: 0 - boot_device: 'hd' - host_id: 1 - vm_resource_pool_id: 7 -two: - id: 2 - uuid: '89e62d32-04d9-4351-b573-b1a253397296' - description: 'production mysqld appliance' + boot_device: hd + host: prod_corp_com + vm_resource_pool: corp_com_production_vmpool +production_mysqld_vm: + uuid: 89e62d32-04d9-4351-b573-b1a253397296 + description: production mysqld appliance num_vcpus_allocated: 2 num_vcpus_used: 1 memory_allocated: 2048 memory_used: 512 - vnic_mac_addr: '15:99:FE:ED:11:EE' - state: 'running' + vnic_mac_addr: 15:99:FE:ED:11:EE + state: running needs_restart: 0 - boot_device: 'network' - host_id: 1 - vm_resource_pool_id: 7 -three: - id: 3 - uuid: 'e2714087-3a71-460c-8112-23e044f0aa1c' - description: 'production ftpd appliance' + boot_device: network + host: prod_corp_com + vm_resource_pool: corp_com_production_vmpool +production_ftpd_vm: + uuid: e2714087-3a71-460c-8112-23e044f0aa1c + description: production ftpd appliance num_vcpus_allocated: 2 num_vcpus_used: 1 memory_allocated: 1024 memory_used: 512 - vnic_mac_addr: 'FF:AA:BB:00:11:55' - state: 'stopped' + vnic_mac_addr: FF:AA:BB:00:11:55 + state: stopped needs_restart: 1 - boot_device: 'cdrom' - host_id: 1 - vm_resource_pool_id: 7 -four: - id: 4 - uuid: '95454587-24e0-4a52-bb0f-c16abf7433d0' - description: 'production postgresql appliance' + boot_device: cdrom + host: prod_corp_com + vm_resource_pool: corp_com_production_vmpool +production_postgresql_vm: + uuid: 95454587-24e0-4a52-bb0f-c16abf7433d0 + description: production postgresql appliance num_vcpus_allocated: 2 num_vcpus_used: 2 memory_allocated: 2048 memory_used: 1536 - vnic_mac_addr: '48:24:12:93:42:11' - state: 'running' + vnic_mac_addr: 48:24:12:93:42:11 + state: running needs_restart: 0 - boot_device: 'hd' - host_id: 1 - vm_resource_pool_id: 7 -five: - id: 5 - uuid: 'aae029b7-0e9a-4327-8f8a-8447f473a75b' - description: 'foobar pipeline stage1: dev' - num_vcpus_allocated: 2 - num_vcpus_used: 2 - memory_allocated: 2048 - memory_used: 2048 - vnic_mac_addr: '19:18:17:16:15:14' - state: 'running' - needs_restart: 0 - boot_device: 'hd' - host_id: 5 - vm_resource_pool_id: 2 -six: - id: 6 - uuid: 'd02d27b9-328b-4d70-8237-28557e053cb6' - description: 'foobar pipeline stage2: qa' - num_vcpus_allocated: 2 - num_vcpus_used: 2 - memory_allocated: 4096 - memory_used: 4098 - vnic_mac_addr: '25:62:A1:0F:EE:BB' - state: 'running' - needs_restart: 0 - boot_device: 'hd' - host_id: 5 - vm_resource_pool_id: 2 -seven: - id: 7 - uuid: '56f9d73d-d7bb-48d1-bc0e-0308fc22c504' - description: 'foobar pipeline stage3: stage1' + boot_device: hd + host: myworkstation_dev_corp_com + vm_resource_pool: corp_com_production_vmpool +foobar_prod1_vm: + uuid: 786c824a-392f-4bce-b5bb-6765f810acd1 + description: foobar prod1 num_vcpus_allocated: 2 num_vcpus_used: 2 memory_allocated: 4096 memory_used: 4096 - vnic_mac_addr: '42:42:42:42:42:42' - state: 'running' + vnic_mac_addr: FF:FF:FF:EE:EE:EE + state: running needs_restart: 0 - boot_device: 'cdrom' - host_id: 5 - vm_resource_pool_id: 2 -eight: - id: 8 - uuid: '1135ffad-78c7-437c-95c6-74302cf48198' - description: 'foobar pipeline stage3: stage2' - num_vcpus_allocated: 2 - num_vcpus_used: 2 - memory_allocated: 4096 - memory_used: 4096 - vnic_mac_addr: '24:24:24:24:24:24' - state: 'running' - needs_restart: 0 - boot_device: 'cdrom' - host_id: 5 - vm_resource_pool_id: 2 -nine: - id: 9 - uuid: '786c824a-392f-4bce-b5bb-6765f810acd1' - description: 'foobar prod1' - num_vcpus_allocated: 2 - num_vcpus_used: 2 - memory_allocated: 4096 - memory_used: 4096 - vnic_mac_addr: 'FF:FF:FF:EE:EE:EE' - state: 'running' - needs_restart: 0 - boot_device: 'cdrom' - host_id: 6 + boot_device: cdrom + host: fedoraworkstation_foobar_com vm_resource_pool_id: 2 ten: - id: 10 - uuid: '24b9a994-d415-481d-ace8-1d810b601eb6' - description: 'foobar prod2' + uuid: 24b9a994-d415-481d-ace8-1d810b601eb6 + description: foobar prod2 num_vcpus_allocated: 2 num_vcpus_used: 2 memory_allocated: 4096 memory_used: 4096 - vnic_mac_addr: 'EE:EE:EE:FF:FF:FF' - state: 'running' + vnic_mac_addr: EE:EE:EE:FF:FF:FF + state: running needs_restart: 0 - boot_device: 'cdrom' + boot_device: cdrom host_id: 6 vm_resource_pool_id: 2 eleven: - id: 11 - uuid: '9b2c3c73-1abe-460e-b671-b8b7b6719e4c' - description: 'corp.com errata appliance' + uuid: 9b2c3c73-1abe-460e-b671-b8b7b6719e4c + description: corp.com errata appliance num_vcpus_allocated: 2 num_vcpus_used: 2 memory_allocated: 2048 memory_used: 2048 - vnic_mac_addr: '77:77:77:77:77:77' - state: 'running' + vnic_mac_addr: 77:77:77:77:77:77 + state: running needs_restart: 0 - boot_device: 'network' + boot_device: network host_id: 8 vm_resource_pool_id: 6 twelve: - id: 12 - uuid: '552134c7-b0ad-4607-bbf5-d6b9a33c2476' - description: 'corp.com bugzilla appliance' + uuid: 552134c7-b0ad-4607-bbf5-d6b9a33c2476 + description: corp.com bugzilla appliance num_vcpus_allocated: 2 num_vcpus_used: 2 memory_allocated: 2048 memory_used: 2048 - vnic_mac_addr: '77:77:77:77:77:77' - state: 'running' + vnic_mac_addr: 77:77:77:77:77:77 + state: running needs_restart: 0 - boot_device: 'network' + boot_device: network host_id: 8 vm_resource_pool_id: 6 diff --git a/src/test/functional/host_controller_test.rb b/src/test/functional/host_controller_test.rb index 9dc73e9..9a97009 100644 --- a/src/test/functional/host_controller_test.rb +++ b/src/test/functional/host_controller_test.rb @@ -1,4 +1,4 @@ -# +# # Copyright (C) 2008 Red Hat, Inc. # Written by Scott Seago <sseago at redhat.com> # @@ -31,7 +31,7 @@ class HostControllerTest < Test::Unit::TestCase @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new - @first_id = hosts(:one).id + @host_id = hosts(:prod_corp_com).id end def test_index @@ -50,7 +50,7 @@ class HostControllerTest < Test::Unit::TestCase end def test_show - get :show, :id => @first_id + get :show, :id => @host_id assert_response :success assert_template 'show' @@ -60,10 +60,10 @@ class HostControllerTest < Test::Unit::TestCase end def test_new - get :new, :hardware_pool_id => 1 + get :new, :hardware_pool_id => pools(:default).id assert_response :redirect - assert_redirected_to :controller => 'hardware', :action => 'show', :id => 1 + assert_redirected_to :controller => 'hardware', :action => 'show', :id => pools(:default).id end def test_create @@ -78,32 +78,32 @@ class HostControllerTest < Test::Unit::TestCase end def test_edit - get :edit, :id => @first_id + get :edit, :id => @host_id assert_response :redirect - assert_redirected_to :action => 'show', :id => @first_id + assert_redirected_to :action => 'show', :id => @host_id assert_not_nil assigns(:host) assert assigns(:host).valid? end def test_update - post :update, :id => @first_id + post :update, :id => @host_id assert_response :redirect - assert_redirected_to :action => 'show', :id => @first_id + assert_redirected_to :action => 'show', :id => @host_id end def test_destroy - assert_nothing_raised { - Host.find(@first_id) - } - - post :destroy, :id => @first_id + #FIXME: this controller method does nothing, do we even need it or a test? + post :destroy, :id => @host_id assert_response :redirect - assert_redirected_to :action => 'show', :id => @first_id + assert_redirected_to :action => 'show', :id => @host_id + end - assert_nothing_raised { - Host.find(@first_id) - } + def test_disable_host + post :host_action, :action_type => 'disable', :id => @host_id + assert_response :success + json = ActiveSupport::JSON.decode(@response.body) + assert_equal 'Host was successfully disabled', json['alert'] end end diff --git a/src/test/functional/nic_controller_test.rb b/src/test/functional/nic_controller_test.rb index 673e399..8a8776a 100644 --- a/src/test/functional/nic_controller_test.rb +++ b/src/test/functional/nic_controller_test.rb @@ -24,14 +24,14 @@ require 'nic_controller' class NicController; def rescue_action(e) raise e end; end class NicControllerTest < Test::Unit::TestCase - fixtures :nics, :permissions + fixtures :permissions, :pools, :nics def setup @controller = NicController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new - @first_id = nics(:nic_one).id + @first_id = nics(:fileserver_nic_one).id end def test_show @@ -45,10 +45,10 @@ class NicControllerTest < Test::Unit::TestCase end def test_new - get :new, :host_id => 1 + get :new, :host_id => pools(:default).id assert_response :redirect - assert_redirected_to :controller => 'host', :action => 'show', :id => 1 + assert_redirected_to :controller => 'host', :action => 'show', :id => pools(:default).id end end diff --git a/src/test/functional/permission_controller_test.rb b/src/test/functional/permission_controller_test.rb index 45e7ec5..c32100a 100644 --- a/src/test/functional/permission_controller_test.rb +++ b/src/test/functional/permission_controller_test.rb @@ -1,4 +1,4 @@ - + # Copyright (C) 2008 Red Hat, Inc. # Written by Scott Seago <sseago at redhat.com> # @@ -24,18 +24,18 @@ require 'permission_controller' class PermissionController; def rescue_action(e) raise e end; end class PermissionControllerTest < Test::Unit::TestCase - fixtures :permissions + fixtures :permissions, :pools def setup @controller = PermissionController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new - @first_id = permissions(:one).id + @permission_id = permissions(:ovirtadmin_default).id end def test_show - get :show, :id => @first_id + get :show, :id => @permission_id assert_response :success assert_template 'show' @@ -45,7 +45,7 @@ class PermissionControllerTest < Test::Unit::TestCase end def test_new - get :new, :pool_id => 1 + get :new, :pool_id => pools(:default).id assert_response :success assert_template 'new' @@ -55,26 +55,32 @@ class PermissionControllerTest < Test::Unit::TestCase def test_create num_permissions = Permission.count - - post :create, :permission => { :user_role => 'Administrator', :uid => 'admin', :pool_id => 2} - + post :create, :permission => { :user_role => 'Administrator', + :uid => 'admin', + :pool_id => pools(:corp_com_production_vmpool).id} assert_response :success - assert_equal num_permissions + 1, Permission.count end def test_destroy - assert_nothing_raised { - Permission.find(@first_id) - } - - post :destroy, :id => @first_id + post :destroy, :id => @permission_id assert_response :redirect - assert_redirected_to :controller => 'hardware', :action => 'show', :id => 1 + assert_redirected_to :controller => 'hardware', :action => 'show', :id => pools(:default).id + assert_equal "<strong>ovirtadmin</strong> permissions were revoked successfully" , flash[:notice] + end + def test_no_perms_to_destroy + post :destroy, :id => permissions(:ovirtadmin_corp_com_qa_pool).id + assert_response :redirect + assert_redirected_to :controller => 'hardware', :action => 'show', :id => pools(:corp_com_qa).id + assert_equal "You do not have permission to delete this permission record" , flash[:notice] + end - assert_raise(ActiveRecord::RecordNotFound) { - Permission.find(@first_id) - } + #FIXME: write the code to make this a real test! + def test_bad_id_on_destroy +# post :destroy, :id => bad_id +# assert_response :success +# The controller needs to gracefully handle ActiveRecord::RecordNotFound, +# which it does not right now. end end diff --git a/src/test/functional/quota_controller_test.rb b/src/test/functional/quota_controller_test.rb index c87faef..dd44dfc 100644 --- a/src/test/functional/quota_controller_test.rb +++ b/src/test/functional/quota_controller_test.rb @@ -1,4 +1,4 @@ -# +# # Copyright (C) 2008 Red Hat, Inc. # Written by Scott Seago <sseago at redhat.com> # @@ -24,18 +24,18 @@ require 'quota_controller' class QuotaController; def rescue_action(e) raise e end; end class QuotaControllerTest < Test::Unit::TestCase - fixtures :quotas + fixtures :quotas, :pools def setup @controller = QuotaController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new - @first_id = quotas(:one).id + @quota_id = quotas(:default_quota).id end def test_show - get :show, :id => @first_id + get :show, :id => @quota_id assert_response :success assert_template 'show' @@ -45,7 +45,7 @@ class QuotaControllerTest < Test::Unit::TestCase end def test_new - get :new, :pool_id => 1 + get :new, :pool_id => pools(:default).id assert_response :success assert_template 'new' @@ -56,7 +56,7 @@ class QuotaControllerTest < Test::Unit::TestCase def test_create num_quotas = Quota.count - post :create, :quota => { :pool_id => 8 } + post :create, :quota => { :pool_id => pools(:default).id } assert_response :success @@ -64,7 +64,7 @@ class QuotaControllerTest < Test::Unit::TestCase end def test_edit - get :edit, :id => @first_id + get :edit, :id => @quota_id assert_response :success assert_template 'edit' @@ -74,22 +74,31 @@ class QuotaControllerTest < Test::Unit::TestCase end def test_update - post :update, :id => @first_id + post :update, :id => @quota_id assert_response :success end def test_destroy - pool = nil - assert_nothing_raised { - quota = Quota.find(@first_id) - pool = quota.pool - } - - post :destroy, :id => @first_id + post :destroy, :id => @quota_id assert_response :success + json = ActiveSupport::JSON.decode(@response.body) + assert_equal 'Quota was successfully deleted.', json['alert'] + end + + def test_not_destroyed + assert true #How do we make it return failure message? + end + + def test_no_perms_to_destroy + post :destroy, :id => quotas(:corp_com_dev_quota).id + assert_response :redirect #Is this really what we want? Or should we just pop up the login page? + end - assert_raise(ActiveRecord::RecordNotFound) { - Quota.find(@first_id) - } + #FIXME: write the code to make this a real test! + def test_bad_id_on_destroy +# post :destroy, :id => bad_id +# assert_response :success +# The controller needs to gracefully handle ActiveRecord::RecordNotFound, +# which it does not right now. end end diff --git a/src/test/functional/resources_controller_test.rb b/src/test/functional/resources_controller_test.rb index 49e8d0e..8e3989b 100644 --- a/src/test/functional/resources_controller_test.rb +++ b/src/test/functional/resources_controller_test.rb @@ -1,4 +1,4 @@ -# +# # Copyright (C) 2008 Red Hat, Inc. # Written by Scott Seago <sseago at redhat.com> # @@ -18,8 +18,20 @@ # also available at http://www.gnu.org/copyleft/gpl.html. require File.dirname(__FILE__) + '/../test_helper' +require 'resources_controller' + +# Re-raise errors caught by the controller. +class ResourcesController; def rescue_action(e) raise e end; end class ResourcesControllerTest < ActionController::TestCase + fixtures :permissions, :pools + + def setup + @controller = ResourcesController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + end + def test_index get :index assert_response :success @@ -27,45 +39,39 @@ class ResourcesControllerTest < ActionController::TestCase end def test_new - get :new, :parent_id => 1 + get :new, :parent_id => pools(:default).id assert_response :success end def test_create assert_difference('VmResourcePool.count') do - post :create, :vm_resource_pool => { :name => 'foo_resource_pool' }, :parent_id => 1 + post :create, :vm_resource_pool => { :name => 'foo_resource_pool' }, :parent_id => pools(:default).id end assert_response :success end def test_show - get :show, :id => 2 + get :show, :id => pools(:corp_com_production_vmpool).id assert_response :success end - def test_get - get :edit, :id => 2 + def test_edit + get :edit, :id => pools(:corp_com_production_vmpool).id assert_response :success end def test_update - put :update, :id => 2, :vm_resource_pool => { } + put :update, :id => pools(:corp_com_production_vmpool).id, :vm_resource_pool => { } assert_response :redirect assert_redirected_to :action => 'list' end - def test_destroy - pool = nil - assert_nothing_raised { - pool = VmResourcePool.find(10).parent.id - } - - post :destroy, :id => 10 + def test_destroy_valid_pool + post :destroy, :id => pools(:corp_com_production_vmpool).id assert_response :success - - assert_raise(ActiveRecord::RecordNotFound) { - VmResourcePool.find(10) - } + json = ActiveSupport::JSON.decode(@response.body) + assert_equal 'Virtual Machine Pool was successfully deleted.', json['alert'] end + end diff --git a/src/test/functional/storage_controller_test.rb b/src/test/functional/storage_controller_test.rb index a9f7eb9..a448fdf 100644 --- a/src/test/functional/storage_controller_test.rb +++ b/src/test/functional/storage_controller_test.rb @@ -1,4 +1,4 @@ -# +# # Copyright (C) 2008 Red Hat, Inc. # Written by Scott Seago <sseago at redhat.com> # @@ -24,14 +24,15 @@ require 'storage_controller' class StorageController; def rescue_action(e) raise e end; end class StorageControllerTest < Test::Unit::TestCase - fixtures :storage_volumes, :storage_pools + fixtures :permissions, :pools, :storage_volumes, :storage_pools def setup @controller = StorageController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new - @first_id = storage_volumes(:one).id + @lun_1_id = storage_volumes(:ovirtpriv_storage_lun_1).id + @ovirtpriv_storage_id = storage_pools(:corp_com_ovirtpriv_storage).id end def test_index @@ -50,7 +51,7 @@ class StorageControllerTest < Test::Unit::TestCase end def test_show - get :show, :id => @first_id + get :show, :id => @ovirtpriv_storage_id assert_response :success assert_template 'show' @@ -60,7 +61,7 @@ class StorageControllerTest < Test::Unit::TestCase end def test_new - get :new, :hardware_pool_id => 4 + get :new, :hardware_pool_id => pools(:corp_com).id assert_response :success assert_template 'new' @@ -80,7 +81,7 @@ class StorageControllerTest < Test::Unit::TestCase end def test_edit - get :edit, :id => @first_id + get :edit, :id => @ovirtpriv_storage_id assert_response :success assert_template 'edit' @@ -90,22 +91,27 @@ class StorageControllerTest < Test::Unit::TestCase end def test_update - post :update, :id => @first_id + post :update, :id => @ovirtpriv_storage_id assert_response :success end def test_destroy - hw_pool_id = nil - assert_nothing_raised { - pool = StoragePool.find(@first_id) - hw_pool_id = pool.hardware_pool.id - } - - post :destroy, :id => @first_id + post :destroy, :id => @ovirtpriv_storage_id assert_response :success + json = ActiveSupport::JSON.decode(@response.body) + assert_equal 'Storage Pool was successfully deleted.', json['alert'] + end + + def test_no_perms_to_destroy + post :destroy, :id => storage_pools(:corp_com_dev_nfs_ovirtnfs).id + assert_response :redirect #Is this really what we want? Or should we just pop up the login page? + end - assert_raise(ActiveRecord::RecordNotFound) { - StoragePool.find(@first_id) - } + #FIXME: write the code to make this a real test! + def test_bad_id_on_destroy +# post :destroy, :id => bad_id +# assert_response :success +# The controller needs to gracefully handle ActiveRecord::RecordNotFound, +# which it does not right now. end end diff --git a/src/test/functional/task_controller_test.rb b/src/test/functional/task_controller_test.rb index a9578b6..3b90756 100644 --- a/src/test/functional/task_controller_test.rb +++ b/src/test/functional/task_controller_test.rb @@ -31,11 +31,11 @@ class TaskControllerTest < Test::Unit::TestCase @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new - @first_id = tasks(:one).id + @task_id = tasks(:shutdown_production_httpd_appliance_task).id end def test_show - get :show, :id => @first_id + get :show, :id => @task_id assert_response :success assert_template 'show' diff --git a/src/test/functional/vm_controller_test.rb b/src/test/functional/vm_controller_test.rb index 3744f4a..7936f01 100644 --- a/src/test/functional/vm_controller_test.rb +++ b/src/test/functional/vm_controller_test.rb @@ -24,18 +24,19 @@ require 'vm_controller' class VmController; def rescue_action(e) raise e end; end class VmControllerTest < Test::Unit::TestCase - fixtures :vms + fixtures :permissions, :pools, :vms def setup @controller = VmController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new - @first_id = vms(:one).id + @vm_id = vms(:production_httpd_vm).id + @default_pool = pools(:default) end def test_show - get :show, :id => @first_id + get :show, :id => @vm_id assert_response :success assert_template 'show' @@ -45,7 +46,7 @@ class VmControllerTest < Test::Unit::TestCase end def test_new - get :new, :hardware_pool_id => 1 + get :new, :hardware_pool_id => @default_pool.id assert_response :redirect assert_redirected_to :controller => 'resources', :action => 'show' @@ -56,7 +57,14 @@ 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 => 262144, :vnic_mac_addr => 'AA:BB:CC:DD:EE:FF', :boot_device => 'network' } + post :create, :vm_resource_pool_name => 'foobar', + :hardware_pool_id => @default_pool.id, + :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', + :boot_device => 'network' } assert_response :success @@ -64,31 +72,30 @@ class VmControllerTest < Test::Unit::TestCase end def test_edit - get :edit, :id => @first_id + get :edit, :id => @vm_id assert_response :success assert_template 'edit' assert_not_nil assigns(:vm) - assert assigns(:vm).valid? + assert assigns(:vm).valid?, assigns(:vm).errors.inspect end def test_update - post :update, :id => @first_id, :vm => {} + post :update, :id => @vm_id, :vm => {} assert_response :success end def test_destroy - pool = nil - assert_nothing_raised { - pool = Vm.find(@first_id).vm_resource_pool_id - } - - post :destroy, :id => @first_id + assert_difference 'Vm.count', -1 do + post :destroy, :id => @vm_id + end assert_response :success + json = ActiveSupport::JSON.decode(@response.body) + assert_equal 'Virtual Machine was successfully deleted.', json['alert'] + end - assert_raise(ActiveRecord::RecordNotFound) { - Vm.find(@first_id) - } + def test_not_destroyed + assert true end end diff --git a/src/test/unit/active_record_env_test.rb b/src/test/unit/active_record_env_test.rb index 1b42cf5..30db689 100644 --- a/src/test/unit/active_record_env_test.rb +++ b/src/test/unit/active_record_env_test.rb @@ -21,11 +21,19 @@ require File.dirname(__FILE__) + '/../test_helper' require File.dirname(__FILE__) + '/../../dutils/active_record_env' class ActiveRecordEnvTest < Test::Unit::TestCase - fixtures :pools, :storage_pools, :hosts, :cpus, :vms, :tasks + fixtures :pools, :hosts, :vms, :boot_types, + :networks, :nics, :ip_addresses, :permissions, :quotas, + :storage_pools, :storage_volumes, :tasks def test_can_find_hosts database_connect hosts = Host.find(:all, :limit => 2) assert_not_nil hosts, 'you have no hosts list!' end + +# def test_can_get_nested_set +# pools = HardwarePool.get_default_pool.full_set_nested(:method => :json_hash_element, +# :privilege => Permission::PRIV_VIEW, :user => get_login_user) +# flunk 'pools contains: ' << pools.inspect +# end end diff --git a/src/test/unit/host_browser_awaken_test.rb b/src/test/unit/host_browser_awaken_test.rb index 4e6f803..d251e90 100644 --- a/src/test/unit/host_browser_awaken_test.rb +++ b/src/test/unit/host_browser_awaken_test.rb @@ -22,8 +22,7 @@ $: << File.join(File.dirname(__FILE__), "../../dutils") $: << File.join(File.dirname(__FILE__), "../../host-browser") require File.dirname(__FILE__) + '/../test_helper' -require 'test/unit' -require 'flexmock/test_unit' +require 'flexmock/test_unit' #probably should move this into test_helper TESTING=true diff --git a/src/test/unit/ip_address_test.rb b/src/test/unit/ip_address_test.rb index 152578e..5ecff77 100644 --- a/src/test/unit/ip_address_test.rb +++ b/src/test/unit/ip_address_test.rb @@ -1,8 +1,13 @@ -require 'test_helper' +require File.dirname(__FILE__) + '/../test_helper' class IpAddressTest < ActiveSupport::TestCase - # Replace this with your real tests. - def test_truth - assert true + fixtures :boot_types, :bondings, :networks, :nics, :ip_addresses + + def test_can_retrieve_nic + assert_equal ip_addresses(:ip_v4_mailserver_nic_one).nic.bandwidth.to_s, '100' + end + + def test_can_get_ipaddress_object + assert_equal ip_addresses(:ip_v4_mailserver_nic_one).address, '172.31.0.15' end end diff --git a/src/test/unit/permission_test.rb b/src/test/unit/permission_test.rb index 3c27b9f..5e2c7ba 100644 --- a/src/test/unit/permission_test.rb +++ b/src/test/unit/permission_test.rb @@ -1,4 +1,4 @@ -# +# # Copyright (C) 2008 Red Hat, Inc. # Written by Scott Seago <sseago at redhat.com> # @@ -23,7 +23,13 @@ class PermissionTest < Test::Unit::TestCase fixtures :permissions # Replace this with your real tests. - def test_truth - assert true + def test_simple_permission + assert_equal permissions(:ovirtadmin_root).user_role, 'Super Admin' + assert_equal permissions(:ovirtadmin_root).pool.name, 'root' + end + + def test_permission_with_parent + assert_equal permissions(:ovirtadmin_default).inherited_from_id, permissions(:ovirtadmin_root).id + assert_equal permissions(:ovirtadmin_default).parent_permission, permissions(:ovirtadmin_root) end end diff --git a/src/test/unit/pool_test.rb b/src/test/unit/pool_test.rb index c591e58..6f20f9f 100644 --- a/src/test/unit/pool_test.rb +++ b/src/test/unit/pool_test.rb @@ -23,7 +23,11 @@ class PoolTest < Test::Unit::TestCase fixtures :pools # Replace this with your real tests. - def test_truth - assert true + def test_get_name + assert_equal(pools(:corp_com_prod).name, 'Production Operations') + end + + def test_get_parent + assert_equal(pools(:corp_com_prod).parent.name, 'corp.com') end end diff --git a/src/test/unit/storage_pool_test.rb b/src/test/unit/storage_pool_test.rb index a446904..8cc8d1b 100644 --- a/src/test/unit/storage_pool_test.rb +++ b/src/test/unit/storage_pool_test.rb @@ -22,8 +22,7 @@ require File.dirname(__FILE__) + '/../test_helper' class StoragePoolTest < Test::Unit::TestCase fixtures :storage_pools - # Replace this with your real tests. - def test_truth - assert true + def test_hardware_pool_relationship + assert_equal 'corp.com', storage_pools(:corp_com_ovirtpriv_storage).hardware_pool.name end end diff --git a/src/test/unit/storage_volume_test.rb b/src/test/unit/storage_volume_test.rb index 5422706..d0a89f4 100644 --- a/src/test/unit/storage_volume_test.rb +++ b/src/test/unit/storage_volume_test.rb @@ -23,7 +23,7 @@ class StorageVolumeTest < Test::Unit::TestCase fixtures :storage_volumes # Replace this with your real tests. - def test_truth - assert true + def test_relationship_to_storage_pool + assert_equal 'corp.com', storage_volumes(:ovirtpriv_storage_lun_1).storage_pool.hardware_pool.name end end diff --git a/src/test/unit/task_test.rb b/src/test/unit/task_test.rb index e9b64b4..33a3bd8 100644 --- a/src/test/unit/task_test.rb +++ b/src/test/unit/task_test.rb @@ -1,4 +1,4 @@ -# +# # Copyright (C) 2008 Red Hat, Inc. # Written by Scott Seago <sseago at redhat.com> # @@ -20,10 +20,11 @@ require File.dirname(__FILE__) + '/../test_helper' class TaskTest < Test::Unit::TestCase - fixtures :tasks + fixtures :pools, :hosts, :vms, :permissions, :tasks - # Replace this with your real tests. - def test_truth - assert true + def test_exercise_task_relationships + assert_equal tasks(:shutdown_production_httpd_appliance_task).task_target.vm_resource_pool.name, 'corp.com production vmpool' + assert_equal tasks(:shutdown_production_httpd_appliance_task).task_target.host.hostname, 'prod.corp.com' end + end diff --git a/src/test/unit/vm_test.rb b/src/test/unit/vm_test.rb index a9ed9dc..a196130 100644 --- a/src/test/unit/vm_test.rb +++ b/src/test/unit/vm_test.rb @@ -88,4 +88,8 @@ class VmTest < Test::Unit::TestCase assert_equal @vm.cobbler_system_name, @vm.uuid, "VMs should be using the UUID as their Cobbler system name." end + + def test_get_pending_state + assert_equal 'stopped', vms(:production_httpd_vm).get_pending_state + end end -- 1.5.6.5
Jason Guiditta
2008-Nov-18 19:49 UTC
[Ovirt-devel] [PATCH server] DB change to support larger numbers.
Fix migration number, 029 was already taken. Since we store mem, storage, etc in KB, we need an 8 byte int. This patch change all tables with this type of data to support larger size. Signed-off-by: Jason Guiditta <jguiditt at redhat.com> --- src/db/migrate/030_update_integer_size.rb | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) create mode 100644 src/db/migrate/030_update_integer_size.rb diff --git a/src/db/migrate/030_update_integer_size.rb b/src/db/migrate/030_update_integer_size.rb new file mode 100644 index 0000000..5c67d48 --- /dev/null +++ b/src/db/migrate/030_update_integer_size.rb @@ -0,0 +1,22 @@ +class UpdateIntegerSize < ActiveRecord::Migration + def self.up + #Since we store mem, storage, etc in KB, we need an 8 byte int. + #Change all tables with this type of data to support larger size + + change_column :hosts, :memory, :integer, :limit => 8 + change_column :storage_volumes, :size, :integer, :limit => 8 + change_column :quotas, :total_vmemory, :integer, :limit => 8 + change_column :quotas, :total_storage, :integer, :limit => 8 + change_column :vms, :memory_allocated, :integer, :limit => 8 + change_column :vms, :memory_used, :integer, :limit => 8 + end + + def self.down + change_column :hosts, :memory, :integer, :limit => 4 + change_column :storage_volumes, :size, :integer, :limit => 4 + change_column :quotas, :total_vmemory, :integer, :limit => 4 + change_column :quotas, :total_storage, :integer, :limit => 4 + change_column :vms, :memory_allocated, :integer, :limit => 4 + change_column :vms, :memory_used, :integer, :limit => 4 + end +end -- 1.5.6.5