forked from apache/airflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AIRFLOW-328][AIRFLOW-371] Remove redundant default configuration & f…
…ix unit test configuration AIRFLOW-328 https://issues.apache.org/jira/browse/AIRFLOW-328 Previously, Airflow had both a default template for airflow.cfg AND a dictionary of default values. Frequently, these get out of sync (an option in one has a different value than in the other, or isn’t present in the other). This commit removes the default dict and uses the airflow.cfg template to provide defaults. The ConfigParser first reads the template, loading all the options it contains, and then reads the user’s actual airflow.cfg to overwrite the default values with any new ones. AIRFLOW-371 https://issues.apache.org/jira/browse/AIRFLOW-371 Calling test_mode() didn't actually change Airflow's configuration! This actually wasn't an issue in unit tests because the unit test run script was hardcoded to point at the unittest.cfg file, but it needed to be fixed. [AIRFLOW-328] Remove redundant default configuration Previously, Airflow had both a default template for airflow.cfg AND a dictionary of default values. Frequently, these get out of sync (an option in one has a different value than in the other, or isn’t present in the other). This commit removes the default dict and uses the airflow.cfg template to provide defaults. The ConfigParser first reads the template, loading all the options it contains, and then reads the user’s actual airflow.cfg to overwrite the default values with any new ones. [AIRFLOW-371] Make test_mode() functional Previously, calling test_mode() didn’t actually do anything. This PR renames it to load_test_config() (to avoid confusion, ht @r39132). In addition, manually entering test_mode after Airflow launches might be too late — some options have already been loaded (DAGS_FOLDER, etc.). This makes it so setting tests/unit_test_mode OR the equivalent env var (AIRFLOW__TESTS__UNIT_TEST_MODE) will load the test config immediately, prior to loading the rest of Airflow. Closes apache#1677 from jlowin/Simplify-config
- Loading branch information
Showing
21 changed files
with
200 additions
and
211 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,7 @@ | |
from airflow.executors import SequentialExecutor, LocalExecutor | ||
from airflow.models import Variable | ||
|
||
configuration.test_mode() | ||
configuration.load_test_config() | ||
from airflow import jobs, models, DAG, utils, macros, settings, exceptions | ||
from airflow.models import BaseOperator | ||
from airflow.operators.bash_operator import BashOperator | ||
|
@@ -116,7 +116,7 @@ class CoreTest(unittest.TestCase): | |
"num_runs": 1} | ||
|
||
def setUp(self): | ||
configuration.test_mode() | ||
configuration.load_test_config() | ||
self.dagbag = models.DagBag( | ||
dag_folder=DEV_NULL, include_examples=True) | ||
self.args = {'owner': 'airflow', 'start_date': DEFAULT_DATE} | ||
|
@@ -836,7 +836,7 @@ def test_task_fail_duration(self): | |
|
||
class CliTests(unittest.TestCase): | ||
def setUp(self): | ||
configuration.test_mode() | ||
configuration.load_test_config() | ||
app = application.create_app() | ||
app.config['TESTING'] = True | ||
self.parser = cli.CLIFactory.get_parser() | ||
|
@@ -1003,7 +1003,7 @@ def test_variables(self): | |
|
||
class WebUiTests(unittest.TestCase): | ||
def setUp(self): | ||
configuration.test_mode() | ||
configuration.load_test_config() | ||
configuration.conf.set("webserver", "authenticate", "False") | ||
app = application.create_app() | ||
app.config['TESTING'] = True | ||
|
@@ -1226,7 +1226,7 @@ def test_unauthorized_password_auth(self): | |
self.assertEqual(response.status_code, 302) | ||
|
||
def tearDown(self): | ||
configuration.test_mode() | ||
configuration.load_test_config() | ||
session = Session() | ||
session.query(models.User).delete() | ||
session.commit() | ||
|
@@ -1310,7 +1310,7 @@ def test_with_filters(self): | |
assert 'Connections' in response.data.decode('utf-8') | ||
|
||
def tearDown(self): | ||
configuration.test_mode() | ||
configuration.load_test_config() | ||
session = Session() | ||
session.query(models.User).delete() | ||
session.commit() | ||
|
@@ -1346,7 +1346,7 @@ def test_group_belonging(self): | |
assert set(auth.ldap_groups) == set(users[user]) | ||
|
||
def tearDown(self): | ||
configuration.test_mode() | ||
configuration.load_test_config() | ||
configuration.conf.set("webserver", "authenticate", "False") | ||
|
||
|
||
|
@@ -1365,7 +1365,7 @@ def prepare_request(self, request): | |
|
||
class HttpOpSensorTest(unittest.TestCase): | ||
def setUp(self): | ||
configuration.test_mode() | ||
configuration.load_test_config() | ||
args = {'owner': 'airflow', 'start_date': DEFAULT_DATE_ISO} | ||
dag = DAG(TEST_DAG_ID, default_args=args) | ||
self.dag = dag | ||
|
@@ -1419,7 +1419,7 @@ def check_for_path(self, hdfs_path): | |
|
||
class ConnectionTest(unittest.TestCase): | ||
def setUp(self): | ||
configuration.test_mode() | ||
configuration.load_test_config() | ||
utils.db.initdb() | ||
os.environ['AIRFLOW_CONN_TEST_URI'] = ( | ||
'postgres://username:[email protected]:5432/the_database') | ||
|
@@ -1475,7 +1475,7 @@ def test_env_var_priority(self): | |
|
||
class WebHDFSHookTest(unittest.TestCase): | ||
def setUp(self): | ||
configuration.test_mode() | ||
configuration.load_test_config() | ||
|
||
def test_simple_init(self): | ||
from airflow.hooks.webhdfs_hook import WebHDFSHook | ||
|
@@ -1498,7 +1498,7 @@ def test_init_proxy_user(self): | |
"Skipping test because S3Hook is not installed") | ||
class S3HookTest(unittest.TestCase): | ||
def setUp(self): | ||
configuration.test_mode() | ||
configuration.load_test_config() | ||
self.s3_test_url = "s3://test/this/is/not/a-real-key.txt" | ||
|
||
def test_parse_s3_url(self): | ||
|
@@ -1523,7 +1523,7 @@ def test_parse_s3_url(self): | |
|
||
class SSHHookTest(unittest.TestCase): | ||
def setUp(self): | ||
configuration.test_mode() | ||
configuration.load_test_config() | ||
from airflow.contrib.hooks.ssh_hook import SSHHook | ||
self.hook = SSHHook() | ||
self.hook.no_host_key_check = True | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.