Beispiel #1
0
    def test_get_erronous_cfg_defaults(self):
        handle, filepath = tempfile.mkstemp()
        self.addCleanup(os.unlink, filepath)

        with os.fdopen(handle, 'w') as conf_file:
            conf_file.write('aaaaaaaaaaa [Defaults]\n')

        with self.assertRaises(errors.MozRegressionError):
            cli.cli(conf_file=filepath)
Beispiel #2
0
 def test_warn_invalid_build_type_in_conf(self):
     filepath = self._create_conf_file("build-type=foo\n")
     conf = cli.cli([], conf_file=filepath)
     warns = []
     conf.logger.warning = warns.append
     conf.validate()
     self.assertIn("Unable to find a suitable build type 'foo'." " (Defaulting to 'opt')", warns)
Beispiel #3
0
def main(argv=None, namespace=None, check_new_version=True):
    """
    main entry point of mozregression command line.
    """
    # terminal color support on windows
    if os.name == 'nt':
        colorama.init()

    if sys.version_info <= (2, 7, 9):
        # requests uses urllib3, and on python <= 2.7.9 there will be a lot
        # of warnings that we do not want. See
        # https://bugzilla.mozilla.org/show_bug.cgi?id=1199020
        import logging
        logging.captureWarnings(True)

    config, app = None, None
    try:
        config = cli(argv=argv, namespace=namespace)
        if check_new_version:
            check_mozregression_version(config.logger)
        config.validate()
        set_http_session(get_defaults={"timeout": config.options.http_timeout})
        app = Application(config.fetch_config, config.options)

        method = getattr(app, config.action)
        sys.exit(method())

    except KeyboardInterrupt:
        sys.exit("\nInterrupted.")
    except UnavailableRelease, exc:
        config.logger.error(str(exc)) if config else sys.exit(str(exc))
        print formatted_valid_release_dates()
        sys.exit(1)
Beispiel #4
0
 def test_missing_tk_credentials(self):
     filepath = self._create_conf_file('app=b2g-aries\n')
     conf = cli.cli([], conf_file=filepath)
     with self.assertRaisesRegexp(
             errors.MozRegressionError,
             "taskcluster-clientid and taskcluster-accesstoken are"
             " required"):
         conf.validate()
Beispiel #5
0
 def test_warn_invalid_build_type_in_conf(self):
     filepath = self._create_conf_file('build-type=foo\n')
     conf = cli.cli([], conf_file=filepath)
     warns = []
     conf.logger.warning = warns.append
     conf.validate()
     self.assertIn(
         "Unable to find a suitable build type 'foo'."
         " (Defaulting to 'opt')", warns)
Beispiel #6
0
 def test_warn_invalid_build_type_in_conf(self):
     filepath = self._create_conf_file('build-type=foo\n')
     conf = cli.cli([], conf_file=filepath)
     warns = []
     conf.logger.warning = warns.append
     conf.validate()
     self.assertIn(
         'foo is not a valid build type (valid: opt, debug)',
         warns
     )
Beispiel #7
0
    def test_get_defaults(self):
        valid_values = {"http-timeout": "10.2", "persist": "/home/foo/.mozregression", "bits": "64"}

        content = ["%s=%s\n" % (key, value) for key, value in valid_values.iteritems()]
        filepath = self._create_conf_file("\n".join(content))

        options = cli.cli(["--bits=32"], conf_file=filepath).options

        self.assertEqual(options.http_timeout, 10.2)
        self.assertEqual(options.persist, "/home/foo/.mozregression")
        self.assertEqual(options.bits, "32")
Beispiel #8
0
    def test_with_tk_credentials(self, get_defaults):
        from mozregression.config import DEFAULTS

        values = dict(DEFAULTS)
        values.update({"app": "b2g-aries", "taskcluster-clientid": "id1", "taskcluster-accesstoken": "mytoken"})
        get_defaults.return_value = values
        filepath = self._create_conf_file("\n".join("%s=%s" % (k, v) for k, v in values.items()))
        conf = cli.cli(["--good=c1", "--bad=c2"], conf_file=filepath)
        conf.validate()
        self.assertEquals(
            conf.fetch_config.tk_options(), {"credentials": {"accessToken": "mytoken", "clientId": "id1"}}
        )
Beispiel #9
0
    def test_get_defaults(self):
        valid_values = {'http-timeout': '10.2',
                        'persist': '/home/foo/.mozregression',
                        'bits': '64'}

        content = ["%s=%s\n" % (key, value)
                   for key, value in valid_values.iteritems()]
        filepath = self._create_conf_file('\n'.join(content))

        options = cli.cli(['--bits=32'], conf_file=filepath).options

        self.assertEqual(options.http_timeout, 10.2)
        self.assertEqual(options.persist, '/home/foo/.mozregression')
        self.assertEqual(options.bits, '32')
