示例#1
0
 def setUp(self):
     with session.begin():
         self.recipe = data_setup.create_recipe(
             task_list=[data_setup.create_task(),
                        data_setup.create_task()])
         data_setup.create_job_for_recipes([self.recipe])
         data_setup.mark_recipe_running(self.recipe)
示例#2
0
    def test_search_api_directly(self):
        with session.begin():
            self.arch_one = u'i386'
            self.osmajor_one = u'testosmajor'
            self.task_one = data_setup.create_task(name=u'/a/b/a', exclude_arches=[self.arch_one])
            self.task_two = data_setup.create_task(name=u'/a/b/b', exclude_arches=[self.arch_one])
            self.task_three = data_setup.create_task(name=u'/a/b/c', exclude_osmajors=[self.osmajor_one])
            data_setup.create_completed_job(task_list=[self.task_one, self.task_two, self.task_three])
            self.recipe_tasks = []
            for id in [t.id for t in [self.task_one, self.task_two, self.task_three]]:
                self.recipe_tasks.extend(self.get_task_query({'task_id': id}, False).all())

        all_tasks = self.recipe_tasks
        self.assertEqual(3, len(all_tasks))

        self.assert_result_counts_match('distro_tree_id', [t.recipe.distro_tree.id for t in all_tasks])
        self.assert_result_counts_match('distro_id', [t.recipe.distro_tree.distro.id for t in all_tasks])
        self.assert_result_counts_match('distro', [t.recipe.distro_tree.distro.name for t in all_tasks])
        self.assert_result_counts_match('arch_id', [t.recipe.distro_tree.arch_id for t in all_tasks])
        self.assert_result_counts_match('task_id', [t.task_id for t in all_tasks])
        self.assert_result_counts_match('task', [t.name for t in all_tasks])
        self.assert_result_counts_match('status', [t.status for t in all_tasks])
        self.assert_result_counts_match('result', [t.result for t in all_tasks])
        self.assert_result_counts_match('osmajor_id', [t.recipe.distro_tree.distro.osversion.osmajor_id for t in all_tasks])

        self.assertEqual(0, self.get_task_query({'is_failed': True}).count())

        self.assertEqual(0, self.get_task_query({'whiteboard': 'foo'}).count())
        self.assertEqual(3, self.get_task_query({'whiteboard': None}).count())

        system = all_tasks[0].recipe.resource.system
        self.assertEqual(3, self.get_task_query({'system': system.fqdn}).count())
        self.assertEqual(3, self.get_task_query({'system_id': system.id}).count())
示例#3
0
    def test_executed_tasks(self):
        with session.begin():
            task_two = data_setup.create_task(
                name=data_setup.unique_name(u'/a/a/a%s'))
            task_one = data_setup.create_task(
                name=data_setup.unique_name(u'/a/a/a%s'))
            job = data_setup.create_completed_job(
                task_list=[task_one, task_two])
        b = self.browser
        r = job.recipesets[0].recipes[0]
        rtask = r.tasks[0]
        b.get(get_server_base() + 'tasks/%d' % rtask.task.id)
        b.find_element_by_xpath(
            "//select[@name='osmajor_id']/"
            "option[normalize-space(text())='%s']" %
            r.distro_tree.distro.osversion.osmajor).click()
        b.find_element_by_xpath("//form[@id='form']").submit()
        self.check_recipetask_present_in_results(rtask)

        # Search by single recipe task id
        b.get(get_server_base() +
              'tasks/executed?recipe_task_id=%s' % rtask.id)
        self.check_recipetask_present_in_results(rtask)

        # Search by multiple recipe task id
        rtask2 = r.tasks[1]
        b.get(get_server_base() +
              'tasks/executed?recipe_task_id=%s&recipe_task_id=%s' %
              (rtask2.id, rtask.id))
        self.check_recipetask_present_in_results(rtask)
        self.check_recipetask_present_in_results(rtask2)
示例#4
0
 def setUpClass(cls):
     with session.begin():
         cls.arch_one = u'i386'
         cls.osmajor_one = u'testosmajor'
         cls.task_one = data_setup.create_task(name=u'/a/a/a', exclude_arches=[cls.arch_one])
         cls.task_two = data_setup.create_task(name=u'/a/a/b', exclude_arches=[cls.arch_one])
         cls.task_three = data_setup.create_task(name=u'/a/a/c', exclude_osmajors=[cls.osmajor_one])
示例#5
0
 def test_task_list_by_type(self):
     with session.begin():
         task1 = data_setup.create_task(type=[u'Regression'])
         task2 = data_setup.create_task()
     out = run_client(['bkr', 'task-list', "--type=Regression"])
     self.assertIn(task1.name, out)
     self.assertNotIn(task2.name, out)
示例#6
0
 def setUp(self):
     self.selenium = self.get_selenium()
     self.arch_one = u'i386'
     self.osmajor_one = u'testosmajor'
     self.task_one = data_setup.create_task(name=u'/a/a/a', exclude_arch=[self.arch_one])
     self.task_two = data_setup.create_task(name=u'/a/a/b', exclude_arch=[self.arch_one])
     self.task_three = data_setup.create_task(name=u'/a/a/c', exclude_osmajor=[self.osmajor_one])
     self.selenium.start()
示例#7
0
 def setUp(self):
     self.browser = self.get_browser()
     data_setup.create_device(device_class="IDE")  #needed for device page
     data_setup.create_distro()  # needed for distro page
     data_setup.create_job()  # needed for job page
     data_setup.create_task()  #create task
     system = data_setup.create_system(shared=True)
     system.activity.append(data_setup.create_system_activity())
示例#8
0
 def setUp(self):
     self.browser = self.get_browser()
     data_setup.create_device(device_class="IDE") #needed for device page
     data_setup.create_distro() # needed for distro page
     data_setup.create_job() # needed for job page
     data_setup.create_task() #create task
     system = data_setup.create_system(shared=True)
     system.activity.append(data_setup.create_system_activity())
