potiuk commented on a change in pull request #14531:
URL: https://github.com/apache/airflow/pull/14531#discussion_r591415464



##########
File path: tests/www/test_views.py
##########
@@ -1154,6 +1154,11 @@ def test_page_instance_name_xss_prevention(self):
 
 
 class TestConfigurationView(TestBase):
+    def setUp(self):
+        super().setUp()
+        with mock.patch.dict(os.environ, {"AIRFLOW__CORE__UNIT_TEST_MODE": 
"False"}):
+            initialize_config()

Review comment:
       Sure. This tests reads value of the airflow configuration and returns it 
to the caller. The test failed (when I run it in parallel) because the config 
was missing. The web api returns the "production" config - no matter if the 
UNIT_TEST_MODE is set to True or not. I have not yet had time to figure out why 
the "airflow.cfg" is missing when I run the test in parallel mode (it is there 
when we run tests sequentially). 
   
   I still have to figure it out (and planned to). My guess is that some factor 
influences the sequence of executing the tests and some other test simply 
deletes the configuration as part of its execution and the config never gets 
restored when the `test_configuration_expose_config' is executed. Unfortunately 
presence of config is 'implicit dependency' in many of our tests - the problem 
is that the config gets automatically created by airflow configuration code 
when it is missing, so if any test depend on its presence it might went 
unnoticed that the config is actually a side effect of either other tests or 
simply running airflow cli. 
   
   So I believe my fix is `proper` fix (but there are probably other tests that 
have similar side-effects dependency). Since this test depends on the 
'airflow.cfg` being present, this should not be side-efffect, it should be 
explicitly initialised int 'setUp' of the test. Which is precisely what I do - 
I make sure that the "unit_test_mode" is set to false, so the "production" and 
not "unittest" config is initialized and then I Initialise it.
   
   I think this is how the test should be written in the first place.
   
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to