You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/04/30 20:48:23 UTC

[GitHub] [airflow] Dr-Denzy opened a new pull request #15617: Improve Test Coverage for Kubernetes Executor

Dr-Denzy opened a new pull request #15617:
URL: https://github.com/apache/airflow/pull/15617


   According to the current stats of codecov.io assessment of the Airflow code base, the test coverage for
   the kubernetes_executor.py module is about 63%. This metric definitely
   needs to be improved upon.
   
   This PR when merge will help to improve this test coverage metric.
   
   fixes part of #15523 
   
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
   


-- 
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



[GitHub] [airflow] kaxil commented on a change in pull request #15617: Improve Test Coverage for Kubernetes Executor

Posted by GitBox <gi...@apache.org>.
kaxil commented on a change in pull request #15617:
URL: https://github.com/apache/airflow/pull/15617#discussion_r624193915



##########
File path: tests/executors/test_kubernetes_executor.py
##########
@@ -120,6 +119,71 @@ def test_execution_date_serialize_deserialize(self):
 
         assert datetime_obj == new_datetime_obj
 
+    @unittest.skipIf(AirflowKubernetesScheduler is None, 'kubernetes python package is not installed')
+    @mock.patch('airflow.executors.kubernetes_executor.get_kube_client')
+    @mock.patch('airflow.executors.kubernetes_executor.client')
+    @mock.patch('airflow.executors.kubernetes_executor.KubernetesJobWatcher')
+    def test_delete_pod_successfully(
+        self, mock_watcher, mock_client, mock_kube_client
+    ):  # pylint: disable=unused-argument
+        pod_id = "my-pod-1"
+        namespace = "my-namespace"
+
+        kube_client = mock.MagicMock()
+        mock_kube_client.return_value.delete_namespaced_pod = kube_client

Review comment:
       This feels weird, why would `mock_kube_client.return_value.delete_namespaced_pod` be equal to `kube_client` ?




-- 
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



[GitHub] [airflow] Dr-Denzy edited a comment on pull request #15617: Improve Test Coverage for Kubernetes Executor

Posted by GitBox <gi...@apache.org>.
Dr-Denzy edited a comment on pull request #15617:
URL: https://github.com/apache/airflow/pull/15617#issuecomment-832183238


   > @Dr-Denzy static check is failing, can you take a look plz
   
   The failure was coming from a black static check. I have fixed it - and the test passed on my local machine before I pushed. Hopefully, it will behave as expected in the CI build.


-- 
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



[GitHub] [airflow] kaxil commented on pull request #15617: Improve Test Coverage for Kubernetes Executor

Posted by GitBox <gi...@apache.org>.
kaxil commented on pull request #15617:
URL: https://github.com/apache/airflow/pull/15617#issuecomment-832098405


   @Dr-Denzy static check is failing, can you take a look plz


-- 
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



[GitHub] [airflow] Dr-Denzy commented on pull request #15617: Improve Test Coverage for Kubernetes Executor

Posted by GitBox <gi...@apache.org>.
Dr-Denzy commented on pull request #15617:
URL: https://github.com/apache/airflow/pull/15617#issuecomment-832183238


   > @Dr-Denzy static check is failing, can you take a look plz
   
   The failure was coming from a black static check. I have fixed it - and the test passed on my local machine before I pushed. Hopefully, it will behave as expected in the CI.


-- 
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



[GitHub] [airflow] Dr-Denzy commented on a change in pull request #15617: Improve Test Coverage for Kubernetes Executor

Posted by GitBox <gi...@apache.org>.
Dr-Denzy commented on a change in pull request #15617:
URL: https://github.com/apache/airflow/pull/15617#discussion_r624754291



##########
File path: tests/executors/test_kubernetes_executor.py
##########
@@ -120,6 +119,71 @@ def test_execution_date_serialize_deserialize(self):
 
         assert datetime_obj == new_datetime_obj
 
+    @unittest.skipIf(AirflowKubernetesScheduler is None, 'kubernetes python package is not installed')
+    @mock.patch('airflow.executors.kubernetes_executor.get_kube_client')
+    @mock.patch('airflow.executors.kubernetes_executor.client')
+    @mock.patch('airflow.executors.kubernetes_executor.KubernetesJobWatcher')
+    def test_delete_pod_successfully(
+        self, mock_watcher, mock_client, mock_kube_client
+    ):  # pylint: disable=unused-argument
+        pod_id = "my-pod-1"
+        namespace = "my-namespace"
+
+        kube_client = mock.MagicMock()
+        mock_kube_client.return_value.delete_namespaced_pod = kube_client

Review comment:
       > This feels weird, why would `mock_kube_client.return_value.delete_namespaced_pod` be equal to `kube_client` ?
   
   Hmm... I will change mock object naming.




-- 
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



[GitHub] [airflow] kaxil merged pull request #15617: Improve Test Coverage for Kubernetes Executor

Posted by GitBox <gi...@apache.org>.
kaxil merged pull request #15617:
URL: https://github.com/apache/airflow/pull/15617


   


-- 
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



[GitHub] [airflow] Dr-Denzy commented on a change in pull request #15617: Improve Test Coverage for Kubernetes Executor

Posted by GitBox <gi...@apache.org>.
Dr-Denzy commented on a change in pull request #15617:
URL: https://github.com/apache/airflow/pull/15617#discussion_r624754291



##########
File path: tests/executors/test_kubernetes_executor.py
##########
@@ -120,6 +119,71 @@ def test_execution_date_serialize_deserialize(self):
 
         assert datetime_obj == new_datetime_obj
 
+    @unittest.skipIf(AirflowKubernetesScheduler is None, 'kubernetes python package is not installed')
+    @mock.patch('airflow.executors.kubernetes_executor.get_kube_client')
+    @mock.patch('airflow.executors.kubernetes_executor.client')
+    @mock.patch('airflow.executors.kubernetes_executor.KubernetesJobWatcher')
+    def test_delete_pod_successfully(
+        self, mock_watcher, mock_client, mock_kube_client
+    ):  # pylint: disable=unused-argument
+        pod_id = "my-pod-1"
+        namespace = "my-namespace"
+
+        kube_client = mock.MagicMock()
+        mock_kube_client.return_value.delete_namespaced_pod = kube_client

Review comment:
       > This feels weird, why would `mock_kube_client.return_value.delete_namespaced_pod` be equal to `kube_client` ?
   
   Hmm... I will change the mock object naming.




-- 
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