Esempio n. 1
0
 def SideEffect(*_, **__):
     SideEffect.call_count += 1
     if SideEffect.call_count == 1:
         return unittest_utils.FakeProcess(
             stdout=json.dumps([{
                 'foo': 'bar'
             }]))
     else:
         return unittest_utils.FakeProcess(
             stdout=json.dumps([{
                 'bar': 'baz'
             }]))
Esempio n. 2
0
 def testNoResults(self):
     """Tests functionality if the query returns no results."""
     self._popen_mock.return_value = unittest_utils.FakeProcess(stdout='[]')
     results, expectation_files = self._querier.QueryBuilder(
         'builder', 'ci')
     self.assertEqual(results, [])
     self.assertIsNone(expectation_files, None)
Esempio n. 3
0
 def testRateLimitRetryFailure(self):
     """Tests that rate limit errors stop retrying after enough iterations."""
     self._popen_mock.return_value = unittest_utils.FakeProcess(
         returncode=1, stdout='Exceeded rate limits for foo.')
     with self.assertRaises(RuntimeError):
         self._querier._RunBigQueryCommandsForJsonOutput('', {})
     self.assertEqual(self._popen_mock.call_count, queries.MAX_QUERY_TRIES)
Esempio n. 4
0
 def testValidResults(self):
     """Tests functionality when valid results are returned."""
     self._relevant_file_mock.return_value = ['foo_expectations']
     query_results = [
         {
             'id':
             'build-1234',
             'test_id':
             ('ninja://chrome/test:telemetry_gpu_integration_test/'
              'gpu_tests.pixel_integration_test.'
              'PixelIntegrationTest.test_name'),
             'status':
             'FAIL',
             'typ_expectations': [
                 'RetryOnFailure',
             ],
             'typ_tags': [
                 'win',
                 'intel',
             ],
             'step_name':
             'step_name',
         },
     ]
     self._popen_mock.return_value = unittest_utils.FakeProcess(
         stdout=json.dumps(query_results))
     results, expectation_files = self._querier.QueryBuilder(
         'builder', 'ci')
     self.assertEqual(len(results), 1)
     self.assertEqual(
         results[0],
         data_types.Result('test_name', ['win', 'intel'], 'Failure',
                           'step_name', '1234'))
     self.assertEqual(expectation_files, ['foo_expectations'])
Esempio n. 5
0
    def testWebGlVersion(self):
        """Tests that only results for the correct WebGL version are returned."""
        query_results = [
            {
                'id':
                'build-1234',
                'test_id':
                ('ninja://chrome/test:telemetry_gpu_integration_test/'
                 'gpu_tests.webgl_conformance_integration_test.'
                 'WebGLConformanceIntegrationTest.test_name'),
                'status':
                'FAIL',
                'typ_expectations': [
                    'RetryOnFailure',
                ],
                'typ_tags': [
                    'webgl-version-1',
                ],
                'step_name':
                'step_name',
            },
            {
                'id':
                'build-2345',
                'test_id':
                ('ninja://chrome/test:telemetry_gpu_integration_test/'
                 'gpu_tests.webgl_conformance_integration_test.'
                 'WebGLConformanceIntegrationTest.test_name'),
                'status':
                'FAIL',
                'typ_expectations': [
                    'RetryOnFailure',
                ],
                'typ_tags': [
                    'webgl-version-2',
                ],
                'step_name':
                'step_name',
            },
        ]
        querier = gpu_uu.CreateGenericGpuQuerier(suite='webgl_conformance1')
        self._popen_mock.return_value = uu.FakeProcess(
            stdout=json.dumps(query_results))
        results, expectation_files = querier.QueryBuilder('builder', 'ci')
        self.assertEqual(len(results), 1)
        self.assertIsNone(expectation_files)
        self.assertEqual(
            results[0],
            data_types.Result('test_name', ['webgl-version-1'], 'Failure',
                              'step_name', '1234'))

        querier = gpu_uu.CreateGenericGpuQuerier(suite='webgl_conformance2')
        results, expectation_files = querier.QueryBuilder('builder', 'ci')
        self.assertEqual(len(results), 1)
        self.assertIsNone(expectation_files)
        self.assertEqual(
            results[0],
            data_types.Result('test_name', ['webgl-version-2'], 'Failure',
                              'step_name', '2345'))
Esempio n. 6
0
 def testJsonReturned(self):
     """Tests that valid JSON parsed from stdout is returned."""
     query_output = [{'foo': 'bar'}]
     self._popen_mock.return_value = unittest_utils.FakeProcess(
         stdout=json.dumps(query_output))
     result = self._querier._RunBigQueryCommandsForJsonOutput('', {})
     self.assertEqual(result, query_output)
     self._popen_mock.assert_called_once()
Esempio n. 7
0
 def testInactiveBuilders(self):
     """Tests that inactive builders are removed."""
     results = [{
         'builder_name': 'foo_builder',
     }]
     fake_process = unittest_utils.FakeProcess(stdout=json.dumps(results))
     self._subprocess_mock.return_value = fake_process
     initial_builders = [
         'foo_builder',
         'bar_builder',
     ]
     expected_builders = ['foo_builder']
     filtered_builders = self._querier._FilterOutInactiveBuilders(
         initial_builders, 'ci')
     self.assertEqual(filtered_builders, expected_builders)
Esempio n. 8
0
 def testByteConversion(self):
     """Tests that bytes are properly handled if returned."""
     results = [{
         'builder_name': 'foo_builder',
     }]
     fake_process = unittest_utils.FakeProcess(
         stdout=json.dumps(results).encode('utf-8'))
     self._subprocess_mock.return_value = fake_process
     initial_builders = [
         'foo_builder',
         'bar_builder',
     ]
     expected_builders = ['foo_builder']
     filtered_builders = self._querier._FilterOutInactiveBuilders(
         initial_builders, 'ci')
     self.assertEqual(filtered_builders, expected_builders)
Esempio n. 9
0
 def testQueryFailureRaised(self):
     """Tests that a query failure is properly surfaced."""
     self._popen_mock.return_value = unittest_utils.FakeProcess(
         returncode=1)
     with self.assertRaises(RuntimeError):
         self._querier.QueryBuilder('builder', 'ci')
Esempio n. 10
0
 def SideEffect(*_, **__):
     SideEffect.call_count += 1
     if SideEffect.call_count == 1:
         return unittest_utils.FakeProcess(
             returncode=1, stdout='Exceeded rate limits for foo.')
     return unittest_utils.FakeProcess(stdout='[]')
Esempio n. 11
0
 def testExceptionRaisedOnFailure(self):
     """Tests that an exception is raised if the query fails."""
     self._popen_mock.return_value = unittest_utils.FakeProcess(
         returncode=1)
     with self.assertRaises(RuntimeError):
         self._querier._RunBigQueryCommandsForJsonOutput('', {})