Beispiel #1
0
 def test_no_matching_systems(self):
     with session.begin():
         data_setup.create_distro_tree(osmajor=u'Fedora21',
                 distro_name=u'Fedora-21', variant=u'Server',
                 arch=u'aarch64', lab_controllers=[self.lc])
     login(self.browser)
     b = self.browser
     b.get(get_server_base() + 'reserveworkflow/')
     Select(b.find_element_by_name('osmajor')).select_by_visible_text('Fedora21')
     Select(b.find_element_by_name('distro')).select_by_visible_text('Fedora-21')
     Select(b.find_element_by_name('distro_tree_id')).select_by_visible_text(
             'Fedora-21 Server aarch64')
     b.find_element_by_xpath(
             '//label[contains(string(.), "Any system from lab:")]'
             '/input[@type="radio"]').click()
     Select(b.find_element_by_name('lab')).select_by_visible_text(self.lc.fqdn)
     b.find_element_by_xpath('//button[text()="Submit job"]').click()
     self.assertIn('No available systems',
             b.find_element_by_class_name('alert-error').text)
     b.find_element_by_xpath(
             '//label[normalize-space(string(.))="Any system"]'
             '/input[@type="radio"]').click()
     b.find_element_by_xpath('//button[text()="Submit job"]').click()
     self.assertIn('No available systems',
             b.find_element_by_class_name('alert-error').text)
    def setupClass(cls):
        data_setup.create_labcontroller()
        cls.distro_one_name = data_setup.unique_name(u'nametest%s')
        cls.distro_one_osmajor = u'osmajortest1'
        cls.distro_one_osminor = u'1'
        cls.distro_one_variant = u'myvariant'
        cls.distro_one_tag = [u'MYTAG']

        cls.distro_one = data_setup.create_distro(name=cls.distro_one_name,
            osmajor=cls.distro_one_osmajor, osminor = cls.distro_one_osminor,
            tags =cls.distro_one_tag)
        cls.distro_tree_one = data_setup.create_distro_tree(distro=cls.distro_one,
            variant=cls.distro_one_variant)
        # Two days in the future
        cls.distro_two_name = data_setup.unique_name(u'nametest%s')
        cls.distro_two_osmajor = u'osmajortest2'
        cls.distro_two_osminor = u'2'

        cls.distro_two = data_setup.create_distro(name=cls.distro_two_name,
            osmajor=cls.distro_two_osmajor, osminor = cls.distro_two_osminor,)
        cls.distro_tree_two = data_setup.create_distro_tree(distro=cls.distro_two)
        cls.distro_tree_two.date_created = datetime.utcnow() + timedelta(days=2)

        cls.distro_three_name = data_setup.unique_name(u'nametest%s')
        cls.distro_three_osmajor = u'osmajortest3'
        cls.distro_three_osminor = u'3'

        cls.distro_three = data_setup.create_distro(name=cls.distro_three_name,
            osmajor=cls.distro_three_osmajor, osminor = cls.distro_three_osminor,)
        cls.distro_tree_three = data_setup.create_distro_tree(distro=cls.distro_three)
Beispiel #3
0
 def setUp(self):
     with session.begin():
         if not Distro.by_name(u'BlueShoeLinux5-5'):
             data_setup.create_distro_tree(distro_name=u'BlueShoeLinux5-5')
         self.user = data_setup.create_user(password=u'password')
     self.server = self.get_server()
     self.server.auth.login_password(self.user.user_name, 'password')
Beispiel #4
0
    def setupClass(cls):
        data_setup.create_labcontroller()
        cls.distro_one_name = data_setup.unique_name(u"nametest%s")
        cls.distro_one_osmajor = u"osmajortest1"
        cls.distro_one_osminor = u"1"
        cls.distro_one_variant = u"myvariant"
        cls.distro_one_tag = [u"MYTAG"]

        cls.distro_one = data_setup.create_distro(
            name=cls.distro_one_name,
            osmajor=cls.distro_one_osmajor,
            osminor=cls.distro_one_osminor,
            tags=cls.distro_one_tag,
        )
        cls.distro_tree_one = data_setup.create_distro_tree(distro=cls.distro_one, variant=cls.distro_one_variant)
        # Two days in the future
        cls.distro_two_name = data_setup.unique_name(u"nametest%s")
        cls.distro_two_osmajor = u"osmajortest2"
        cls.distro_two_osminor = u"2"

        cls.distro_two = data_setup.create_distro(
            name=cls.distro_two_name, osmajor=cls.distro_two_osmajor, osminor=cls.distro_two_osminor
        )
        cls.distro_tree_two = data_setup.create_distro_tree(distro=cls.distro_two)
        cls.distro_tree_two.date_created = datetime.utcnow() + timedelta(days=2)

        cls.distro_three_name = data_setup.unique_name(u"nametest%s")
        cls.distro_three_osmajor = u"osmajortest3"
        cls.distro_three_osminor = u"3"

        cls.distro_three = data_setup.create_distro(
            name=cls.distro_three_name, osmajor=cls.distro_three_osmajor, osminor=cls.distro_three_osminor
        )
        cls.distro_tree_three = data_setup.create_distro_tree(distro=cls.distro_three)
 def test_no_requested_tasks(self):
     # If you don't request any tasks (by passing the --task option)
     # each recipe should contain only the install checking task
     # and nothing more.
     with session.begin():
         # This one will use /distribution/check-install
         data_setup.create_distro_tree(osmajor=u'Fedorarawhide')
         # This one will use /distribution/install
         data_setup.create_distro_tree(osmajor=u'RedHatEnterpriseLinux7')
     out = run_client(['bkr', 'harness-test'])
     self.assertIn("Submitted:", out)
     with session.begin():
         new_job = Job.query.order_by(Job.id.desc()).first()
         # There will be one recipe per OS major that exists in the database,
         # which is potentially a large number left from earlier tests.
         # What we care about is that every recipe must have one task,
         # either /distribution/check-install (default)
         # or /distribution/install (on known, older distros).
         self.assertGreater(len(new_job.recipesets), 1)
         for recipe in new_job.all_recipes:
             self.assertEqual(len(recipe.tasks), 1)
             if recipe.installation.osmajor == 'Fedorarawhide':
                 self.assertEqual(recipe.tasks[0].name, '/distribution/check-install')
             if recipe.installation.osmajor == 'RedHatEnterpriseLinux7':
                 self.assertEqual(recipe.tasks[0].name, '/distribution/install')
