Ejemplo n.º 1
0
def create_app(group_name='hoplite.jobs'):
    app = Flask(__name__)
    app.register_blueprint(site_bp, url_prefix='/')
    app.register_blueprint(jobs_bp, url_prefix='/jobs')
    app.register_blueprint(job_plugins_bp, url_prefix='/job_plugins')
    hoplite.api.helpers.manager = JobManager(EntryPointManager(group_name))
    return app
Ejemplo n.º 2
0
class TestJobManager(HopliteTestCase):
    def setUp(self):
        super(TestJobManager, self).setUp()
        self.manager = JobManager(EntryPointManager('hoplite.test_jobs'))

    def test_available_jobs(self):
        job_list = self.manager.available_job_plugins()
        self.assertEquals(len(job_list), 4)
        expected = [
            self.test_jobs_module.constants.THROW_AN_EXCEPTION_JOB_NAME,
            self.test_jobs_module.constants.CREATE_FILE_JOB_NAME,
            self.test_jobs_module.constants.WAIT_10_SECONDS_JOB_NAME,
            self.test_jobs_module.constants.JOB_FAILED_EXCEPTION_JOB_NAME
        ]
        self.assertEquals(sorted(job_list), sorted(expected))

    def test_job_info_raises_on_invalid_id(self):
        # Rases an exception when passed a bad job id
        self.assertRaises(JobDoesNotExistError, self.manager.get_job, 1)

    def test_job_info_gets_correct_job(self):
        job = self.manager.create_job(
            self.test_jobs_module.constants.WAIT_10_SECONDS_JOB_NAME, {},
            port=5001)
        job_2 = self.manager.get_job(job.uuid)
        self.assertEquals(job, job_2)

    def test_create_job_raises_on_invalid_job_plugin_name(self):
        with self.assertRaises(JobPluginDoesNotExistError):
            self.manager.create_job("Fake Job Name", {}, port=5001)

    def test_create_job_running_false(self):
        job = self.manager.create_job(
            self.test_jobs_module.constants.THROW_AN_EXCEPTION_JOB_NAME, {},
            port=5001)
        self.assertIsNotNone(job.uuid)
        self.assertFalse(job.running())

    def test_create_job_running_true_runs_job(self):
        job = self.manager.create_job(
            self.test_jobs_module.constants.WAIT_10_SECONDS_JOB_NAME, {},
            True,
            port=5001)
        self.assertIsNotNone(job.uuid)
        self.assertTrue(job.running())
        job.kill()
Ejemplo n.º 3
0
class TestJobManager(HopliteTestCase):
    def setUp(self):
        super(TestJobManager, self).setUp()
        self.manager = JobManager(EntryPointManager('hoplite.test_jobs'))

    def test_available_jobs(self):
        job_list = self.manager.available_job_plugins()
        self.assertEquals(len(job_list), 4)
        expected = [self.test_jobs_module.constants.THROW_AN_EXCEPTION_JOB_NAME,
                    self.test_jobs_module.constants.CREATE_FILE_JOB_NAME,
                    self.test_jobs_module.constants.WAIT_10_SECONDS_JOB_NAME,
                    self.test_jobs_module.constants.JOB_FAILED_EXCEPTION_JOB_NAME]
        self.assertEquals(sorted(job_list), sorted(expected))

    def test_job_info_raises_on_invalid_id(self):
        # Rases an exception when passed a bad job id
        self.assertRaises(JobDoesNotExistError, self.manager.get_job, 1)

    def test_job_info_gets_correct_job(self):
        job = self.manager.create_job(self.test_jobs_module.constants.WAIT_10_SECONDS_JOB_NAME, {}, port=5001)
        job_2 = self.manager.get_job(job.uuid)
        self.assertEquals(job, job_2)

    def test_create_job_raises_on_invalid_job_plugin_name(self):
        with self.assertRaises(JobPluginDoesNotExistError):
            self.manager.create_job("Fake Job Name", {}, port=5001)

    def test_create_job_running_false(self):
        job = self.manager.create_job(self.test_jobs_module.constants.THROW_AN_EXCEPTION_JOB_NAME, {}, port=5001)
        self.assertIsNotNone(job.uuid)
        self.assertFalse(job.running())

    def test_create_job_running_true_runs_job(self):
        job = self.manager.create_job(self.test_jobs_module.constants.WAIT_10_SECONDS_JOB_NAME, {}, True, port=5001)
        self.assertIsNotNone(job.uuid)
        self.assertTrue(job.running())
        job.kill()
Ejemplo n.º 4
0
 def setUp(self):
     super(TestJobManager, self).setUp()
     self.manager = JobManager(EntryPointManager('hoplite.test_jobs'))
Ejemplo n.º 5
0
 def setUp(self):
     super(TestJobManager, self).setUp()
     self.manager = JobManager(EntryPointManager('hoplite.test_jobs'))