kaxil commented on issue #7507: [AIRFLOW-6885] Delete worker on success
URL: https://github.com/apache/airflow/pull/7507#issuecomment-590610930
 
 
   Travis failed:
   ```
   tests/executors/test_kubernetes_executor.py ........F
   _______________ TestKubernetesExecutor.test_change_state_failed 
________________
   self = <tests.executors.test_kubernetes_executor.TestKubernetesExecutor 
testMethod=test_change_state_failed>
   mock_delete_pod = <MagicMock name='delete_pod' id='140527588788768'>
   mock_get_kube_client = <MagicMock name='get_kube_client' 
id='140527589891936'>
   mock_kubernetes_job_watcher = <MagicMock name='KubernetesJobWatcher' 
id='140527589720472'>
       @mock.patch('airflow.executors.kubernetes_executor.KubernetesJobWatcher')
       @mock.patch('airflow.executors.kubernetes_executor.get_kube_client')
       
@mock.patch('airflow.executors.kubernetes_executor.AirflowKubernetesScheduler.delete_pod')
       def test_change_state_failed(self, mock_delete_pod, 
mock_get_kube_client, mock_kubernetes_job_watcher):
           executor = KubernetesExecutor()
           executor.start()
           test_time = timezone.utcnow()
           key = ('dag_id', 'task_id', test_time, 'try_number3')
           executor._change_state(key, State.FAILED, 'pod_id', 'default')
           self.assertTrue(executor.event_buffer[key] == State.FAILED)
   >       mock_delete_pod.assert_not_called()
   tests/executors/test_kubernetes_executor.py:266: 
   _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
_ _ 
   _mock_self = <MagicMock name='delete_pod' id='140527588788768'>
       def assert_not_called(_mock_self):
           """assert that the mock was never called.
           """
           self = _mock_self
           if self.call_count != 0:
               msg = ("Expected '%s' to not have been called. Called %s 
times.%s"
                      % (self._mock_name or 'mock',
                         self.call_count,
                         self._calls_repr()))
   >           raise AssertionError(msg)
   E           AssertionError: Expected 'delete_pod' to not have been called. 
Called 1 times.
   E           Calls: [call('pod_id', 'default')].
   /usr/local/lib/python3.6/site-packages/mock/mock.py:871: AssertionError
   ----------------------------- Captured stdout call 
-----------------------------
   [%(asctime)s] {{%(filename)s:%(lineno)d}} %(levelname)s - %(message)s
   [%(asctime)s] {{%(filename)s:%(lineno)d}} %(levelname)s - %(message)s
   [%(asctime)s] {{%(filename)s:%(lineno)d}} %(levelname)s - %(message)s
   tests/executors/test_kubernetes_executor.py F
   _________ TestKubernetesExecutor.test_change_state_failed_pod_deletion 
_________
   self = <tests.executors.test_kubernetes_executor.TestKubernetesExecutor 
testMethod=test_change_state_failed_pod_deletion>
   mock_delete_pod = <MagicMock name='delete_pod' id='140527588755552'>
   mock_get_kube_client = <MagicMock name='get_kube_client' 
id='140527588795280'>
   mock_kubernetes_job_watcher = <MagicMock name='KubernetesJobWatcher' 
id='140527588672288'>
       @mock.patch('airflow.executors.kubernetes_executor.KubernetesJobWatcher')
       @mock.patch('airflow.executors.kubernetes_executor.get_kube_client')
       
@mock.patch('airflow.executors.kubernetes_executor.AirflowKubernetesScheduler.delete_pod')
       def test_change_state_failed_pod_deletion(self, mock_delete_pod, 
mock_get_kube_client,
                                                 mock_kubernetes_job_watcher):
           executor = KubernetesExecutor()
           executor.kube_config.delete_worker_pods_on_success = True
           executor.start()
           key = ('dag_id', 'task_id', 'ex_time', 'try_number2')
           executor._change_state(key, State.FAILED, 'pod_id', 'test-namespace')
           self.assertTrue(executor.event_buffer[key] == State.FAILED)
   >       mock_delete_pod.assert_not_called()
   tests/executors/test_kubernetes_executor.py:296: 
   _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
_ _ 
   _mock_self = <MagicMock name='delete_pod' id='140527588755552'>
       def assert_not_called(_mock_self):
           """assert that the mock was never called.
           """
           self = _mock_self
           if self.call_count != 0:
               msg = ("Expected '%s' to not have been called. Called %s 
times.%s"
                      % (self._mock_name or 'mock',
                         self.call_count,
                         self._calls_repr()))
   >           raise AssertionError(msg)
   E           AssertionError: Expected 'delete_pod' to not have been called. 
Called 1 times.
   E           Calls: [call('pod_id', 'test-namespace')].
   /usr/local/lib/python3.6/site-packages/mock/mock.py:871: AssertionError
   ```

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


With regards,
Apache Git Services

Reply via email to