Beispiel #6
0
    def setUp(self):
        self.distro = data_setup.create_distro()
        self.distro_tree1 = data_setup.create_distro_tree(distro=self.distro,
            arch='x86_64')
        self.distro_tree2 = data_setup.create_distro_tree(distro=self.distro,
            arch='i386')

        self.distro_tree1.activity.append(DistroTreeActivity(
            user=User.by_user_name(data_setup.ADMIN_USER),
            service=u'testdata', field_name=u'Nonesente',
            old_value=u'sdfas', new_value=u'sdfa', action='Added'))
        self.distro_tree2.activity.append(DistroTreeActivity(
            user=User.by_user_name(data_setup.ADMIN_USER), 
            service=u'testdata', field_name=u'Noneseonce',
            old_value=u'bsdf', new_value=u'sdfas', action='Added'))

        self.distro.activity.append(DistroActivity(
                user=User.by_user_name(data_setup.ADMIN_USER), service=u'testdata',
                action=u'Nothing', field_name=u'Nonsense',
                old_value=u'asdf', new_value=u'omgwtfbbq'))
        self.system = data_setup.create_system()
        self.system.activity.append(SystemActivity(
                user=User.by_user_name(data_setup.ADMIN_USER), service=u'testdata',
                action=u'Nothing', field_name=u'Nonsense',
                old_value=u'asdf', new_value=u'omgwtfbbq'))
        self.group2 = data_setup.create_group()
        self.group = data_setup.create_group()
        self.group.activity.append(GroupActivity(
                user=User.by_user_name(data_setup.ADMIN_USER), service=u'testdata',
                action=u'Nothing', field_name=u'Nonsense',
                old_value=u'asdf', new_value=u'omgwtfbbq'))
        self.browser = self.get_browser()
Beispiel #7
0
 def setUp(self):
     self.browser = self.get_browser()
     with session.begin():
         self.user = data_setup.create_user(password=u'password')
         if not Distro.by_name(u'BlueShoeLinux5-5'):
             data_setup.create_distro_tree(distro_name=u'BlueShoeLinux5-5')
         data_setup.create_product(product_name=u'the_product')
 def test_filters_out_excluded_families(self):
     with session.begin():
         rhel3_i386 = data_setup.create_distro_tree(
             osmajor=u"RedHatEnterpriseLinux3", arch=u"i386", distro_tags=[u"STABLE"]
         )
         rhel3_x86_64 = data_setup.create_distro_tree(
             osmajor=u"RedHatEnterpriseLinux3", arch=u"x86_64", distro_tags=[u"STABLE"]
         )
         rhel4_i386 = data_setup.create_distro_tree(
             osmajor=u"RedHatEnterpriseLinux4", arch=u"i386", distro_tags=[u"STABLE"]
         )
         rhel4_x86_64 = data_setup.create_distro_tree(
             osmajor=u"RedHatEnterpriseLinux4", arch=u"x86_64", distro_tags=[u"STABLE"]
         )
         # system with RHEL4 i386 and RHEL3 x86_64 excluded
         system = data_setup.create_system(arch=u"i386")
         system.arch.append(Arch.by_name(u"x86_64"))
         system.excluded_osmajor.extend(
             [
                 ExcludeOSMajor(arch=Arch.by_name(u"i386"), osmajor=OSMajor.by_name(u"RedHatEnterpriseLinux4")),
                 ExcludeOSMajor(arch=Arch.by_name(u"x86_64"), osmajor=OSMajor.by_name(u"RedHatEnterpriseLinux3")),
             ]
         )
     out = run_client(["bkr", "machine-test", "--machine", system.fqdn])
     self.assert_(out.startswith("Submitted:"), out)
     with session.begin():
         new_job = Job.query.order_by(Job.id.desc()).first()
         distro_trees = [recipe.distro_tree for recipe in new_job.all_recipes]
         self.assert_(rhel3_i386 in distro_trees, distro_trees)
         self.assert_(rhel3_x86_64 not in distro_trees, distro_trees)
         self.assert_(rhel4_i386 not in distro_trees, distro_trees)
         self.assert_(rhel4_x86_64 in distro_trees, distro_trees)
 def setUp(self):
     session.begin()
     from bkr.server.jobs import Jobs
     self.controller = Jobs()
     self.user = data_setup.create_user()
     data_setup.create_distro_tree(distro_name=u'BlueShoeLinux5-5')
     session.flush()
 def test_machine_hours(self):
     user = data_setup.create_user()
     # recipes/reservations straddle the boundary of the reporting period
     # to test we clamp them properly
     data_setup.create_completed_job(owner=user,
             distro_tree=data_setup.create_distro_tree(arch=u'ia64'),
             start_time=datetime.datetime(2012, 9, 30, 23, 0, 0),
             finish_time=datetime.datetime(2012, 10, 1, 1, 0, 0))
     data_setup.create_manual_reservation(user=user,
             system=data_setup.create_system(arch=u'ia64'),
             start=datetime.datetime(2012, 10, 31, 22, 30, 0),
             finish=datetime.datetime(2012, 11, 1, 1, 0, 0))
     data_setup.create_completed_job(owner=user,
             distro_tree=data_setup.create_distro_tree(arch=u'ppc64'),
             start_time=datetime.datetime(2012, 9, 30, 20, 0, 0),
             finish_time=datetime.datetime(2012, 10, 1, 2, 0, 0))
     data_setup.create_manual_reservation(user=user,
             system=data_setup.create_system(arch=u'ppc64'),
             start=datetime.datetime(2012, 10, 31, 23, 0, 0),
             finish=datetime.datetime(2012, 11, 1, 10, 0, 0))
     session.flush()
     rows = self.execute_reporting_query('machine-hours-by-user-arch')
     user_rows = [row for row in rows if row.username == user.user_name]
     self.assertEquals(len(user_rows), 2, user_rows)
     self.assertEquals(user_rows[0].arch, 'ia64')
     self.assertEquals(user_rows[0].machine_hours, Decimal('2.5'))
     self.assertEquals(user_rows[1].arch, 'ppc64')
     self.assertEquals(user_rows[1].machine_hours, Decimal('3.0'))
 def test_no_requested_tasks(self):
     # If you don't request any tasks (by passing the --task or --inventory
     # options) each recipe should contain only the install checking task
     # and nothing more.
     with session.begin():
         # This one will use /distribution/check-install
         data_setup.create_distro_tree(osmajor=u'Fedorarawhide')
         # This one will use /distribution/install
         data_setup.create_distro_tree(osmajor=u'RedHatEnterpriseLinux7')
     out = run_client(['bkr', 'machine-test',
                       '--machine', self.system.fqdn,
                       '--arch', 'i386',
                       '--family', 'Fedorarawhide',
                       '--family', 'RedHatEnterpriseLinux7'])
     self.assertIn("Submitted:", out)
     with session.begin():
         new_job = Job.query.order_by(Job.id.desc()).first()
         rawhide_recipe = new_job.recipesets[0].recipes[0]
         self.assertEqual(rawhide_recipe.installation.osmajor, u'Fedorarawhide')
         self.assertEqual(len(rawhide_recipe.tasks), 1)
         self.assertEqual(rawhide_recipe.tasks[0].name, '/distribution/check-install')
         rhel7_recipe = new_job.recipesets[1].recipes[0]
         self.assertEqual(rhel7_recipe.installation.osmajor, u'RedHatEnterpriseLinux7')
         self.assertEqual(len(rhel7_recipe.tasks), 1)
         self.assertEqual(rhel7_recipe.tasks[0].name, '/distribution/install')