示例#9
0
 def setUp(self):
     with session.begin():
         self.arch_one = u'i386'
         self.osmajor_one = u'testosmajor'
         self.task_one = data_setup.create_task(name=u'/a/a/a', exclude_arch=[self.arch_one])
         self.task_two = data_setup.create_task(name=u'/a/a/b', exclude_arch=[self.arch_one])
         self.task_three = data_setup.create_task(name=u'/a/a/c', exclude_osmajor=[self.osmajor_one])
     self.browser = self.get_browser()
示例#10
0
    def test_search_api_directly(self):
        with session.begin():
            self.arch_one = u'i386'
            self.osmajor_one = u'testosmajor'
            self.task_one = data_setup.create_task(
                name=u'/a/b/a', exclude_arches=[self.arch_one])
            self.task_two = data_setup.create_task(
                name=u'/a/b/b', exclude_arches=[self.arch_one])
            self.task_three = data_setup.create_task(
                name=u'/a/b/c', exclude_osmajors=[self.osmajor_one])
            data_setup.create_completed_job(
                task_list=[self.task_one, self.task_two, self.task_three])
            self.recipe_tasks = []
            for id in [
                    t.id
                    for t in [self.task_one, self.task_two, self.task_three]
            ]:
                self.recipe_tasks.extend(
                    self.get_task_query({
                        'task_id': id
                    }, False).all())

        all_tasks = self.recipe_tasks
        self.assertEqual(3, len(all_tasks))

        self.assert_result_counts_match(
            'distro_tree_id', [t.recipe.distro_tree.id for t in all_tasks])
        self.assert_result_counts_match(
            'distro_id', [t.recipe.distro_tree.distro.id for t in all_tasks])
        self.assert_result_counts_match(
            'distro', [t.recipe.distro_tree.distro.name for t in all_tasks])
        self.assert_result_counts_match(
            'arch_id', [t.recipe.distro_tree.arch_id for t in all_tasks])
        self.assert_result_counts_match('task_id',
                                        [t.task_id for t in all_tasks])
        self.assert_result_counts_match('task', [t.name for t in all_tasks])
        self.assert_result_counts_match('status',
                                        [t.status for t in all_tasks])
        self.assert_result_counts_match('result',
                                        [t.result for t in all_tasks])
        self.assert_result_counts_match('osmajor_id', [
            t.recipe.distro_tree.distro.osversion.osmajor_id for t in all_tasks
        ])

        self.assertEqual(0, self.get_task_query({'is_failed': True}).count())

        self.assertEqual(0, self.get_task_query({'whiteboard': 'foo'}).count())
        self.assertEqual(3, self.get_task_query({'whiteboard': None}).count())

        system = all_tasks[0].recipe.resource.system
        self.assertEqual(3,
                         self.get_task_query({
                             'system': system.fqdn
                         }).count())
        self.assertEqual(3,
                         self.get_task_query({
                             'system_id': system.id
                         }).count())
示例#11
0
 def test_destructive_all(self):
     with session.begin():
         task1 = data_setup.create_task()
         task1.destructive = True
         task2 = data_setup.create_task()
         task2.destructive = False
     out = run_client(['bkr', 'task-list'])
     self.assert_(task1.name in out.splitlines(), out)
     self.assert_(task2.name in out.splitlines(), out)
示例#12
0
 def test_filter_by_osmajor(self):
     with session.begin():
         included = data_setup.create_task()
         excluded = data_setup.create_task(
             exclude_osmajors=[u'MagentaGloveLinux4'])
     result = self.server.tasks.filter(dict(osmajor=u'MagentaGloveLinux4'))
     task_names = [task['name'] for task in result]
     self.assertIn(included.name, task_names)
     self.assertNotIn(excluded.name, task_names)
示例#13
0
 def test_filter_by_osmajor(self):
     with session.begin():
         included = data_setup.create_task()
         excluded = data_setup.create_task(
                 exclude_osmajors=[u'MagentaGloveLinux4'])
     result = self.server.tasks.filter(dict(osmajor=u'MagentaGloveLinux4'))
     task_names = [task['name'] for task in result]
     self.assertIn(included.name, task_names)
     self.assertNotIn(excluded.name, task_names)
示例#14
0
 def test_destructive_all(self):
     with session.begin():
         task1 = data_setup.create_task()
         task1.destructive = True
         task2 = data_setup.create_task()
         task2.destructive = False
     out = run_client(['bkr', 'task-list'])
     self.assert_(task1.name in out.splitlines(), out)
     self.assert_(task2.name in out.splitlines(), out)
示例#15
0
 def setUpClass(cls):
     with session.begin():
         cls.arch_one = u'i386'
         cls.osmajor_one = u'testosmajor'
         cls.task_one = data_setup.create_task(
             name=u'/a/a/a', exclude_arches=[cls.arch_one])
         cls.task_two = data_setup.create_task(
             name=u'/a/a/b', exclude_arches=[cls.arch_one])
         cls.task_three = data_setup.create_task(
             name=u'/a/a/c', exclude_osmajors=[cls.osmajor_one])
示例#16
0
 def test_by_distro(self):
     with session.begin():
         distro = data_setup.create_distro(osmajor=u'RedHatEnterpriseLinux6')
         included = data_setup.create_task()
         excluded = data_setup.create_task(
                 exclude_osmajor=[u'RedHatEnterpriseLinux6'])
     out = run_client(['bkr', 'task-list', '--distro', distro.name])
     task_names = out.splitlines()
     self.assertIn(included.name, task_names)
     self.assertNotIn(excluded.name, task_names)
示例#17
0
 def test_by_distro(self):
     with session.begin():
         distro = data_setup.create_distro(osmajor=u'RedHatEnterpriseLinux6')
         included = data_setup.create_task()
         excluded = data_setup.create_task(
                 exclude_osmajors=[u'RedHatEnterpriseLinux6'])
     out = run_client(['bkr', 'task-list', '--distro', distro.name])
     task_names = out.splitlines()
     self.assertIn(included.name, task_names)
     self.assertNotIn(excluded.name, task_names)
