示例#1
0
 def test_get_marker_from_db(self):
     marker_dt = date_utils.get_datetime_utc_now() - datetime.timedelta(minutes=5)
     marker_db = DumperMarkerDB(marker=isotime.format(marker_dt, offset=False),
                                updated_at=date_utils.get_datetime_utc_now())
     DumperMarker.add_or_update(marker_db)
     exec_exporter = ExecutionsExporter(None, None)
     export_marker = exec_exporter._get_export_marker_from_db()
     self.assertEqual(export_marker, date_utils.add_utc_tz(marker_dt))
示例#2
0
 def test_get_marker_from_db(self):
     marker_dt = date_utils.get_datetime_utc_now() - datetime.timedelta(minutes=5)
     marker_db = DumperMarkerDB(marker=isotime.format(marker_dt, offset=False),
                                updated_at=date_utils.get_datetime_utc_now())
     DumperMarker.add_or_update(marker_db)
     exec_exporter = ExecutionsExporter(None, None)
     export_marker = exec_exporter._get_export_marker_from_db()
     self.assertEqual(export_marker, date_utils.add_utc_tz(marker_dt))
示例#3
0
    def test_bootstrap(self):
        exec_exporter = ExecutionsExporter(None, None)
        exec_exporter._bootstrap()
        self.assertEqual(exec_exporter.pending_executions.qsize(), len(self.saved_executions))

        count = 0
        while count < exec_exporter.pending_executions.qsize():
            self.assertIsInstance(exec_exporter.pending_executions.get(), ActionExecutionAPI)
            count += 1
示例#4
0
 def test_process(self):
     some_execution = self.saved_executions.values()[5]
     exec_exporter = ExecutionsExporter(None, None)
     self.assertEqual(exec_exporter.pending_executions.qsize(), 0)
     exec_exporter.process(some_execution)
     self.assertEqual(exec_exporter.pending_executions.qsize(), 1)
     some_execution.status = 'scheduled'
     exec_exporter.process(some_execution)
     self.assertEqual(exec_exporter.pending_executions.qsize(), 1)
示例#5
0
    def test_bootstrap(self):
        exec_exporter = ExecutionsExporter(None, None)
        exec_exporter._bootstrap()
        self.assertEqual(exec_exporter.pending_executions.qsize(), len(self.saved_executions))

        count = 0
        while count < exec_exporter.pending_executions.qsize():
            self.assertTrue(isinstance(exec_exporter.pending_executions.get(), ActionExecutionAPI))
            count += 1
示例#6
0
 def test_get_missed_executions_from_db_with_marker(self):
     exec_exporter = ExecutionsExporter(None, None)
     all_execs = exec_exporter._get_missed_executions_from_db(export_marker=None)
     min_timestamp = min([item.end_timestamp for item in all_execs])
     marker = min_timestamp + datetime.timedelta(seconds=1)
     execs_greater_than_marker = [item for item in all_execs if item.end_timestamp > marker]
     all_execs = exec_exporter._get_missed_executions_from_db(export_marker=marker)
     self.assertTrue(len(all_execs) > 0)
     self.assertTrue(len(all_execs) == len(execs_greater_than_marker))
     for item in all_execs:
         self.assertTrue(item.end_timestamp > marker)
示例#7
0
 def test_get_missed_executions_from_db_with_marker(self):
     exec_exporter = ExecutionsExporter(None, None)
     all_execs = exec_exporter._get_missed_executions_from_db(export_marker=None)
     min_timestamp = min([item.end_timestamp for item in all_execs])
     marker = min_timestamp + datetime.timedelta(seconds=1)
     execs_greater_than_marker = [item for item in all_execs if item.end_timestamp > marker]
     all_execs = exec_exporter._get_missed_executions_from_db(export_marker=marker)
     self.assertTrue(len(all_execs) > 0)
     self.assertTrue(len(all_execs) == len(execs_greater_than_marker))
     for item in all_execs:
         self.assertTrue(item.end_timestamp > marker)
示例#8
0
 def test_process(self):
     some_execution = list(self.saved_executions.values())[5]
     exec_exporter = ExecutionsExporter(None, None)
     self.assertEqual(exec_exporter.pending_executions.qsize(), 0)
     exec_exporter.process(some_execution)
     self.assertEqual(exec_exporter.pending_executions.qsize(), 1)
     some_execution.status = 'scheduled'
     exec_exporter.process(some_execution)
     self.assertEqual(exec_exporter.pending_executions.qsize(), 1)
示例#9
0
 def test_get_missed_executions_from_db_no_marker(self):
     exec_exporter = ExecutionsExporter(None, None)
     all_execs = exec_exporter._get_missed_executions_from_db(export_marker=None)
     self.assertEqual(len(all_execs), len(self.saved_executions.values()))
示例#10
0
 def test_get_missed_executions_from_db_no_marker(self):
     exec_exporter = ExecutionsExporter(None, None)
     all_execs = exec_exporter._get_missed_executions_from_db(export_marker=None)
     self.assertEqual(len(all_execs), len(self.saved_executions.values()))