kaxil commented on a change in pull request #7507: [AIRFLOW-6885] Delete worker
on success
URL: https://github.com/apache/airflow/pull/7507#discussion_r382996801
##########
File path: tests/executors/test_kubernetes_executor.py
##########
@@ -260,7 +260,7 @@ def test_change_state_failed(self, mock_delete_pod,
mock_get_kube_client, mock_k
key = ('dag_id', 'task_id', 'ex_time', 'try_number3')
executor._change_state(key, State.FAILED, 'pod_id')
self.assertTrue(executor.event_buffer[key] == State.FAILED)
- mock_delete_pod.assert_called_once_with('pod_id')
+ mock_delete_pod.assert_not_called()
Review comment:
This test is failing !
```
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='139826376881768'>
mock_get_kube_client = <MagicMock name='get_kube_client'
id='139826376870040'>
mock_kubernetes_job_watcher = <MagicMock name='KubernetesJobWatcher'
id='139826376809104'>
@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()
key = ('dag_id', 'task_id', 'ex_time', 'try_number3')
executor._change_state(key, State.FAILED, 'pod_id')
self.assertTrue(executor.event_buffer[key] == State.FAILED)
> mock_delete_pod.assert_not_called()
tests/executors/test_kubernetes_executor.py:263:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _
_mock_self = <MagicMock name='delete_pod' id='139826376881768'>
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')].
/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