Beispiel #10
0
    def test_get_defaults(self):
        valid_values = {'http-timeout': '10.2',
                        'persist': '/home/foo/.mozregression',
                        'bits': '64'}

        content = ["%s=%s\n" % (key, value)
                   for key, value in valid_values.iteritems()]
        filepath = self._create_conf_file('\n'.join(content))

        options = cli.cli(['--bits=32'], conf_file=filepath).options

        self.assertEqual(options.http_timeout, 10.2)
        self.assertEqual(options.persist, '/home/foo/.mozregression')
        self.assertEqual(options.bits, '32')
Beispiel #11
0
def main(
    argv=None,
    namespace=None,
    check_new_version=True,
    mozregression_variant="console",
):
    """
    main entry point of mozregression command line.
    """
    # terminal color support on windows
    if os.name == "nt":
        colorama.init()

    config, app = None, None
    try:
        config = cli(argv=argv, namespace=namespace)
        if check_new_version:
            check_mozregression_version()
        config.validate()
        set_http_session(get_defaults={"timeout": config.options.http_timeout})

        app = Application(config.fetch_config, config.options)
        send_telemetry_ping_oop(
            UsageMetrics(
                variant=mozregression_variant,
                appname=config.fetch_config.app_name,
                build_type=config.fetch_config.build_type,
                good=config.options.good,
                bad=config.options.bad,
                launch=config.options.launch,
            ),
            config.enable_telemetry,
        )

        method = getattr(app, config.action)
        sys.exit(method())

    except KeyboardInterrupt:
        sys.exit("\nInterrupted.")
    except (MozRegressionError, RequestException) as exc:
        if isinstance(exc, HTTPError) and exc.response.status_code == 401:
            # remove the taskcluster credential file - looks like it's wrong
            # anyway. This will force mozregression to ask again next time.
            mozfile.remove(TC_CREDENTIALS_FNAME)
        LOG.error(str(exc)) if config else sys.exit(str(exc))
        sys.exit(1)
    finally:
        if app:
            app.clear()
Beispiel #12
0
    def test_get_defaults(self):
        valid_values = {
            "http-timeout": "10.2",
            "persist": "/home/foo/.mozregression",
            "bits": "64",
        }

        content = ["%s=%s\n" % (key, value) for key, value in six.iteritems(valid_values)]
        filepath = self._create_conf_file("\n".join(content))

        options = cli.cli(["--bits=32"], conf_file=filepath).options

        self.assertEqual(options.http_timeout, 10.2)
        self.assertEqual(options.persist, "/home/foo/.mozregression")
        self.assertEqual(options.bits, "32")
Beispiel #13
0
    def test_get_defaults(self):
        valid_values = {'http-timeout': '10.2',
                        'persist': '/home/foo/.mozregression',
                        'bits': '64'}

        handle, filepath = tempfile.mkstemp()
        self.addCleanup(os.unlink, filepath)

        with os.fdopen(handle, 'w') as conf_file:
            for key, value in valid_values.iteritems():
                conf_file.write("%s=%s\n" % (key, value))

        options = cli.cli(['--bits=32'], conf_file=filepath).options

        self.assertEqual(options.http_timeout, 10.2)
        self.assertEqual(options.persist, '/home/foo/.mozregression')
        self.assertEqual(options.bits, '32')
Beispiel #14
0
 def test_with_tk_credentials(self, get_defaults):
     from mozregression.config import DEFAULTS
     values = dict(DEFAULTS)
     values.update({
         'app': 'b2g-aries',
         'taskcluster-clientid': 'id1',
         'taskcluster-accesstoken': 'mytoken',
     })
     get_defaults.return_value = values
     filepath = self._create_conf_file('\n'.join(
         '%s=%s' % (k, v) for k, v in values.items()))
     conf = cli.cli(['--good=c1', '--bad=c2'], conf_file=filepath)
     conf.validate()
     self.assertEquals(
         conf.fetch_config.tk_options(),
         {'credentials': {
             'accessToken': 'mytoken',
             'clientId': 'id1'
         }})
