Exemplo n.º 1
0
def create_cronjob(config=None, name=None):
    if config is None:
        config = create_config()
    obj = K8sCronJob(
        config=config,
        name=name
    )
    return obj
Exemplo n.º 2
0
 def test_observe_active_deadline_seconds(self):
     cfg = _utils.create_config()
     cj = CronJob(_constants.cronjob_exit_1())
     k8s = K8sCronJob(config=cfg, name="yo")
     k8s.model = cj
     if _utils.is_reachable(cfg):
         k8s.create()
         self.assertIsInstance(k8s, K8sCronJob)
 def test_init_no_args(self):
     try:
         K8sCronJob()
         self.fail("Should not fail.")
     except SyntaxError:
         pass
     except IOError:
         pass
     except Exception as err:
         self.fail("Unhandled exception: [ {0} ]".format(err))
Exemplo n.º 4
0
 def test_active_deadline_seconds(self):
     ads = 50
     cfg = _utils.create_config()
     cj = CronJob(_constants.cronjob())
     k8s = K8sCronJob(config=cfg, name="yo")
     k8s.model = cj
     self.assertIsNone(k8s.active_deadline_seconds)
     k8s.active_deadline_seconds = ads
     self.assertIsNotNone(k8s.active_deadline_seconds)
     self.assertEqual(k8s.active_deadline_seconds, ads)
Exemplo n.º 5
0
def cleanup_cronjobs():
    ref = create_cronjob(name="throwaway")
    if is_reachable(ref.config.api_host):
        _list = ref.list()
        while len(_list) > 0:
            for j in _list:
                try:
                    job = K8sCronJob(config=ref.config, name=j['metadata']['name']).get()
                    job.delete()
                except NotFoundException:
                    continue
            _list = ref.list()
 def test_init_with_invalid_config(self):
     config = object()
     with self.assertRaises(SyntaxError):
         K8sCronJob(config=config)