Пример #1
0
 def test_or_lab_controller(self):
     lc1 = data_setup.create_labcontroller(fqdn=u'lab1')
     lc2 = data_setup.create_labcontroller(fqdn=u'lab2')
     lc3 = data_setup.create_labcontroller(fqdn=u'lab3')
     included = data_setup.create_system()
     included.lab_controller = lc1
     excluded = data_setup.create_system()
     excluded.lab_controller = lc3
     self.check_filter("""
            <hostRequires>
             <or>
              <hostlabcontroller op="=" value="lab1"/>
              <hostlabcontroller op="=" value="lab2"/>
             </or>
            </hostRequires>
         """,
         present=[included], absent=[excluded])
     self.check_filter("""
            <hostRequires>
             <or>
              <labcontroller op="=" value="lab1"/>
              <labcontroller op="=" value="lab2"/>
             </or>
            </hostRequires>
         """,
         present=[included], absent=[excluded])
Пример #2
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)
Пример #3
0
 def setUp(self):
     with session.begin():
         self.lc = data_setup.create_labcontroller()
         self.lc.user.password = u"logmein"
         self.lc2 = data_setup.create_labcontroller()
         self.lc2.user.password = u"logmein"
     self.server = self.get_server()
Пример #4
0
    def test_list_systems_lc_disabled(self):
        with session.begin():
            lc1 = data_setup.create_labcontroller()
            lc2 = data_setup.create_labcontroller()
            system1 = data_setup.create_system(fqdn=data_setup.unique_name(u'aaaa%s.testdata'))
            system1.lab_controller = lc1
            system2 = data_setup.create_system(fqdn=data_setup.unique_name(u'aaaa%s.testdata'))
            system2.lab_controller = lc2

            # set lc2 to disabled
            lc2.disabled = True

        out = run_client(['bkr', 'system-list'])
        systems = out.splitlines()
        self.assertIn(system1.fqdn, systems)
        self.assertIn(system2.fqdn, systems)

        out = run_client(['bkr', 'system-list', '--free'])
        systems = out.splitlines()
        self.assertIn(system1.fqdn, systems)
        self.assertNotIn(system2.fqdn, systems)

        out = run_client(['bkr', 'system-list', '--available'])
        systems = out.splitlines()
        self.assertIn(system1.fqdn, systems)
        self.assertIn(system2.fqdn, systems)
Пример #5
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)
Пример #6
0
 def setUp(self):
     with session.begin():
         data_setup.create_labcontroller(fqdn=u'lab-devel.rhts.eng.bos.redhat.com')
     self.selenium = self.get_selenium()
     self.selenium.start()
     self.condition_report = 'never being fixed'
     logged_in = self.login()
Пример #7
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)
Пример #8
0
 def setUp(self):
     self.page_size = 20
     with session.begin():
         self.lc = data_setup.create_labcontroller()
         other_lc = data_setup.create_labcontroller()
         for _ in range(self.page_size + 5):
             other_lc.record_activity(service=u'testdata',
                     field=u'nothing', action=u'nothing')
     self.browser = self.get_browser()
Пример #9
0
 def test_no_quotes(self):
     with session.begin():
         data_setup.create_labcontroller(fqdn=u'imhoff.bkr')
     b = self.browser
     login(b)
     b.get(get_server_base() + 'csv/csv_import')
     b.find_element_by_name('csv_file').send_keys(
             pkg_resources.resource_filename(self.__module__, 'bz787519.csv'))
     b.find_element_by_name('csv_file').submit()
     self.failUnless(is_text_present(self.browser, "No Errors"))
Пример #10
0
    def setUp(self):
        with session.begin():
            self.owner = data_setup.create_user(password=u'password')
            self.lc1 = data_setup.create_labcontroller(fqdn=u'bz704399.example.invalid')
            self.lc2 = data_setup.create_labcontroller()

            self.s1 = data_setup.create_system(lab_controller=self.lc1, loaned=self.owner)
            self.s2 = data_setup.create_system(lab_controller=self.lc2, loaned=self.owner)

        self.browser = self.get_browser()
        login(self.browser, user=self.owner.user_name, password=u'password')
Пример #11
0
 def setUp(self):
     with session.begin():
         self.user = data_setup.create_user(password=u'password')
         self.system = data_setup.create_system(
             lab_controller=data_setup.create_labcontroller())
         self.system.loaned = self.user
         self.another_system = data_setup.create_system(
             lab_controller=data_setup.create_labcontroller())
         self.another_system.loaned = self.user
     self.browser = self.get_browser()
     login(self.browser, user=self.user.user_name, password=u'password')
 def test_change_fqdn(self):
     with session.begin():
         lc = data_setup.create_labcontroller()
         another_lc = data_setup.create_labcontroller()
     new_fqdn = data_setup.unique_name(u'lab%s.testdata.invalid')
     run_client(['bkr', 'labcontroller-modify',
                 '--fqdn', new_fqdn,
                 lc.fqdn])
     with session.begin():
         session.refresh(lc)
         self.assertEquals(lc.fqdn, new_fqdn)
