def test_api_create(self):
     name = "job-{}".format(uuid.uuid4())
     job = Job(utils.job())
     k8s_job = utils.create_job(name=name)
     k8s_job.model = job
     if utils.is_reachable(k8s_job.config.api_host):
         k8s_job.create()
         self.assertIsInstance(k8s_job, K8sJob)
 def test_api_scale(self):
     name = "job-{}".format(uuid.uuid4())
     job = Job(utils.job())
     k8s_job = utils.create_job(name=name)
     k8s_job.model = job
     k8s_job.completions = 30
     if utils.is_reachable(k8s_job.config.api_host):
         k8s_job.create()
         k8s_job.scale(10)
         self.assertEqual(k8s_job.parallelism, 10)
 def test_api_list(self):
     name = "job-{}".format(uuid.uuid4())
     job = Job(_constants.job())
     k8s_job = _utils.create_job(name=name)
     k8s_job.model = job
     if _utils.is_reachable(k8s_job.config):
         k8s_job.create()
         _list = k8s_job.list()
         for x in _list:
             self.assertIsInstance(x, K8sJob)
Beispiel #4
0
 def list(self, pattern=None, labels=None):
     ls = super(K8sJob, self).list(labels=labels)
     jobs = list(map(lambda x: Job(x), ls))
     if pattern is not None:
         jobs = list(filter(lambda x: pattern in x.name, jobs))
     k8s = []
     for x in jobs:
         j = K8sJob(config=self.config, name=x.name).from_model(m=x)
         k8s.append(j)
     return k8s
Beispiel #5
0
 def list(self, pattern=None):
     ls = super(K8sJob, self).list()
     jobs = map(lambda x: Job(x), ls)
     if pattern is not None:
         jobs = filter(lambda x: pattern in x.name, jobs)
     k8s = []
     for x in jobs:
         j = K8sJob(config=self.config, name=x.name)
         j.model = x
         k8s.append(j)
     return k8s
 def test_api_update(self):
     name = "job-{}".format(uuid.uuid4())
     job = Job(_constants.job())
     k8s_job = _utils.create_job(name=name)
     k8s_job.model = job
     k8s_job.completions = 30
     if _utils.is_reachable(k8s_job.config):
         k8s_job.create()
         k8s_job.parallelism = 10
         k8s_job.update()
         self.assertEqual(k8s_job.parallelism, 10)
Beispiel #7
0
 def get(self):
     self.model = Job(self.get_model())
     return self