Example #1
0
def cli(argv=None):
    """
    main entry point of mozregression command line.
    """
    options = parse_args(argv)
    logger = commandline.setup_logging("mozregression", options,
                                       {"mach": sys.stdout})
    check_mozregression_version(logger)

    if options.list_releases:
        print(formatted_valid_release_dates())
        sys.exit()

    cache_session = limitedfilecache.get_cache(
        options.http_cache_dir,
        limitedfilecache.ONE_GIGABYTE,
        logger=get_default_logger('Limited File Cache'))
    set_http_cache_session(cache_session,
                           get_defaults={"timeout": options.http_timeout})

    fetch_config = create_config(options.app, mozinfo.os, options.bits)

    if options.command is None:
        launcher_kwargs = dict(
            addons=options.addons,
            profile=options.profile,
            cmdargs=options.cmdargs,
            preferences=preference(options.prefs_files, options.prefs),
        )
        test_runner = ManualTestRunner(launcher_kwargs=launcher_kwargs)
    else:
        test_runner = CommandTestRunner(options.command)

    runner = ResumeInfoBisectRunner(fetch_config, test_runner, options)

    if fetch_config.is_inbound():
        # this can be useful for both inbound and nightly, because we
        # can go to inbound from nightly.
        fetch_config.set_inbound_branch(options.inbound_branch)

    # bisect inbound if last good revision or first bad revision are set
    if options.first_bad_revision or options.last_good_revision:
        bisect = bisect_inbound
    else:
        bisect = bisect_nightlies

    try:
        launcher_class = APP_REGISTRY.get(fetch_config.app_name)
        launcher_class.check_is_runnable()

        sys.exit(bisect(runner, logger))
    except KeyboardInterrupt:
        sys.exit("\nInterrupted.")
    except UnavailableRelease as exc:
        sys.exit("%s\n%s" % (exc, formatted_valid_release_dates()))
    except (MozRegressionError, RequestException) as exc:
        sys.exit(str(exc))
Example #2
0
def cli(argv=None):
    """
    main entry point of mozregression command line.
    """
    options = parse_args(argv)
    logger = commandline.setup_logging("mozregression",
                                       options,
                                       {"mach": sys.stdout})
    check_mozregression_version(logger)

    if options.list_releases:
        print(formatted_valid_release_dates())
        sys.exit()

    cache_session = limitedfilecache.get_cache(
        options.http_cache_dir, limitedfilecache.ONE_GIGABYTE,
        logger=get_default_logger('Limited File Cache'))
    set_http_cache_session(cache_session,
                           get_defaults={"timeout": options.http_timeout})

    fetch_config = create_config(options.app, mozinfo.os, options.bits)

    if options.command is None:
        launcher_kwargs = dict(
            addons=options.addons,
            profile=options.profile,
            cmdargs=options.cmdargs,
            preferences=preference(options.prefs_files, options.prefs),
        )
        test_runner = ManualTestRunner(launcher_kwargs=launcher_kwargs)
    else:
        test_runner = CommandTestRunner(options.command)

    runner = ResumeInfoBisectRunner(fetch_config, test_runner, options)

    if fetch_config.is_inbound():
        # this can be useful for both inbound and nightly, because we
        # can go to inbound from nightly.
        fetch_config.set_inbound_branch(options.inbound_branch)

    # bisect inbound if last good revision or first bad revision are set
    if options.first_bad_revision or options.last_good_revision:
        bisect = bisect_inbound
    else:
        bisect = bisect_nightlies

    try:
        launcher_class = APP_REGISTRY.get(fetch_config.app_name)
        launcher_class.check_is_runnable()

        sys.exit(bisect(runner, logger))
    except KeyboardInterrupt:
        sys.exit("\nInterrupted.")
    except UnavailableRelease as exc:
        sys.exit("%s\n%s" % (exc, formatted_valid_release_dates()))
    except (MozRegressionError, RequestException) as exc:
        sys.exit(str(exc))
Example #3
0
    def test_get_http_session(self):
        utils.set_http_cache_session(self.make_cache())
        a_session = utils.get_http_session()

        # verify session exists
        self.assertTrue(isinstance(a_session, requests.Session))

        # turns out CacheControl is just a function not a class
        # so it makes verifying that we're actually using it
        # a little messy
        for k, v in a_session.adapters.items():
            self.assertTrue(
                isinstance(v.cache, limitedfilecache.LimitedFileCache))
Example #4
0
    def test_get_http_session(self):
        utils.set_http_cache_session(self.make_cache())
        a_session = utils.get_http_session()

        # verify session exists
        self.assertTrue(isinstance(a_session, requests.Session))

        # turns out CacheControl is just a function not a class
        # so it makes verifying that we're actually using it
        # a little messy
        for k, v in a_session.adapters.items():
            self.assertTrue(isinstance(v.cache,
                            limitedfilecache.LimitedFileCache))
Example #5
0
 def test_set_http_session_with_get_defaults(self):
     original_get = Mock()
     session = Mock(get=original_get)
     utils.set_http_cache_session(session, get_defaults={"timeout": 10.0})
     # default is applied
     utils.get_http_session().get('url')
     original_get.assert_called_with('url', timeout=10.0)
     # this is just a default, it can be overriden
     utils.get_http_session().get('url', timeout=5.0)
     original_get.assert_called_with('url', timeout=5.0)
     # you can still pass a None session
     with patch('requests.Session') as Session:
         Session.return_value = session
         utils.set_http_cache_session(None, get_defaults={'timeout': 1.0})
         # a new session has been returned
         self.assertEquals(session, utils.get_http_session())
         # with defaults patch too
         utils.get_http_session().get('url')
         original_get.assert_called_with('url', timeout=1.0)
Example #6
0
 def test_set_http_session_with_get_defaults(self):
     original_get = Mock()
     session = Mock(get=original_get)
     utils.set_http_cache_session(session, get_defaults={"timeout": 10.0})
     # default is applied
     utils.get_http_session().get('url')
     original_get.assert_called_with('url', timeout=10.0)
     # this is just a default, it can be overriden
     utils.get_http_session().get('url', timeout=5.0)
     original_get.assert_called_with('url', timeout=5.0)
     # you can still pass a None session
     with patch('requests.Session') as Session:
         Session.return_value = session
         utils.set_http_cache_session(None, get_defaults={'timeout': 1.0})
         # a new session has been returned
         self.assertEquals(session, utils.get_http_session())
         # with defaults patch too
         utils.get_http_session().get('url')
         original_get.assert_called_with('url', timeout=1.0)
Example #7
0
 def test_none_returns_requests(self):
     utils.set_http_cache_session(self.make_cache())
     utils.set_http_cache_session(None)
     self.assertEquals(utils.get_http_session(), requests)
def apply_prefs(options):
    cache_session = limitedfilecache.get_cache(options['http_cache_dir'],
                                               limitedfilecache.ONE_GIGABYTE)
    set_http_cache_session(cache_session,
                           get_defaults={"timeout": options['http_timeout']})
Example #9
0
 def test_none_returns_requests(self):
     utils.set_http_cache_session(self.make_cache())
     utils.set_http_cache_session(None)
     self.assertEquals(utils.get_http_session(), requests)
Example #10
0
def apply_prefs(options):
    cache_session = limitedfilecache.get_cache(options['http_cache_dir'],
                                               limitedfilecache.ONE_GIGABYTE)
    set_http_cache_session(cache_session,
                           get_defaults={"timeout": options['http_timeout']})