Пример #13
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
Пример #14
0
 def test_cannot_change_fqdn_to_duplicate(self):
     with session.begin():
         lc = data_setup.create_labcontroller()
         other_lc = data_setup.create_labcontroller()
     b = self.browser
     b.get(get_server_base() + "labcontrollers/edit?id=%s" % lc.id)
     b.find_element_by_name("fqdn").clear()
     b.find_element_by_name("fqdn").send_keys(other_lc.fqdn)
     b.find_element_by_id("form").submit()
     self.assertEquals(
         b.find_element_by_xpath('//input[@name="fqdn"]/following-sibling::span').text, "FQDN is not unique"
     )
 def test_change_fqdn_being_used_by_another_lab_controller(self):
     with session.begin():
         lc = data_setup.create_labcontroller()
         another_lc = data_setup.create_labcontroller()
     new_fqdn = data_setup.unique_name(u'lab%s.testdata.invalid')
     try:
         run_client(['bkr', 'labcontroller-modify',
                     '--fqdn', another_lc.fqdn,
                     lc.fqdn])
         self.fail('Must error out')
     except ClientError as e:
         self.assertIn('FQDN %s already in use' % another_lc.fqdn,
                       e.stderr_output)
Пример #16
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
Пример #17
0
    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)
Пример #18
0
 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))
Пример #19
0
 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)
Пример #20
0
def setup_package():
    global lc_fqdn, _daemons_running_externally
    conf = get_conf()

    if not 'BEAKER_LABCONTROLLER_HOSTNAME' in os.environ:
        # Need to start the lab controller daemons ourselves
        with session.begin():
            user = data_setup.create_user(user_name=conf.get('USERNAME').decode('utf8'), password=conf.get('PASSWORD'))
            lc = data_setup.create_labcontroller(fqdn=u'localhost', user=user)
        processes.extend([
            Process('beaker-proxy',
                    args=['python', '../LabController/src/bkr/labcontroller/main.py',
                          '-c', config_file, '-f'],
                    listen_port=8000,
                    stop_signal=signal.SIGTERM),
            Process('beaker-provision',
                    args=['python', '../LabController/src/bkr/labcontroller/provision.py',
                          '-c', config_file, '-f'],
                    stop_signal=signal.SIGTERM),
            Process('beaker-watchdog',
                    args=['python', '../LabController/src/bkr/labcontroller/watchdog.py',
                          '-c', config_file, '-f'],
                    stop_signal=signal.SIGTERM),
        ])
        lc_fqdn = u'localhost'
    else:
        _daemons_running_externally = True
        # We have been passed a space seperated list of LCs
        lab_controllers = os.environ.get('BEAKER_LABCONTROLLER_HOSTNAME').decode('utf8')
        lab_controllers_list = lab_controllers.split()
        # Just get the last one, it shouldn't matter to us
        lab_controller = lab_controllers_list.pop()
        # Make sure that the LC is in the DB
        data_setup.create_labcontroller(fqdn=lab_controller)
        lc_fqdn = lab_controller

    # Clear out any existing job logs, so that they are registered correctly 
    # when first created.
    # If we've been passed a remote hostname for the LC, we assume it's been 
    # freshly provisioned and the dir will already be empty.
    shutil.rmtree(conf.get('CACHEPATH'), ignore_errors=True)

    try:
        for process in processes:
            process.start()
    except:
        for process in processes:
            process.stop()
        raise
Пример #21
0
 def test_cannot_change_username_to_duplicate(self):
     # Changing an LC's username to an existing user account is okay, but 
     # you can't change it to a user account that is already being used by 
     # another LC.
     with session.begin():
         lc = data_setup.create_labcontroller()
         other_lc = data_setup.create_labcontroller()
     b = self.browser
     b.get(get_server_base() + 'labcontrollers/edit?id=%s' % lc.id)
     b.find_element_by_name('lusername').clear()
     b.find_element_by_name('lusername').send_keys(other_lc.user.user_name)
     b.find_element_by_id('form').submit()
     self.assertEquals(b.find_element_by_xpath(
             '//input[@name="lusername"]/following-sibling::span').text,
             'Username is in use by a different lab controller')
Пример #22
0
 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])
