From 69ce3e347ca74afb236453246eb1b65776bb138a Mon Sep 17 00:00:00 2001 From: jonathan343 Date: Mon, 4 Nov 2024 14:22:02 -0500 Subject: [PATCH] Use randomized bucket names for S3 integration tests. --- .../customizations/s3/test_plugin.py | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tests/integration/customizations/s3/test_plugin.py b/tests/integration/customizations/s3/test_plugin.py index e943eaee46d08..82c17986bd860 100644 --- a/tests/integration/customizations/s3/test_plugin.py +++ b/tests/integration/customizations/s3/test_plugin.py @@ -27,6 +27,8 @@ import shutil import copy import logging +import uuid +import datetime import pytest @@ -307,8 +309,9 @@ def test_mv_with_large_file(self): len(file_contents.getvalue())) def test_mv_to_nonexistent_bucket(self): + bucket_name = random_bucket_name() full_path = self.files.create_file('foo.txt', 'this is foo.txt') - p = aws('s3 mv %s s3://bad-noexist-13143242/foo.txt' % (full_path,)) + p = aws(f's3 mv {full_path} s3://{bucket_name}/foo.txt') self.assertEqual(p.rc, 1) def test_cant_move_file_onto_itself_small_file(self): @@ -518,8 +521,9 @@ def test_cleans_up_aborted_uploads(self): "aborted after receiving Ctrl-C: %s" % uploads_after) def test_cp_to_nonexistent_bucket(self): + bucket_name = random_bucket_name() foo_txt = self.files.create_file('foo.txt', 'this is foo.txt') - p = aws('s3 cp %s s3://noexist-bucket-foo-bar123/foo.txt' % (foo_txt,)) + p = aws(f's3 cp {foo_txt} s3://{bucket_name}/foo.txt') self.assertEqual(p.rc, 1) def test_cp_empty_file(self): @@ -531,7 +535,8 @@ def test_cp_empty_file(self): self.assertTrue(self.key_exists(bucket_name, 'foo.txt')) def test_download_non_existent_key(self): - p = aws('s3 cp s3://jasoidfjasdjfasdofijasdf/foo.txt foo.txt') + bucket_name = random_bucket_name() + p = aws(f's3 cp s3://{bucket_name}/foo.txt foo.txt') self.assertEqual(p.rc, 1) expected_err_msg = ( 'An error occurred (404) when calling the ' @@ -1360,7 +1365,8 @@ def test_error_output(self): foo_txt = self.files.create_file('foo.txt', 'foo contents') # Copy file into bucket. - p = aws('s3 cp %s s3://non-existant-bucket/' % foo_txt) + bucket_name = random_bucket_name() + p = aws(f's3 cp {foo_txt} s3://{bucket_name}/') # Check that there were errors and that the error was print to stderr. self.assertEqual(p.rc, 1) self.assertIn('upload failed', p.stderr) @@ -1369,7 +1375,8 @@ def test_error_ouput_quiet(self): foo_txt = self.files.create_file('foo.txt', 'foo contents') # Copy file into bucket. - p = aws('s3 cp %s s3://non-existant-bucket/ --quiet' % foo_txt) + bucket_name = random_bucket_name() + p = aws(f's3 cp {foo_txt} s3://{bucket_name}/ --quiet') # Check that there were errors and that the error was not # print to stderr. self.assertEqual(p.rc, 1) @@ -1379,8 +1386,8 @@ def test_error_ouput_only_show_errors(self): foo_txt = self.files.create_file('foo.txt', 'foo contents') # Copy file into bucket. - p = aws('s3 cp %s s3://non-existant-bucket/ --only-show-errors' - % foo_txt) + bucket_name = random_bucket_name() + p = aws(f's3 cp {foo_txt} s3://{bucket_name}/ --only-show-errors') # Check that there were errors and that the error was print to stderr. self.assertEqual(p.rc, 1) self.assertIn('upload failed', p.stderr)