Пример #1
0
    def test_add_group(self):
        with session.begin():
            group = data_setup.create_group()
            user_password = '******'
            user = data_setup.create_user(password=user_password)
            data_setup.add_user_to_group(user, group)
            orig_date_modified = self.system.date_modified

        # as admin, assign the system to our test group
        b = self.browser
        login(b)
        self.go_to_system_view(tab='Groups')
        b.find_element_by_name('group.text').send_keys(group.group_name)
        b.find_element_by_name('groups').submit()
        b.find_element_by_xpath(
                '//div[@id="groups"]'
                '//td[normalize-space(text())="%s"]' % group.group_name)
        with session.begin():
            session.refresh(self.system)
            self.assert_(self.system.date_modified > orig_date_modified)

        # as a user in the group, can we see it?
        logout(b)
        login(b, user.user_name, user_password)
        click_menu_item(b, 'Systems', 'Available')
        b.find_element_by_name('simplesearch').send_keys(self.system.fqdn)
        b.find_element_by_name('systemsearch_simple').submit()
        check_system_search_results(b, present=[self.system])
Пример #2
0
    def test_add_group(self):
        with session.begin():
            group = data_setup.create_group()
            user_password = '******'
            user = data_setup.create_user(password=user_password)
            data_setup.add_user_to_group(user, group)
            orig_date_modified = self.system.date_modified

        # as admin, assign the system to our test group
        b = self.browser
        login(b)
        self.go_to_system_view(tab='Groups')
        b.find_element_by_name('group.text').send_keys(group.group_name)
        b.find_element_by_name('groups').submit()
        b.find_element_by_xpath('//div[@id="groups"]'
                                '//td[normalize-space(text())="%s"]' %
                                group.group_name)
        with session.begin():
            session.refresh(self.system)
            self.assert_(self.system.date_modified > orig_date_modified)

        # as a user in the group, can we see it?
        logout(b)
        login(b, user.user_name, user_password)
        click_menu_item(b, 'Systems', 'Available')
        b.find_element_by_name('simplesearch').send_keys(self.system.fqdn)
        b.find_element_by_name('systemsearch_simple').submit()
        check_system_search_results(b, present=[self.system])
Пример #3
0
 def test_can_reserve_manual_system(self):
     with session.begin():
         broken_system = data_setup.create_system(
             arch=u"i386", shared=True, status=SystemStatus.broken, lab_controller=self.lc
         )
         manual_system = data_setup.create_system(
             arch=u"i386", shared=True, status=SystemStatus.manual, lab_controller=self.lc
         )
     b = self.browser
     login(b)
     # broken system should not be present
     go_to_reserve_systems(b, distro_tree=self.distro_tree_i386)
     search_for_system(b, broken_system)
     check_system_search_results(b, absent=[broken_system])
     # provision manual system
     go_to_reserve_systems(b, distro_tree=self.distro_tree_i386)
     search_for_system(b, manual_system)
     row = b.find_element_by_xpath('//tr[normalize-space(string(td))="%s"]' % manual_system.fqdn)
     row.find_element_by_link_text("Reserve Now").click()
     b.find_element_by_xpath('//button[normalize-space(text())="Submit job"]').click()
     # should end up on the job page
     job_id = b.find_element_by_xpath('//td[preceding-sibling::th/text()="Job ID"]/a').text
     with session.begin():
         job = TaskBase.get_by_t_id(job_id)
         cloned_job_xml = job.to_xml(clone=True).toxml()  # cloning re-parses hostRequires
         self.assertIn(u'<hostRequires force="%s"/>' % manual_system.fqdn, cloned_job_xml)
Пример #4
0
 def test_serial_number_column(self):
     with session.begin():
         system_with_serial = data_setup.create_system()
         system_with_serial.serial = u'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
         system_without_serial = data_setup.create_system()
         system_without_serial.serial = None
     b = self.browser
     b.get(get_server_base())
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     Select(b.find_element_by_name('systemsearch-0.table'))\
         .select_by_visible_text('System/SerialNumber')
     Select(b.find_element_by_name('systemsearch-0.operation'))\
         .select_by_visible_text('is')
     # This also tests that whitespace does not foil us
     b.find_element_by_name('systemsearch-0.value').send_keys(
             ' %s ' % system_with_serial.serial)
     b.find_element_by_link_text('Toggle Result Columns').click()
     wait_for_animation(b, '#selectablecolumns')
     b.find_element_by_link_text('Select None').click()
     b.find_element_by_name('systemsearch_column_System/Name').click()
     b.find_element_by_name('systemsearch_column_System/SerialNumber').click()
     b.find_element_by_id('searchform').submit()
     check_system_search_results(b, present=[system_with_serial],
             absent=[system_without_serial])
     b.find_element_by_xpath('//table[@id="widget"]'
             '//td[2][normalize-space(text())="%s"]' % system_with_serial.serial)
