Exemplo n.º 1
0
 def _run_local_jobs(self):
     print(_("[Running Local Jobs]").center(80, '='))
     manager = SessionManager.create_with_state(self.session)
     try:
         manager.state.metadata.title = "plainbox dev analyze session"
         manager.state.metadata.flags = [SessionMetaData.FLAG_INCOMPLETE]
         manager.checkpoint()
         runner = JobRunner(manager.storage.location,
                            self.provider_list,
                            os.path.join(manager.storage.location,
                                         'io-logs'),
                            command_io_delegate=self)
         again = True
         while again:
             for job in self.session.run_list:
                 if job.plugin == 'local':
                     if self.session.job_state_map[
                             job.id].result.outcome is None:
                         self._run_local_job(manager, runner, job)
                         break
             else:
                 again = False
         manager.state.metadata.flags = []
         manager.checkpoint()
     finally:
         manager.destroy()
Exemplo n.º 2
0
 def test_create_with_state(self, **mocks):
     """
     verify that SessionManager.create_with_state() correctly sets up
     storage repository and creates session directories
     """
     mocks['SessionStorage'].create.return_value = mock.MagicMock(
         spec_set=SessionStorage)
     # Mock an empty list of units in teh session state object
     self.state.unit_list = []
     # Create the new manager
     manager = SessionManager.create_with_state(self.state)
     # Ensure that a default repository was created
     mocks['SessionStorageRepository'].assert_called_with()
     repo = mocks['SessionStorageRepository']()
     # Ensure that a storage was created, with repository location and
     # without legacy mode turned on
     mocks['SessionStorage'].create.assert_called_with(repo.location)
     storage = mocks['SessionStorage'].create()
     # Ensure that a default directories were created
     mocks['WellKnownDirsHelper'].assert_called_with(storage)
     helper = mocks['WellKnownDirsHelper']()
     helper.populate.assert_called_with()
     # Ensure that the device context was created with the right state
     # object
     mocks['SessionDeviceContext'].assert_called_with(self.state)
     # Ensure that the resulting manager has correct data inside
     self.assertEqual(manager.device_context_list,
                      [mocks['SessionDeviceContext']()])
     # self.assertEqual(manager.state, self.state)
     self.assertEqual(manager.storage, storage)
Exemplo n.º 3
0
 def test_create_with_state(self, **mocks):
     """
     verify that SessionManager.create_with_state() correctly sets up
     storage repository and creates session directories
     """
     # Mock job list
     state = mock.Mock(name='state', spec=SessionState)
     # Create the new manager
     manager = SessionManager.create_with_state(state)
     # Ensure that a default repository was created
     mocks['SessionStorageRepository'].assert_called_with()
     repo = mocks['SessionStorageRepository']()
     # Ensure that a storage was created, with repository location and
     # without legacy mode turned on
     mocks['SessionStorage'].create.assert_called_with(repo.location, False)
     storage = mocks['SessionStorage'].create()
     # Ensure that a default directories were created
     mocks['WellKnownDirsHelper'].assert_called_with(storage)
     helper = mocks['WellKnownDirsHelper']()
     helper.populate.assert_called_with()
     # Ensure that the resulting manager has correct data inside
     self.assertEqual(manager.state, state)
     self.assertEqual(manager.storage, storage)
Exemplo n.º 4
0
 def test_create_with_state(self, **mocks):
     """
     verify that SessionManager.create_with_state() correctly sets up
     storage repository and creates session directories
     """
     # Mock job list
     state = mock.Mock(name='state', spec=SessionState)
     # Create the new manager
     manager = SessionManager.create_with_state(state)
     # Ensure that a default repository was created
     mocks['SessionStorageRepository'].assert_called_with()
     repo = mocks['SessionStorageRepository']()
     # Ensure that a storage was created, with repository location and
     # without legacy mode turned on
     mocks['SessionStorage'].create.assert_called_with(repo.location, False)
     storage = mocks['SessionStorage'].create()
     # Ensure that a default directories were created
     mocks['WellKnownDirsHelper'].assert_called_with(storage)
     helper = mocks['WellKnownDirsHelper']()
     helper.populate.assert_called_with()
     # Ensure that the resulting manager has correct data inside
     self.assertEqual(manager.state, state)
     self.assertEqual(manager.storage, storage)
Exemplo n.º 5
0
 def _run_local_jobs(self):
     print(_("[Running Local Jobs]").center(80, '='))
     manager = SessionManager.create_with_state(self.session)
     try:
         manager.state.metadata.title = "plainbox dev analyze session"
         manager.state.metadata.flags = [SessionMetaData.FLAG_INCOMPLETE]
         manager.checkpoint()
         runner = JobRunner(
             manager.storage.location, self.provider_list,
             os.path.join(manager.storage.location, 'io-logs'),
             command_io_delegate=self)
         again = True
         while again:
             for job in self.session.run_list:
                 if job.plugin == 'local':
                     if self.session.job_state_map[job.id].result.outcome is None:
                         self._run_local_job(manager, runner, job)
                         break
             else:
                 again = False
         manager.state.metadata.flags = []
         manager.checkpoint()
     finally:
         manager.destroy()