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)
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)
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)
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)
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)
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)
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)
def test_init_with_invalid_name(self): name = object() with self.assertRaises(SyntaxError): _utils.create_job(name=name)
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
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
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)
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
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
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)
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
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
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
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)