Пример #5
0
 def test_can_reserve_manual_system(self):
     with session.begin():
         broken_system = data_setup.create_system(arch=u'i386', shared=True,
                                                  status=SystemStatus.broken,
                                                  lab_controller=self.lc)
         manual_system = data_setup.create_system(arch=u'i386', shared=True,
                                                  status=SystemStatus.manual,
                                                  lab_controller=self.lc)
     b = self.browser
     login(b)
     # broken system should not be present
     go_to_reserve_systems(b, distro_tree=self.distro_tree_i386)
     search_for_system(b, broken_system)
     check_system_search_results(b, absent=[broken_system])
     # provision manual system
     go_to_reserve_systems(b, distro_tree=self.distro_tree_i386)
     search_for_system(b, manual_system)
     row = b.find_element_by_xpath('//tr[normalize-space(string(td))="%s"]' % manual_system.fqdn)
     row.find_element_by_link_text('Reserve Now').click()
     b.find_element_by_xpath('//button[normalize-space(text())="Submit job"]').click()
     # should end up on the job page
     job_id = b.find_element_by_xpath('//td[preceding-sibling::th/text()="Job ID"]/a').text
     with session.begin():
         job = TaskBase.get_by_t_id(job_id)
         cloned_job_xml = job.to_xml(clone=True).toxml() # cloning re-parses hostRequires
         self.assertIn(
             u'<hostRequires force="%s"/>' % manual_system.fqdn,
             cloned_job_xml)
Пример #6
0
 def test_uninventoried_search(self):
     with session.begin():
         system = data_setup.create_system(loaned=self.user)
     b = self.browser
     perform_search(b, [('System/LastInventoried', 'is', ' ')],
                    search_url='mine')
     check_system_search_results(b, present=[system])
Пример #7
0
 def test_pool_column(self):
     with session.begin():
         pool = data_setup.create_system_pool()
         system_in_pool = data_setup.create_system()
         system_in_pool.pools.append(pool)
         system_outside_pool = data_setup.create_system()
     b = self.browser
     b.get(get_server_base())
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     Select(b.find_element_by_name('systemsearch-0.table'))\
         .select_by_visible_text('System/Pools')
     Select(b.find_element_by_name('systemsearch-0.operation'))\
         .select_by_visible_text('is')
     b.find_element_by_name('systemsearch-0.value').send_keys(pool.name)
     b.find_element_by_link_text('Toggle Result Columns').click()
     wait_for_animation(b, '#selectablecolumns')
     b.find_element_by_link_text('Select None').click()
     b.find_element_by_name('systemsearch_column_System/Name').click()
     b.find_element_by_name('systemsearch_column_System/Pools').click()
     b.find_element_by_id('searchform').submit()
     check_system_search_results(b,
                                 present=[system_in_pool],
                                 absent=[system_outside_pool])
     b.find_element_by_xpath('//table[@id="widget"]'
                             '//td[2][normalize-space(text())="%s"]' %
                             pool.name)
Пример #8
0
 def test_uninventoried_search(self):
     with session.begin():
         system = data_setup.create_system(loaned=self.user)
     b = self.browser
     perform_search(b, [('System/LastInventoried', 'is', ' ')],
             search_url='mine')
     check_system_search_results(b, present=[system])
Пример #9
0
    def test_by_device(self):
        b = self.browser
        b.get(get_server_base())
        b.find_element_by_link_text('Show Search Options').click()
        wait_for_animation(b, '#searchform')
        Select(b.find_element_by_name('systemsearch-0.table'))\
            .select_by_visible_text('Devices/Subsys_device_id')
        Select(b.find_element_by_name('systemsearch-0.operation'))\
            .select_by_visible_text('is')
        b.find_element_by_name('systemsearch-0.value').send_keys('1112')
        b.find_element_by_id('searchform').submit()
        check_system_search_results(b,
                                    present=[self.system_three],
                                    absent=[self.system_one, self.system_two])

        Select(b.find_element_by_name('systemsearch-0.table'))\
            .select_by_visible_text('Devices/Subsys_vendor_id')
        Select(b.find_element_by_name('systemsearch-0.operation'))\
            .select_by_visible_text('is not')
        b.find_element_by_name('systemsearch-0.value').send_keys('1111')
        b.find_element_by_id('doclink').click()
        Select(b.find_element_by_name('systemsearch-1.table'))\
            .select_by_visible_text('Devices/Subsys_device_id')
        Select(b.find_element_by_name('systemsearch-1.operation'))\
            .select_by_visible_text('is')
        b.find_element_by_name('systemsearch-1.value').send_keys('2224')
        b.find_element_by_id('searchform').submit()
        check_system_search_results(
            b,
            present=[self.system_two],
            absent=[self.system_one, self.system_three])
Пример #10
0
 def test_no_value(self):
     # This is just a bizarre edge case in how the existing search bar
     # handles adding new rows to the search, causing the value control to
     # be "unsuccessful" in HTML forms parlance.
     # Just delete this test when the search bar is improved in future.
     with session.begin():
         not_virtualised = data_setup.create_system(
             fqdn=u'bz1498804.notvirtualised')
         not_virtualised.hypervisor = None
         virtualised = data_setup.create_system(
             fqdn=u'bz1498804.virtualised')
         virtualised.hypervisor = Hypervisor.by_name(u'KVM')
     b = self.browser
     # Open a page with an existing search filled in.
     b.get(get_server_base() + '?systemsearch-0.table=System%2FName'
           '&systemsearch-0.operation=contains'
           '&systemsearch-0.value=bz1498804')
     # Add a new row to the search
     b.find_element_by_id('doclink').click()
     # Select a field, but don't type anything into the value
     Select(b.find_element_by_name('systemsearch-1.table'))\
         .select_by_visible_text('System/Hypervisor')
     b.find_element_by_id('searchform').submit()
     check_system_search_results(b,
                                 present=[not_virtualised],
                                 absent=[virtualised])
