test_s3_file_uploader_general.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # Copyright (c) 2020, Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License").
5 # You may not use this file except in compliance with the License.
6 # A copy of the License is located at
7 #
8 # http://aws.amazon.com/apache2.0
9 #
10 # or in the "license" file accompanying this file. This file is distributed
11 # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 # express or implied. See the License for the specific language governing
13 # permissions and limitations under the License.
14 
15 import sys
16 
17 import rostest
18 
19 from file_helpers import create_temp_file, create_temp_files, create_large_temp_file
20 from s3_file_uploader_test_base import S3FileUploaderTestBase
21 
22 PKG = 'rosbag_uploader_ros1_integration_tests'
23 NAME = 'test_s3_file_uploader_general'
24 OVERSIZE_FILE_RESULT_CODE = 100 # Currently oversize file returns UNKNOWN(100)
25 
27  def test_upload_file(self):
29  temp_file_name = create_temp_file()
30  self.files_to_delete.append(temp_file_name)
31  result = self._upload_temp_files([temp_file_name])
32  self._assert_successful_upload(result, [temp_file_name])
33 
36  temp_file_names = create_temp_files(10)
37  self.files_to_delete += temp_file_names
38  result = self._upload_temp_files(temp_file_names)
39  self._assert_successful_upload(result, temp_file_names)
40 
43  # S3 Limit is 5GB, add a little extra to be sure
44  file_size_in_mb = 5500
45  temp_file_name = create_large_temp_file(file_size_in_mb)
46  self.files_to_delete.append(temp_file_name)
47  result = self._upload_temp_files([temp_file_name])
48  self.assertFalse(result.result_code.success)
49  self.assertEqual(result.result_code.error_code, OVERSIZE_FILE_RESULT_CODE,
50  "Result code was %d" % result.result_code.error_code)
51 
52 if __name__ == '__main__':
53  rostest.rosrun(PKG, NAME, TestS3FileUploaderGeneral, sys.argv)
def create_temp_files(total_files)
Definition: file_helpers.py:21
def _assert_successful_upload(self, result, temp_file_names)
def create_temp_file()
Definition: file_helpers.py:27
def create_large_temp_file(file_size_in_mb)
Definition: file_helpers.py:34


integ_tests
Author(s): AWS RoboMaker
autogenerated on Thu Mar 4 2021 03:52:30