potiuk commented on code in PR #39946:
URL: https://github.com/apache/airflow/pull/39946#discussion_r1623280225


##########
airflow/providers/amazon/provider.yaml:
##########
@@ -92,17 +92,17 @@ dependencies:
   # We should update minimum version of boto3 and here regularly to avoid 
`pip` backtracking with the number
   # of candidates to consider. Make sure to configure boto3 version here as 
well as in all the tools below
   # in the `devel-dependencies` section to be the same minimum version.
-  - boto3>=1.33.0
-  - botocore>=1.33.0
+  - boto3>=1.34.0
+  - botocore>=1.34.0
   - inflection>=0.5.1
   # Allow a wider range of watchtower versions for flexibility among users
-  - watchtower>=2.0.1,<4
+  - watchtower>=3.0.0,<4

Review Comment:
   BTW. Those are the two failing tests when we downgrade watchtower to 2.0.1
   
   ```python
   ____________________________________________________________________ 
TestCloudwatchTaskHandler.test_write_json_logs[json-serialize] 
____________________________________________________________________
   
   self = <Mock name='Queue().put' id='281471674722144'>, args = ({'message': 
'{"datetime": "2023-01-01T00:00:00+00:00", "customObject": 
"SomeCustomSerialization(...)"}', 'timestamp': <ANY>},)
   kwargs = {}, expected = (({'message': '{"datetime": 
"2023-01-01T00:00:00+00:00", "customObject": "SomeCustomSerialization(...)"}', 
'timestamp': <ANY>},), {})
   actual = call({'timestamp': 1717256635862, 'message': '{"datetime": 
"2023-01-01T00:00:00+00:00", "customObject": null}'})
   _error_message = <function 
NonCallableMock.assert_called_with.<locals>._error_message at 0xffff31e23310>, 
cause = None
   
       def assert_called_with(self, /, *args, **kwargs):
           """assert that the last call was made with the specified arguments.
   
           Raises an AssertionError if the args and keyword args passed in are
           different to the last call to the mock."""
           if self.call_args is None:
               expected = self._format_mock_call_signature(args, kwargs)
               actual = 'not called.'
               error_message = ('expected call not found.\nExpected: 
%s\nActual: %s'
                       % (expected, actual))
               raise AssertionError(error_message)
   
           def _error_message():
               msg = self._format_mock_failure_message(args, kwargs)
               return msg
           expected = self._call_matcher((args, kwargs))
           actual = self._call_matcher(self.call_args)
           if expected != actual:
               cause = expected if isinstance(expected, Exception) else None
   >           raise AssertionError(_error_message()) from cause
   E           AssertionError: expected call not found.
   E           Expected: put({'message': '{"datetime": 
"2023-01-01T00:00:00+00:00", "customObject": "SomeCustomSerialization(...)"}', 
'timestamp': <ANY>})
   E           Actual: put({'timestamp': 1717256635862, 'message': 
'{"datetime": "2023-01-01T00:00:00+00:00", "customObject": null}'})
   
   /usr/local/lib/python3.8/unittest/mock.py:913: AssertionError
   
   During handling of the above exception, another exception occurred:
   
   self = <Mock name='Queue().put' id='281471674722144'>, args = ({'message': 
'{"datetime": "2023-01-01T00:00:00+00:00", "customObject": 
"SomeCustomSerialization(...)"}', 'timestamp': <ANY>},)
   kwargs = {}
   
       def assert_called_once_with(self, /, *args, **kwargs):
           """assert that the mock was called exactly once and that that call 
was
           with the specified arguments."""
           if not self.call_count == 1:
               msg = ("Expected '%s' to be called once. Called %s times.%s"
                      % (self._mock_name or 'mock',
                         self.call_count,
                         self._calls_repr()))
               raise AssertionError(msg)
   >       return self.assert_called_with(*args, **kwargs)
   E       AssertionError: expected call not found.
   E       Expected: put({'message': '{"datetime": "2023-01-01T00:00:00+00:00", 
"customObject": "SomeCustomSerialization(...)"}', 'timestamp': <ANY>})
   E       Actual: put({'timestamp': 1717256635862, 'message': '{"datetime": 
"2023-01-01T00:00:00+00:00", "customObject": null}'})
   E
   E       pytest introspection follows:
   E
   E       Args:
   E       assert equals failed
   E         (                                                                  
                          (
   E           {                                                                
                            {
   E             'message': '{"datetime": "2023-01-01T00:00:00+00:00", 
"customObject": null}',                'message': '{"datetime": 
"2023-01-01T00:00:00+00:00", "customObject": "SomeCustomSerial
   E                                                                            
                          ization(...)"}',
   E             'timestamp': 1717256635862,                                    
                              'timestamp': <ANY>,
   E           },                                                               
                            },
   E         )                                                                  
                          )
   
   /usr/local/lib/python3.8/unittest/mock.py:925: AssertionError
   
   During handling of the above exception, another exception occurred:
   
   self = 
<tests.providers.amazon.aws.log.test_cloudwatch_task_handler.TestCloudwatchTaskHandler
 object at 0xffff7c382130>, mock_get_log_events = <MagicMock 
name='get_log_events' id='281471693451856'>
   conf_json_serialize = 
'airflow.providers.amazon.aws.log.cloudwatch_task_handler.json_serialize'
   expected_serialized_output = '{"datetime": "2023-01-01T00:00:00+00:00", 
"customObject": "SomeCustomSerialization(...)"}'
   
       @pytest.mark.parametrize(
           "conf_json_serialize, expected_serialized_output",
           [
               pytest.param(
                   
"airflow.providers.amazon.aws.log.cloudwatch_task_handler.json_serialize_legacy",
                   '{"datetime": "2023-01-01T00:00:00+00:00", "customObject": 
null}',
                   id="json-serialize-legacy",
               ),
               pytest.param(
                   
"airflow.providers.amazon.aws.log.cloudwatch_task_handler.json_serialize",
                   '{"datetime": "2023-01-01T00:00:00+00:00", "customObject": 
"SomeCustomSerialization(...)"}',
                   id="json-serialize",
               ),
               pytest.param(
                   None, '{"datetime": "2023-01-01T00:00:00+00:00", 
"customObject": null}', id="not-set"
               ),
           ],
       )
       @mock.patch.object(AwsLogsHook, "get_log_events")
       def test_write_json_logs(self, mock_get_log_events, conf_json_serialize, 
expected_serialized_output):
           class ToSerialize:
               def __init__(self):
                   pass
   
               def __repr__(self):
                   return "SomeCustomSerialization(...)"
   
           with conf_vars({("aws", "cloudwatch_task_handler_json_serializer"): 
conf_json_serialize}):
               handler = self.cloudwatch_task_handler
               handler.set_context(self.ti)
               message = logging.LogRecord(
                   name="test_log_record",
                   level=logging.DEBUG,
                   pathname="fake.path",
                   lineno=42,
                   args=None,
                   exc_info=None,
                   msg={
                       "datetime": datetime(2023, 1, 1),
                       "customObject": ToSerialize(),
                   },
               )
               with mock.patch("watchtower.threading.Thread"), 
mock.patch("watchtower.queue.Queue") as mq:
                   mock_queue = Mock()
                   mq.return_value = mock_queue
                   handler.handle(message)
   >               mock_queue.put.assert_called_once_with(
                       {"message": expected_serialized_output, "timestamp": ANY}
                   )
   E               AssertionError: expected call not found.
   E               Expected: put({'message': '{"datetime": 
"2023-01-01T00:00:00+00:00", "customObject": "SomeCustomSerialization(...)"}', 
'timestamp': <ANY>})
   E               Actual: put({'timestamp': 1717256635862, 'message': 
'{"datetime": "2023-01-01T00:00:00+00:00", "customObject": null}'})
   E
   E               pytest introspection follows:
   E
   E               Args:
   E               assert equals failed
   E                 (                                                          
                                  (
   E                   {                                                        
                                    {
   E                     'message': '{"datetime": "2023-01-01T00:00:00+00:00", 
"customObject": null}',                'message': '{"datetime": 
"2023-01-01T00:00:00+00:00", "customObject": "SomeCustomSerial
   E                                                                            
                                  ization(...)"}',
   E                     'timestamp': 1717256635862,                            
                                      'timestamp': <ANY>,
   E                   },                                                       
                                    },
   E                 )                                                          
                                  )
   
   tests/providers/amazon/aws/log/test_cloudwatch_task_handler.py:220: 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to