def test_scheduled_operation_log_update(self):
        log_ref = self._create_scheduled_operation_log()
        log_id = log_ref['id']
        log_ref = db.scheduled_operation_log_update(self.ctxt, log_id,
                                                    {"state": "success"})
        self.assertEqual('success', log_ref['state'])

        log_ref = db.scheduled_operation_log_get(self.ctxt, log_id)
        self.assertEqual('success', log_ref['state'])

        self.assertRaises(exception.ScheduledOperationLogNotFound,
                          db.scheduled_operation_log_update, self.ctxt, 100,
                          {"state": "success"})
Beispiel #2
0
    def test_scheduled_operation_log_update(self):
        log_ref = self._create_scheduled_operation_log()
        log_id = log_ref['id']
        log_ref = db.scheduled_operation_log_update(self.ctxt,
                                                    log_id,
                                                    {"state": "success"})
        self.assertEqual('success', log_ref['state'])

        log_ref = db.scheduled_operation_log_get(self.ctxt, log_id)
        self.assertEqual('success', log_ref['state'])

        self.assertRaises(exception.ScheduledOperationLogNotFound,
                          db.scheduled_operation_log_update,
                          self.ctxt, 100, {"state": "success"})
    def test_scheduled_operation_log_delete_oldest(self):
        log_ids = []
        states = ['success', 'in_progress', 'success', 'success']
        for i in range(4):
            t = datetime.now() + timedelta(hours=i)
            log = self._create_scheduled_operation_log(states[i], t)
            log_ids.append(log['id'])

        db.scheduled_operation_log_delete_oldest(self.ctxt, self.operation_id,
                                                 3)
        self.assertRaises(exception.ScheduledOperationLogNotFound,
                          db.scheduled_operation_log_get, self.ctxt,
                          log_ids[0])

        db.scheduled_operation_log_delete_oldest(self.ctxt, self.operation_id,
                                                 1, ['in_progress'])
        log_ref = db.scheduled_operation_log_get(self.ctxt, log_ids[1])
        self.assertEqual('in_progress', log_ref['state'])
        self.assertRaises(exception.ScheduledOperationLogNotFound,
                          db.scheduled_operation_log_get, self.ctxt,
                          log_ids[2])
Beispiel #4
0
    def test_scheduled_operation_log_delete_oldest(self):
        log_ids = []
        states = ['success', 'in_progress', 'success', 'success']
        for i in range(4):
            t = datetime.now() + timedelta(hours=i)
            log = self._create_scheduled_operation_log(
                states[i], t)
            log_ids.append(log['id'])

        db.scheduled_operation_log_delete_oldest(
            self.ctxt, self.operation_id, 3)
        self.assertRaises(exception.ScheduledOperationLogNotFound,
                          db.scheduled_operation_log_get,
                          self.ctxt, log_ids[0])

        db.scheduled_operation_log_delete_oldest(
            self.ctxt, self.operation_id, 1, ['in_progress'])
        log_ref = db.scheduled_operation_log_get(self.ctxt, log_ids[1])
        self.assertEqual('in_progress', log_ref['state'])
        self.assertRaises(exception.ScheduledOperationLogNotFound,
                          db.scheduled_operation_log_get,
                          self.ctxt, log_ids[2])
Beispiel #5
0
 def get_by_id(cls, context, id):
     db_log = db.scheduled_operation_log_get(context, id)
     if db_log:
         return cls._from_db_object(context, cls(), db_log)
 def test_scheduled_operation_log_get(self):
     log_ref = self._create_scheduled_operation_log()
     log_ref = db.scheduled_operation_log_get(self.ctxt, log_ref['id'])
     self.assertEqual('in_progress', log_ref['state'])
Beispiel #7
0
 def test_scheduled_operation_log_get(self):
     log_ref = self._create_scheduled_operation_log()
     log_ref = db.scheduled_operation_log_get(self.ctxt, log_ref['id'])
     self.assertEqual('in_progress', log_ref['state'])