- @mock.patch('arvados.collection.CollectionReader')
- @mock.patch('arvados.api')
- def test_job_report(self, mock_api, mock_cr):
- mock_api().jobs().get().execute.return_value = self.fake_job
- mock_cr().__iter__.return_value = ['fake-logfile.txt']
- mock_cr().open.return_value = gzip.open(self.logfile)
- args = crunchstat_summary.command.ArgumentParser().parse_args(
- ['--job', self.fake_job_uuid])
- summarizer = crunchstat_summary.command.Command(args).summarizer()
- summarizer.run()
- self.diff_known_report(self.logfile, summarizer)
- mock_api().jobs().get.assert_called_with(uuid=self.fake_job_uuid)
- mock_cr.assert_called_with(self.fake_log_id)
- mock_cr().open.assert_called_with('fake-logfile.txt')
-
-
-class SummarizePipeline(ReportDiff):
- fake_instance = {
- 'uuid': 'zzzzz-d1hrv-i3e77t9z5y8j9cc',
- 'owner_uuid': 'zzzzz-tpzed-xurymjxw79nv3jz',
- 'components': collections.OrderedDict([
- ['foo', {
- 'job': {
- 'uuid': 'zzzzz-8i9sb-000000000000000',
- 'log': 'fake-log-pdh-0',
- 'runtime_constraints': {
- 'min_ram_mb_per_node': 900,
- 'min_cores_per_node': 1,
- },
- },
- }],
- ['bar', {
- 'job': {
- 'uuid': 'zzzzz-8i9sb-000000000000001',
- 'log': 'fake-log-pdh-1',
- 'runtime_constraints': {
- 'min_ram_mb_per_node': 900,
- 'min_cores_per_node': 1,
- },
- },
- }],
- ['no-job-assigned', {}],
- ['unfinished-job', {
- 'job': {
- 'uuid': 'zzzzz-8i9sb-xxxxxxxxxxxxxxx',
- },
- }],
- ['baz', {
- 'job': {
- 'uuid': 'zzzzz-8i9sb-000000000000002',
- 'log': 'fake-log-pdh-2',
- 'runtime_constraints': {
- 'min_ram_mb_per_node': 900,
- 'min_cores_per_node': 1,
- },
- },
- }]]),
+
+class SummarizeEdgeCases(TestCase):
+ def test_error_messages(self):
+ logfile = io.open(os.path.join(TESTS_DIR, 'crunchstat_error_messages.txt'), encoding='utf-8')
+ s = crunchstat_summary.summarizer.Summarizer(reader.StubReader(logfile))
+ s.run()
+ self.assertRegex(self.logbuf.getvalue(), r'CPU stats are missing -- possible cluster configuration issue')
+ self.assertRegex(self.logbuf.getvalue(), r'memory stats are missing -- possible cluster configuration issue')
+ self.assertRegex(self.logbuf.getvalue(), r'network I/O stats are missing -- possible cluster configuration issue')
+ self.assertRegex(self.logbuf.getvalue(), r'storage space stats are missing -- possible cluster configuration issue')
+
+class SummarizeContainerCommon(TestCase):
+ fake_container = {
+ 'uuid': '9tee4-dz642-lymtndkpy39eibk',
+ 'created_at': '2017-08-18T14:27:25.371388141',
+ 'log': '9tee4-4zz18-ihyzym9tcwjwg4r',