Beispiel #12
0
 def setUp(self):
     data_setup.create_product(product_name=u'the_product')
     data_setup.create_group(group_name=u'somegroup')
     data_setup.create_distro_tree(distro_name=u'BlueShoeLinux5-5')
     self.user_foo = data_setup.create_user(password=u'foo')
     self.user_bar = data_setup.create_user(password=u'bar')
     self.bot = data_setup.create_user(password=u'bot')
     # Add bot as delegate submission of foo
     self.user_foo.add_submission_delegate(self.bot, service=u'testdata')
Beispiel #13
0
 def setUp(self):
     from bkr.server.jobs import Jobs
     self.controller = Jobs()
     self.user = data_setup.create_user()
     group = data_setup.create_group(group_name='somegroup')
     self.user.groups.append(group)
     testutil.set_identity_user(self.user)
     data_setup.create_distro_tree(distro_name=u'BlueShoeLinux5-5')
     data_setup.create_product(product_name=u'the_product')
 def test_filter_by_arch(self):
     with session.begin():
         # one distro which has the desired arch
         dt_in = data_setup.create_distro_tree(arch=u"i386", lab_controllers=[self.other_lc, self.lc])
         # ... and another which does not
         dt_out = data_setup.create_distro_tree(arch=u"ppc64", lab_controllers=[self.other_lc, self.lc])
     self.server.auth.login_password(self.lc.user.user_name, u"logmein")
     result = self.server.labcontrollers.get_distro_trees({"arch": ["i386", "x86_64"]})
     self.assertEquals(len(result), 1)
     self.assertEquals(result[0]["distro_tree_id"], dt_in.id)
 def setUp(self):
     i386 = Arch.by_name(u'i386')
     x86_64 = Arch.by_name(u'x86_64')
     self.distro = data_setup.create_distro(osmajor=u'MyAwesomeLinux',
                                            tags=[u'STABLE'],
                                            arches=[i386, x86_64])
     data_setup.create_distro_tree(distro=self.distro,
                                   arch=u'i386')
     data_setup.create_distro_tree(distro=self.distro,
                                   arch=u'x86_64')
Beispiel #16
0
    def setUp(self):
        from bkr.server.jobs import Jobs

        self.controller = Jobs()
        self.user = data_setup.create_user()
        group = data_setup.create_group(group_name="somegroup")
        self.user.groups.append(group)
        testutil.set_identity_user(self.user)
        if not Distro.by_name(u"BlueShoeLinux5-5"):
            data_setup.create_distro_tree(distro_name=u"BlueShoeLinux5-5")
        data_setup.create_product(product_name=u"the_product")
Beispiel #17
0
    def test_edit_osmajor_alias(self):
        with session.begin():
            data_setup.create_distro_tree(osmajor=u'LinuxLinux2.1', arch=u'ia64')

        b = self.browser
        go_to_edit_osmajor(b, 'LinuxLinux2.1')
        b.find_element_by_xpath('//input[@id="form_alias"]').send_keys('linux21')
        b.find_element_by_xpath('//button[text()="Edit OSMajor"]').submit()
        self.assertEquals(
            b.find_element_by_class_name('flash').text,
            'Changes saved for LinuxLinux2.1')
 def test_get_all_distro_trees(self):
     with session.begin():
         # one distro which is in the lab
         dt_in = data_setup.create_distro_tree(lab_controllers=[self.other_lc, self.lc])
         # ... and another which is not
         dt_out = data_setup.create_distro_tree(lab_controllers=[self.other_lc])
     self.server.auth.login_password(self.lc.user.user_name, u"logmein")
     result = self.server.labcontrollers.get_distro_trees()
     self.assertEquals(len(result), 1)
     self.assertEquals(result[0]["distro_tree_id"], dt_in.id)
     for lc, url in result[0]["available"]:
         self.assertEquals(lc, self.lc.fqdn)
