Esempio n. 1
0
    def test_action_check_status(self):
        specs = [
            {'name': 'A01', 'target': 'cluster_001'},
            {'name': 'A02', 'target': 'node_001'},
        ]

        id_of = {}
        for spec in specs:
            action = _create_action(self.ctx, **spec)
            id_of[spec['name']] = action.id

        db_api.dependency_add(self.ctx, id_of['A02'], id_of['A01'])
        action1 = db_api.action_get(self.ctx, id_of['A01'])
        self.assertEqual(consts.ACTION_WAITING, action1.status)

        timestamp = time.time()
        status = db_api.action_check_status(self.ctx, id_of['A01'], timestamp)
        self.assertEqual(consts.ACTION_WAITING, status)

        status = db_api.action_check_status(self.ctx, id_of['A01'], timestamp)
        self.assertEqual(consts.ACTION_WAITING, status)
        timestamp = time.time()
        db_api.action_mark_succeeded(self.ctx, id_of['A02'], timestamp)

        status = db_api.action_check_status(self.ctx, id_of['A01'], timestamp)
        self.assertEqual(consts.ACTION_READY, status)

        action1 = db_api.action_get(self.ctx, id_of['A01'])
        self.assertEqual('All depended actions completed.',
                         action1.status_reason)
        self.assertEqual(timestamp, action1.end_time)
Esempio n. 2
0
    def test_action_check_status(self):
        specs = [
            {'name': 'A01', 'target': 'cluster_001'},
            {'name': 'A02', 'target': 'node_001'},
        ]

        id_of = {}
        for spec in specs:
            action = _create_action(self.ctx, **spec)
            id_of[spec['name']] = action.id

        db_api.dependency_add(self.ctx, id_of['A02'], id_of['A01'])
        action1 = db_api.action_get(self.ctx, id_of['A01'])
        self.assertEqual(consts.ACTION_WAITING, action1.status)

        timestamp = time.time()
        status = db_api.action_check_status(self.ctx, id_of['A01'], timestamp)
        self.assertEqual(consts.ACTION_WAITING, status)

        status = db_api.action_check_status(self.ctx, id_of['A01'], timestamp)
        self.assertEqual(consts.ACTION_WAITING, status)
        timestamp = time.time()
        db_api.action_mark_succeeded(self.ctx, id_of['A02'], timestamp)

        status = db_api.action_check_status(self.ctx, id_of['A01'], timestamp)
        self.assertEqual(consts.ACTION_READY, status)

        action1 = db_api.action_get(self.ctx, id_of['A01'])
        self.assertEqual('All depended actions completed.',
                         action1.status_reason)
        self.assertEqual(round(timestamp, 6), float(action1.end_time))
Esempio n. 3
0
    def test_action_mark_succeeded(self):
        timestamp = time.time()
        id_of = self._check_dependency_add_dependent_list()

        db_api.action_mark_succeeded(self.ctx, id_of['A01'], timestamp)

        res = db_api.dependency_get_depended(self.ctx, id_of['A01'])
        self.assertEqual(0, len(res))

        action = db_api.action_get(self.ctx, id_of['A01'])
        self.assertEqual(consts.ACTION_SUCCEEDED, action.status)
        self.assertEqual(timestamp, action.end_time)

        for aid in [id_of['A02'], id_of['A03'], id_of['A04']]:
            res = db_api.dependency_get_dependents(self.ctx, aid)
            self.assertEqual(0, len(res))
Esempio n. 4
0
    def test_action_mark_succeeded(self):
        timestamp = time.time()
        id_of = self._check_dependency_add_dependent_list()

        db_api.action_mark_succeeded(self.ctx, id_of['A01'], timestamp)

        res = db_api.dependency_get_depended(self.ctx, id_of['A01'])
        self.assertEqual(0, len(res))

        action = db_api.action_get(self.ctx, id_of['A01'])
        self.assertEqual(consts.ACTION_SUCCEEDED, action.status)
        self.assertEqual(round(timestamp, 6), float(action.end_time))

        for aid in [id_of['A02'], id_of['A03'], id_of['A04']]:
            res = db_api.dependency_get_dependents(self.ctx, aid)
            self.assertEqual(0, len(res))
Esempio n. 5
0
    def test_action_mark_succeeded(self):
        timestamp = time.time()
        id_of = self._check_action_add_dependency_dependent_list()
        db_api.action_mark_succeeded(self.ctx, id_of['action_001'], timestamp)

        action = db_api.action_get(self.ctx, id_of['action_001'])
        self.assertEqual(0, len(action.depended_by))
        self.assertEqual(db_api.ACTION_SUCCEEDED, action.status)
        self.assertEqual(db_api.ACTION_SUCCEEDED, action.status)
        self.assertEqual(timestamp, action.end_time)

        for id in [id_of['action_002'],
                   id_of['action_003'],
                   id_of['action_004']]:
            action = db_api.action_get(self.ctx, id)
            self.assertEqual(0, len(action.depends_on))