示例#18
0
 def setUp(self):
     with session.begin():
         self.arch_one = u'i386'
         self.osmajor_one = u'testosmajor'
         self.task_one = data_setup.create_task(
             name=u'/a/a/a', exclude_arches=[self.arch_one])
         self.task_two = data_setup.create_task(
             name=u'/a/a/b', exclude_arches=[self.arch_one])
         self.task_three = data_setup.create_task(
             name=u'/a/a/c', exclude_osmajors=[self.osmajor_one])
     self.browser = self.get_browser()
示例#19
0
 def setUp(self):
     self.verificationErrors = []
     self.selenium = self.get_selenium()
     self.selenium.start()
     data_setup.create_device(device_class="IDE") #needed for device page
     data_setup.create_distro() # needed for distro page
     data_setup.create_job() # needed for job page
     data_setup.create_task() #create task
     system = data_setup.create_system()
     system.shared = True
     system.activity.append(data_setup.create_system_activity())
示例#20
0
def setup_package():
    assert os.path.exists(CONFIG_FILE), 'Config file %s must exist' % CONFIG_FILE
    load_config(configfile=CONFIG_FILE)
    log_to_stream(sys.stdout, level=logging.DEBUG)

    from bkr.inttest import data_setup
    if not 'BEAKER_SKIP_INIT_DB' in os.environ:
        data_setup.setup_model()
    with session.begin():
        data_setup.create_labcontroller() #always need a labcontroller
        data_setup.create_task(name=u'/distribution/install', requires=
                u'make gcc nfs-utils wget procmail redhat-lsb ntp '
                u'@development-tools @development-libs @development '
                u'@desktop-platform-devel @server-platform-devel '
                u'libxml2-python expect pyOpenSSL'.split())
        data_setup.create_task(name=u'/distribution/reservesys',
                requires=u'emacs vim-enhanced unifdef sendmail'.split())
        data_setup.create_distro()

    if not os.path.exists(turbogears.config.get('basepath.rpms')):
        os.mkdir(turbogears.config.get('basepath.rpms'))

    setup_slapd()

    turbogears.testutil.make_app(Root)
    turbogears.testutil.start_server()

    if 'BEAKER_SERVER_BASE_URL' not in os.environ:
        # need to start the server ourselves
        # Usual pkg_resources ugliness is needed to ensure gunicorn doesn't
        # import pkg_resources before we get a chance to specify our
        # requirements in bkr.server.wsgi
        processes.extend([
            Process('gunicorn', args=[sys.executable, '-c',
                '__requires__ = ["CherryPy < 3.0"]; import pkg_resources; ' \
                'from gunicorn.app.wsgiapp import run; run()',
                '--bind', ':%s' % turbogears.config.get('server.socket_port'),
                '--workers', '8', '--access-logfile', '-', '--preload',
                'bkr.server.wsgi:application'],
                listen_port=turbogears.config.get('server.socket_port')),
        ])
    processes.extend([
        Process('slapd', args=['slapd', '-d0', '-F/tmp/beaker-tests-slapd-config',
                '-hldap://127.0.0.1:3899/'],
                listen_port=3899, stop_signal=signal.SIGINT),
    ])
    try:
        for process in processes:
            process.start()
    except:
        for process in processes:
            process.stop()
        raise
示例#21
0
def setup_package():
    log.info('Loading test configuration from %s', CONFIG_FILE)
    assert os.path.exists(CONFIG_FILE), 'Config file %s must exist' % CONFIG_FILE
    update_config(configfile=CONFIG_FILE, modulename='bkr.server.config')

    # Override loaded logging config, in case we are using the server's config file
    # (we really always want our tests' logs to go to stdout, not /var/log/beaker/)
    log_to_stream(sys.stdout, level=logging.NOTSET)

    from bkr.inttest import data_setup
    if not 'BEAKER_SKIP_INIT_DB' in os.environ:
        data_setup.setup_model()
    with session.begin():
        data_setup.create_labcontroller() #always need a labcontroller
        data_setup.create_task(name=u'/distribution/install', requires=
                u'make gcc nfs-utils wget procmail redhat-lsb ntp '
                u'@development-tools @development-libs @development '
                u'@desktop-platform-devel @server-platform-devel '
                u'libxml2-python expect pyOpenSSL'.split())
        data_setup.create_task(name=u'/distribution/reservesys',
                requires=u'emacs vim-enhanced unifdef sendmail'.split())
        data_setup.create_distro()

    if not os.path.exists(turbogears.config.get('basepath.rpms')):
        os.mkdir(turbogears.config.get('basepath.rpms'))

    setup_slapd()

    turbogears.testutil.make_app(Root)
    turbogears.testutil.start_server()

    if 'BEAKER_SERVER_BASE_URL' not in os.environ:
        # need to start the server ourselves
        # (this only works from the IntegrationTests dir of a Beaker checkout)
        processes.extend([
            Process('beaker', args=['../Server/start-server.py', CONFIG_FILE],
                    listen_port=turbogears.config.get('server.socket_port'),
                    stop_signal=signal.SIGINT)
        ])
    processes.extend([
        Process('slapd', args=['slapd', '-d0', '-F/tmp/beaker-tests-slapd-config',
                '-hldap://127.0.0.1:3899/'],
                listen_port=3899, stop_signal=signal.SIGINT),
    ])
    try:
        for process in processes:
            process.start()
    except:
        for process in processes:
            process.stop()
        raise
示例#22
0
 def test_details_invalid_tasks(self):
     with session.begin():
         task = data_setup.create_task(name=u'invalid_task', valid=False)
         task.uploader = None
     out = run_client(['bkr', 'task-details', '--invalid', task.name])
     details = eval(out[len(task.name) + 1:]) # XXX dodgy
     self.assertEquals(details['name'], 'invalid_task')
