コード例 #1
0
 def test_struct_job(self):
     name = "yomama"
     job = _utils.create_job(name=name)
     self.assertIsInstance(job.model, Job)
     self.assertIsInstance(job.model.metadata, ObjectMeta)
     self.assertIsInstance(job.model.spec, JobSpec)
     self.assertIsInstance(job.model.status, JobStatus)
コード例 #2
0
 def test_api_created_by(self):
     job = _utils.create_job(name="yo")
     if _utils.is_reachable(job.config):
         jobs = job.list()
         for job in jobs:
             obj = job.created_by
             self.assertIsInstance(obj, K8sObject)
コード例 #3
0
 def test_struct_k8s_job(self):
     name = "yomama"
     job = _utils.create_job(name=name)
     self.assertIsNotNone(job)
     self.assertIsInstance(job, K8sJob)
     self.assertIsNotNone(job.model)
     self.assertIsInstance(job.model, Job)
コード例 #4
0
 def test_restart_policy(self):
     p = "Never"
     name = "job-{}".format(str(uuid.uuid4()))
     job = _utils.create_job(name=name)
     self.assertEqual("OnFailure", job.restart_policy)
     job.restart_policy = p
     self.assertEqual(p, job.restart_policy)
コード例 #5
0
 def test_api_create(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()
         self.assertIsInstance(k8s_job, K8sJob)
コード例 #6
0
 def test_api_scale(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.api_host):
         k8s_job.create()
         k8s_job.scale(10)
         self.assertEqual(k8s_job.parallelism, 10)
コード例 #7
0
 def test_init_with_name(self):
     name = "yomama"
     rc = _utils.create_job(name=name)
     self.assertIsNotNone(rc)
     self.assertIsInstance(rc, K8sJob)
     self.assertEqual(rc.name, name)
コード例 #8
0
 def test_init_with_invalid_name(self):
     name = object()
     with self.assertRaises(SyntaxError):
         _utils.create_job(name=name)
コード例 #9
0
 def test_completions_invalid_arg(self):
     c = object()
     name = "job-{}".format(str(uuid.uuid4()))
     job = _utils.create_job(name=name)
     with self.assertRaises(SyntaxError):
         job.completions = c
コード例 #10
0
 def test_restart_policy_invalid_arg(self):
     p = "Always"
     name = "job-{}".format(str(uuid.uuid4()))
     job = _utils.create_job(name=name)
     with self.assertRaises(SyntaxError):
         job.restart_policy = p
コード例 #11
0
 def test_active_deadline_seconds(self):
     s = 5
     name = "job-{}".format(str(uuid.uuid4()))
     job = _utils.create_job(name=name)
     job.active_deadline_seconds = s
     self.assertEqual(s, job.active_deadline_seconds)
コード例 #12
0
 def test_active_deadline_seconds_negative_int(self):
     s = -5
     name = "job-{}".format(str(uuid.uuid4()))
     job = _utils.create_job(name=name)
     with self.assertRaises(SyntaxError):
         job.active_deadline_seconds = s
コード例 #13
0
 def test_active_deadline_seconds_invalid_arg(self):
     s = object()
     name = "job-{}".format(str(uuid.uuid4()))
     job = _utils.create_job(name=name)
     with self.assertRaises(SyntaxError):
         job.active_deadline_seconds = s
コード例 #14
0
 def test_completions(self):
     c = 5
     name = "job-{}".format(str(uuid.uuid4()))
     job = _utils.create_job(name=name)
     job.completions = c
     self.assertEqual(c, job.completions)
コード例 #15
0
 def test_completions_negative_int(self):
     c = -5
     name = "job-{}".format(str(uuid.uuid4()))
     job = _utils.create_job(name=name)
     with self.assertRaises(SyntaxError):
         job.completions = c
コード例 #16
0
 def test_parallelism_invalid_arg(self):
     p = object()
     name = "job-{}".format(str(uuid.uuid4()))
     job = _utils.create_job(name=name)
     with self.assertRaises(SyntaxError):
         job.parallelism = p
コード例 #17
0
 def test_parallelism_negative_int(self):
     p = -5
     name = "job-{}".format(str(uuid.uuid4()))
     job = _utils.create_job(name=name)
     with self.assertRaises(SyntaxError):
         job.parallelism = p
コード例 #18
0
 def test_parallelism(self):
     p = 5
     name = "job-{}".format(str(uuid.uuid4()))
     job = _utils.create_job(name=name)
     job.parallelism = p
     self.assertEqual(p, job.parallelism)