airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [airflow] mik-laj commented on a change in pull request #6579: [AIRFLOW-5926] Fix race-condition in TestCliWebServer
Date Wed, 13 Nov 2019 19:34:53 GMT
mik-laj commented on a change in pull request #6579: [AIRFLOW-5926] Fix race-condition in TestCliWebServer
URL: https://github.com/apache/airflow/pull/6579#discussion_r345960220
 
 

 ##########
 File path: tests/cli/test_cli.py
 ##########
 @@ -801,30 +817,24 @@ def test_cli_webserver_foreground_with_pid(self):
     @unittest.skipIf("TRAVIS" in os.environ and bool(os.environ["TRAVIS"]),
                      "Skipping test due to lack of required file permission")
     def test_cli_webserver_background(self):
-        # Confirm that webserver hasn't been launched.
-        self.assertEqual(1, subprocess.Popen(["pgrep", "-c", "airflow"]).wait())
-        self.assertEqual(1, subprocess.Popen(["pgrep", "-c", "gunicorn"]).wait())
+        pidfile_webserver = cli.setup_locations("webserver")[0]
+        pidfile_monitor = cli.setup_locations("webserver-monitor")[0]
 
-        # Run webserver in background.
+        # Run webserver as deamon in background. Note that the wait method is not called.
         subprocess.Popen(["airflow", "webserver", "-D"])
-        pidfile = cli.setup_locations("webserver")[0]
-        self._wait_pidfile(pidfile)
+
+        pid_monitor = self._wait_pidfile(pidfile_monitor)
+        self._wait_pidfile(pidfile_webserver)
 
         # Assert that gunicorn and its monitor are launched.
-        self.assertEqual(0, subprocess.Popen(["pgrep", "-c", "airflow"]).wait())
+        self.assertEqual(0, subprocess.Popen(["pgrep", "-f", "-c", "airflow webserver"]).wait())
         self.assertEqual(0, subprocess.Popen(["pgrep", "-c", "gunicorn"]).wait())
 
         # Terminate monitor process.
-        pidfile = cli.setup_locations("webserver-monitor")[0]
-        pid = self._wait_pidfile(pidfile)
-        proc = psutil.Process(pid)
+        proc = psutil.Process(pid_monitor)
 
 Review comment:
   It is necessary to check whether the monitor has started earlier, otherwise we are not
sure if pgrep will be successful.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message