示例#23
0
 def test_details_invalid_tasks(self):
     with session.begin():
         task = data_setup.create_task(name=u'invalid_task', valid=False)
         task.uploader = None
     out = run_client(['bkr', 'task-details', '--invalid', task.name])
     details = eval(out[len(task.name) + 1:])  # XXX dodgy
     self.assertEquals(details['name'], 'invalid_task')
示例#24
0
文件: test_jobs.py 项目: omps/beaker
 def test_job_with_excluded_task(self):
     with session.begin():
         distro_tree = data_setup.create_distro_tree(arch=u'ia64')
         excluded_task = data_setup.create_task(exclude_arch=[u'ia64'])
     b = self.browser
     login(b)
     b.get(get_server_base())
     click_menu_item(b, 'Scheduler', 'New Job')
     xml_file = tempfile.NamedTemporaryFile()
     xml_file.write('''
         <job>
             <whiteboard>job with excluded task</whiteboard>
             <recipeSet>
                 <recipe>
                     <distroRequires>
                         <distro_name op="=" value="%s" />
                         <distro_arch op="=" value="ia64" />
                     </distroRequires>
                     <hostRequires/>
                     <task name="/distribution/install" role="STANDALONE">
                         <params/>
                     </task>
                     <task name="%s" role="STANDALONE">
                         <params/>
                     </task>
                 </recipe>
             </recipeSet>
         </job>
         ''' % (distro_tree.distro.name, excluded_task.name))
     xml_file.flush()
     b.find_element_by_id('jobs_filexml').send_keys(xml_file.name)
     b.find_element_by_xpath('//button[text()="Submit Data"]').click()
     b.find_element_by_xpath('//button[text()="Queue"]').click()
     flash_message = b.find_element_by_class_name('flash').text
     self.assert_(flash_message.startswith('Success!'), flash_message)
示例#25
0
    def test_task_details_xml(self):
        with session.begin():
            task = data_setup.create_task(
                path=u'/testing/path',
                description=u'blah',
                exclude_arches=[u'i386', u'ppc'],
                exclude_osmajors=[u'MajorFoo', u'WunderFooBar'],
                requires=[u'2+2', u'Tofudebeast'],
                runfor=[u'philip', u'bradley'],
                type=[u'type3', u'type4'],
            )

        # regular xml
        out = run_client(['bkr', 'task-details', '--xml', task.name])

        task_elem = lxml.etree.fromstring(re.sub(task.name, '', out, count=1))
        self.assert_(task_elem.get('version') == task.version)
        self.assert_(task_elem.get('nda') == task.nda or 'False')
        self.assert_(task_elem.get('name') == task.name)
        self.assert_(
            task_elem.get('destructive') == task.destructive or 'False')
        self.assert_(task_elem.find('description').text == task.description)
        self.assert_(task_elem.find('owner').text == task.owner)
        self.assert_(task_elem.find('path').text == task.path)

        self.assert_(len(task_elem.xpath("types/type[text()='type3']")) == 1)
        self.assert_(len(task_elem.xpath("types/type[text()='type4']")) == 1)
        self.assert_(
            len(task_elem.xpath("requires/package[text()='Tofudebeast']")) ==
            1)
        self.assert_(
            len(task_elem.xpath("requires/package[text()='2+2']")) == 1)
        self.assert_(
            len(task_elem.xpath("runFor/package[text()='philip']")) == 1)
        self.assert_(
            len(task_elem.xpath("runFor/package[text()='bradley']")) == 1)
        self.assert_(
            len(
                task_elem.xpath(
                    "excludedDistroFamilies/distroFamily[text()='MajorFoo']"))
            == 1)
        self.assert_(
            len(
                task_elem.xpath(
                    "excludedDistroFamilies/distroFamily[text()='WunderFooBar']"
                )) == 1)
        self.assert_(
            len(task_elem.xpath("excludedArches/arch[text()='i386']")) == 1)
        self.assert_(
            len(task_elem.xpath("excludedArches/arch[text()='ppc']")) == 1)

        # pretty xml
        pretty_out = run_client(
            ['bkr', 'task-details', '--prettyxml', task.name])
        pretty_minus_leading_name = re.sub(task.name, '', pretty_out, count=1)
        task_elem_pretty = lxml.etree.tostring(task_elem,
                                               pretty_print=True,
                                               encoding='utf8')
        self.assert_(
            task_elem_pretty.strip() == pretty_minus_leading_name.strip())
示例#26
0
    def test_return_system_reservation(self):
        b = self.browser
        with session.begin():
            recipe = data_setup.create_recipe(
                task_list=[data_setup.create_task()],
                reservesys=True,
                reservesys_duration=1800,
            )
            job = data_setup.create_job_for_recipes([recipe], owner=self.user)
            data_setup.mark_recipe_tasks_finished(job.recipesets[0].recipes[0])
            job.update_status()

        self.go_to_recipe_view(recipe)
        b.find_element_by_xpath('//span[@class="statusReserved"]')
        duration = b.find_element_by_xpath(
            '//span[@class="reservation_duration"]').text
        self.assertRegexpMatches(duration, r'(0:\d\d:\d\d remaining)')
        b.find_element_by_link_text('Release System').click()
        b.find_element_by_xpath(
            '//h1[text()="Release reserved system for Recipe %s"]' % recipe.id)
        b.find_element_by_xpath(
            '//form[@id="end_recipe_reservation"]//input[@type="submit"]'
        ).click()
        flash_text = b.find_element_by_class_name('flash').text
        self.assertEquals(
            'Successfully released reserved system for %s' % recipe.t_id,
            flash_text)
