def test_upload_without_component_revisions(self): """Log should contain message on empty component revisions.""" self.mock.get_component_range_list.return_value = [] mock_gsutil = mock.MagicMock() self.mock.write_data.return_value = mock_gsutil self.fs.create_file( self.testcase_path + '.stats2', contents='{"stat": 1000, "timestamp": 1472846341.017923, "kind": ' '"TestcaseRun", "job": "job", "fuzzer": "fuzzer", ' '"build_revision": 123}\n') crash_result = CrashResult(return_code=1, crash_time=5, output='fake output') testcase_manager.upload_testcase_output(crash_result, self.testcase_path) # Date and time below is derived from 1472846341 timestamp value. self.mock.write_data.assert_called_once_with( 'Component revisions (build r123):\n' 'Not available.\n\n' 'Return code: 1\n\nfake output', 'gs://fake-gcs-logs/fuzzer/job/2016-09-02/19:59:01:017923.log')
def test_upload_without_timestamp(self): """Log name should be generated using current (mocked) timestamp value.""" mock_gsutil = mock.MagicMock() self.mock.write_data.return_value = mock_gsutil self.fs.CreateFile( self.testcase_path + '.stats2', contents='{"stat": 1000, "kind": "TestcaseRun", "job": "job", ' '"fuzzer": "fuzzer", "build_revision": 123}\n') crash_result = CrashResult(return_code=None, crash_time=None, output=None) testcase_manager.upload_testcase_output(crash_result, self.testcase_path) self.mock.write_data.assert_called_once_with( 'Component revisions (build r123):\n' 'Component: REVISION\nComponent2: REVISION2\n\n' 'Return code: None\n\nNo output!', 'gs://fake-gcs-logs/fuzzer/job/2017-05-15/16:10:28:374119.log')
def test_upload_with_timestamp_from_stats(self): """Log name should be generated using timestamp value from the stats.""" mock_gsutil = mock.MagicMock() self.mock.write_data.return_value = mock_gsutil self.fs.CreateFile( self.testcase_path + '.stats2', contents='{"stat": 1000, "timestamp": 1472846341.017923, "kind": ' '"TestcaseRun", "job": "job", "fuzzer": "fuzzer", ' '"build_revision": 123}\n') crash_result = CrashResult( return_code=1, crash_time=5, output='fake output') testcase_manager.upload_testcase_output(crash_result, self.testcase_path) # Date and time below is derived from 1472846341 timestamp value. self.mock.write_data.assert_called_once_with( 'Component revisions (build r123):\n' 'Component: REVISION\nComponent2: REVISION2\n\n' 'Return code: 1\n\nfake output', 'gs://fake-gcs-logs/fuzzer/job/2016-09-02/19:59:01:017923.log')