Beispiel #19
0
 def test_lookup_arches_by_family(self):
     # When a family is given but no arches, the workflow commands are 
     # supposed to look up all applicable arches and create a recipe set for 
     # each one.
     with session.begin():
         distro = data_setup.create_distro(osmajor=u'DansAwesomeLinux7',
                 tags=[u'STABLE'])
         data_setup.create_distro_tree(distro=distro, arch=u'x86_64')
         data_setup.create_distro_tree(distro=distro, arch=u's390x')
     self.submit_job_and_check_arches(
             ['--family', distro.osversion.osmajor.osmajor],
             [u'x86_64', u's390x'])
Beispiel #20
0
 def setUp(self):
     session.begin()
     from bkr.server.jobs import Jobs
     self.controller = Jobs()
     self.user = data_setup.create_user(user_name=u'test-job-owner',
             email_address=u'*****@*****.**')
     group = data_setup.create_group(group_name='somegroup')
     group.add_member(self.user)
     testutil.set_identity_user(self.user)
     data_setup.create_distro_tree(distro_name=u'BlueShoeLinux5-5')
     data_setup.create_product(product_name=u'the_product')
     session.flush()
    def setUp(self):
        self.lc = data_setup.create_labcontroller()
        self.system = data_setup.create_system(arch=u"i386", shared=True)
        self.system2 = data_setup.create_system(arch=u"x86_64", shared=True)
        self.unique_distro_name = data_setup.unique_name("distro%s")
        self.distro = data_setup.create_distro(name=self.unique_distro_name)
        self.distro_tree_i386 = data_setup.create_distro_tree(variant=u"Server", arch=u"i386", distro=self.distro)
        self.distro_tree_x86_64 = data_setup.create_distro_tree(variant=u"Server", arch=u"x86_64", distro=self.distro)

        self.system.lab_controller = self.lc
        self.system2.lab_controller = self.lc

        self.browser = self.get_browser()
 def test_filtering_by_treepath(self):
     with session.begin():
         distro_tree_in = data_setup.create_distro_tree()
         distro_tree_out = data_setup.create_distro_tree()
         lc = data_setup.create_labcontroller()
         distro_tree_in.lab_controller_assocs.append(LabControllerDistroTree(
                 lab_controller=lc, url='nfs://example.com/somewhere/'))
         distro_tree_out.lab_controller_assocs.append(LabControllerDistroTree(
                 lab_controller=lc, url='nfs://example.com/nowhere/'))
     output = run_client(['bkr', 'distro-trees-list', '--format=json', '--treepath', '%somewhere%'])
     trees = json.loads(output)
     self.assert_(any(distro_tree_in.id == tree['distro_tree_id'] for tree in trees))
     self.assert_(not any(distro_tree_out.id == tree['distro_tree_id'] for tree in trees))
    def setUp(cls):
        # Create two unique labs
        lab1 = data_setup.create_labcontroller(fqdn=u'lab_%d' %
                                               int(time.time() * 1000))
        lab2 = data_setup.create_labcontroller(fqdn=u'lab_%d' %
                                               int(time.time() * 1000))

        # Create two distros and only put one in each lab.
        cls.distro_tree1 = data_setup.create_distro_tree()
        cls.distro_tree2 = data_setup.create_distro_tree()
        session.flush()
        cls.distro_tree1.lab_controller_assocs = [LabControllerDistroTree(
                lab_controller=lab2, url=u'http://notimportant')]
        cls.distro_tree2.lab_controller_assocs = [LabControllerDistroTree(
                lab_controller=lab1, url=u'http://notimportant')]

        # Create a user
        user = data_setup.create_user()

        # Create two systems but only put them in lab1.
        system1 = data_setup.create_system(owner=user)
        system2 = data_setup.create_system(owner=user)
        system1.lab_controller = lab1
        system2.lab_controller = lab1

        session.flush()

        # Create two jobs, one requiring distro_tree1 and one requiring distro_tree2
        job = '''
            <job>
                <whiteboard>%s</whiteboard>
                <recipeSet>
                    <recipe>
                        <distroRequires>
                            <distro_name op="=" value="%s" />
                        </distroRequires>
                        <hostRequires/>
                        <task name="/distribution/install" role="STANDALONE">
                            <params/>
                        </task>
                    </recipe>
                </recipeSet>
            </job>
                 ''' 
        xmljob1 = XmlJob(xmltramp.parse(job % (cls.distro_tree1.distro.name,
                cls.distro_tree1.distro.name)))
        xmljob2 = XmlJob(xmltramp.parse(job % (cls.distro_tree2.distro.name,
                cls.distro_tree2.distro.name)))

        cls.job1 = Jobs().process_xmljob(xmljob1, user)
        cls.job2 = Jobs().process_xmljob(xmljob2, user)
 def test_clearing_alias_stores_null(self):
     with session.begin():
         data_setup.create_distro_tree(osmajor=u'YellowSpaceshipLinux2')
         osmajor = OSMajor.by_name(u'YellowSpaceshipLinux2')
         osmajor.alias = u'YSL2'
     b = self.browser
     go_to_edit_osmajor(b, 'YellowSpaceshipLinux2')
     b.find_element_by_xpath('//input[@id="form_alias"]').clear()
     b.find_element_by_xpath('//button[text()="Edit OSMajor"]').submit()
     self.assertEquals(b.find_element_by_class_name('flash').text,
             'Changes saved for YellowSpaceshipLinux2')
     with session.begin():
         session.refresh(osmajor)
         self.assertEquals(osmajor.alias, None) # not ''
