예제 #1
0
    def test_api_create_long_running_with_concurrency(self):
        name = "job-{}".format(uuid.uuid4())
        job = CronJob(utils.scheduledjob_90())

        k8s_cronjob = utils.create_cronjob(name=name)
        k8s_cronjob.model = job
        k8s_cronjob.concurrency_policy = "Allow"

        if utils.is_reachable(k8s_cronjob.config.api_host):
            k8s_cronjob.create()
            self.assertIsInstance(k8s_cronjob, K8sCronJob)
            self.assertEqual('Allow', k8s_cronjob.concurrency_policy)
    def test_list(self):
        name = "job-{}".format(uuid.uuid4())
        job = CronJob(_constants.scheduledjob_90())

        k8s_cronjob = _utils.create_cronjob(name=name)
        k8s_cronjob.model = job
        k8s_cronjob.concurrency_policy = "Forbid"
        k8s_cronjob.starting_deadline_seconds = 10

        if _utils.is_reachable(k8s_cronjob.config):
            k8s_cronjob.create()
            crons = k8s_cronjob.list()
            for c in crons:
                self.assertIsInstance(c, K8sCronJob)
    def test_api_create_long_running_no_concurrency(self):
        name = "job-{}".format(uuid.uuid4())
        job = CronJob(_constants.scheduledjob_90())

        k8s_cronjob = _utils.create_cronjob(name=name)
        k8s_cronjob.model = job
        k8s_cronjob.concurrency_policy = "Forbid"
        k8s_cronjob.starting_deadline_seconds = 10

        if _utils.is_reachable(k8s_cronjob.config):
            k8s_cronjob.create()
            self.assertIsInstance(k8s_cronjob, K8sCronJob)
            self.assertEqual('Forbid', k8s_cronjob.concurrency_policy)
            self.assertEqual(10, k8s_cronjob.starting_deadline_seconds)
예제 #4
0
    def test_run(self):
        name = "job-{}".format(uuid.uuid4())
        model = CronJob(_constants.scheduledjob_90())

        cj = _utils.create_cronjob(name=name)
        cj.model = model
        cj.concurrency_policy = "Forbid"
        cj.starting_deadline_seconds = 10

        if _utils.is_reachable(cj.config):
            cj.create()
            self.assertFalse(cj.suspend)
            cj.run()
            self.assertFalse(cj.suspend)
예제 #5
0
    def test_run_already_running(self):
        name = "job-{}".format(uuid.uuid4())
        model = CronJob(_constants.scheduledjob_90())

        cj = _utils.create_cronjob(name=name)
        cj.model = model
        cj.concurrency_policy = "Forbid"
        cj.starting_deadline_seconds = 10

        if _utils.is_reachable(cj.config):
            cj.create()
            while not cj.last_schedule_time:
                cj.get()
                time.sleep(2)
            with self.assertRaises(CronJobAlreadyRunningException):
                cj.run()
예제 #6
0
    def test_pod(self):
        name = "job-{}".format(uuid.uuid4())
        model = CronJob(_constants.scheduledjob_90())

        cj = _utils.create_cronjob(name=name)
        cj.model = model
        cj.concurrency_policy = "Forbid"
        cj.starting_deadline_seconds = 10

        if _utils.is_reachable(cj.config):
            cj.create()
            while not cj.last_schedule_time:
                cj.get()
                time.sleep(2)
            pod = cj.pod
            self.assertIsInstance(pod, K8sPod)
    def test_last_schedule_time(self):
        name = "job-{}".format(uuid.uuid4())
        job = CronJob(_constants.scheduledjob_90())

        k8s_cronjob = _utils.create_cronjob(name=name)
        k8s_cronjob.model = job
        k8s_cronjob.concurrency_policy = "Forbid"
        k8s_cronjob.starting_deadline_seconds = 10

        if _utils.is_reachable(k8s_cronjob.config):
            k8s_cronjob.create()
            while not k8s_cronjob.last_schedule_time:
                k8s_cronjob.get()
                time.sleep(2)
            lst = k8s_cronjob.last_schedule_time
            self.assertIsNotNone(lst)
            self.assertIsInstance(lst, str)
예제 #8
0
 def get(self):
     self.model = CronJob(self.get_model())
     return self