def _parse_args_and_configure_logging(args):
    parser = argparse.ArgumentParser(prog='job_reporter', description=__doc__)
    loglib.add_logging_options(parser)

    # General configuration
    parser.add_argument('--jobdir', default='/usr/local/autotest/leases',
                        help='Path to job leases directory.')
    parser.add_argument('--lucifer-path', default='/usr/bin/lucifer',
                        help='Path to lucifer binary')

    # Job specific

    # General
    parser.add_argument('--lucifer-level', required=True,
                        help='Lucifer level', choices=['STARTING'])
    parser.add_argument('--job-id', type=int, required=True,
                        help='Autotest Job ID')
    parser.add_argument('--results-dir', required=True,
                        help='Path to job results directory.')

    # STARTING flags
    parser.add_argument('--execution-tag', default=None,
                        help='Autotest execution tag.')
    parser.add_argument('--parsing-only', action='store_true',
                        help='Whether to only do parsing'
                        ' (only with --lucifer-level STARTING)')

    args = parser.parse_args(args)
    loglib.configure_logging_with_args(parser, args)
    return args
示例#2
0
 def test_parse_and_config_defaults(self):
     """Test default args satisfy configure_logging_with_args()."""
     parser = argparse.ArgumentParser(prog='unittest')
     loglib.add_logging_options(parser)
     args = parser.parse_args([])
     with mock.patch.object(loglib, 'configure_logging',
                            autospec=True) as configure:
         loglib.configure_logging_with_args(parser, args)
     configure.assert_called_once_with(name='unittest')
示例#3
0
def main(args):
    """Main function

    @param args: list of command line args
    """

    parser = argparse.ArgumentParser(prog='job_aborter', description=__doc__)
    parser.add_argument('--jobdir', required=True)
    loglib.add_logging_options(parser)
    args = parser.parse_args(args)
    loglib.configure_logging_with_args(parser, args)
    logger.info('Starting with args: %r', args)

    autotest.monkeypatch()
    ts_mon_config = autotest.chromite_load('ts_mon_config')
    with ts_mon_config.SetupTsMonGlobalState('job_aborter'):
        _main_loop(jobdir=args.jobdir)
    assert False  # cannot exit normally
示例#4
0
def _parse_args_and_configure_logging(args):
    parser = argparse.ArgumentParser(prog='job_reporter', description=__doc__)
    loglib.add_logging_options(parser)

    # General configuration
    parser.add_argument('--jobdir',
                        default='/usr/local/autotest/leases',
                        help='Path to job leases directory.')
    parser.add_argument('--run-job-path',
                        default='/usr/bin/lucifer_run_job',
                        help='Path to lucifer_run_job binary')
    parser.add_argument('--watcher-path',
                        default='/usr/bin/lucifer_watcher',
                        help='Path to lucifer_watcher binary')

    # Job specific
    parser.add_argument('--job-id',
                        type=int,
                        required=True,
                        help='Autotest Job ID')
    parser.add_argument('--lucifer-level', required=True, help='Lucifer level')
    parser.add_argument('--autoserv-exit',
                        type=int,
                        default=None,
                        help='''
autoserv exit status.  If this is passed, then autoserv will not be run
as the caller has presumably already run it.
''')
    parser.add_argument('--need-gather',
                        action='store_true',
                        help='Whether to gather logs'
                        ' (only with --lucifer-level GATHERING)')
    parser.add_argument('--num-tests-failed',
                        type=int,
                        default=-1,
                        help='Number of tests failed'
                        ' (only with --need-gather)')
    parser.add_argument('--results-dir',
                        required=True,
                        help='Path to job leases directory.')
    args = parser.parse_args(args)
    loglib.configure_logging_with_args(parser, args)
    return args
def main():
    """Entry point of test_push."""
    autotest.monkeypatch()
    metrics = autotest.chromite_load('metrics')
    ts_mon_config = autotest.chromite_load('ts_mon_config')

    parser = _get_parser()
    loglib.add_logging_options(parser)
    args = parser.parse_args()
    loglib.configure_logging_with_args(parser, args)

    with ts_mon_config.SetupTsMonGlobalState(service_name='skylab_test_push',
                                             indirect=True):
        success = False
        try:
            with metrics.SecondsTimer(_METRICS_PREFIX + '/durations/total',
                                      add_exception_field=True):
                _run_test_push(args)
            success = True
        finally:
            metrics.Counter(_METRICS_PREFIX +
                            '/tick').increment(fields={'success': success})