Beispiel #25
0
    def setUp(self):
        self.lc = data_setup.create_labcontroller()
        self.system = data_setup.create_system(arch=u'i386', shared=True,
                                               lab_controller=self.lc)
        self.system2 = data_setup.create_system(arch=u'x86_64', shared=True,
                                                lab_controller=self.lc)
        self.unique_distro_name = data_setup.unique_name('distro%s')
        self.distro = data_setup.create_distro(name=self.unique_distro_name)
        self.distro_tree_i386 = data_setup.create_distro_tree(
                variant=u'Server', arch=u'i386', distro=self.distro)
        self.distro_tree_x86_64= data_setup.create_distro_tree(
                variant=u'Server', arch=u'x86_64', distro=self.distro)

        self.browser = self.get_browser()
 def test_filtering_by_lab_controller(self):
     with session.begin():
         good_lc = data_setup.create_labcontroller()
         bad_lc = data_setup.create_labcontroller()
         distro_tree_in = data_setup.create_distro_tree()
         distro_tree_out = data_setup.create_distro_tree()
         session.flush()
         distro_tree_in.lab_controller_assocs[:] = [LabControllerDistroTree(
                 lab_controller=good_lc, url=u'http://notimportant')]
         distro_tree_out.lab_controller_assocs[:] = [LabControllerDistroTree(
                 lab_controller=bad_lc, url=u'http://notimportant')]
     distro_trees = self.server.distrotrees.filter({'labcontroller': good_lc.fqdn})
     self.assert_(distro_tree_in.id in [d['distro_tree_id'] for d in distro_trees], distro_trees)
     self.assert_(distro_tree_out.id not in [d['distro_tree_id'] for d in distro_trees], distro_trees)
 def test_filtering_by_lab_controller(self):
     with session.begin():
         distro_tree_in = data_setup.create_distro_tree()
         distro_tree_out = data_setup.create_distro_tree()
         good_lc = data_setup.create_labcontroller()
         bad_lc = data_setup.create_labcontroller()
         distro_tree_in.lab_controller_assocs.append(LabControllerDistroTree(
                 lab_controller=good_lc, url=u'http://notimportant'))
         distro_tree_out.lab_controller_assocs.append(LabControllerDistroTree(
                 lab_controller=bad_lc, url=u'http://notimportant'))
     output = run_client(['bkr', 'distro-trees-list', '--format=json', '--labcontroller', good_lc.fqdn])
     trees = json.loads(output)
     self.assert_(any(distro_tree_in.id == tree['distro_tree_id'] for tree in trees))
     self.assert_(not any(distro_tree_out.id == tree['distro_tree_id'] for tree in trees))
Beispiel #28
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)
 def test_xml_filter(self):
     with session.begin():
         distro_trees_in = [
             data_setup.create_distro_tree(distro_tags=[u'MYTAG1']),
             data_setup.create_distro_tree(distro_tags=[u'MYTAG2']),
         ]
         distro_tree_out = data_setup.create_distro_tree(distro_tags=[u'MYTAG3'])
     distro_trees = self.server.distrotrees.filter({'xml': '''
         <or>
             <distro_tag value="MYTAG1" />
             <distro_tag value="MYTAG2" />
         </or>
         '''})
     returned_ids = set(dt['distro_tree_id'] for dt in distro_trees)
     self.assertEquals(returned_ids, set(dt.id for dt in distro_trees_in))
Beispiel #30
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)
Beispiel #31
0
    def setupClass(cls):
        # Each distro needs to have a tree in some lab controller, otherwise it
        # won't show up in search results.
        data_setup.create_labcontroller()

        cls.distro_one_name = data_setup.unique_name(u'nametest%s')
        cls.distro_one_osmajor = u'osmajortest1'
        cls.distro_one_osminor = u'1'
        cls.distro_one_tags = None

        cls.distro_one = data_setup.create_distro(
            name=cls.distro_one_name,
            osmajor=cls.distro_one_osmajor,
            osminor=cls.distro_one_osminor,
            tags=cls.distro_one_tags)
        data_setup.create_distro_tree(distro=cls.distro_one)
        # Two days in the future
        cls.distro_one.date_created = datetime.utcnow() + timedelta(days=2)
        cls.distro_two_name = data_setup.unique_name(u'nametest%s')
        cls.distro_two_osmajor = u'osmajortest2'
        cls.distro_two_osminor = u'2'
        cls.distro_two_tags = None

        cls.distro_two = data_setup.create_distro(
            name=cls.distro_two_name,
            osmajor=cls.distro_two_osmajor,
            osminor=cls.distro_two_osminor,
            tags=cls.distro_two_tags)
        data_setup.create_distro_tree(distro=cls.distro_two)

        cls.distro_three_name = data_setup.unique_name(u'nametest%s')
        cls.distro_three_osmajor = u'osmajortest3'
        cls.distro_three_osminor = u'3'
        cls.distro_three_tags = None

        cls.distro_three = data_setup.create_distro(
            name=cls.distro_three_name,
            osmajor=cls.distro_three_osmajor,
            osminor=cls.distro_three_osminor,
            tags=cls.distro_three_tags)
        data_setup.create_distro_tree(distro=cls.distro_three)
 def setUp(self):
     self.browser = self.get_browser()
     with session.begin():
         self.lc = data_setup.create_labcontroller()
         self.distro_tree = data_setup.create_distro_tree(
             osmajor=u'RedHatEnterpriseLinux6', lab_controllers=[self.lc])
 def setUp(self):
     self.browser = self.get_browser()
     with session.begin():
         self.lc = data_setup.create_labcontroller()
         self.distro_tree = data_setup.create_distro_tree(
             lab_controllers=[self.lc])
