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 2022/10/26 09:33:39 UTC

[GitHub] [airflow] Taragolis commented on a diff in pull request #27214: Refactor amazon providers tests which use `moto`

Taragolis commented on code in PR #27214:
URL: https://github.com/apache/airflow/pull/27214#discussion_r1005447497


##########
tests/providers/amazon/conftest.py:
##########
@@ -0,0 +1,59 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from __future__ import annotations
+
+import warnings
+
+try:
+    import importlib_metadata
+except ImportError:
+    from importlib import metadata as importlib_metadata  # type: ignore[no-redef]
+
+import pytest
+
+
+@pytest.fixture(scope="session")
+def botocore_version():
+    try:
+        version = importlib_metadata.version("botocore")
+    except importlib_metadata.PackageNotFoundError:
+        warnings.warn("'botocore' package not found'", UserWarning)
+        return None
+
+    try:
+        return tuple(map(int, version.split(".")[:3]))
+    except Exception:
+        warnings.warn(f"Unable to parse botocore {version!r}", UserWarning)
+        return None
+
+
+@pytest.fixture(autouse=True)
+def filter_botocore_warnings(botocore_version):
+    """Filter known botocore future warnings."""
+
+    with warnings.catch_warnings():
+        if botocore_version and botocore_version < (1, 28):
+            # Deprecate Usage of sslComonName in Endpoint Creation.
+            # See: https://github.com/boto/botocore/issues/2705
+            warnings.filterwarnings(
+                "ignore",
+                category=FutureWarning,
+                module="botocore.client",
+                message="The .* client is currently using a deprecated endpoint.*",
+            )
+        yield

Review Comment:
   Seems like latest botocore (at least 1.28.0) still show warning that legacy endpoints use even if should changed to new endpoints.
   I will check is it reproduce in regular environment or it related to some `moto` behaviour
   
   ```
   tests/providers/amazon/aws/hooks/test_emr.py::TestEmrHook::test_get_conn_returns_a_boto3_connection
       /usr/local/lib/python3.7/site-packages/botocore/client.py:627: FutureWarning: The elasticmapreduce client is currently using a deprecated endpoint: ap-southeast-2.elasticmapreduce.amazonaws.com. In the next minor version this will be moved to elasticmapreduce.ap-southeast-2.amazonaws.com. See https://github.com/boto/botocore/issues/2705 for more details.
         category=FutureWarning,
     
     tests/providers/amazon/aws/hooks/test_rds.py: 1 warning
     tests/providers/amazon/aws/operators/test_rds.py: 28 warnings
     tests/providers/amazon/aws/sensors/test_rds.py: 10 warnings
       /usr/local/lib/python3.7/site-packages/botocore/client.py:627: FutureWarning: The rds client is currently using a deprecated endpoint: rds.amazonaws.com. In the next minor version this will be moved to rds.us-east-1.amazonaws.com. See https://github.com/boto/botocore/issues/2705 for more details.
         category=FutureWarning,
     
     tests/providers/amazon/aws/hooks/test_sqs.py::TestSqsHook::test_get_conn
     tests/providers/amazon/aws/operators/test_sqs.py::TestSqsPublishOperator::test_execute_failure_fifo_queue
     tests/providers/amazon/aws/operators/test_sqs.py::TestSqsPublishOperator::test_execute_success
     tests/providers/amazon/aws/operators/test_sqs.py::TestSqsPublishOperator::test_execute_success_fifo_queue
     tests/providers/amazon/aws/sensors/test_sqs.py::TestSqsSensor::test_poke_batch_messages
     tests/providers/amazon/aws/sensors/test_sqs.py::TestSqsSensor::test_poke_message_invalid_filtering
     tests/providers/amazon/aws/sensors/test_sqs.py::TestSqsSensor::test_poke_no_message_failed
     tests/providers/amazon/aws/sensors/test_sqs.py::TestSqsSensor::test_poke_success
       /usr/local/lib/python3.7/site-packages/botocore/client.py:627: FutureWarning: The sqs client is currently using a deprecated endpoint: queue.amazonaws.com. In the next minor version this will be moved to sqs.us-east-1.amazonaws.com. See https://github.com/boto/botocore/issues/2705 for more details.
         category=FutureWarning,
   ```



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org