Пример #11
0
    def test_by_key_value_is(self):
        b = self.browser
        b.get(get_server_base())
        b.find_element_by_link_text('Show Search Options').click()
        wait_for_animation(b, '#searchform')
        Select(b.find_element_by_name('systemsearch-0.table'))\
            .select_by_visible_text('Key/Value')
        Select(b.find_element_by_name('systemsearch-0.keyvalue'))\
            .select_by_visible_text('CPUMODEL')
        Select(b.find_element_by_name('systemsearch-0.operation'))\
            .select_by_visible_text('is')
        b.find_element_by_name('systemsearch-0.value').send_keys('foocodename')
        b.find_element_by_id('searchform').submit()
        check_system_search_results(b, present=[self.system_one],
                                    absent=[self.system_two, 
                                            self.system_three, 
                                            self.system_four])

        # Key Value search from "Removed Systems"
        b.get(urljoin(get_server_base(), 'removed'))
        b.find_element_by_link_text('Show Search Options').click()
        wait_for_animation(b, '#searchform')
        Select(b.find_element_by_name('systemsearch-0.table'))\
            .select_by_visible_text('Key/Value')
        Select(b.find_element_by_name('systemsearch-0.keyvalue'))\
            .select_by_visible_text('CPUMODEL')
        Select(b.find_element_by_name('systemsearch-0.operation'))\
            .select_by_visible_text('is')
        b.find_element_by_name('systemsearch-0.value').send_keys('foocodename')
        b.find_element_by_id('searchform').submit()
        check_system_search_results(b, present=[self.system_four],
                                    absent=[self.system_one, 
                                            self.system_two, 
                                            self.system_three])
Пример #12
0
 def test_search_size_greater_than(self):
     b = self.browser
     perform_search(b, [('Disk/Size', 'greater than', '10000000000')],
                    search_url='mine')
     check_system_search_results(b,
                                 present=[self.big_disk, self.two_disks],
                                 absent=[self.small_disk, self.no_disks])
Пример #13
0
 def test_group_column(self):
     with session.begin():
         group = data_setup.create_group()
         system_with_group = data_setup.create_system()
         system_with_group.groups.append(group)
         system_without_group = data_setup.create_system()
     b = self.browser
     b.get(get_server_base())
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     Select(b.find_element_by_name('systemsearch-0.table'))\
         .select_by_visible_text('System/Group')
     Select(b.find_element_by_name('systemsearch-0.operation'))\
         .select_by_visible_text('is')
     b.find_element_by_name('systemsearch-0.value').send_keys(group.group_name)
     b.find_element_by_link_text('Toggle Result Columns').click()
     wait_for_animation(b, '#selectablecolumns')
     b.find_element_by_link_text('Select None').click()
     b.find_element_by_name('systemsearch_column_System/Name').click()
     b.find_element_by_name('systemsearch_column_System/Group').click()
     b.find_element_by_id('searchform').submit()
     check_system_search_results(b, present=[system_with_group],
             absent=[system_without_group])
     b.find_element_by_xpath('//table[@id="widget"]'
             '//td[2][normalize-space(text())="%s"]' % group.group_name)
Пример #14
0
    def test_by_device(self):
        b = self.browser
        b.get(get_server_base())
        b.find_element_by_link_text('Show Search Options').click()
        wait_for_animation(b, '#searchform')
        Select(b.find_element_by_name('systemsearch-0.table'))\
            .select_by_visible_text('Devices/Subsys_device_id')
        Select(b.find_element_by_name('systemsearch-0.operation'))\
            .select_by_visible_text('is')
        b.find_element_by_name('systemsearch-0.value').send_keys('1112')
        b.find_element_by_id('searchform').submit()
        check_system_search_results(b, present=[self.system_three],
                absent=[self.system_one, self.system_two])

        Select(b.find_element_by_name('systemsearch-0.table'))\
            .select_by_visible_text('Devices/Subsys_vendor_id')
        Select(b.find_element_by_name('systemsearch-0.operation'))\
            .select_by_visible_text('is not')
        b.find_element_by_name('systemsearch-0.value').send_keys('1111')
        b.find_element_by_id('doclink').click()
        Select(b.find_element_by_name('systemsearch-1.table'))\
            .select_by_visible_text('Devices/Subsys_device_id')
        Select(b.find_element_by_name('systemsearch-1.operation'))\
            .select_by_visible_text('is')
        b.find_element_by_name('systemsearch-1.value').send_keys('2224')
        b.find_element_by_id('searchform').submit()
        check_system_search_results(b, present=[self.system_two],
                absent=[self.system_one, self.system_three])
