autoland: add a configurable setting for the reviewboard service url (
bug 1337517) r?smacleod
Add a configurable setting for the Reviewboard service URL so that application and test code can use it.
MozReview-Commit-ID: AJ320DAPnJr
--- a/autoland/webapi/autolandweb/server.py
+++ b/autoland/webapi/autolandweb/server.py
@@ -12,48 +12,63 @@ import tornado.web
from autolandweb.dockerflow import read_version
from autolandweb.mozlog import get_mozlog_config, tornado_log_function
from autolandweb.routes import ROUTES
logger = logging.getLogger(__name__)
-def make_app(debug, version_data):
- """Construct a fully configured Tornado Application object."""
+def make_app(debug=False, version_data=None, reviewboard_url=''):
+ """Construct a fully configured Tornado Application object.
+
+ Leaving out the version_data argument may lead to unexpected behaviour.
+
+ Args:
+ debug: Optional boolean, turns on the Tornado application server's
+ debug mode.
+ version_data: A dictionary with keys and data matching the Dockerflow
+ spec versions.json. Optional, but excluding it may lead to
+ unexpected behaviour.
+ See https://github.com/mozilla-services/Dockerflow/blob/master/docs/version_object.md # noqa
+ reviewboard_url: Optional string, the URL of the reviewboard host and
+ port to use for API requests. (e.g. 'http://foo.something:0000')
+ """
return tornado.web.Application(
ROUTES,
debug=debug,
log_function=tornado_log_function,
- version_data=version_data
+ version_data=version_data,
+ reviewboard_url=reviewboard_url
)
@click.command()
@click.option('--debug', envvar='AUTOLANDWEB_DEBUG', is_flag=True)
+@click.option('--reviewboard-url', envvar='REVIEWBOARD_URL', default='')
@click.option('--port', envvar='AUTOLANDWEB_PORT', default=8888)
@click.option('--pretty-log', envvar='AUTOLANDWEB_PRETTY_LOG', default=False)
@click.option(
'--version-path',
envvar='AUTOLANDWEB_VERSION_PATH',
default='/app/version.json'
)
-def autolandweb(debug, port, pretty_log, version_path):
+def autolandweb(debug, reviewboard_url, port, pretty_log, version_path):
logging_config = get_mozlog_config(debug=debug, pretty=pretty_log)
logging.config.dictConfig(logging_config)
version_data = read_version(version_path)
if not version_data:
logger.critical(
{
'msg': 'Could not load version.json, shutting down',
'path': version_path,
}, 'app.fatal'
)
sys.exit(1)
- app = make_app(debug, version_data)
+ app = make_app(debug, version_data, reviewboard_url)
app.listen(port)
tornado.ioloop.IOLoop.current().start()
if __name__ == '__main__':
autolandweb()
--- a/autoland/webapi/tests/test_dockerflow_container_api.py
+++ b/autoland/webapi/tests/test_dockerflow_container_api.py
@@ -15,18 +15,22 @@ import pytest
import sys
sys.path.insert(0, '/app')
from autolandweb.server import make_app # noqa
@pytest.fixture
def app():
+ """Returns the tornado.Application instance we'll be testing against.
+
+ Required for pytest-tornado to function.
+ """
return make_app(
- False, {
+ version_data={
'commit': None,
'version': 'test',
'source': 'https://hg.mozilla.org/automation/conduit',
'build': 'test',
}
)