Пример #23
0
 def test_peer_roles(self):
     with session.begin():
         dt = data_setup.create_distro_tree()
         lc = data_setup.create_labcontroller()
         systems = [
             data_setup.create_system(fqdn=u'server.peer-roles.invalid', lab_controller=lc),
             data_setup.create_system(fqdn=u'clientone.peer-roles.invalid', lab_controller=lc),
             data_setup.create_system(fqdn=u'clienttwo.peer-roles.invalid', lab_controller=lc),
         ]
         job = data_setup.create_job_for_recipes([
             data_setup.create_recipe(distro_tree=dt, role=u'SERVERS'),
             data_setup.create_recipe(distro_tree=dt, role=u'CLIENTS'),
             data_setup.create_recipe(distro_tree=dt, role=u'CLIENTS'),
         ])
         job.recipesets[0].recipes[0].tasks[0].role = None
         # Normally you wouldn't use the same role name with different 
         # meaning at the task level, because that would just get 
         # confusing... but it is possible
         job.recipesets[0].recipes[1].tasks[0].role = u'SERVERS'
         job.recipesets[0].recipes[2].tasks[0].role = u'CLIENTTWO'
         for i in range(3):
             data_setup.mark_recipe_running(job.recipesets[0].recipes[i], system=systems[i])
     self.server.auth.login_password(self.lc.user.user_name, u'logmein')
     expected = {
         'SERVERS': ['server.peer-roles.invalid', 'clientone.peer-roles.invalid'],
         'CLIENTS': ['clientone.peer-roles.invalid', 'clienttwo.peer-roles.invalid'],
         'None': ['server.peer-roles.invalid'],
         'CLIENTTWO': ['clienttwo.peer-roles.invalid'],
     }
     for i in range(3):
         self.assertEquals(self.server.recipes.tasks.peer_roles(
                 job.recipesets[0].recipes[i].tasks[0].id),
                 expected)
Пример #24
0
 def test_role_fqdns_not_duplicated(self):
     with session.begin():
         dt = data_setup.create_distro_tree()
         lc = data_setup.create_labcontroller()
         systems = [
             data_setup.create_system(fqdn=u'server.bz951283', lab_controller=lc),
             data_setup.create_system(fqdn=u'client.bz951283', lab_controller=lc),
         ]
         job = data_setup.create_job_for_recipes([
             data_setup.create_recipe(distro_tree=dt, role=u'SERVERS'),
             data_setup.create_recipe(distro_tree=dt, role=u'CLIENTS'),
         ])
         # same roles on the tasks as on the recipes
         job.recipesets[0].recipes[0].tasks[0].role = u'SERVERS'
         job.recipesets[0].recipes[1].tasks[0].role = u'CLIENTS'
         for i in range(2):
             data_setup.mark_recipe_running(job.recipesets[0].recipes[i], system=systems[i])
     self.server.auth.login_password(self.lc.user.user_name, u'logmein')
     expected = {
         'SERVERS': ['server.bz951283'],
         'CLIENTS': ['client.bz951283'],
     }
     for i in range(2):
         self.assertEquals(self.server.recipes.tasks.peer_roles(
                 job.recipesets[0].recipes[i].tasks[0].id),
                 expected)
Пример #25
0
    def setUp(self):
        with session.begin():
            self.lab_controller = data_setup.create_labcontroller()
            self.system_owner = data_setup.create_user()
            self.unprivileged_user = data_setup.create_user(password=u'password')
            self.system = data_setup.create_system(lab_controller=self.lab_controller,
                    owner=self.system_owner, status=u'Automated', arch=u'i386')
            self.distro_tree = data_setup.create_distro_tree(
                    lab_controllers=[self.lab_controller])
            self.system.provisions[self.distro_tree.arch] = Provision(
                    arch=self.distro_tree.arch, ks_meta=u'some_ks_meta_var=1',
                    kernel_options=u'some_kernel_option=1',
                    kernel_options_post=u'some_kernel_option=2')
            self.system.provisions[self.distro_tree.arch]\
                .provision_families[self.distro_tree.distro.osversion.osmajor] = \
                    ProvisionFamily(osmajor=self.distro_tree.distro.osversion.osmajor,
                        ks_meta=u'some_ks_meta_var=2', kernel_options=u'some_kernel_option=3',
                        kernel_options_post=u'some_kernel_option=4')
            self.system.provisions[self.distro_tree.arch]\
                .provision_families[self.distro_tree.distro.osversion.osmajor]\
                .provision_family_updates[self.distro_tree.distro.osversion] = \
                    ProvisionFamilyUpdate(osversion=self.distro_tree.distro.osversion,
                        ks_meta=u'some_ks_meta_var=3', kernel_options=u'some_kernel_option=5',
                        kernel_options_post=u'some_kernel_option=6')

        self.browser = self.get_browser()