Пример #15
0
 def test_by_multiple_key_values_again(self):
     b = self.browser
     b.get(get_server_base())
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     Select(b.find_element_by_name('systemsearch-0.table'))\
         .select_by_visible_text('Key/Value')
     Select(b.find_element_by_name('systemsearch-0.keyvalue'))\
         .select_by_visible_text('HVM')
     Select(b.find_element_by_name('systemsearch-0.operation'))\
         .select_by_visible_text('is')
     b.find_element_by_name('systemsearch-0.value').send_keys('1')
     b.find_element_by_id('doclink').click()
     Select(b.find_element_by_name('systemsearch-1.table'))\
         .select_by_visible_text('Key/Value')
     Select(b.find_element_by_name('systemsearch-1.keyvalue'))\
         .select_by_visible_text('DISKSPACE')
     Select(b.find_element_by_name('systemsearch-1.operation'))\
         .select_by_visible_text('greater than')
     b.find_element_by_name('systemsearch-1.value').send_keys('1000')
     b.find_element_by_id('searchform').submit()
     check_system_search_results(
         b,
         present=[self.system_one],
         absent=[self.system_two, self.system_three])
Пример #16
0
    def test_by_key_value_is(self):
        b = self.browser
        b.get(get_server_base())
        b.find_element_by_link_text('Show Search Options').click()
        wait_for_animation(b, '#searchform')
        Select(b.find_element_by_name('systemsearch-0.table'))\
            .select_by_visible_text('Key/Value')
        Select(b.find_element_by_name('systemsearch-0.keyvalue'))\
            .select_by_visible_text('CPUMODEL')
        Select(b.find_element_by_name('systemsearch-0.operation'))\
            .select_by_visible_text('is')
        b.find_element_by_name('systemsearch-0.value').send_keys('foocodename')
        b.find_element_by_id('searchform').submit()
        check_system_search_results(
            b,
            present=[self.system_one],
            absent=[self.system_two, self.system_three, self.system_four])

        # Key Value search from "Removed Systems"
        b.get(urljoin(get_server_base(), 'removed'))
        b.find_element_by_link_text('Show Search Options').click()
        wait_for_animation(b, '#searchform')
        Select(b.find_element_by_name('systemsearch-0.table'))\
            .select_by_visible_text('Key/Value')
        Select(b.find_element_by_name('systemsearch-0.keyvalue'))\
            .select_by_visible_text('CPUMODEL')
        Select(b.find_element_by_name('systemsearch-0.operation'))\
            .select_by_visible_text('is')
        b.find_element_by_name('systemsearch-0.value').send_keys('foocodename')
        b.find_element_by_id('searchform').submit()
        check_system_search_results(
            b,
            present=[self.system_four],
            absent=[self.system_one, self.system_two, self.system_three])
Пример #17
0
    def test_inventoried_search_range(self):

        b = self.browser
        b.get(get_server_base() + 'mine')
        b.find_element_by_link_text('Show Search Options').click()
        wait_for_animation(b, '#searchform')

        #after
        Select(b.find_element_by_id('systemsearch_0_table'))\
            .select_by_visible_text('System/LastInventoried')
        Select(b.find_element_by_id('systemsearch_0_operation'))\
            .select_by_visible_text('after')
        b.find_element_by_id('systemsearch_0_value').clear()
        b.find_element_by_id('systemsearch_0_value').send_keys(self.date_yesterday)

        b.find_element_by_id('doclink').click()

        #before
        Select(b.find_element_by_id('systemsearch_1_table'))\
            .select_by_visible_text('System/LastInventoried')
        Select(b.find_element_by_id('systemsearch_1_operation'))\
            .select_by_visible_text('before')
        b.find_element_by_id('systemsearch_1_value').clear()
        b.find_element_by_id('systemsearch_1_value').send_keys(self.date_tomorrow)

        b.find_element_by_id('searchform').submit()
        check_system_search_results(b, present=[self.inv1, self.inv2],
                absent=[self.not_inv, self.inv3, self.inv4])
Пример #18
0
 def test_numa_column(self):
     with session.begin():
         system_with_numa = data_setup.create_system()
         system_with_numa.numa = Numa(nodes=2)
         system_without_numa = data_setup.create_system()
         system_without_numa.numa = None
     b = self.browser
     b.get(get_server_base())
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     Select(b.find_element_by_name('systemsearch-0.table'))\
         .select_by_visible_text('System/NumaNodes')
     Select(b.find_element_by_name('systemsearch-0.operation'))\
         .select_by_visible_text('is not')
     b.find_element_by_link_text('Toggle Result Columns').click()
     wait_for_animation(b, '#selectablecolumns')
     b.find_element_by_link_text('Select None').click()
     b.find_element_by_name('systemsearch_column_System/Name').click()
     b.find_element_by_name('systemsearch_column_System/NumaNodes').click()
     b.find_element_by_id('searchform').submit()
     check_system_search_results(b,
                                 present=[system_with_numa],
                                 absent=[system_without_numa])
     b.find_element_by_xpath('//table[@id="widget"]'
                             '//td[2][normalize-space(text())="2"]')
