Exemplo n.º 1
0
 def test_export_bigquery(self, mock_bq, mock_bq_2, mock_bq_3):
     with mock_bq, mock_bq_2, mock_bq_3, \
             self.assertLogs(level='DEBUG') as log:
         mock_bq.return_value = []
         export(self.data, self.exporters[2])
         self.assertEqual(len(log.output), 5)
         self.assertEqual(len(log.records), 5)
Exemplo n.º 2
0
 def test_export_bigquery_error(self, mock_bq, mock_bq_2, mock_bq_3):
     with mock_bq, mock_bq_2, mock_bq_3, \
             self.assertLogs(level='DEBUG') as log:
         mock_bq.return_value = self.load_fixture(
             filename=f'{cwd}/fixtures/bq_error.json', load_json=True)
         with self.assertRaises(BigQueryError):
             export(self.data, self.exporters[2])
         self.assertEqual(len(log.output), 4)
         self.assertEqual(len(log.records), 4)
Exemplo n.º 3
0
 def test_export_stackdriver(self):
     with self.assertLogs(level='DEBUG') as log:
         channel = self.make_grpc_stub()
         patch = mock.patch("google.api_core.grpc_helpers.create_channel")
         with patch as create_channel:
             create_channel.return_value = channel
             export(self.data, self.exporters[1])
         self.assertEqual(len(log.output), 6)
         self.assertEqual(len(log.records), 6)
 def test_export_bigquery(self, mock_bq, mock_bq_2, mock_bq_3):
     export(SLO_REPORT, EXPORTERS[2])
 def test_export_stackdriver(self, mock):
     export(SLO_REPORT, EXPORTERS[1])
 def test_export_pubsub(self, mock_pubsub, mock_pubsub_res):
     export(SLO_REPORT, EXPORTERS[0])
Exemplo n.º 7
0
 def test_export_deprecated(self, mock):
     with self.assertWarns(FutureWarning):
         export(SLO_REPORT, EXPORTERS[6])
Exemplo n.º 8
0
 def test_export_dynatrace_error(self, mock):
     responses = export(SLO_REPORT, EXPORTERS[5])
     codes = [r[0]['response']['error']['code'] for r in responses]
     self.assertTrue(all(code == 429 for code in codes))
Exemplo n.º 9
0
 def test_export_dynatrace(self, mock):
     export(SLO_REPORT, EXPORTERS[5])
Exemplo n.º 10
0
 def test_export_multiple_error(self, *mocks):
     exporters = [EXPORTERS[1], EXPORTERS[2]]
     results = export(SLO_REPORT, exporters)
     self.assertTrue(isinstance(results[-1], BigQueryError))
Exemplo n.º 11
0
 def test_export_bigquery(self, *mocks):
     export(SLO_REPORT, EXPORTERS[2])
Exemplo n.º 12
0
 def test_export_pubsub(self, mock_pubsub, mock_pubsub_res):
     with mock_pubsub, mock_pubsub_res, \
             self.assertLogs(level='DEBUG') as log:
         export(self.data, self.exporters[0])
     self.assertEqual(len(log.output), 5)
     self.assertEqual(len(log.records), 5)
Exemplo n.º 13
0
def main(data, context):
    data = json.loads(base64.b64decode(data['data']))
    compute.export(data, exporters)
Exemplo n.º 14
0
 def test_export_multiple_error_raise(self, *mocks):
     exporters = [EXPORTERS[1], EXPORTERS[2]]
     with self.assertRaises(BigQueryError):
         export(SLO_REPORT, exporters, raise_on_error=True)
Exemplo n.º 15
0
 def test_export_bigquery_error(self, mock_bq, mock_bq_2, mock_bq_3):
     with self.assertRaises(BigQueryError):
         export(SLO_REPORT, EXPORTERS[2])
Exemplo n.º 16
0
 def test_export_datadog(self):
     export(SLO_REPORT, EXPORTERS[4])
Exemplo n.º 17
0
 def test_export_prometheus(self, mock):
     export(SLO_REPORT, EXPORTERS[3])
Exemplo n.º 18
0
 def test_export_bigquery_error(self, *mocks):
     with self.assertRaises(BigQueryError):
         export(SLO_REPORT, EXPORTERS[2], raise_on_error=True)