示例#27
0
 def test_job_with_excluded_task(self):
     with session.begin():
         distro_tree = data_setup.create_distro_tree(arch=u'ia64')
         excluded_task = data_setup.create_task(exclude_arch=[u'ia64'])
     b = self.browser
     login(b)
     b.get(get_server_base())
     click_menu_item(b, 'Scheduler', 'New Job')
     xml_file = tempfile.NamedTemporaryFile()
     xml_file.write('''
         <job>
             <whiteboard>job with excluded task</whiteboard>
             <recipeSet>
                 <recipe>
                     <distroRequires>
                         <distro_name op="=" value="%s" />
                         <distro_arch op="=" value="ia64" />
                     </distroRequires>
                     <hostRequires/>
                     <task name="/distribution/install" role="STANDALONE">
                         <params/>
                     </task>
                     <task name="%s" role="STANDALONE">
                         <params/>
                     </task>
                 </recipe>
             </recipeSet>
         </job>
         ''' % (distro_tree.distro.name, excluded_task.name))
     xml_file.flush()
     b.find_element_by_id('jobs_filexml').send_keys(xml_file.name)
     b.find_element_by_xpath('//button[text()="Submit Data"]').click()
     b.find_element_by_xpath('//button[text()="Queue"]').click()
     flash_message = b.find_element_by_class_name('flash').text
     self.assert_(flash_message.startswith('Success!'), flash_message)
示例#28
0
 def test_task_list_with_xml_params(self):
     with session.begin():
         task = data_setup.create_task()
     out = run_client(['bkr', 'task-list', '--xml', '--params', 'key=value'])
     self.assertIn('<task name="%s">'
                  '\n\t<params>\n\t\t<param name="key" value="value"/>\n\t</params>'
                  '\n</task>\n' % task.name, out)
示例#29
0
 def test_details_without_owner(self):
     # We no longer permit empty Owner but older tasks may still lack it
     with session.begin():
         task = data_setup.create_task()
         task.owner = None
     out = run_client(['bkr', 'task-details', task.name])
     details = eval(out[len(task.name) + 1:])  # XXX dodgy
     self.assertEquals(details['owner'], None)
 def test_task_durations(self):
     short_task = data_setup.create_task()
     long_task = data_setup.create_task()
     r = data_setup.create_recipe(task_list=[short_task, long_task])
     data_setup.mark_job_complete(data_setup.create_job_for_recipes([r]))
     r.tasks[0].start_time = datetime.datetime(2012, 10, 15, 10, 54, 0)
     r.tasks[0].finish_time = datetime.datetime(2012, 10, 15, 11, 0, 0)
     r.tasks[1].start_time = datetime.datetime(2012, 10, 15, 11, 0, 0)
     r.tasks[1].finish_time = datetime.datetime(2012, 10, 15, 21, 0, 0)
     session.flush()
     rows = list(self.execute_reporting_query('task-durations-by-arch'))
     short_task_row, = [row for row in rows if row.task == short_task.name]
     self.assertEquals(short_task_row.executions, 1)
     self.assertEquals(short_task_row.avg_duration, Decimal('0.1'))
     long_task_row, = [row for row in rows if row.task == long_task.name]
     self.assertEquals(long_task_row.executions, 1)
     self.assertEquals(long_task_row.avg_duration, Decimal('10.0'))
示例#31
0
 def test_details_without_owner(self):
     # We no longer permit empty Owner but older tasks may still lack it
     with session.begin():
         task = data_setup.create_task()
         task.owner = None
     out = run_client(['bkr', 'task-details', task.name])
     details = eval(out[len(task.name) + 1:]) # XXX dodgy
     self.assertEquals(details['owner'], None)
示例#32
0
 def test_details_without_uploader(self):
     # We now always record Uploader, but older tasks may lack it
     with session.begin():
         task = data_setup.create_task()
         task.uploader = None
     out = run_client(['bkr', 'task-details', task.name])
     details = eval(out[len(task.name) + 1:]) # XXX dodgy
     self.assertEquals(details['uploader'], None)
示例#33
0
 def test_details_without_uploader(self):
     # We now always record Uploader, but older tasks may lack it
     with session.begin():
         task = data_setup.create_task()
         task.uploader = None
     out = run_client(['bkr', 'task-details', task.name])
     details = eval(out[len(task.name) + 1:])  # XXX dodgy
     self.assertEquals(details['uploader'], None)
示例#34
0
    def test_filters_task_by_arch_with_given_taskfile(self):
        with session.begin():
            ignored_task = data_setup.create_task(exclude_arch=[self.distro_tree.arch.arch])
            included_task = data_setup.create_task()

        taskfile = NamedTemporaryFile()
        taskfile.write('\n'.join([ignored_task.name, included_task.name]))
        taskfile.flush()

        out = run_client(['bkr', 'workflow-simple',
                          '--dryrun', '--prettyxml',
                          '--family', self.distro.osversion.osmajor.osmajor,
                          '--arch', self.distro_tree.arch.arch,
                          '--taskfile', taskfile.name])

        self.assertNotIn(ignored_task.name, out)
        self.assertIn(included_task.name, out)
示例#35
0
 def test_details_include_owner_and_priority(self):
     with session.begin():
         owner = u'*****@*****.**'
         task = data_setup.create_task(owner=owner, priority=u'Low')
     out = run_client(['bkr', 'task-details', task.name])
     details = eval(out[len(task.name) + 1:])  # XXX dodgy
     self.assertEquals(details['owner'], owner)
     self.assertEquals(details['priority'], u'Low')
示例#36
0
 def test_details_include_owner_and_priority(self):
     with session.begin():
         owner = u'*****@*****.**'
         task = data_setup.create_task(owner=owner, priority=u'Low')
     out = run_client(['bkr', 'task-details', task.name])
     details = eval(out[len(task.name) + 1:]) # XXX dodgy
     self.assertEquals(details['owner'], owner)
     self.assertEquals(details['priority'], u'Low')
示例#37
0
 def test_details_include_owner_and_priority(self):
     with session.begin():
         owner = data_setup.create_user(user_name=u'*****@*****.**')
         task = data_setup.create_task(owner=owner, priority=u'Low')
     out = run_client(['bkr', 'task-details', task.name])
     details = eval(out[len(task.name) + 1:]) # XXX dodgy
     self.assertEquals(details['owner'], u'*****@*****.**')
     self.assertEquals(details['priority'], u'Low')