Пример #19
0
 def test_serial_number_column(self):
     with session.begin():
         system_with_serial = data_setup.create_system()
         system_with_serial.serial = u'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
         system_without_serial = data_setup.create_system()
         system_without_serial.serial = None
     b = self.browser
     b.get(get_server_base())
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     Select(b.find_element_by_name('systemsearch-0.table'))\
         .select_by_visible_text('System/SerialNumber')
     Select(b.find_element_by_name('systemsearch-0.operation'))\
         .select_by_visible_text('is')
     # This also tests that whitespace does not foil us
     b.find_element_by_name('systemsearch-0.value').send_keys(
         ' %s ' % system_with_serial.serial)
     b.find_element_by_link_text('Toggle Result Columns').click()
     wait_for_animation(b, '#selectablecolumns')
     b.find_element_by_link_text('Select None').click()
     b.find_element_by_name('systemsearch_column_System/Name').click()
     b.find_element_by_name(
         'systemsearch_column_System/SerialNumber').click()
     b.find_element_by_id('searchform').submit()
     check_system_search_results(b,
                                 present=[system_with_serial],
                                 absent=[system_without_serial])
     b.find_element_by_xpath('//table[@id="widget"]'
                             '//td[2][normalize-space(text())="%s"]' %
                             system_with_serial.serial)
Пример #20
0
    def test_inventoried_search_range(self):

        b = self.browser
        b.get(get_server_base() + 'mine')
        b.find_element_by_link_text('Show Search Options').click()
        wait_for_animation(b, '#searchform')

        #after
        Select(b.find_element_by_id('systemsearch_0_table'))\
            .select_by_visible_text('System/LastInventoried')
        Select(b.find_element_by_id('systemsearch_0_operation'))\
            .select_by_visible_text('after')
        b.find_element_by_id('systemsearch_0_value').clear()
        b.find_element_by_id('systemsearch_0_value').send_keys(
            self.date_yesterday)

        b.find_element_by_id('doclink').click()

        #before
        Select(b.find_element_by_id('systemsearch_1_table'))\
            .select_by_visible_text('System/LastInventoried')
        Select(b.find_element_by_id('systemsearch_1_operation'))\
            .select_by_visible_text('before')
        b.find_element_by_id('systemsearch_1_value').clear()
        b.find_element_by_id('systemsearch_1_value').send_keys(
            self.date_tomorrow)

        b.find_element_by_id('searchform').submit()
        check_system_search_results(
            b,
            present=[self.inv1, self.inv2],
            absent=[self.not_inv, self.inv3, self.inv4])
Пример #21
0
 def test_inventoried_search_is(self):
     with session.begin():
         system = data_setup.create_system(loaned=self.user)
         system.date_lastcheckin = datetime.datetime(2001, 1, 15, 14, 12, 0)
     b = self.browser
     perform_search(b, [('System/LastInventoried', 'is', '2001-01-15')],
                    search_url='mine')
     check_system_search_results(b, present=[system])
Пример #22
0
 def test_inventoried_search_is(self):
     with session.begin():
         system = data_setup.create_system(loaned=self.user)
         system.date_lastcheckin = datetime.datetime(2001, 1, 15, 14, 12, 0)
     b = self.browser
     perform_search(b, [('System/LastInventoried', 'is', '2001-01-15')],
             search_url='mine')
     check_system_search_results(b, present=[system])
Пример #23
0
 def test_closing_script_tag_from_search_value_is_escaped(self):
     bad_string = u"</script><script>alert('hi')</script>"
     with session.begin():
         system = data_setup.create_system(location=bad_string)
         another_system = data_setup.create_system()
     b = self.browser
     perform_search(b, [('System/Location', 'is', bad_string)])
     check_system_search_results(b, present=[system],
             absent=[another_system])
Пример #24
0
 def check_system_is_available(self, system):
     """
     Checks that the system can be found by searching on the Available page, 
     indicating that the logged-in user has access to reserve it.
     """
     b = self.browser
     b.get(get_server_base() + 'available')
     search_for_system(b, system)
     check_system_search_results(b, present=[system])
Пример #25
0
 def test_by_key_value_is_not(self):
     with session.begin():
         self.another_system.key_values_string.append(Key_Value_String(
                 Key.by_name(u'CPUMODEL'), 'foocodename'))
     b = self.browser
     perform_search(b, [('Key/Value', 'CPUMODEL', 'is not', 'foocodename')],
             search_url=u'mine')
     check_system_search_results(b, present=[self.system],
             absent=[self.another_system])
Пример #26
0
 def check_system_is_available(self, system):
     """
     Checks that the system can be found by searching on the Available page, 
     indicating that the logged-in user has access to reserve it.
     """
     b = self.browser
     b.get(get_server_base() + 'available')
     search_for_system(b, system)
     check_system_search_results(b, present=[system])
Пример #27
0
 def check_system_is_free(self, system):
     """
     Checks that the system can be found by searching on the Free page, 
     indicating that the logged-in user has access to reserve it and it is 
     currently not in use.
     """
     b = self.browser
     b.get(get_server_base() + 'free')
     search_for_system(b, system)
     check_system_search_results(b, present=[system])
Пример #28
0
 def test_sector_size_is_not_for_multiple_disks(self):
     # The search bar special-cases "is not" searches on one-to-many 
     # relationships. "Disk/Size is not 1000" does not mean "systems with 
     # a disk whose size is not 1000" but rather "systems with no disks of 
     # size 1000".
     b = self.browser
     perform_search(b, [('Disk/SectorSize', 'is not', '512')],
             search_url='mine')
     check_system_search_results(b, present=[self.big_disk, self.no_disks],
             absent=[self.small_disk, self.two_disks])
