def test_machine_ignore_other_options(self):
        p = start_client(['bkr', 'workflow-simple',
                          '--dryrun', '--prettyxml',
                          '--hostrequire', 'hostlabcontroller=lab.example.com',
                          '--random',
                          '--host-filter', 'my_awesome_filter',
                          '--machine', 'test.system',
                          '--ignore-system-status',
                          '--arch', self.distro_tree.arch.arch,
                          '--family', self.distro.osversion.osmajor.osmajor,
                          '--task', self.task.name])

        out, err = p.communicate()
        self.assertEquals(p.returncode, 0, err)
        self.assertIn('Warning: Ignoring --hostrequire because '
                      '--machine was specified', err.split('\n'))
        self.assertIn('Warning: Ignoring --random because '
                      '--machine was specified', err.split('\n'))
        self.assertIn('Warning: Ignoring --host-filter because '
                      '--machine was specified', err.split('\n'))
        self.assertNotIn('<hostlabcontroller op="=" value="lab.example.com"/>',
                         out)
        self.assertNotIn('<autopick random="true"/>', out)
        self.assertIn('<hostRequires force="test.system"/>',
                      out)
Exemple #2
0
    def test_machine_ignore_other_options(self):
        p = start_client([
            'bkr', 'workflow-simple', '--dryrun', '--prettyxml',
            '--hostrequire', 'hostlabcontroller=lab.example.com', '--random',
            '--host-filter', 'my_awesome_filter', '--machine', 'test.system',
            '--ignore-system-status', '--arch', self.distro_tree.arch.arch,
            '--family', self.distro.osversion.osmajor.osmajor, '--task',
            self.task.name
        ])

        out, err = p.communicate()
        self.assertEquals(p.returncode, 0, err)
        self.assertIn(
            'Warning: Ignoring --hostrequire because '
            '--machine was specified', err.split('\n'))
        self.assertIn(
            'Warning: Ignoring --random because '
            '--machine was specified', err.split('\n'))
        self.assertIn(
            'Warning: Ignoring --host-filter because '
            '--machine was specified', err.split('\n'))
        self.assertNotIn('<hostlabcontroller op="=" value="lab.example.com"/>',
                         out)
        self.assertNotIn('<autopick random="true"/>', out)
        self.assertIn('<hostRequires force="test.system"/>', out)
 def test_exits_141_when_pipe_is_closed(self):
     with session.begin():
         job = data_setup.create_job(whiteboard=u'jobwb')
     p = start_client(['bkr', 'job-watch', job.t_id])
     self.assertEquals(p.stdout.readline(),
             'Watching tasks (this may be safely interrupted)...\n')
     p.stdout.close()
     err = p.stderr.read()
     p.wait()
     self.assertEquals(p.returncode, 141, err)
Exemple #4
0
 def test_exits_141_when_pipe_is_closed(self):
     with session.begin():
         job = data_setup.create_job(whiteboard=u'jobwb')
     p = start_client(['bkr', 'job-watch', job.t_id])
     self.assertEquals(
         p.stdout.readline(),
         'Watching tasks (this may be safely interrupted)...\n')
     p.stdout.close()
     err = p.stderr.read()
     p.wait()
     self.assertEquals(p.returncode, 141, err)
 def test_processes_all_arguments_even_if_one_fails(self):
     # This behaviour is actually contrary to what the other subcommands do, 
     # but it's what we have, so let's test it anyway...
     p = start_client(['bkr', 'job-modify', 'J:thiswillfail', self.job.t_id,
                 '--whiteboard', 'uneasy dreams'])
     out, err = p.communicate()
     self.assertEquals(p.returncode, 1)
     self.assertIn('Failed to modify J:thiswillfail', err)
     self.assertEquals(out, 'Successfully modified jobs %s\n' % self.job.t_id)
     with session.begin():
         session.expire_all()
         self.assertEquals(self.job.whiteboard, u'uneasy dreams')
Exemple #6
0
 def test_processes_all_arguments_even_if_one_fails(self):
     # This behaviour is actually contrary to what the other subcommands do,
     # but it's what we have, so let's test it anyway...
     p = start_client(['bkr', 'job-modify', 'J:thiswillfail', self.job.t_id,
                 '--whiteboard', 'uneasy dreams'])
     out, err = p.communicate()
     self.assertEquals(p.returncode, 1)
     self.assertIn('Failed to modify J:thiswillfail', err)
     self.assertEquals(out, 'Successfully modified jobs %s\n' % self.job.t_id)
     with session.begin():
         session.expire_all()
         self.assertEquals(self.job.whiteboard, u'uneasy dreams')
