def test_set_job_definition(self):
     experiment = ExperimentFactory()
     job_uuid = uuid.uuid4().hex
     create_job(job_uuid=job_uuid, experiment=experiment)
     job = ExperimentJob.objects.last()
     assert job.role == TaskType.MASTER
     assert job.resources is None
     assert job.node_selector is None
     assert job.affinity is None
     assert job.tolerations is None
     assert job.definition == {}
     definition = {'spec': {}}
     set_job_definition(job_uuid=job_uuid, definition=definition)
     job = ExperimentJob.objects.last()
     assert job.definition == definition
Пример #2
0
    def test_create_job(self):
        experiment = ExperimentFactory()
        assert ExperimentJob.objects.count() == 0

        node_selector = {'polyaxon': 'selector'}
        affinity = {
            'podAffinity': {
                'preferredDuringSchedulingIgnoredDuringExecution': [{
                    'podAffinityTerm': {
                        'topologyKey': 'kubernetes.io/hostname',
                        'labelSelector': {
                            'matchExpressions': [{
                                'operator': 'In',
                                'key': 'polyaxon',
                                'values': ['high-cpu']
                            }]
                        }
                    },
                    'weight':
                    100
                }]
            }
        }
        tolerations = [{
            'operator': 'Equal',
            'effect': 'NoSchedule',
            'key': 'polyaxon',
            'value': 'somevalue'
        }]

        create_job(job_uuid=uuid.uuid4(),
                   experiment=experiment,
                   definition={'spec': {}},
                   node_selector=node_selector,
                   affinity=affinity,
                   tolerations=tolerations)
        assert ExperimentJob.objects.count() == 1
        job = ExperimentJob.objects.last()
        assert job.role == TaskType.MASTER
        assert job.resources is None
        assert job.node_selector == node_selector
        assert job.affinity == affinity
        assert job.tolerations == tolerations