Пример #29
0
 def check_system_is_free(self, system):
     """
     Checks that the system can be found by searching on the Free page, 
     indicating that the logged-in user has access to reserve it and it is 
     currently not in use.
     """
     b = self.browser
     b.get(get_server_base() + 'free')
     search_for_system(b, system)
     check_system_search_results(b, present=[system])
Пример #30
0
 def test_admin_cannot_reserve_any_system(self):
     with session.begin():
         group_system = data_setup.create_system(shared=False)
         group_system.lab_controller = self.lc
         group_system.custom_access_policy.add_rule(
                 permission=SystemPermission.reserve,
                 group=data_setup.create_group())
     login(self.browser)
     b = self.browser
     go_to_reserve_systems(b, self.distro_tree)
     check_system_search_results(b, absent=[group_system])
Пример #31
0
 def test_prototype_systems_are_shown(self):
     # The scheduler will *not* pick a Prototype normally, but Reserve 
     # Workflow will show you them if you have access, and then 
     # <hostRequires force=""/> will let you use it even if the scheduler 
     # would have skipped it otherwise.
     with session.begin():
         self.system.type = SystemType.prototype
     b = self.browser
     login(b)
     go_to_reserve_systems(b, self.distro_tree)
     check_system_search_results(b, present=[self.system])
Пример #32
0
 def test_prototype_systems_are_shown(self):
     # The scheduler will *not* pick a Prototype normally, but Reserve
     # Workflow will show you them if you have access, and then
     # <hostRequires force=""/> will let you use it even if the scheduler
     # would have skipped it otherwise.
     with session.begin():
         self.system.type = SystemType.prototype
     b = self.browser
     login(b)
     go_to_reserve_systems(b, self.distro_tree)
     check_system_search_results(b, present=[self.system])
Пример #33
0
 def test_admin_cannot_reserve_any_system(self):
     with session.begin():
         group_system = data_setup.create_system(shared=False)
         group_system.lab_controller = self.lc
         group_system.custom_access_policy.add_rule(
             permission=SystemPermission.reserve, group=data_setup.create_group()
         )
     login(self.browser)
     b = self.browser
     go_to_reserve_systems(b, self.distro_tree)
     check_system_search_results(b, absent=[group_system])
Пример #34
0
 def test_multiple_cpu_flags(self):
     with session.begin():
         system = data_setup.create_system()
         system.cpu = Cpu(flags=['flag1', 'flag2'])
         another_system = data_setup.create_system()
         another_system.cpu = Cpu(flags=['flag3'])
     b = self.browser
     perform_search(b, [('CPU/Flags', 'is', 'flag1'),
             ('CPU/Flags', 'is', 'flag2')])
     check_system_search_results(b, present=[system],
             absent=[another_system])
Пример #35
0
 def test_can_search_by_numa_node_count(self):
     with session.begin():
         self.system.numa = Numa(nodes=1)
         self.another_system.numa = Numa(nodes=2)
     b = self.browser
     perform_search(b, [('System/NumaNodes', 'greater than', '1')])
     check_system_search_results(b, present=[self.another_system],
             absent=[self.system])
     b.get(get_server_base())
     perform_search(b, [('System/NumaNodes', 'less than', '2')])
     check_system_search_results(b, present=[self.system],
             absent=[self.another_system])
Пример #36
0
 def test_by_key_value_is_on_removed_systems_page(self):
     with session.begin():
         system = data_setup.create_system()
         removed_system = data_setup.create_system(status=SystemStatus.removed)
         removed_system.key_values_string.append(Key_Value_String(
                 Key.by_name(u'CPUMODEL'), 'foocodename'))
     # Key Value search from "Removed Systems"
     b = self.browser
     perform_search(b, [('Key/Value', 'CPUMODEL', 'is', 'foocodename')],
             search_url='removed')
     check_system_search_results(b, present=[removed_system],
             absent=[system])
Пример #37
0
 def test_search_works_on_reserve_report(self):
     # Reserve Report is a specialisation of the regular systems grid, so we 
     # aren't testing it exhaustively, we just want to make sure that the 
     # search is wired up properly.
     with session.begin():
         included = data_setup.create_system()
         data_setup.create_manual_reservation(included)
         excluded = data_setup.create_system(fqdn=data_setup.unique_name(u'aardvark%s'))
         data_setup.create_manual_reservation(excluded)
     b = self.browser
     perform_search(b, [('System/Name', 'is', included.fqdn)],
             search_url='reports/')
     check_system_search_results(b, present=[included], absent=[excluded])
Пример #38
0
 def test_inventoried_search_range(self):
     with session.begin():
         system_one = data_setup.create_system(loaned=self.user)
         system_one.date_lastcheckin = datetime.datetime(2001, 1, 15, 14, 12, 0)
         system_two = data_setup.create_system(loaned=self.user)
         system_two.date_lastcheckin = datetime.datetime(2001, 1, 14, 14, 12, 0)
         system_three = data_setup.create_system(loaned=self.user)
         system_three.date_lastcheckin = datetime.datetime(2001, 1, 16, 14, 12, 0)
     b = self.browser
     perform_search(b, [('System/LastInventoried', 'after', '2001-01-14'),
         ('System/LastInventoried', 'before', '2001-01-16')], search_url='mine')
     check_system_search_results(b, present=[system_one],
             absent=[system_two, system_three])