Exemple #7
0
 def test_watch_job(self):
     with session.begin():
         job = data_setup.create_job()
     p = start_client(["bkr", "job-watch", job.t_id])
     time.sleep(1)  # XXX better would be to read the client's stdout
     with session.begin():
         data_setup.mark_job_complete(job)
     out, err = p.communicate()
     self.assertEquals(p.returncode, 0, err)
     self.assert_(out.startswith("Watching tasks"), out)
     self.assert_("New: 1 [total: 1]" in out, out)
     self.assert_("Completed: 1 [total: 1]" in out, out)
 def test_dryrun(self):
     with session.begin():
         distro = data_setup.create_distro(tags=[u'STABLE'])
         distro_tree = data_setup.create_distro_tree(distro=distro)
     p = start_client(['bkr', 'workflow-installer-test',
                       '--family', distro.osversion.osmajor.osmajor,
                       '--arch', distro_tree.arch.arch,
                       '--template', self.template_file_name,
                       '--task',
                       self.task.name,
                       '--dryrun'])
     out, err = p.communicate()
     self.assertEquals(p.returncode, 0)
     self.assertEquals('', out)
Exemple #9
0
 def test_watch_job(self):
     with session.begin():
         job = data_setup.create_job(whiteboard=u'jobwb')
     p = start_client(['bkr', 'job-watch', job.t_id])
     self.assertEquals(p.stdout.readline(),
             'Watching tasks (this may be safely interrupted)...\n')
     self.assertEquals(p.stdout.readline(), '%s jobwb: New\n' % job.t_id)
     self.assertEquals(p.stdout.readline(), '--> New: 1 [total: 1]\n')
     with session.begin():
         data_setup.mark_job_complete(job)
     out, err = p.communicate()
     self.assertEquals(p.returncode, 0, err)
     self.assertEquals(out,
             '%s jobwb: New -> Completed\n'
             '--> Completed: 1 [total: 1]\n' % job.t_id)
 def test_update_inventory_wait(self):
     args = ['bkr', 'update-inventory',
             '--wait', self.system1.fqdn]
     proc = start_client(args)
     out = proc.stdout.readline().rstrip()
     self.assert_(out.startswith('Submitted:'), out)
     m = re.search('J:(\d+)', out)
     job_id = m.group(1)
     out = proc.stdout.readline().rstrip()
     self.assert_('Watching tasks (this may be safely interrupted)...' == out)
     with session.begin():
         job = Job.by_id(job_id)
         job.cancel()
         job.update_status()
     returncode = proc.wait()
     self.assertEquals(returncode, 1)
Exemple #11
0
 def test_watch_job(self):
     with session.begin():
         job = data_setup.create_job(whiteboard=u'jobwb')
     p = start_client(['bkr', 'job-watch', job.t_id])
     self.assertEquals(
         p.stdout.readline(),
         'Watching tasks (this may be safely interrupted)...\n')
     self.assertEquals(p.stdout.readline(), '%s jobwb: New\n' % job.t_id)
     self.assertEquals(p.stdout.readline(), '--> New: 1 [total: 1]\n')
     with session.begin():
         data_setup.mark_job_complete(job)
     out, err = p.communicate()
     self.assertEquals(p.returncode, 0, err)
     self.assertEquals(
         out, '%s jobwb: New -> Completed\n'
         '--> Completed: 1 [total: 1]\n' % job.t_id)
Exemple #12
0
 def test_update_inventory_wait(self):
     args = ['bkr', 'update-inventory',
             '--wait', self.system1.fqdn]
     proc = start_client(args)
     out = proc.stdout.readline().rstrip()
     self.assert_(out.startswith('Submitted:'), out)
     m = re.search('J:(\d+)', out)
     job_id = m.group(1)
     out = proc.stdout.readline().rstrip()
     self.assert_('Watching tasks (this may be safely interrupted)...' == out)
     with session.begin():
         job = Job.by_id(job_id)
         job.cancel()
         job.update_status()
     returncode = proc.wait()
     self.assertEquals(returncode, 1)
Exemple #13
0
 def test_watch_recipe(self):
     with session.begin():
         job = data_setup.create_job(recipe_whiteboard=u'recipewb')
         recipe = job.recipesets[0].recipes[0]
     p = start_client(['bkr', 'job-watch', recipe.t_id])
     self.assertEquals(p.stdout.readline(),
             'Watching tasks (this may be safely interrupted)...\n')
     self.assertEquals(p.stdout.readline(), '%s recipewb: New\n' % recipe.t_id)
     self.assertEquals(p.stdout.readline(), '--> New: 1 [total: 1]\n')
     with session.begin():
         data_setup.mark_job_complete(job)
     out, err = p.communicate()
     self.assertEquals(p.returncode, 0, err)
     self.assertEquals(out,
             '%s recipewb: New -> Completed (%s)\n'
             '--> Completed: 1 [total: 1]\n'
             % (recipe.t_id, recipe.resource.fqdn))
