def upload_log(log, log_time): """Upload the output into corresponding GCS logs bucket.""" fuzz_logs_bucket = environment.get_value('FUZZ_LOGS_BUCKET') if not fuzz_logs_bucket: return fuzzer_logs.upload_to_logs(fuzz_logs_bucket, log, time=log_time)
def test_upload_to_logs(self): """Test a simple call to upload_to_logs.""" mock_gsutil = mock.MagicMock() self.mock.write_data.return_value = mock_gsutil fuzzer_logs.upload_to_logs('fake-gcs-bucket', 'fake content') self.mock.write_data.assert_called_once_with( 'fake content', 'gs://fake-gcs-bucket/fuzzer_1/fake_job/2017-03-21/11:15:13:666666.log' )
def test_upload_to_logs_with_all_arguments(self): """Test a call to upload_to_logs with all arguments being passed.""" mock_gsutil = mock.MagicMock() self.mock.write_data.return_value = mock_gsutil fuzzer_logs.upload_to_logs('gcs-bucket', 'fake content', time=self.fake_log_time, fuzzer_name='fuzzer_2', job_type='another_job') self.mock.write_data.assert_called_once_with( 'fake content', 'gs://gcs-bucket/fuzzer_2/another_job/2017-04-22/12:16:14:777777.log' )
def upload_testcase(testcase_path, log_time): """Uploads testcase so that a log file can be matched with it folder.""" fuzz_logs_bucket = environment.get_value('FUZZ_LOGS_BUCKET') if not fuzz_logs_bucket: return if not os.path.exists(testcase_path): return with open(testcase_path, 'rb') as file_handle: testcase_contents = file_handle.read() fuzzer_logs.upload_to_logs(fuzz_logs_bucket, testcase_contents, time=log_time, file_extension='.testcase')