Пример #39
0
 def test_search_hypervisor_is_blank(self):
     b = self.browser
     b.get(get_server_base() + 'mine')
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     Select(b.find_element_by_name('systemsearch-0.table'))\
         .select_by_visible_text('System/Hypervisor')
     Select(b.find_element_by_name('systemsearch-0.operation'))\
         .select_by_visible_text('is')
     Select(b.find_element_by_name('systemsearch-0.value'))\
         .select_by_visible_text('')
     b.find_element_by_id('searchform').submit()
     check_system_search_results(b, present=[self.phys], absent=[self.kvm, self.xen])
Пример #40
0
 def test_search_hypervisor_is_blank(self):
     b = self.browser
     b.get(get_server_base() + 'mine')
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     Select(b.find_element_by_name('systemsearch-0.table'))\
         .select_by_visible_text('System/Hypervisor')
     Select(b.find_element_by_name('systemsearch-0.operation'))\
         .select_by_visible_text('is')
     Select(b.find_element_by_name('systemsearch-0.value'))\
         .select_by_visible_text('')
     b.find_element_by_id('searchform').submit()
     check_system_search_results(b, present=[self.phys], absent=[self.kvm, self.xen])
Пример #41
0
 def test_by_name(self):
     b = self.browser
     b.get(get_server_base())
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     Select(b.find_element_by_name('systemsearch-0.table'))\
         .select_by_visible_text('System/Name')
     Select(b.find_element_by_name('systemsearch-0.operation'))\
         .select_by_visible_text('is')
     b.find_element_by_name('systemsearch-0.value').send_keys(self.system_one.fqdn)
     b.find_element_by_id('searchform').submit()
     check_system_search_results(b, present=[self.system_one],
             absent=[self.system_two, self.system_three])
Пример #42
0
    def test_exluded_distro_system_not_there(self):
        with session.begin():
            self.system.excluded_osmajor.append(ExcludeOSMajor(
                    osmajor=self.distro_tree.distro.osversion.osmajor,
                    arch=self.distro_tree.arch))
        login(self.browser)
        b = self.browser
        go_to_reserve_systems(b, self.distro_tree)
        check_system_search_results(b, absent=[self.system])

        with session.begin():
            self.system.arch.append(Arch.by_name(u'x86_64')) # Make sure it still works with two archs
        go_to_reserve_systems(b, self.distro_tree)
        check_system_search_results(b, absent=[self.system])
Пример #43
0
    def test_by_date_added(self):
        with session.begin():
            new_system = data_setup.create_system()
            new_system.date_added = datetime.datetime(2020, 6, 21, 11, 30, 0)
            old_system = data_setup.create_system()
            old_system.date_added = datetime.datetime(2001, 1, 15, 14, 12, 0)

        b = self.browser
        perform_search(b, [('System/Added', 'is', '2001-01-15')])
        check_system_search_results(b,
                                    present=[old_system],
                                    absent=[new_system])

        perform_search(b, [('System/Added', 'before', '2001-01-16')])
        check_system_search_results(b,
                                    present=[old_system],
                                    absent=[new_system])

        perform_search(b, [('System/Added', 'after', '2020-12-31')])
        # no results
        b.find_element_by_xpath('//table[@id="widget" and not(.//td)]')

        perform_search(b, [('System/Added', 'after', '2020-06-20')])
        check_system_search_results(b,
                                    present=[new_system],
                                    absent=[old_system])

        perform_search(b, [('System/Added', 'after', '2020-06-20'),
                           ('System/Added', 'before', '2020-06-22')])
        check_system_search_results(b,
                                    present=[new_system],
                                    absent=[old_system])
Пример #44
0
 def test_search_size_greater_than(self):
     b = self.browser
     b.get(get_server_base() + 'mine')
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     Select(b.find_element_by_id('systemsearch_0_table'))\
         .select_by_visible_text('Disk/Size')
     Select(b.find_element_by_id('systemsearch_0_operation'))\
         .select_by_visible_text('greater than')
     b.find_element_by_id('systemsearch_0_value').clear()
     b.find_element_by_id('systemsearch_0_value').send_keys('10000000000')
     b.find_element_by_id('searchform').submit()
     check_system_search_results(b, present=[self.big_disk, self.two_disks],
             absent=[self.small_disk, self.no_disks])
Пример #45
0
    def test_by_notes(self):
        with session.begin():
            owner = data_setup.create_user()
            new_system = data_setup.create_system()
            new_system.add_note("Note1", owner)
            old_system = data_setup.create_system()
            old_system.add_note("Note2", owner)

        b = self.browser

        # System/Notes search is supposed to be case-insensitive
        perform_search(b, [('System/Notes', 'contains', 'nOTe1')])
        check_system_search_results(b,
                                    present=[new_system],
                                    absent=[old_system])

        # Specific search
        perform_search(b, [('System/Notes', 'is', 'Note2')])
        check_system_search_results(b,
                                    present=[old_system],
                                    absent=[new_system])

        # All systems without any note
        perform_search(b, [('System/Notes', 'is', '')])
        check_system_search_results(b, absent=[old_system, new_system])

        # All systems with any note
        perform_search(b, [('System/Notes', 'is not', '')])
        check_system_search_results(b, present=[old_system, new_system])

        perform_search(b, [('System/Notes', 'is', 'foobar')])
        # no results
        b.find_element_by_xpath('//table[@id="widget" and not(.//td)]')