示例#38
0
    def test_filters_task_by_arch_with_given_taskfile(self):
        with session.begin():
            ignored_task = data_setup.create_task(
                exclude_arches=[self.distro_tree.arch.arch])
            included_task = data_setup.create_task()

        taskfile = NamedTemporaryFile()
        taskfile.write('\n'.join([ignored_task.name, included_task.name]))
        taskfile.flush()

        out = run_client([
            'bkr', 'workflow-simple', '--dryrun', '--prettyxml', '--family',
            self.distro.osversion.osmajor.osmajor, '--arch',
            self.distro_tree.arch.arch, '--taskfile', taskfile.name
        ])

        self.assertNotIn(ignored_task.name, out)
        self.assertIn(included_task.name, out)
示例#39
0
 def setUp(self):
     with session.begin():
         self.recipe = data_setup.create_recipe(task_name=u'/distribution/install')
         self.recipe.tasks.extend([
             RecipeTask.from_task(data_setup.create_task()),
             RecipeTask.from_fetch_url(u'http://example.com/tasks/example.tar.bz2'),
         ])
         data_setup.create_job_for_recipes([self.recipe])
         data_setup.mark_recipe_running(self.recipe)
示例#40
0
 def test_exclusive_arches(self):
     with session.begin():
         task = data_setup.create_task(runfor=[u'httpd'],
                 exclusive_arches=[u's390', u's390x'])
     result = self.server.tasks.filter(dict(packages=['httpd']))
     self.assertEquals(result[0]['name'], task.name)
     # Note that the 'arches' key is actually the *excluded* arches.
     self.assertEquals(result[0]['arches'],
             ['aarch64', 'arm', 'armhfp', 'i386', 'ia64', 'ppc', 'ppc64', 'ppc64le', 'x86_64'])
 def test_task_durations(self):
     short_task = data_setup.create_task()
     long_task = data_setup.create_task()
     r = data_setup.create_recipe(task_list=[short_task, long_task])
     data_setup.mark_job_complete(
             data_setup.create_job_for_recipes([r]))
     r.tasks[0].start_time = datetime.datetime(2012, 10, 15, 10, 54, 0)
     r.tasks[0].finish_time = datetime.datetime(2012, 10, 15, 11, 0, 0)
     r.tasks[1].start_time = datetime.datetime(2012, 10, 15, 11, 0, 0)
     r.tasks[1].finish_time = datetime.datetime(2012, 10, 15, 21, 0, 0)
     session.flush()
     rows = list(self.execute_reporting_query('task-durations-by-arch'))
     short_task_row, = [row for row in rows if row.task == short_task.name]
     self.assertEquals(short_task_row.executions, 1)
     self.assertEquals(short_task_row.avg_duration, Decimal('0.1'))
     long_task_row, = [row for row in rows if row.task == long_task.name]
     self.assertEquals(long_task_row.executions, 1)
     self.assertEquals(long_task_row.avg_duration, Decimal('10.0'))
示例#42
0
    def test_filters_task_by_osmajor_with_given_taskfile(self):
        with session.begin():
            ignored_task = data_setup.create_task(exclude_osmajor=[self.distro.osversion.osmajor.osmajor])
            included_task = data_setup.create_task()

        taskfile = NamedTemporaryFile()
        taskfile.write('\n'.join([ignored_task.name, included_task.name]))
        taskfile.flush()

        p = start_client(['bkr', 'workflow-simple',
                          '--dryrun', '--prettyxml',
                          '--family', self.distro.osversion.osmajor.osmajor,
                          '--arch', self.distro_tree.arch.arch,
                          '--taskfile', taskfile.name])
        out, err = p.communicate()
        self.assertEqual(p.returncode, 0)
        self.assertEqual('WARNING: task %s not applicable for distro, ignoring\n' % ignored_task.name, err)
        self.assertNotIn(ignored_task.name, out)
        self.assertIn(included_task.name, out)
示例#43
0
 def test_details_without_owner(self):
     # The original bug was that the owner was not filled in, so some older
     # task rows would still have None. However for bug 859785 these were
     # coerced to empty string.
     with session.begin():
         task = data_setup.create_task()
         task.owner = u''
     out = run_client(['bkr', 'task-details', task.name])
     details = eval(out[len(task.name) + 1:])  # XXX dodgy
     self.assertEquals(details['owner'], '')
示例#44
0
 def test_details_without_owner(self):
     # The original bug was that the owner was not filled in, so some older 
     # task rows would still have None. However for bug 859785 these were 
     # coerced to empty string.
     with session.begin():
         task = data_setup.create_task()
         task.owner = ''
     out = run_client(['bkr', 'task-details', task.name])
     details = eval(out[len(task.name) + 1:]) # XXX dodgy
     self.assertEquals(details['owner'], '')