Beispiel #34
0
    def test_single_job(self):
        with session.begin():
            unique_whiteboard = data_setup.unique_name('whiteboard%s')
            non_unique_whiteboard = data_setup.unique_name('whiteboard%s')
            non_unique_rwhiteboard = data_setup.unique_name('rwhiteboard%s')
            distro_tree = data_setup.create_distro_tree(arch=u'i386')
            for i in range(0, 9):
                data_setup.create_completed_job(
                    whiteboard=non_unique_whiteboard,
                    result=TaskResult.pass_,
                    recipe_whiteboard=non_unique_rwhiteboard,
                    distro_tree=distro_tree)

            single_job = data_setup.create_completed_job(
                whiteboard=unique_whiteboard,
                result=TaskResult.pass_,
                recipe_whiteboard=data_setup.unique_name('rwhiteboard%s'),
                distro_tree=distro_tree)

        b = self.browser
        b.get(get_server_base() + 'matrix')
        # No need to filter the whiteboard, we just created the jobs so they
        # will be at the top of the list of whiteboards.
        b.find_element_by_xpath("//select/option[@value='%s']" %
                                unique_whiteboard).click()
        b.find_element_by_xpath(
            '//button[@type="submit" and text()="Generate"]').click()
        b.find_element_by_link_text('Pass: 1').click()
        # Should take us to Executed Tasks filtered by whiteboard.
        # There should only be one task in the results.
        tasks_table = b.find_element_by_css_selector('table.tasks')
        task_ids = [
            e.text for e in tasks_table.find_elements_by_xpath(
                'tbody/tr/td[1][@class="task"]')
        ]
        self.assertEquals(task_ids,
                          [single_job.recipesets[0].recipes[0].tasks[0].t_id])

        # Test by job id
        # See https://bugzilla.redhat.com/show_bug.cgi?id=803713
        with session.begin():
            single_job_2 = data_setup.create_completed_job(
                whiteboard=non_unique_whiteboard,
                result=TaskResult.pass_,
                recipe_whiteboard=non_unique_rwhiteboard,
                distro_tree=distro_tree)
        b = self.browser
        b.get(get_server_base() + 'matrix')
        b.find_element_by_id('remote_form_job_ids').send_keys(
            str(single_job_2.id))
        b.find_element_by_xpath(
            '//button[@type="submit" and text()="Generate"]').click()
        b.find_element_by_link_text('Pass: 1').click()
        # Should take us to Executed Tasks filtered by whiteboard and job ID.
        # There should only be one task in the results.
        tasks_table = b.find_element_by_css_selector('table.tasks')
        task_ids = [
            e.text for e in tasks_table.find_elements_by_xpath(
                'tbody/tr/td[1][@class="task"]')
        ]
        self.assertEquals(
            task_ids, [single_job_2.recipesets[0].recipes[0].tasks[0].t_id])
Beispiel #35
0
 def test_edit_osmajor_install_options(self):
     with session.begin():
         data_setup.create_distro_tree(osmajor=u'LinuxLinux2.1',
                                       arch=u'ia64')
         data_setup.create_distro_tree(osmajor=u'LinuxLinux2.1',
                                       arch=u'ppc64')
     b = self.browser
     # set them from scratch
     go_to_edit_osmajor(b, 'LinuxLinux2.1')
     b.find_element_by_xpath(
         '//*[@id="install_options_all"]'
         '//div[normalize-space(label/text())="Kickstart Metadata"]'
         '//input').send_keys('one')
     b.find_element_by_xpath(
         '//*[@id="install_options_all"]'
         '//div[normalize-space(label/text())="Kernel Options"]'
         '//input').send_keys('two')
     b.find_element_by_xpath(
         '//*[@id="install_options_all"]'
         '//div[normalize-space(label/text())="Kernel Options Post"]'
         '//input').send_keys('three')
     b.find_element_by_xpath(
         '//*[@id="install_options_ppc64"]'
         '//div[normalize-space(label/text())="Kickstart Metadata"]'
         '//input').send_keys('four')
     b.find_element_by_xpath(
         '//*[@id="install_options_ppc64"]'
         '//div[normalize-space(label/text())="Kernel Options"]'
         '//input').send_keys('five')
     b.find_element_by_xpath(
         '//*[@id="install_options_ppc64"]'
         '//div[normalize-space(label/text())="Kernel Options Post"]'
         '//input').send_keys('six')
     b.find_element_by_xpath('//button[text()="Save Changes"]').click()
     self.assertEquals(
         b.find_element_by_class_name('flash').text,
         'Install options saved for LinuxLinux2.1')
     # check everything is saved
     with session.begin():
         o = OSMajor.by_name(u'LinuxLinux2.1')
         ia64 = Arch.by_name(u'ia64')
         ppc64 = Arch.by_name(u'ppc64')
         self.assertEquals(set(o.install_options_by_arch.keys()),
                           set([None, ia64, ppc64]),
                           o.install_options_by_arch)
         self.assertEquals(o.install_options_by_arch[None].ks_meta, 'one')
         self.assertEquals(o.install_options_by_arch[None].kernel_options,
                           'two')
         self.assertEquals(
             o.install_options_by_arch[None].kernel_options_post, 'three')
         self.assertEquals(o.install_options_by_arch[ia64].ks_meta, '')
         self.assertEquals(o.install_options_by_arch[ia64].kernel_options,
                           '')
         self.assertEquals(
             o.install_options_by_arch[ia64].kernel_options_post, '')
         self.assertEquals(o.install_options_by_arch[ppc64].ks_meta, 'four')
         self.assertEquals(o.install_options_by_arch[ppc64].kernel_options,
                           'five')
         self.assertEquals(
             o.install_options_by_arch[ppc64].kernel_options_post, 'six')
     # now edit the existing options
     go_to_edit_osmajor(b, 'LinuxLinux2.1')
     input = b.find_element_by_xpath(
         '//*[@id="install_options_ppc64"]'
         '//div[normalize-space(label/text())="Kickstart Metadata"]'
         '//input')
     self.assertEquals(input.get_attribute('value'), 'four')
     input.clear()
     input.send_keys('something else')
     input = b.find_element_by_xpath(
         '//*[@id="install_options_ppc64"]'
         '//div[normalize-space(label/text())="Kernel Options"]'
         '//input')
     self.assertEquals(input.get_attribute('value'), 'five')
     input.clear()
     input.send_keys('something else')
     input = b.find_element_by_xpath(
         '//*[@id="install_options_ppc64"]'
         '//div[normalize-space(label/text())="Kernel Options Post"]'
         '//input')
     self.assertEquals(input.get_attribute('value'), 'six')
     input.clear()
     input.send_keys('something else')
     b.find_element_by_xpath('//button[text()="Save Changes"]').click()
     self.assertEquals(
         b.find_element_by_class_name('flash').text,
         'Install options saved for LinuxLinux2.1')
     # check they are updated
     with session.begin():
         session.expunge_all()
         o = OSMajor.by_name(u'LinuxLinux2.1')
         ppc64 = Arch.by_name(u'ppc64')
         self.assertEquals(o.install_options_by_arch[ppc64].ks_meta,
                           'something else')
         self.assertEquals(o.install_options_by_arch[ppc64].kernel_options,
                           'something else')
         self.assertEquals(
             o.install_options_by_arch[ppc64].kernel_options_post,
             'something else')
