Skip to content

Commit

Permalink
Use randomized bucket names for S3 integration tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan343 committed Nov 4, 2024
1 parent 08f02e9 commit 69ce3e3
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions tests/integration/customizations/s3/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import shutil
import copy
import logging
import uuid
import datetime

import pytest

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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 '
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 69ce3e3

Please sign in to comment.