From 4884e75bcd12e27afb68aabad33667430e4346f9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Ollivier?= Date: Thu, 10 Apr 2025 15:24:46 +0200 Subject: [PATCH] Rather override request_checksum_calculation by user's config MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit cat ~/.aws/config [default] request_checksum_calculation = WHEN_REQUIRED response_checksum_validation = WHEN_REQUIRED Change-Id: I27842b255e0c154d0cbacf9c4e240b8852fddcff Signed-off-by: Cédric Ollivier --- xtesting/core/campaign.py | 5 +---- xtesting/core/testcase.py | 5 +---- xtesting/tests/unit/core/test_testcase.py | 26 ++++++++------------------ 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/xtesting/core/campaign.py b/xtesting/core/campaign.py index 72207436..98b2f1a8 100644 --- a/xtesting/core/campaign.py +++ b/xtesting/core/campaign.py @@ -183,10 +183,7 @@ class Campaign(): for filename in files: zfile.write(os.path.join(root, filename)) b3resource = boto3.resource( - 's3', endpoint_url=os.environ["S3_ENDPOINT_URL"], - config=botocore.config.Config( - request_checksum_calculation="when_required", - response_checksum_validation="when_required")) + 's3', endpoint_url=os.environ["S3_ENDPOINT_URL"]) dst_s3_url = os.environ["S3_DST_URL"] multipart_threshold = 5 * 1024 ** 5 if "google" in os.environ[ "S3_ENDPOINT_URL"] else 8 * 1024 * 1024 diff --git a/xtesting/core/testcase.py b/xtesting/core/testcase.py index 65d875f6..559f35a6 100644 --- a/xtesting/core/testcase.py +++ b/xtesting/core/testcase.py @@ -285,10 +285,7 @@ class TestCase(metaclass=abc.ABCMeta): """ try: b3resource = boto3.resource( - 's3', endpoint_url=os.environ["S3_ENDPOINT_URL"], - config=botocore.config.Config( - request_checksum_calculation="when_required", - response_checksum_validation="when_required")) + 's3', endpoint_url=os.environ["S3_ENDPOINT_URL"]) dst_s3_url = os.environ["S3_DST_URL"] multipart_threshold = 5 * 1024 ** 5 if "google" in os.environ[ "S3_ENDPOINT_URL"] else 8 * 1024 * 1024 diff --git a/xtesting/tests/unit/core/test_testcase.py b/xtesting/tests/unit/core/test_testcase.py index 2e481697..f7d1b940 100644 --- a/xtesting/tests/unit/core/test_testcase.py +++ b/xtesting/tests/unit/core/test_testcase.py @@ -354,16 +354,14 @@ class TestCaseTesting(unittest.TestCase): self.assertEqual(self.test.publish_artifacts(), testcase.TestCase.EX_PUBLISH_ARTIFACTS_ERROR) args[0].assert_called_once_with( - 's3', endpoint_url=os.environ['S3_ENDPOINT_URL'], - config=mock.ANY) + 's3', endpoint_url=os.environ['S3_ENDPOINT_URL']) @mock.patch('boto3.resource', side_effect=Exception) def test_publish_artifacts_exc3(self, *args): self.assertEqual(self.test.publish_artifacts(), testcase.TestCase.EX_PUBLISH_ARTIFACTS_ERROR) args[0].assert_called_once_with( - 's3', endpoint_url=os.environ['S3_ENDPOINT_URL'], - config=mock.ANY) + 's3', endpoint_url=os.environ['S3_ENDPOINT_URL']) @mock.patch('boto3.resource') def test_publish_artifacts_exc4(self, *args): @@ -371,8 +369,7 @@ class TestCaseTesting(unittest.TestCase): self.assertEqual(self.test.publish_artifacts(), testcase.TestCase.EX_PUBLISH_ARTIFACTS_ERROR) args[0].assert_called_once_with( - 's3', endpoint_url=os.environ['S3_ENDPOINT_URL'], - config=mock.ANY) + 's3', endpoint_url=os.environ['S3_ENDPOINT_URL']) @mock.patch('boto3.resource') def test_publish_artifacts_exc5(self, *args): @@ -383,8 +380,7 @@ class TestCaseTesting(unittest.TestCase): self.assertEqual(self.test.publish_artifacts(), testcase.TestCase.EX_PUBLISH_ARTIFACTS_ERROR) args[0].assert_called_once_with( - 's3', endpoint_url=os.environ['S3_ENDPOINT_URL'], - config=mock.ANY) + 's3', endpoint_url=os.environ['S3_ENDPOINT_URL']) @mock.patch('mimetypes.guess_type', return_value=(None, None)) @mock.patch('boto3.resource') @@ -394,8 +390,7 @@ class TestCaseTesting(unittest.TestCase): testcase.TestCase.EX_OK) args[0].assert_called_once_with(self.test.res_dir) args[1].assert_called_once_with( - 's3', endpoint_url=os.environ['S3_ENDPOINT_URL'], - config=mock.ANY) + 's3', endpoint_url=os.environ['S3_ENDPOINT_URL']) @mock.patch('mimetypes.guess_type', return_value=(None, None)) @mock.patch('boto3.resource') @@ -409,8 +404,7 @@ class TestCaseTesting(unittest.TestCase): testcase.TestCase.EX_OK) args[0].assert_called_once_with(self.test.res_dir) args[1].assert_called_once_with( - 's3', endpoint_url=os.environ['S3_ENDPOINT_URL'], - config=mock.ANY) + 's3', endpoint_url=os.environ['S3_ENDPOINT_URL']) @mock.patch('mimetypes.guess_type', return_value=(None, None)) @mock.patch('os.path.exists', return_value=True) @@ -423,9 +417,7 @@ class TestCaseTesting(unittest.TestCase): testcase.TestCase.EX_OK) args[0].assert_called_once_with(self.test.res_dir) expected = [ - mock.call( - 's3', endpoint_url=os.environ['S3_ENDPOINT_URL'], - config=mock.ANY), + mock.call('s3', endpoint_url=os.environ['S3_ENDPOINT_URL']), mock.call().meta.client.head_bucket(Bucket='xtesting'), mock.call().Bucket('xtesting'), mock.call().Bucket().upload_file( @@ -459,9 +451,7 @@ class TestCaseTesting(unittest.TestCase): testcase.TestCase.EX_OK) args[0].assert_called_once_with(self.test.res_dir) expected = [ - mock.call( - 's3', endpoint_url=os.environ['S3_ENDPOINT_URL'], - config=mock.ANY), + mock.call('s3', endpoint_url=os.environ['S3_ENDPOINT_URL']), mock.call().meta.client.head_bucket(Bucket='xtesting'), mock.call().Bucket('xtesting'), mock.call().Bucket().upload_file( -- 2.16.6