Beispiel #36
0
 def setUp(self):
     self.browser = self.get_browser()
     with session.begin():
         self.user = data_setup.create_user(password=u'password')
         data_setup.create_distro_tree(distro_name=u'BlueShoeLinux5-5')
         data_setup.create_product(product_name=u'the_product')
Beispiel #37
0
 def setUp(self):
     self.distro = data_setup.create_distro(tags=[u'STABLE'])
     self.distro_tree = data_setup.create_distro_tree(distro=self.distro)
     # multihost task required as bkr assumes there is always one available
     self.multihost_task = data_setup.create_task(type=['Multihost'])
     self.task = data_setup.create_task(runfor=['apache'])
Beispiel #38
0
 def setUp(self):
     self.distro_tree = data_setup.create_distro_tree()
Beispiel #39
0
    def test_system_reserved_notification_on(self):
        with session.begin():
            owner = data_setup.create_user(
                email_address=u'*****@*****.**')
            system = data_setup.create_system(
                fqdn=u'funcooker.ge.invalid',
                lab_controller=data_setup.create_labcontroller())
            distro_tree = data_setup.create_distro_tree(
                distro_name=u'MicrowaveOS-20141016.0',
                variant=u'ThreeHeats',
                arch=u'x86_64')
            job = data_setup.create_running_job(
                owner=owner,
                system=system,
                distro_tree=distro_tree,
                whiteboard=u'Chain Reaction of Mental Anguish',
                recipe_whiteboard=u'Christmas Attack Zone')
            recipe = job.recipesets[0].recipes[0]

        mail_capture_thread.start_capturing()
        with session.begin():
            bkr.server.mail.reservesys_notify(job.recipesets[0].recipes[0])
        captured_mails = mail_capture_thread.stop_capturing()
        self.assertEqual(len(captured_mails), 1)
        sender, rcpts, raw_msg = captured_mails[0]
        self.assertEqual(rcpts, [owner.email_address])
        msg = email.message_from_string(raw_msg)
        self.assertEqual(msg['To'], owner.email_address)
        self.assertEqual(msg['Subject'],
                         '[Beaker System Reserved] funcooker.ge.invalid')
        self.assertEqual(msg['X-Beaker-Notification'], 'system-reservation')

        expected_mail_body = u"""\
**  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **
                 This System is reserved by [email protected]

 To return this system early, you can click on 'Release System' against this recipe
 from the Web UI. Ensure you have your logs off the system before returning to
 Beaker.
  %(base)srecipes/%(recipeid)s

 For ssh, kvm, serial and power control operations please look here:
  %(base)sview/funcooker.ge.invalid

 For the default root password, see:
  %(base)sprefs

      Beaker Test information:
                         HOSTNAME=funcooker.ge.invalid
                            JOBID=%(jobid)s
                         RECIPEID=%(recipeid)s
                           DISTRO=MicrowaveOS-20141016.0 ThreeHeats x86_64
                     ARCHITECTURE=x86_64

      Job Whiteboard: Chain Reaction of Mental Anguish

      Recipe Whiteboard: Christmas Attack Zone
**  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **""" \
            % dict(base=get_server_base(), recipeid=recipe.id, jobid=job.id)
        actual_mail_body = msg.get_payload(decode=True)
        self.assertEqual(actual_mail_body, expected_mail_body)
Beispiel #40
0
 def setUp(self):
     with session.begin():
         self.user = data_setup.create_user(password=u'password')
         self.lc = data_setup.create_labcontroller()
         self.distro_tree = data_setup.create_distro_tree()
 def test_uses_original_install_task_on_older_distros(self):
     with session.begin():
         distro = data_setup.create_distro(
             osmajor=u'RedHatEnterpriseLinux7')
         data_setup.create_distro_tree(distro=distro)
     self._verify_check_install(distro=distro)
Beispiel #42
0
 def setUp(self):
     data_setup.create_distro_tree(distro_name=u'BlueShoeLinux5-5')
     data_setup.create_product(product_name=u'the_product')
     self.browser = self.get_browser()
Beispiel #43
0
 def setUp(self):
     self.distro = data_setup.create_distro()
     data_setup.create_distro_tree(distro=self.distro)
Beispiel #44
0
 def setUp(self):
     self.distro = data_setup.create_distro(tags=[u'STABLE'])
     self.distro_tree = data_setup.create_distro_tree(distro=self.distro)
     self.task = data_setup.create_task()
Beispiel #45
0
 def setUp(self):
     self.system = data_setup.create_system(arch=u'i386')
     self.distro = data_setup.create_distro(tags=[u'STABLE'])
     data_setup.create_distro_tree(distro=self.distro)
Beispiel #46
0
 def setUp(self):
     data_setup.create_product(product_name=u'the_product')
     data_setup.create_group(group_name='somegroup')
     data_setup.create_distro_tree(distro_name=u'BlueShoeLinux5-5')
