Example #1
0
    def setup_action_models(cls):
        action_db = ActionDB()
        action_db.name = 'action-1'
        action_db.description = 'awesomeness'
        action_db.enabled = True
        action_db.pack = 'wolfpack'
        action_db.entry_point = ''
        action_db.runner_type = {'name': 'test-runner'}
        action_db.parameters = {
            'actionstr': {'type': 'string', 'position': 1, 'required': True},
            'actionint': {'type': 'number', 'default': 10, 'position': 0},
            'runnerdummy': {'type': 'string', 'default': 'actiondummy'}
        }
        ActionDBUtilsTestCase.action_db = Action.add_or_update(action_db)

        actionexec_db = ActionExecutionDB()
        actionexec_db.status = 'initializing'
        actionexec_db.start_timestamp = datetime.datetime.utcnow()
        actionexec_db.action = ResourceReference(
            name=ActionDBUtilsTestCase.action_db.name,
            pack=ActionDBUtilsTestCase.action_db.pack).ref
        params = {
            'actionstr': 'foo',
            'some_key_that_aint_exist_in_action_or_runner': 'bar',
            'runnerint': 555
        }
        actionexec_db.parameters = params
        ActionDBUtilsTestCase.actionexec_db = ActionExecution.add_or_update(actionexec_db)
Example #2
0
 def _get_action_exec_db_model(self, params):
     actionexec_db = ActionExecutionDB()
     actionexec_db.status = 'initializing'
     actionexec_db.start_timestamp = datetime.datetime.utcnow()
     actionexec_db.action = ResourceReference(name=ParamsUtilsTest.action_db.name,
                                              pack=ParamsUtilsTest.action_db.pack).ref
     actionexec_db.parameters = params
     return actionexec_db
Example #3
0
 def _get_action_exec_db_model(self, params):
     actionexec_db = ActionExecutionDB()
     actionexec_db.status = 'initializing'
     actionexec_db.start_timestamp = datetime.datetime.utcnow()
     actionexec_db.action = ResourceReference(
         name=ParamsUtilsTest.action_db.name,
         pack=ParamsUtilsTest.action_db.pack).ref
     actionexec_db.parameters = params
     return actionexec_db
 def _get_failingaction_exec_db_model(self, params):
     actionexec_db = ActionExecutionDB()
     actionexec_db.status = 'initializing'
     actionexec_db.start_timestamp = datetime.datetime.now()
     actionexec_db.action = ResourceReference(
         name=RunnerContainerTest.failingaction_db.name,
         pack=RunnerContainerTest.failingaction_db.pack).ref
     actionexec_db.parameters = params
     actionexec_db.context = {'user': cfg.CONF.system_user.user}
     return actionexec_db
Example #5
0
 def _get_failingaction_exec_db_model(self, params):
     actionexec_db = ActionExecutionDB()
     actionexec_db.status = 'initializing'
     actionexec_db.start_timestamp = datetime.datetime.now()
     actionexec_db.action = ResourceReference(
         name=RunnerContainerTest.failingaction_db.name,
         pack=RunnerContainerTest.failingaction_db.pack).ref
     actionexec_db.parameters = params
     actionexec_db.context = {'user': cfg.CONF.system_user.user}
     return actionexec_db
Example #6
0
    def test_update_actionexecution_status_invalid(self):
        actionexec_db = ActionExecutionDB()
        actionexec_db.status = 'initializing'
        actionexec_db.start_timestamp = datetime.datetime.utcnow()
        actionexec_db.action = ResourceReference(
            name=ActionDBUtilsTestCase.action_db.name,
            pack=ActionDBUtilsTestCase.action_db.pack).ref
        params = {
            'actionstr': 'foo',
            'some_key_that_aint_exist_in_action_or_runner': 'bar',
            'runnerint': 555
        }
        actionexec_db.parameters = params
        actionexec_db = ActionExecution.add_or_update(actionexec_db)

        # Update by id.
        self.assertRaises(ValueError, action_db_utils.update_actionexecution_status,
                          'mea culpa', actionexec_id=actionexec_db.id)
Example #7
0
    def test_update_actionexecution_status(self):
        actionexec_db = ActionExecutionDB()
        actionexec_db.status = 'initializing'
        actionexec_db.start_timestamp = datetime.datetime.utcnow()
        actionexec_db.action = ResourceReference(
            name=ActionDBUtilsTestCase.action_db.name,
            pack=ActionDBUtilsTestCase.action_db.pack).ref
        params = {
            'actionstr': 'foo',
            'some_key_that_aint_exist_in_action_or_runner': 'bar',
            'runnerint': 555
        }
        actionexec_db.parameters = params
        actionexec_db = ActionExecution.add_or_update(actionexec_db)
        origactionexec_db = copy.copy(actionexec_db)

        # Update by id.
        newactionexec_db = action_db_utils.update_actionexecution_status(
            'running', actionexec_id=actionexec_db.id)
        # Verify id didn't change.
        self.assertEqual(origactionexec_db.id, newactionexec_db.id)
        self.assertEqual(newactionexec_db.status, 'running')
Example #8
0
    def test_update_actionexecution_status_and_end_timestamp(self):
        actionexec_db = ActionExecutionDB()
        actionexec_db.status = 'initializing'
        actionexec_db.start_timestamp = datetime.datetime.utcnow()
        actionexec_db.action = ResourceReference(
            name=ActionDBUtilsTestCase.action_db.name,
            pack=ActionDBUtilsTestCase.action_db.pack).ref
        actionexec_db.parameters = {}
        actionexec_db = ActionExecution.add_or_update(actionexec_db)
        origactionexec_db = copy.copy(actionexec_db)

        # Update by id
        now = datetime.datetime.now()
        newactionexec_db = action_db_utils.update_actionexecution_status(
            status='running',
            end_timestamp=now,
            actionexec_id=actionexec_db.id)

        # Verify id didn't change and end_timestamp has been set
        self.assertEqual(origactionexec_db.id, newactionexec_db.id)
        self.assertEqual(newactionexec_db.status, 'running')
        self.assertEqual(newactionexec_db.end_timestamp, now)