Пример #26
0
    def test_distro_and_system_overrides_recipe(self):

        with session.begin():
            lc = data_setup.create_labcontroller()
            i386_distro = self._create_i386_distro(lc)
            system1 = data_setup.create_system(lab_controller=lc, arch=u'x86_64')
            system2 = data_setup.create_system(lab_controller=lc, arch=u'i386')
            system2.provisions[system2.arch[0]] = Provision(arch=system2.arch[0],
                kernel_options_post='usshopper')
        recipe = self._create_recipe(system1)

        # recipe uses system1 + x86_64 distro. We pass in system2 and i386
        # distro, so we should pick up the provision options of system2 + i386
        distro_tree_id = i386_distro.trees[0].id
        kickstart = self._run_create_kickstart(['--recipe-id', str(recipe.id),
                                                '--system', system2.fqdn,
                                                '--distro-tree-id', str(distro_tree_id),])

        # Make sure we are using the tree from --distro-tree-id
        self.assertIn('url=http://lab.test-kickstart.example.com/distros/'
            'RHEL-6.3/Workstation/i386/os/', kickstart)
        self.assertIn('usshopper', kickstart)
        # Make sure we are using system2
        self.assertIn(system2.fqdn, kickstart)
        self.assertNotIn(system1.fqdn, kickstart)
Пример #27
0
    def setUp(self):
        self.selenium = self.get_selenium()
        self.password = '******'

        # create users
        self.user_1 = data_setup.create_user(password=self.password)
        self.user_2 = data_setup.create_user(password=self.password)
        self.user_3 = data_setup.create_user(password=self.password)

        # create admin users
        self.admin_1 = data_setup.create_user(password=self.password)
        self.admin_1.groups.append(Group.by_name(u'admin'))
        self.admin_2 = data_setup.create_user(password=self.password)
        self.admin_2.groups.append(Group.by_name(u'admin'))

        # create systems
        self.system_1 = data_setup.create_system(shared=True)
        self.system_2 = data_setup.create_system(shared=True)
        self.system_3 = data_setup.create_system(shared=False,
                                                 owner=self.user_3)

        # create group and add users/systems to it
        self.group_1 = data_setup.create_group()
        self.user_3.groups.append(self.group_1)
        self.admin_2.groups.append(self.group_1)
        self.system_2.groups.append(self.group_1)

        lc = data_setup.create_labcontroller()
        self.system_1.lab_controller = lc
        self.system_2.lab_controller = lc
        self.system_3.lab_controller = lc

        self.selenium.start()
Пример #28
0
    def test_can_return_manual_reservation_when_automated(self):

        with session.begin():
            user = data_setup.create_user(password='******')
            system = data_setup.create_system(owner=user, status=SystemStatus.manual)

        b = self.browser
        login(b, user=user.user_name, password="******")

        # Take
        b.get(get_server_base() + 'view/%s' % system.fqdn)
        b.find_element_by_link_text('Take').click()
        b.find_element_by_xpath('//div[contains(@class, "system-quick-usage")]'
                '//span[@class="label" and text()="Reserved"]')

        # toggle status to Automated
        with session.begin():
            system.lab_controller = data_setup.create_labcontroller()
            system.status = SystemStatus.automated

        # Attempt to return
        b.get(get_server_base() + 'view/%s' % system.fqdn)
        b.find_element_by_link_text('Return').click()
        b.find_element_by_xpath('//div[contains(@class, "system-quick-usage")]'
                '//span[@class="label" and text()="Idle"]')
Пример #29
0
 def setUp(self):
     with session.begin():
         self.lab_controller = data_setup.create_labcontroller()
         self.lab_controller.user.password = u'logmein'
     self.server = self.get_server()
     self.server.auth.login_password(self.lab_controller.user.user_name,
             u'logmein')
Пример #30
0
    def test_new_power_settings(self):
        with session.begin():
            lc = data_setup.create_labcontroller()
            system = data_setup.create_system(lab_controller=lc, 
                                              with_power=False)

        b = self.browser
        login(b)
        self.go_to_system_view(system=system, tab='Power Settings')
        tab = b.find_element_by_id('power-settings')
        BootstrapSelect(tab.find_element_by_name('power_type'))\
            .select_by_visible_text('virsh')
        tab.find_element_by_name('power_address').send_keys \
            ('qemu+ssh:10.10.10.10')
        tab.find_element_by_name('power_user').send_keys('root')
        tab.find_element_by_name('power_id').send_keys(system.fqdn)
        tab.find_element_by_tag_name('form').submit()

        # check activity records
        power_fields_changed = {'power_type': 'virsh',
                                'power_address': 'qemu+ssh:10.10.10.1',
                                'power_user': '******',
                                'power_id': system.fqdn,
                                'power_quiescent_period': 5}
        with session.begin():
            session.refresh(system)
            for activity in system.activity:
                self.assertEquals(activity.new_value,
                                  power_fields_changed[activity])