Beispiel #15
0
 def test_with_tk_credentials(self, get_defaults):
     from mozregression.config import DEFAULTS
     values = dict(DEFAULTS)
     values.update({
         'app': 'b2g-aries',
         'taskcluster-clientid': 'id1',
         'taskcluster-accesstoken': 'mytoken',
     })
     get_defaults.return_value = values
     filepath = self._create_conf_file(
         '\n'.join('%s=%s' % (k, v) for k, v in values.items())
     )
     conf = cli.cli(['--good-rev=1', '--bad-rev=2'], conf_file=filepath)
     conf.validate()
     self.assertEquals(conf.fetch_config.tk_options(), {
         'credentials': {
             'accessToken': 'mytoken',
             'clientId': 'id1'
         }
     })
Beispiel #16
0
def main(argv=None, namespace=None, check_new_version=True):
    """
    main entry point of mozregression command line.
    """
    # terminal color support on windows
    if os.name == 'nt':
        colorama.init()

    if sys.version_info <= (2, 7, 9):
        # requests uses urllib3, and on python <= 2.7.9 there will be a lot
        # of warnings that we do not want. See
        # https://bugzilla.mozilla.org/show_bug.cgi?id=1199020
        import logging
        logging.captureWarnings(True)

    config, app = None, None
    try:
        config = cli(argv=argv, namespace=namespace)
        if check_new_version:
            check_mozregression_version()
        config.validate()
        set_http_session(get_defaults={"timeout": config.options.http_timeout})
        app = Application(config.fetch_config, config.options)

        method = getattr(app, config.action)
        sys.exit(method())

    except KeyboardInterrupt:
        sys.exit("\nInterrupted.")
    except (MozRegressionError, RequestException) as exc:
        if isinstance(exc, HTTPError) and exc.response.status_code == 401:
            # remove the taskcluster credential file - looks like it's wrong
            # anyway. This will force mozregression to ask again next time.
            mozfile.remove(TC_CREDENTIALS_FNAME)
        LOG.error(str(exc)) if config else sys.exit(str(exc))
        sys.exit(1)
    finally:
        if app:
            app.clear()
Beispiel #17
0
def main(argv=None, namespace=None, check_new_version=True):
    """
    main entry point of mozregression command line.
    """
    # terminal color support on windows
    if os.name == 'nt':
        colorama.init()

    if sys.version_info <= (2, 7, 9):
        # requests uses urllib3, and on python <= 2.7.9 there will be a lot
        # of warnings that we do not want. See
        # https://bugzilla.mozilla.org/show_bug.cgi?id=1199020
        import logging
        logging.captureWarnings(True)

    config, app = None, None
    try:
        config = cli(argv=argv, namespace=namespace)
        if check_new_version:
            check_mozregression_version()
        config.validate()
        set_http_session(get_defaults={"timeout": config.options.http_timeout})
        app = Application(config.fetch_config, config.options)

        method = getattr(app, config.action)
        sys.exit(method())

    except KeyboardInterrupt:
        sys.exit("\nInterrupted.")
    except (MozRegressionError, RequestException) as exc:
        if isinstance(exc, HTTPError) and exc.response.status_code == 401:
            # remove the taskcluster credential file - looks like it's wrong
            # anyway. This will force mozregression to ask again next time.
            mozfile.remove(TC_CREDENTIALS_FNAME)
        LOG.error(str(exc)) if config else sys.exit(str(exc))
        sys.exit(1)
    finally:
        if app:
            app.clear()
Beispiel #18
0
    def test_get_erronous_cfg_defaults(self):
        filepath = self._create_conf_file('aaaaaaaaaaa [Defaults]\n')

        with self.assertRaises(errors.MozRegressionError):
            cli.cli(conf_file=filepath)
Beispiel #19
0
def test_warning_no_conf(mocker):
    out = []
    stdout = mocker.patch('sys.stdout')
    stdout.write = out.append
    cli.cli([], conf_file='blah_this is not a valid file_I_hope')
    assert "You should use a config file" in '\n'.join(out)
Beispiel #20
0
def do_cli(*argv):
    conf = cli.cli(argv, conf_file=None)
    conf.validate()
    return conf
Beispiel #21
0
    def test_get_erronous_cfg_defaults(self):
        filepath = self._create_conf_file("aaaaaaaaaaa [Defaults]\n")

        with self.assertRaises(errors.MozRegressionError):
            cli.cli(conf_file=filepath)
Beispiel #22
0
def test_warning_no_conf(mocker):
    out = []
    stdout = mocker.patch("sys.stdout")
    stdout.write = out.append
    cli.cli([], conf_file="blah_this is not a valid file_I_hope")
    assert "You should use a config file" in "\n".join(out)
Beispiel #23
0
def do_cli(*argv):
    conf = cli.cli(argv, conf_file=None)
    conf.validate()
    return conf