Beispiel #47
0
    def test_cancel_while_scheduling(self):
        # This test simulates a user cancelling their job at the same time as
        # beakerd is scheduling it. beakerd assigns a system and creates
        # a watchdog and sets the recipe status to Waiting, then it's
        # overwritten by another transaction setting the status to Cancelled.
        with session.begin():
            lab_controller = data_setup.create_labcontroller()
            system = data_setup.create_system(shared=True,
                                              lab_controller=lab_controller)
            distro_tree = data_setup.create_distro_tree(
                osmajor=u'Fedora20', lab_controllers=[lab_controller])
            job = data_setup.create_job(distro_tree=distro_tree)
            job.recipesets[0].recipes[0]._host_requires = (u"""
                <hostRequires>
                    <hostname op="=" value="%s" />
                </hostRequires>
                """ % system.fqdn)
        beakerd.process_new_recipes()
        beakerd.update_dirty_jobs()
        with session.begin():
            job = Job.by_id(job.id)
            system = System.query.get(system.id)
            self.assertEquals(job.status, TaskStatus.processed)
            self.assertEquals(job.recipesets[0].recipes[0].systems, [system])

        # Two "concurrent" transactions, in the first one beakerd has
        # scheduled the recipe and is about to commit...
        class ScheduleThread(Thread):
            def __init__(self, **kwargs):
                super(ScheduleThread, self).__init__(**kwargs)
                self.ready_evt = Event()
                self.continue_evt = Event()

            def run(self):
                session.begin()
                recipeset = Job.by_id(job.id).recipesets[0]
                assert recipeset.status == TaskStatus.processed
                self.ready_evt.set()
                self.continue_evt.wait()
                try:
                    beakerd.queue_processed_recipeset(recipeset.id)
                    assert False, 'should raise'
                except StaleTaskStatusException:
                    pass  # expected
                session.rollback()

        # ... and in the second transaction the user is cancelling the recipe.
        class CancelThread(Thread):
            def __init__(self, **kwargs):
                super(CancelThread, self).__init__(**kwargs)
                self.ready_evt = Event()
                self.continue_evt = Event()

            def run(self):
                session.begin()
                recipe = Job.by_id(job.id).recipesets[0].recipes[0]
                assert not recipe.watchdog
                assert not recipe.resource
                recipe.recipeset.cancel()
                self.ready_evt.set()
                self.continue_evt.wait()
                session.commit()

        sched_thread = ScheduleThread()
        cancel_thread = CancelThread()
        sched_thread.start()
        cancel_thread.start()
        sched_thread.ready_evt.wait()
        cancel_thread.ready_evt.wait()
        sched_thread.continue_evt.set()
        cancel_thread.continue_evt.set()
        sched_thread.join()
        cancel_thread.join()
        with session.begin():
            session.expire_all()
            job.update_status()
            self.assertEquals(job.status, TaskStatus.cancelled)
            self.assertEquals(job.recipesets[0].recipes[0].watchdog, None)
            self.assertEquals(system.open_reservation, None)
Beispiel #48
0
 def setUp(self):
     with session.begin():
         data_setup.create_distro_tree(distro_name=u'BlueShoeLinux5-5')
         self.user = data_setup.create_user(password=u'password')
     self.server = self.get_server()
     self.server.auth.login_password(self.user.user_name, 'password')
Beispiel #49
0
 def setUp(self):
     self.system = data_setup.create_system()
     data_setup.create_task(name=u'/distribution/inventory')
     self.distro = data_setup.create_distro(tags=[u'STABLE'])
     data_setup.create_distro_tree(distro=self.distro)
 def test_uses_new_check_install_task_by_default(self):
     with session.begin():
         distro = data_setup.create_distro(osmajor=u'Fedora29')
         data_setup.create_distro_tree(distro=distro)
     self._verify_check_install(distro=distro)
Beispiel #51
0
    def test_reserved_openstack_instance(self):
        with session.begin():
            owner = data_setup.create_user(
                email_address=u'*****@*****.**')
            distro_tree = data_setup.create_distro_tree(
                distro_name=u'MicrowaveOS-20141016.1',
                variant=u'ThreeHeats',
                arch=u'x86_64')
            job = data_setup.create_job(
                owner=owner,
                distro_tree=distro_tree,
                whiteboard=u'Operation Righteous Cowboy Lightning',
                recipe_whiteboard=u'Everything Sunny All the Time Always')
            recipe = job.recipesets[0].recipes[0]
            data_setup.mark_recipe_running(
                recipe,
                virt=True,
                instance_id=uuid.UUID('00000000-1111-2222-3333-444444444444'),
                fqdn=u'bitenuker.ge.invalid')

        mail_capture_thread.start_capturing()
        with session.begin():
            bkr.server.mail.reservesys_notify(recipe)
        captured_mails = mail_capture_thread.stop_capturing()
        self.assertEqual(len(captured_mails), 1)
        sender, rcpts, raw_msg = captured_mails[0]
        self.assertEqual(rcpts, [owner.email_address])
        msg = email.message_from_string(raw_msg)
        self.assertEqual(msg['To'], owner.email_address)
        self.assertEqual(msg['Subject'],
                         '[Beaker System Reserved] bitenuker.ge.invalid')
        self.assertEqual(msg['X-Beaker-Notification'], 'system-reservation')

        expected_mail_body = u"""\
**  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **
                 This System is reserved by [email protected]

 To return this system early, you can click on 'Release System' against this recipe
 from the Web UI. Ensure you have your logs off the system before returning to
 Beaker.
  %(base)srecipes/%(recipeid)s

 For system details, see:
  http://openstack.example.invalid/dashboard/project/instances/00000000-1111-2222-3333-444444444444/

 For the default root password, see:
  %(base)sprefs

      Beaker Test information:
                         HOSTNAME=bitenuker.ge.invalid
                            JOBID=%(jobid)s
                         RECIPEID=%(recipeid)s
                           DISTRO=MicrowaveOS-20141016.1 ThreeHeats x86_64
                     ARCHITECTURE=x86_64

      Job Whiteboard: Operation Righteous Cowboy Lightning

      Recipe Whiteboard: Everything Sunny All the Time Always
**  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **""" \
            % dict(base=get_server_base(), recipeid=recipe.id, jobid=job.id)
        actual_mail_body = msg.get_payload(decode=True)
        self.assertMultiLineEqual(actual_mail_body, expected_mail_body)