Пример #31
0
 def test_broken_system_notification_off(self):
     with session.begin():
         owner = data_setup.create_user(email_address=u'*****@*****.**',
                                        notify_broken_system=False)
         lc = data_setup.create_labcontroller()
         system = data_setup.create_system(
             fqdn=u'home-two',
             owner=owner,
             lender=u"Aunty Jane's Dodgy Shop",
             location=u'shed out the front',
             lab_controller=lc,
             vendor=u'Acorn',
             arch=u'i386')
         system.arch.append(Arch.by_name(u'x86_64'))
         data_setup.configure_system_power(system,
                                           power_type=u'drac',
                                           address=u'pdu3.home-one',
                                           power_id=u'42')
     with session.begin():
         bkr.server.mail.broken_system_notify(system,
                                              reason="It's not a tarp!")
         self.assertEqual(len(self.mail_capture.captured_mails), 0)
Пример #32
0
 def test_action_buttons(self):
     """ Check that the right action buttons appear in the right circumstances. """
     with session.begin():
         user = data_setup.create_user(password=u'asdflol')
         no_access = data_setup.create_system(shared=False)
         lc1 = data_setup.create_labcontroller()
         borrowable = data_setup.create_system(lab_controller=lc1)
         borrowable.custom_access_policy.add_rule(
                 SystemPermission.loan_self, user=user)
         borrowable_but_loaned = data_setup.create_system()
         borrowable_but_loaned.loaned = data_setup.create_user()
         borrowable_but_loaned.custom_access_policy.add_rule(
                 SystemPermission.loan_self, user=user)
         borrowed = data_setup.create_system()
         borrowed.loaned = user
         # "stealable" means loaned to someone else but you have perms to return their loan
         stealable = data_setup.create_system()
         stealable.loaned = data_setup.create_user()
         stealable.custom_access_policy.add_rule(
                 SystemPermission.loan_any, user=user)
         manual = data_setup.create_system(status=SystemStatus.manual, shared=True)
         taken = data_setup.create_system(status=SystemStatus.manual, shared=True)
         taken.reserve_manually(user=user, service=u'testdata')
     login(self.browser, user=user.user_name, password='******')
     self.go_to_system_view(no_access)
     self.assertEquals(self.action_button_labels(), ['Request Loan'])
     self.go_to_system_view(borrowable_but_loaned)
     self.assertEquals(self.action_button_labels(), ['Schedule Reservation'])
     self.go_to_system_view(borrowable)
     self.assertEquals(self.action_button_labels(), ['Borrow'])
     self.go_to_system_view(borrowed)
     self.assertEquals(self.action_button_labels(), ['Take', 'Return Loan'])
     self.go_to_system_view(stealable)
     self.assertEquals(self.action_button_labels(), ['Return Loan'])
     self.go_to_system_view(manual)
     self.assertEquals(self.action_button_labels(), ['Take'])
     self.go_to_system_view(taken)
     self.assertEquals(self.action_button_labels(), ['Return'])
Пример #33
0
 def setUp(self):
     self.lab_controller = data_setup.create_labcontroller()
     self.distro_tree = data_setup.create_distro_tree(
         osmajor=u'Fedora20',
         arch=u'i386',
         lab_controllers=[self.lab_controller])
     self.usable_system = data_setup.create_system(
         arch=u'i386',
         owner=User.by_user_name(data_setup.ADMIN_USER),
         status=u'Manual',
         shared=True)
     data_setup.configure_system_power(self.usable_system,
                                       power_type=u'drac',
                                       address=u'nowhere.example.com',
                                       user=u'teh_powz0r',
                                       password=u'onoffonoff',
                                       power_id=u'asdf')
     self.usable_system.lab_controller = self.lab_controller
     self.usable_system.user = data_setup.create_user(password=u'password')
     self.usable_system.provisions[self.distro_tree.arch] = Provision(
         arch=self.distro_tree.arch,
         kernel_options='ksdevice=eth0 console=ttyS0')
     self.server = self.get_server()
