Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AIRFLOW-3124] Fix RBAC webserver debug mode #3958

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions airflow/bin/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -870,8 +870,12 @@ def webserver(args):
print(
"Starting the web server on port {0} and host {1}.".format(
args.port, args.hostname))
app = create_app_rbac(conf) if settings.RBAC else create_app(conf)
app.run(debug=True, port=args.port, host=args.hostname,
if settings.RBAC:
app, _ = create_app_rbac(conf, testing=conf.get('core', 'unit_test_mode'))
else:
app = create_app(conf, testing=conf.get('core', 'unit_test_mode'))
app.run(debug=True, use_reloader=False if app.config['TESTING'] else True,
port=args.port, host=args.hostname,
ssl_context=(ssl_cert, ssl_key) if ssl_cert and ssl_key else None)
else:
os.environ['SKIP_DAGS_PARSING'] = 'True'
Expand Down
16 changes: 15 additions & 1 deletion tests/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,21 @@ def test_ready_prefix_on_cmdline_dead_process(self):
self.assertEqual(get_num_ready_workers_running(self.gunicorn_master_proc), 0)

def test_cli_webserver_debug(self):
p = psutil.Popen(["airflow", "webserver", "-d"])
env = os.environ.copy()
p = psutil.Popen(["airflow", "webserver", "-d"], env=env)
sleep(3) # wait for webserver to start
return_code = p.poll()
self.assertEqual(
None,
return_code,
"webserver terminated with return code {} in debug mode".format(return_code))
p.terminate()
p.wait()

def test_cli_rbac_webserver_debug(self):
env = os.environ.copy()
env['AIRFLOW__WEBSERVER__RBAC'] = 'True'
p = psutil.Popen(["airflow", "webserver", "-d"], env=env)
sleep(3) # wait for webserver to start
return_code = p.poll()
self.assertEqual(
Expand Down