Пример #46
0
    def test_exluded_distro_system_not_there(self):
        with session.begin():
            self.system.excluded_osmajor.append(
                ExcludeOSMajor(osmajor=self.distro_tree.distro.osversion.osmajor, arch=self.distro_tree.arch)
            )
        login(self.browser)
        b = self.browser
        go_to_reserve_systems(b, self.distro_tree)
        check_system_search_results(b, absent=[self.system])

        with session.begin():
            self.system.arch.append(Arch.by_name(u"x86_64"))  # Make sure it still works with two archs
        go_to_reserve_systems(b, self.distro_tree)
        check_system_search_results(b, absent=[self.system])
Пример #47
0
    def test_uninventoried_search(self):

        b = self.browser
        b.get(get_server_base() + 'mine')
        b.find_element_by_link_text('Show Search Options').click()
        wait_for_animation(b, '#searchform')
        Select(b.find_element_by_id('systemsearch_0_table'))\
            .select_by_visible_text('System/LastInventoried')
        Select(b.find_element_by_id('systemsearch_0_operation'))\
            .select_by_visible_text('is')
        b.find_element_by_id('systemsearch_0_value').clear()
        b.find_element_by_id('systemsearch_0_value').send_keys(' ')
        b.find_element_by_id('searchform').submit()
        check_system_search_results(b, present=[self.not_inv],
                absent=[self.inv1, self.inv2, self.inv3, self.inv4])
Пример #48
0
 def test_by_multiple_key_values(self):
     with session.begin():
         self.system = data_setup.create_system()
         self.system.key_values_string.append(Key_Value_String(
             Key.by_name(u'CPUMODEL'), 'foocodename'))
         self.system.key_values_string.append(Key_Value_String(
             Key.by_name(u'HVM'), '1'))
         self.system.key_values_int.append(Key_Value_Int(
             Key.by_name(u'DISKSPACE'), '1024'))
     b = self.browser
     perform_search(b, [('Key/Value', 'HVM', 'is', '1'),
         ('Key/Value', 'CPUMODEL', 'is', 'foocodename'),
         ('Key/Value', 'DISKSPACE', 'greater than', '1000')])
     check_system_search_results(b, present=[self.system],
             absent=[self.another_system])
Пример #49
0
    def test_mine_systems(self):

        b = self.browser
        with session.begin():
            user = data_setup.create_user(password='******')
            system1 = data_setup.create_system()
            system2 = data_setup.create_system(status=SystemStatus.removed)
            system1.loaned = user
            system2.loaned = user

        login(b, user=user.user_name, password='******')
        b.get(urljoin(get_server_base(),'mine'))
        check_system_search_results(b, present=[system1], absent=[system2])
        self.assertEqual(
            b.find_element_by_class_name('item-count').text, 'Items found: 1')
Пример #50
0
    def test_loaned_not_free(self):
        with session.begin():
            lc1 = data_setup.create_labcontroller()
            self.system_one.lab_controller=lc1

        b = self.browser
        b.get(get_server_base() + 'free')
        self.assertEquals(b.title, 'Free Systems')
        check_system_search_results(b, present=[], absent=[self.system_one])

        with session.begin():
            self.system_one.loaned = User.by_user_name(data_setup.ADMIN_USER)
        b.get(get_server_base() + 'free')
        self.assertEquals(b.title, 'Free Systems')
        check_system_search_results(b, present=[self.system_one])
Пример #51
0
 def test_search_size_greater_than(self):
     b = self.browser
     b.get(get_server_base() + 'mine')
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     Select(b.find_element_by_id('systemsearch_0_table'))\
         .select_by_visible_text('Disk/Size')
     Select(b.find_element_by_id('systemsearch_0_operation'))\
         .select_by_visible_text('greater than')
     b.find_element_by_id('systemsearch_0_value').clear()
     b.find_element_by_id('systemsearch_0_value').send_keys('10000000000')
     b.find_element_by_id('searchform').submit()
     check_system_search_results(b,
                                 present=[self.big_disk, self.two_disks],
                                 absent=[self.small_disk, self.no_disks])
Пример #52
0
    def test_group_systems(self):

        b = self.browser
        with session.begin():
            group = data_setup.create_group()
            system1 = data_setup.create_system()
            system1.groups.append(group)
            system2 = data_setup.create_system(status=SystemStatus.removed)
            system2.groups.append(group)

        b.get(urljoin(get_server_base(),
                      'groups/systems?group_id={0}'.format(group.group_id)))
        b.find_element_by_xpath('//h1[text()="Systems in Group {0}"]'.format(group.group_name))
        check_system_search_results(b, present=[system1], absent=[system2])
        self.assertEqual(
            b.find_element_by_class_name('item-count').text, 'Items found: 1')