Пример #34
0
 def test_filtering_by_lab_controller(self):
     with session.begin():
         self.distro_tree_x86_64.lab_controller_assocs[:] = [LabControllerDistroTree(
                 lab_controller=self.lc, url=u'http://whatever')]
         other_lc = data_setup.create_labcontroller()
         self.distro_tree_i386.lab_controller_assocs[:] = [LabControllerDistroTree(
                 lab_controller=other_lc, url=u'http://whatever')]
     login(self.browser)
     b = self.browser
     b.get(get_server_base() + 'reserveworkflow/')
     Select(b.find_element_by_name('osmajor'))\
         .select_by_visible_text(self.distro.osversion.osmajor.osmajor)
     Select(b.find_element_by_name('distro')).select_by_visible_text(self.distro.name)
     Select(b.find_element_by_name('distro_tree_id')).select_by_visible_text(
             '%s Server i386' % self.distro.name)
     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('%s Server i386 is not available on %s'
                 % (self.distro.name, self.lc.fqdn),
             b.find_element_by_class_name('alert-error').text)
Пример #35
0
    def test_distro_overrides_recipe(self):
        with session.begin():
            lc = data_setup.create_labcontroller()
            system1 = data_setup.create_system(lab_controller=lc,
                arch=u'x86_64')
            i386_distro = self._create_i386_distro(lc)
            osmajor = i386_distro.osversion.osmajor
            io = OSMajorInstallOptions.lazy_create(osmajor_id=osmajor.id,
                arch_id=Arch.by_name('i386').id)
            io.ks_meta = 'lang=en_UK.UTF-8'
            session.expire(osmajor, ['install_options_by_arch'])
        recipe = self._create_recipe(system1)
        distro_tree_id = i386_distro.trees[0].id
        kickstart = self._run_create_kickstart(['--recipe-id', str(recipe.id),
            '--distro-tree-id', str(distro_tree_id),])

        # Make sure we are using the tree from --distro-tree-id
        self.assertIn('url=http://lab.test-kickstart.example.com/distros/'
            'RHEL-6.3/Workstation/i386/os/', kickstart)
        self.assertNotIn('url=http://lab.test-kickstart.invalid/distros/'
            'RHEL-6.2/Server/x86_64/os/', kickstart)
        self.assertIn('lang en_UK.UTF-8', kickstart)
        self.assertNotIn('lang en_US.UTF-8', kickstart)
Пример #36
0
 def setUpClass(cls):
     with session.begin():
         # ensure we have lots of systems
         for cores in [1, 2, 3]:
             for vendor, model, status, type, reserved_since, user in zip(
                 [u'Acer', u'Dell', u'HP'],
                 [u'slow model', u'fast model', u'big model'],
                 [u'Automated', u'Manual', u'Removed'],
                 [u'Machine', u'Prototype'], [
                     datetime.datetime(2012, 10, 31, 23, 0, 0),
                     datetime.datetime(2015, 1, 1, 6, 0, 0),
                     datetime.datetime(2020, 1, 6, 10, 0, 0),
                 ], [data_setup.create_user() for _ in range(3)]):
                 system = data_setup.create_system(vendor=vendor,
                                                   model=model,
                                                   status=status,
                                                   type=type)
                 system.cpu = Cpu(cores=cores)
                 system.user = user
                 system.lab_controller = data_setup.create_labcontroller()
                 data_setup.create_manual_reservation(system,
                                                      reserved_since,
                                                      user=user)
Пример #37
0
    def test_labcontroller(self):
        # Add
        with session.begin():
            lc = data_setup.create_labcontroller()
            distro_tree = data_setup.create_distro_tree()
        b = self.browser
        login(b)
        go_to_distro_tree_view(b, distro_tree)
        b.find_element_by_xpath("//select[@id='lab_controller_id']/"
            "option[normalize-space(text())='%s']" % lc.fqdn).click()
        b.find_element_by_xpath("//input[@id='url']"). \
            send_keys('http://blah.com')
        b.find_element_by_name('lab_controller_add_form').submit()
        # A trailing '/' is added automatically if it's not present. RHBZ#912242
        self.assertEqual(
            b.find_element_by_class_name('flash').text,
            'Added %s http://blah.com/' % lc.fqdn)

        # Delete
        delete_and_confirm(b, "//td[preceding-sibling::td/a[@href='http://blah.com/']]/form")
        self.assertEqual(
            b.find_element_by_class_name('flash').text,
            'Deleted %s http://blah.com/' % lc.fqdn)
Пример #38
0
 def setupClass(cls):
     with session.begin():
         cls.owner_email_address = data_setup.unique_name(
             u'*****@*****.**')
         cls.system_owner = data_setup.create_user(
             email_address=cls.owner_email_address)
         cls.system_fqdn = data_setup.unique_name('ncc1701d%s')
         cls.system = data_setup.create_system(fqdn=cls.system_fqdn,
                                               owner=cls.system_owner)
         cls.lc_name = data_setup.unique_name(u'testing_for_mail%s')
         lc = data_setup.create_labcontroller(cls.lc_name)
         cls.system.lab_controller = lc
         lender = u'amd'
         location = u'bne'
         vendor = u'intel'
         cls.system.lender = lender
         cls.system.location = location
         cls.system.vendor = vendor
         cls.reporter_email_address = data_setup.unique_name(
             u'*****@*****.**')
         cls.problem_reporter = data_setup.create_user(
             password=u'password',
             display_name=data_setup.unique_name('Crusher Lady%s'),
             email_address=cls.reporter_email_address)