示例#45
0
    def test_show_failed_results(self):
        # To check correct display of failed results
        #   - create 3 recipes with 2 tasks each
        #   - for each recipe, mark the first task as failed in some way
        #     (Fail, Warn, Panic)
        #   - check clicking "Show Failed Results" tab shows only the first
        #   - check clicking "Hide" hides the loaded task
        status_result_pairs = []
        for result in (TaskResult.fail, TaskResult.warn, TaskResult.panic):
            for status in (TaskStatus.completed, TaskStatus.cancelled,
                            TaskStatus.aborted):
                status_result_pairs.append((status, result))

        with session.begin():
            recipes = []
            for __ in status_result_pairs:
                tasks = [data_setup.create_task() for i in range(2)]
                recipe = data_setup.create_recipe(task_list=tasks)
                recipes.append(recipe)
            job = data_setup.create_job_for_recipes(recipes, owner=self.user)
            data_setup.mark_job_queued(job)
            data_setup.mark_job_running(job)
            for recipe, (status, result) in zip(recipes, status_result_pairs):
                task_result = RecipeTaskResult(path=u'failure_result',
                                                result=result)
                recipe.tasks[0].results = [task_result]
                recipe.tasks[0].status = status
                recipe.tasks[1].start()
            job.update_status()

        b = self.browser
        for recipe in recipes:
            failed, incomplete = recipe.tasks
            expected_result = failed.results[0].result
            # These assertions ensure the task setup code above is correct
            self.assertEqual(recipe.status, TaskStatus.running)
            self.assertEqual(recipe.result, expected_result)
            self.assertEqual(failed.result, expected_result)
            self.assertEqual(incomplete.result, TaskResult.new)
            self.go_to_recipe_view(recipe)
            # Tasks should only be loaded on demand
            for t in recipe.tasks:
                self.check_task_not_loaded(recipe, t)
            # Failed result tab should only load the first task
            b.find_element_by_xpath(
                '//div[@id="recipe%s"]//a[text()="Show Failed Results"]'
                    % recipe.id).click()
            self.check_task_visible(recipe, failed)
            self.check_task_not_loaded(recipe, incomplete)
            # Clicking "Hide" should hide the loaded task
            b.find_element_by_xpath(
                    '//div[@id="recipe%s"]//a[text()="Hide"]'
                    % recipe.id).click()
            self.check_task_hidden(recipe, failed)
            self.check_task_not_loaded(recipe, incomplete)
示例#46
0
 def test_exclusive_arches(self):
     with session.begin():
         task = data_setup.create_task(runfor=[u'httpd'],
                                       exclusive_arches=[u's390', u's390x'])
     result = self.server.tasks.filter(dict(packages=['httpd']))
     self.assertEquals(result[0]['name'], task.name)
     # Note that the 'arches' key is actually the *excluded* arches.
     self.assertEquals(result[0]['arches'], [
         'aarch64', 'arm', 'armhfp', 'i386', 'ia64', 'ppc', 'ppc64',
         'ppc64le', 'x86_64'
     ])
示例#47
0
 def setUp(self):
     with session.begin():
         self.recipe = data_setup.create_recipe(
             task_name=u'/distribution/install')
         self.recipe.tasks.extend([
             RecipeTask.from_task(data_setup.create_task()),
             RecipeTask.from_fetch_url(
                 u'http://example.com/tasks/example.tar.bz2'),
         ])
         data_setup.create_job_for_recipes([self.recipe])
         data_setup.mark_recipe_running(self.recipe)
示例#48
0
    def test_task_pagination(self):
        with session.begin():
            num_of_tasks = 35
            the_tasks = [data_setup.create_task() for t in range(num_of_tasks)]
            the_recipe = data_setup.create_recipe(task_list=the_tasks)
            the_job = data_setup.create_job_for_recipes([the_recipe], owner=self.user)

        b = self.browser
        self.go_to_recipe_view(the_recipe)
        b.find_element_by_id("all_recipe_%s" % the_recipe.id).click()
        for t in the_job.recipesets[0].recipes[0].tasks:
            self.assertTrue(is_text_present(b, "T:%s" %t.id))
示例#49
0
    def setUp(self):
        with session.begin():
            self.arch_one = u'i386'
            self.osmajor_one = u'testosmajor'
            self.task_one = data_setup.create_task(
                name=u'/a/a/a', exclude_arches=[self.arch_one])
            self.task_two = data_setup.create_task(
                name=u'/a/a/b', exclude_arches=[self.arch_one])
            self.task_three = data_setup.create_task(
                name=u'/a/a/c', exclude_osmajors=[self.osmajor_one])
            data_setup.create_completed_job(
                task_list=[self.task_one, self.task_two, self.task_three])

        self.recipe_tasks = []
        t = Tasks()
        for id in [
                t.id for t in [self.task_one, self.task_two, self.task_three]
        ]:
            self.recipe_tasks = self.recipe_tasks + self.get_task_query(
                {
                    'task_id': id
                }, False).all()
示例#50
0
    def test_task_pagination(self):
        with session.begin():
            num_of_tasks = 35
            the_tasks = [data_setup.create_task() for t in range(num_of_tasks)]
            the_recipe = data_setup.create_recipe(task_list=the_tasks)
            the_job = data_setup.create_job_for_recipes([the_recipe], owner=self.user)

        b = self.browser
        self.go_to_recipe_view(the_recipe)
        b.find_element_by_xpath('//div[@id="recipe%s"]//a[text()="Show Results"]'
                % the_recipe.id).click()
        for t in the_job.recipesets[0].recipes[0].tasks:
            self.assertTrue(is_text_present(b, "T:%s" %t.id))
示例#51
0
    def test_details_without_nda(self):
        with session.begin():
            task = data_setup.create_task()
            task.nda = None
        out = run_client(['bkr', 'task-details', task.name])
        details = eval(out[len(task.name) + 1:])  # XXX dodgy
        self.assertEquals(details['nda'], None)

        # output in xml format
        out = run_client(['bkr', 'task-details', '--xml', task.name])

        task_elem = lxml.etree.fromstring(re.sub(task.name, '', out, count=1))
        self.assert_(task_elem.get('nda') == None)
示例#52
0
    def test_details_without_destructive(self):
        with session.begin():
            task = data_setup.create_task()
            task.destructive = None
        out = run_client(['bkr', 'task-details', task.name])
        details = eval(out[len(task.name) + 1:]) # XXX dodgy
        self.assertEquals(details['destructive'], None)

        # output in xml format
        out = run_client(['bkr', 'task-details', '--xml', task.name])

        task_elem = lxml.etree.fromstring(re.sub(task.name, '', out, count=1))
        self.assert_(task_elem.get('destructive') == None)
