예제 #1
0
    def setup_action_runs(self):
        self.run_time = datetime.datetime(2012, 3, 14, 15, 9, 26)
        actions = [Turtle(name='act1'), Turtle(name='act2')]
        self.action_graph = actiongraph.ActionGraph(
            actions, dict((a.name, a) for a in actions))

        mock_node = mock.create_autospec(node.Node)
        self.job_run = jobrun.JobRun('jobname',
                                     7,
                                     self.run_time,
                                     mock_node,
                                     action_graph=self.action_graph)

        self.action_state_data = {
            'job_run_id': 'job_run_id',
            'action_name': 'act1',
            'state': 'succeeded',
            'run_time': 'the_run_time',
            'start_time': None,
            'end_time': None,
            'command': 'do action1',
            'node_name': 'anode'
        }
        self.action_runner = mock.create_autospec(
            actioncommand.SubprocessActionRunnerFactory)
예제 #2
0
    def setup_action_runs(self):
        self.run_time = datetime.datetime(2012, 3, 14, 15, 9, 26)
        a1 = MagicMock()
        a1.name = 'act1'
        a2 = MagicMock()
        a2.name = 'act2'
        actions = [a1, a2]
        self.action_graph = actiongraph.ActionGraph(
            actions,
            {a.name: a
             for a in actions},
        )

        mock_node = mock.create_autospec(node.Node)
        self.job_run = jobrun.JobRun(
            'jobname',
            7,
            self.run_time,
            mock_node,
            action_graph=self.action_graph,
        )

        self.action_state_data = {
            'job_run_id': 'job_run_id',
            'action_name': 'act1',
            'state': 'succeeded',
            'run_time': 'the_run_time',
            'start_time': None,
            'end_time': None,
            'command': 'do action1',
            'node_name': 'anode',
        }
        self.action_runner = mock.create_autospec(
            actioncommand.SubprocessActionRunnerFactory, )
예제 #3
0
 def job_run(self, tmpdir, mock_event_bus):
     action_foo = action.Action('foo', 'command', None)
     action_after_foo = action.Action('after_foo', 'command', None)
     action_bar = action.Action('bar', 'command', None, triggered_by={'trigger'})
     action_graph = actiongraph.ActionGraph(
         action_map={
             'foo': action_foo,
             'after_foo': action_after_foo,
             'bar': action_bar,
         },
         required_actions={'foo': set(), 'after_foo': {'foo'}, 'bar': set()},
         required_triggers={'foo': set(), 'after_foo': set(), 'bar': {'trigger'}},
     )
     mock_job = mock.Mock(
         output_path=filehandler.OutputPath(tmpdir),
         action_graph=action_graph,
         action_runner=actioncommand.NoActionRunnerFactory(),
     )
     job_run = jobrun.JobRun.for_job(
         mock_job,
         run_num=1,
         run_time=datetime.datetime.now(),
         node=mock.Mock(),
         manual=False,
     )
     return job_run
예제 #4
0
 def setup_adapter(self):
     self.ar1 = mock.MagicMock(action_name="a1")
     self.ar2 = mock.MagicMock(action_name="a2")
     self.a1 = mock.MagicMock()
     self.a2 = mock.MagicMock()
     self.a1.name = 'a1'
     self.a2.name = 'a2'
     self.action_runs = mock.create_autospec(
         actionrun.ActionRunCollection,
         action_graph=actiongraph.ActionGraph(
             {
                 'a1': self.a1,
                 'a2': self.a2
             },
             {
                 'a1': set(),
                 'a2': {'a1'}
             },
             {
                 'a1': set(),
                 'a2': set()
             },
         ),
     )
     self.adapter = adapter.ActionRunGraphAdapter(self.action_runs)
     self.action_runs.__iter__.return_value = [self.ar1, self.ar2]
예제 #5
0
    def setup_graph(self):
        self.action_names = [
            'base_one',
            'base_two',
            'dep_one',
            'dep_one_one',
            'dep_multi',
        ]
        self.action_map = {}
        for name in self.action_names:
            self.action_map[name] = mock.MagicMock()
            self.action_map[name].name = name

        self.required_actions = {
            'base_one': set(),
            'base_two': set(),
            'dep_multi': {'dep_one_one', 'base_two'},
            'dep_one_one': {'dep_one'},
            'dep_one': {'base_one'},
        }
        self.required_triggers = {
            'base_one': {'MASTER.otherjob.first'},
            'base_two': set(),
            'dep_multi': set(),
            'dep_one_one': set(),
            'dep_one': set(),
        }

        self.action_graph = actiongraph.ActionGraph(self.action_map, self.required_actions, self.required_triggers)
예제 #6
0
    def setup_graph(self):
        self.action_names = [
            'base_one', 'base_two', 'dep_one', 'dep_one_one', 'dep_multi']
        am = self.action_map = dict(
            (name, turtle.Turtle(name=name)) for name in self.action_names)

        am['dep_multi'].required_actions   = [am['dep_one_one'], am['base_two']]
        am['dep_one_one'].required_actions = [am['dep_one']]
        am['dep_one'].required_actions     = [am['base_one']]

        self.graph = [am['base_one'], am['base_two']]
        self.action_graph = actiongraph.ActionGraph(self.graph, am)
예제 #7
0
    def setup_runs(self):
        action_names = ['action_name', 'second_name', 'cleanup']

        action_graph = [
            mock.Mock(name=name, required_actions=[]) for name in action_names
        ]
        self.action_graph = actiongraph.ActionGraph(
            action_graph, dict((a.name, a) for a in action_graph))
        self.output_path = filehandler.OutputPath(tempfile.mkdtemp())
        self.command = "do command"
        self.action_runs = [self._build_run(name) for name in action_names]
        self.run_map = dict((a.action_name, a) for a in self.action_runs)
        self.run_map['cleanup'].is_cleanup = True
        self.collection = ActionRunCollection(self.action_graph, self.run_map)
예제 #8
0
    def setup_collection(self):
        action_names = ['action_name', 'second_name', 'cleanup']

        action_graph = [
            Turtle(name=name, required_actions=[]) for name in action_names
        ]
        self.second_act = second_act = action_graph.pop(1)
        second_act.required_actions.append(action_graph[0])
        action_map = dict((a.name, a) for a in action_graph)
        action_map['second_name'] = second_act
        self.action_graph = actiongraph.ActionGraph(action_graph, action_map)

        self.output_path = filehandler.OutputPath(tempfile.mkdtemp())
        self.command = "do command"
        self.action_runs = [self._build_run(name) for name in action_names]
        self.run_map = dict((a.action_name, a) for a in self.action_runs)
        self.run_map['cleanup'].is_cleanup = True
        self.collection = ActionRunCollection(self.action_graph, self.run_map)
예제 #9
0
    def setup_graph(self):
        self.action_names = [
            'base_one',
            'base_two',
            'dep_one',
            'dep_one_one',
            'dep_multi',
        ]
        am = self.action_map = {}
        for name in self.action_names:
            am[name] = mock.MagicMock()
            am[name].name = name

        am['dep_multi'].required_actions = [am['dep_one_one'], am['base_two']]
        am['dep_one_one'].required_actions = [am['dep_one']]
        am['dep_one'].required_actions = [am['base_one']]

        self.graph = [am['base_one'], am['base_two']]
        self.action_graph = actiongraph.ActionGraph(self.graph, am)