Пример #39
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()
Пример #40
0
 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])
Пример #41
0
 def setUp(self):
     with session.begin():
         self.system = data_setup.create_system(
             lab_controller=data_setup.create_labcontroller())
         self.browser = self.get_browser()
Пример #42
0
 def setUp(self):
     self.lab_controller = data_setup.create_labcontroller()
Пример #43
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)
Пример #44
0
def create_lab_controller():
    return data_setup.create_labcontroller(fqdn=u'lab.test-kickstart.invalid')
Пример #45
0
 def setUp(self):
     with session.begin():
         self.lc = data_setup.create_labcontroller(
             fqdn='lab.ipxescript.httptest')
Пример #46
0
 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])
Пример #47
0
 def setUp(self):
     with session.begin():
         self.lc = data_setup.create_labcontroller()
Пример #48
0
 def setUp(self):
     self.lc = data_setup.create_labcontroller()
     self.removed_lc = data_setup.create_labcontroller()
     self.removed_lc.removed = datetime.utcnow()
Пример #49
0
 def setUp(self):
     self.lab_controller = data_setup.create_labcontroller()
     self.server = self.get_server()
Пример #50
0
    def test_cee_ops_provided_queries(self):
        # CEE Ops is a team within Red Hat who relies heavily on Beaker. These
        # queries are used by their tooling to integrate with Beaker's
        # inventory. The queries are covered here in our test suite so that
        # they will know if any Beaker schema changes will affect these
        # queries.

        cee_users = data_setup.create_group(group_name=u'cee-users')
        cee_user = data_setup.create_user(user_name=u'billybob')
        cee_users.add_member(cee_user)
        # Create a system which has been manually reserved
        reserved_system = data_setup.create_system(fqdn=u'gsslab.reserved',
                                                   status='Manual')
        data_setup.create_manual_reservation(reserved_system,
                                             user=cee_user,
                                             start=datetime.datetime(
                                                 2016, 1, 1, 0, 0))
        # Create a system which is loaned out
        loaned_system = data_setup.create_system(fqdn=u'gsslab.loaned',
                                                 status='Manual')
        data_setup.create_system_loan(loaned_system,
                                      user=cee_user,
                                      start=datetime.datetime(
                                          2016, 1, 2, 0, 0))
        # Create a system which has been provisioned with RHEL7.1
        provisioned_system = data_setup.create_system(
            fqdn=u'gsslab.provisioned',
            status='Automated',
            lab_controller=data_setup.create_labcontroller())
        recipe = data_setup.create_recipe(distro_name=u'RHEL-7.1',
                                          variant=u'Server')
        data_setup.create_job_for_recipes([recipe], owner=cee_user)
        data_setup.mark_recipe_complete(recipe, system=provisioned_system)
        # Create a non-CEE system which has been provisioned 20 times
        noncee_provisioned_system = data_setup.create_system(
            fqdn=u'noncee.provisioned',
            status='Automated',
            lab_controller=data_setup.create_labcontroller())
        for _ in range(20):
            recipe = data_setup.create_recipe()
            data_setup.create_job_for_recipes([recipe], owner=cee_user)
            data_setup.mark_recipe_complete(recipe,
                                            system=noncee_provisioned_system)
        session.flush()

        rows = self.execute_reporting_query('cee/all-systems').fetchall()
        self.assertEqual(len(rows), 3)

        rows = self.execute_reporting_query('cee/reserved-systems').fetchall()
        self.assertEqual(len(rows), 1)
        self.assertEqual(rows[0].fqdn, u'gsslab.reserved')
        self.assertEqual(rows[0].start_time,
                         datetime.datetime(2016, 1, 1, 0, 0))

        rows = self.execute_reporting_query('cee/loaned-systems').fetchall()
        self.assertEqual(len(rows), 1)
        self.assertEqual(rows[0].fqdn, u'gsslab.loaned')

        rows = self.execute_reporting_query(
            'cee/loaned-systems-by-date').fetchall()
        self.assertEqual(len(rows), 1)
        self.assertEqual(rows[0].fqdn, u'gsslab.loaned')
        self.assertEqual(rows[0].loan_date,
                         datetime.datetime(2016, 1, 2, 0, 0))

        rows = self.execute_reporting_query('cee/system-provisions').fetchall()
        self.assertEqual(len(rows), 1)
        self.assertEqual(rows[0].fqdn, u'gsslab.provisioned')
        self.assertEqual(rows[0].count, 1)

        rows = self.execute_reporting_query(
            'cee/system-reservations').fetchall()
        self.assertEqual(len(rows), 2)
        self.assertEqual(rows[0].fqdn, u'gsslab.provisioned')
        self.assertEqual(rows[0].count, 1)
        self.assertEqual(rows[1].fqdn, u'gsslab.reserved')
        self.assertEqual(rows[1].count, 1)

        rows = self.execute_reporting_query(
            'cee/system-distrotrees').fetchall()
        self.assertEqual(len(rows), 1)
        self.assertEqual(rows[0].fqdn, u'gsslab.provisioned')
        self.assertEqual(rows[0].operatingsystem, u'RHEL-7.1 Server i386')

        rows = self.execute_reporting_query(
            'cee/provisions-by-distrotree').fetchall()
        self.assertEqual(len(rows), 1)
        self.assertEqual(rows[0].operatingsystem, u'RHEL-7.1 Server i386')
        self.assertEqual(rows[0].count, 1)

        rows = self.execute_reporting_query(
            'cee/provisions-by-user').fetchall()
        self.assertEqual(len(rows), 1)
        self.assertEqual(rows[0].user_name, u'billybob')
        self.assertEqual(rows[0].count, 21)

        rows = self.execute_reporting_query(
            'cee/non-cee-provisions-by-user').fetchall()
        self.assertEqual(len(rows), 1)
        self.assertEqual(rows[0].fqdn, u'noncee.provisioned')
        self.assertEqual(rows[0].count, 20)