Exemple #14
0
    def test_filters_task_by_osmajor_with_given_taskfile(self):
        with session.begin():
            ignored_task = data_setup.create_task(exclude_osmajor=[self.distro.osversion.osmajor.osmajor])
            included_task = data_setup.create_task()

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

        p = start_client(['bkr', 'workflow-simple',
                          '--dryrun', '--prettyxml',
                          '--family', self.distro.osversion.osmajor.osmajor,
                          '--arch', self.distro_tree.arch.arch,
                          '--taskfile', taskfile.name])
        out, err = p.communicate()
        self.assertEqual(p.returncode, 0)
        self.assertEqual('WARNING: task %s not applicable for distro, ignoring\n' % ignored_task.name, err)
        self.assertNotIn(ignored_task.name, out)
        self.assertIn(included_task.name, out)
Exemple #15
0
 def test_watch_recipe(self):
     with session.begin():
         job = data_setup.create_job(recipe_whiteboard=u'recipewb')
         recipe = job.recipesets[0].recipes[0]
     p = start_client(['bkr', 'job-watch', recipe.t_id])
     self.assertEquals(
         p.stdout.readline(),
         'Watching tasks (this may be safely interrupted)...\n')
     self.assertEquals(p.stdout.readline(),
                       '%s recipewb: New\n' % recipe.t_id)
     self.assertEquals(p.stdout.readline(), '--> New: 1 [total: 1]\n')
     with session.begin():
         data_setup.mark_job_complete(job)
     out, err = p.communicate()
     self.assertEquals(p.returncode, 0, err)
     self.assertEquals(
         out, '%s recipewb: New -> Completed (%s)\n'
         '--> Completed: 1 [total: 1]\n' %
         (recipe.t_id, recipe.resource.fqdn))
Exemple #16
0
    def test_submit_job_wait(self):
        args = ['bkr', 'workflow-simple', '--random',
                '--arch', self.distro_tree.arch.arch,
                '--family', self.distro.osversion.osmajor.osmajor,
                '--task', self.task.name,
                '--wait']
        proc = start_client(args)
        out = proc.stdout.readline().rstrip()
        self.assert_(out.startswith('Submitted:'), out)
        m = re.search('J:(\d+)', out)
        job_id = m.group(1)

        out = proc.stdout.readline().rstrip()
        self.assert_('Watching tasks (this may be safely interrupted)...' == out)

        with session.begin():
            job = Job.by_id(job_id)
            job.cancel()
            job.update_status()

        returncode = proc.wait()
        self.assert_(returncode == 1)
Exemple #17
0
    def test_filters_task_by_osmajor_with_given_taskfile(self):
        with session.begin():
            ignored_task = data_setup.create_task(
                exclude_osmajors=[self.distro.osversion.osmajor.osmajor])
            included_task = data_setup.create_task()

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

        p = start_client([
            'bkr', 'workflow-simple', '--dryrun', '--prettyxml', '--family',
            self.distro.osversion.osmajor.osmajor, '--arch',
            self.distro_tree.arch.arch, '--taskfile', taskfile.name
        ])
        out, err = p.communicate()
        self.assertEqual(p.returncode, 0)
        self.assertEqual(
            'WARNING: task %s not applicable for distro, ignoring\n' %
            ignored_task.name, err)
        self.assertNotIn(ignored_task.name, out)
        self.assertIn(included_task.name, out)
    def test_submit_job_wait(self):
        args = ['bkr', 'workflow-simple', '--random',
                '--arch', self.distro_tree.arch.arch,
                '--family', self.distro.osversion.osmajor.osmajor,
                '--task', self.task.name,
                '--wait']
        proc = start_client(args)
        out = proc.stdout.readline().rstrip()
        self.assert_(out.startswith('Submitted:'), out)
        m = re.search('J:(\d+)', out)
        job_id = m.group(1)

        out = proc.stdout.readline().rstrip()
        self.assert_('Watching tasks (this may be safely interrupted)...' == out)

        with session.begin():
            job = Job.by_id(job_id)
            job.cancel()
            job.update_status()

        returncode = proc.wait()
        self.assert_(returncode == 1)
Exemple #19
0
    def test_watch_job(self):
        args = [
            'bkr', 'workflow-reserve', '--machine', self.system.fqdn,
            '--family', 'RedHatEnterpriseLinux7', '--wait'
        ]
        proc = start_client(args)
        out = proc.stdout.readline().rstrip()
        self.assert_(out.startswith('Submitted:'), out)
        m = re.search('J:(\d+)', out)
        job_id = m.group(1)

        out = proc.stdout.readline().rstrip()

        self.assert_(
            'Watching tasks (this may be safely interrupted)...' == out)

        with session.begin():
            job = Job.by_id(job_id)
            job.cancel()
            job.update_status()

        returncode = proc.wait()
        self.assert_(returncode == 1)