示例#53
0
    def test_filters_task_by_osmajor_with_given_taskfile(self):
        with session.begin():
            ignored_task = data_setup.create_task(
                exclude_osmajors=[self.distro.osversion.osmajor.osmajor])
            included_task = data_setup.create_task()

        taskfile = NamedTemporaryFile()
        taskfile.write('\n'.join([ignored_task.name, included_task.name]))
        taskfile.flush()

        p = start_client([
            'bkr', 'workflow-simple', '--dryrun', '--prettyxml', '--family',
            self.distro.osversion.osmajor.osmajor, '--arch',
            self.distro_tree.arch.arch, '--taskfile', taskfile.name
        ])
        out, err = p.communicate()
        self.assertEqual(p.returncode, 0)
        self.assertEqual(
            'WARNING: task %s not applicable for distro, ignoring\n' %
            ignored_task.name, err)
        self.assertNotIn(ignored_task.name, out)
        self.assertIn(included_task.name, out)
示例#54
0
 def test_executed_tasks_system_filter(self):
     with session.begin():
         task = data_setup.create_task()
         system = data_setup.create_system(
                 lab_controller=data_setup.create_labcontroller())
         job = data_setup.create_completed_job(task_name=task.name,
                 system=system)
     b = self.browser
     b.get(get_server_base() + 'tasks/%d' % task.id)
     b.find_element_by_id('form_system').click()
     b.find_element_by_id('form_system').send_keys(system.fqdn)
     b.find_element_by_id('form').submit()
     rtask = job.recipesets[0].recipes[0].tasks[0]
     self.check_recipetask_present_in_results(rtask)
示例#55
0
 def test_executed_tasks_system_filter(self):
     with session.begin():
         task = data_setup.create_task()
         system = data_setup.create_system(
             lab_controller=data_setup.create_labcontroller())
         job = data_setup.create_completed_job(task_name=task.name,
                                               system=system)
     b = self.browser
     b.get(get_server_base() + 'tasks/%d' % task.id)
     b.find_element_by_id('form_system').click()
     b.find_element_by_id('form_system').send_keys(system.fqdn)
     b.find_element_by_id('form').submit()
     rtask = job.recipesets[0].recipes[0].tasks[0]
     self.check_recipetask_present_in_results(rtask)
示例#56
0
 def test_search_by_version(self):
     with session.begin():
         task = data_setup.create_task()
         old_recipe = data_setup.create_recipe(task_list=[task])
         data_setup.create_job_for_recipes([old_recipe])
         old_recipe.tasks[0].version = u'1.0-0'
         recent_recipe = data_setup.create_recipe(task_list=[task])
         data_setup.create_job_for_recipes([recent_recipe])
         recent_recipe.tasks[0].version = u'2.3-4'
     b = self.browser
     b.get(get_server_base() + 'tasks%s' % task.name)
     b.find_element_by_id('form_version').send_keys('1.0-*')
     b.find_element_by_id('form').submit()
     self.check_recipetask_present_in_results(old_recipe.tasks[0])
     self.check_recipetask_absent_from_results(recent_recipe.tasks[0])
示例#57
0
 def test_executed_tasks_family_sorting(self):
     with session.begin():
         task = data_setup.create_task()
         data_setup.create_completed_job(task_name=task.name,
                 distro_tree=data_setup.create_distro_tree(osmajor=u'BlueShoe10'))
         data_setup.create_completed_job(task_name=task.name,
                 distro_tree=data_setup.create_distro_tree(osmajor=u'BlueShoe9'))
         # plus one that is never used
         OSMajor.lazy_create(osmajor=u'neverused666')
     b = self.browser
     b.get(get_server_base() + 'tasks/%d' % task.id)
     options = [element.text for element in
             b.find_elements_by_xpath("//select[@name='osmajor_id']/option")]
     self.assert_(options.index('BlueShoe9') < options.index('BlueShoe10'), options)
     self.assert_('neverused666' not in options, options)
示例#58
0
    def test_executed_tasks(self):
        with session.begin():
            task_two = data_setup.create_task(name=data_setup.unique_name(u'/a/a/a%s'))
            task_one = data_setup.create_task(name=data_setup.unique_name(u'/a/a/a%s'))
            job = data_setup.create_completed_job(task_list=[task_one, task_two])
        b = self.browser
        r = job.recipesets[0].recipes[0]
        rtask = r.tasks[0]
        b.get(get_server_base() + 'tasks/%d' % rtask.task.id)
        b.find_element_by_xpath("//select[@name='osmajor_id']/"
            "option[normalize-space(text())='%s']" %
             r.distro_tree.distro.osversion.osmajor).click()
        b.find_element_by_xpath("//form[@id='form']").submit()
        self.check_recipetask_present_in_results(rtask)

        # Search by single recipe task id
        b.get(get_server_base() + 'tasks/executed?recipe_task_id=%s' % rtask.id)
        self.check_recipetask_present_in_results(rtask)

        # Search by multiple recipe task id
        rtask2 = r.tasks[1]
        b.get(get_server_base() + 'tasks/executed?recipe_task_id=%s&recipe_task_id=%s' % (rtask2.id, rtask.id))
        self.check_recipetask_present_in_results(rtask)
        self.check_recipetask_present_in_results(rtask2)
示例#59
0
 def test_search_by_version(self):
     with session.begin():
         task = data_setup.create_task()
         old_recipe = data_setup.create_recipe(task_list=[task])
         data_setup.create_job_for_recipes([old_recipe])
         old_recipe.tasks[0].version = u'1.0-0'
         recent_recipe = data_setup.create_recipe(task_list=[task])
         data_setup.create_job_for_recipes([recent_recipe])
         recent_recipe.tasks[0].version = u'2.3-4'
     b = self.browser
     b.get(get_server_base() + 'tasks%s' % task.name)
     b.find_element_by_id('form_version').send_keys('1.0-*')
     b.find_element_by_id('form').submit()
     self.check_recipetask_present_in_results(old_recipe.tasks[0])
     self.check_recipetask_absent_from_results(recent_recipe.tasks[0])