Пример #51
0
 def setUp(self):
     with session.begin():
         self.lc = data_setup.create_labcontroller()
     self.orig_VirtManager = dynamic_virt.VirtManager
     dynamic_virt.VirtManager = DummyVirtManager
     DummyVirtManager.lab_controller = self.lc
Пример #52
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)
Пример #53
0
 def setUp(self):
     with session.begin():
         self.lc = data_setup.create_labcontroller()
         self.lc.user.password = u'logmein'
     self.server = self.get_server()
Пример #54
0
def setup_package():
    global lc_fqdn, _daemons_running_externally
    conf = get_conf()

    if not 'BEAKER_LABCONTROLLER_HOSTNAME' in os.environ:
        # Need to start the lab controller daemons ourselves
        with session.begin():
            user = data_setup.create_user(
                user_name=conf.get('USERNAME').decode('utf8'),
                password=conf.get('PASSWORD'))
            lc = data_setup.create_labcontroller(fqdn=u'localhost', user=user)
        processes.extend([
            Process('beaker-proxy',
                    args=[
                        'python',
                        '../LabController/src/bkr/labcontroller/main.py', '-c',
                        config_file, '-f'
                    ],
                    listen_port=8000,
                    stop_signal=signal.SIGTERM),
            Process('beaker-provision',
                    args=[
                        'python',
                        '../LabController/src/bkr/labcontroller/provision.py',
                        '-c', config_file, '-f'
                    ],
                    stop_signal=signal.SIGTERM),
            Process('beaker-watchdog',
                    args=[
                        'python',
                        '../LabController/src/bkr/labcontroller/watchdog.py',
                        '-c', config_file, '-f'
                    ],
                    stop_signal=signal.SIGTERM),
        ])
        lc_fqdn = u'localhost'
    else:
        _daemons_running_externally = True
        # We have been passed a space seperated list of LCs
        lab_controllers = os.environ.get(
            'BEAKER_LABCONTROLLER_HOSTNAME').decode('utf8')
        lab_controllers_list = lab_controllers.split()
        # Just get the last one, it shouldn't matter to us
        lab_controller = lab_controllers_list.pop()
        # Make sure that the LC is in the DB
        data_setup.create_labcontroller(fqdn=lab_controller)
        lc_fqdn = lab_controller

    # Clear out any existing job logs, so that they are registered correctly
    # when first created.
    # If we've been passed a remote hostname for the LC, we assume it's been
    # freshly provisioned and the dir will already be empty.
    shutil.rmtree(conf.get('CACHEPATH'), ignore_errors=True)

    try:
        for process in processes:
            process.start()
    except:
        for process in processes:
            process.stop()
        raise
Пример #55
0
 def setUp(self):
     self.lc_fqdn = u'lab.domain.com'
     with session.begin():
         lc = data_setup.create_labcontroller(fqdn=self.lc_fqdn)
Пример #56
0
 def setUp(self):
     with session.begin():
         self.lc = data_setup.create_labcontroller()
     DummyVirtManager.lab_controller = self.lc