Ejemplo n.º 1
0
    def test_api_create_long_running_with_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 = "Allow"

        if _utils.is_reachable(k8s_cronjob.config):
            k8s_cronjob.create()
            self.assertIsInstance(k8s_cronjob, K8sCronJob)
            self.assertEqual('Allow', k8s_cronjob.concurrency_policy)
Ejemplo n.º 2
0
    def test_api_create_long_running_with_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 = "Allow"

        if _utils.is_reachable(k8s_cronjob.config):
            k8s_cronjob.create()
            self.assertIsInstance(k8s_cronjob, K8sCronJob)
            self.assertEqual('Allow', k8s_cronjob.concurrency_policy)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
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)
Ejemplo n.º 6
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)
Ejemplo n.º 7
0
    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)
Ejemplo n.º 8
0
    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)
Ejemplo n.º 9
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()
Ejemplo n.º 10
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)
Ejemplo n.º 11
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()
Ejemplo n.º 12
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)
Ejemplo n.º 13
0
    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)
Ejemplo n.º 14
0
    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)