def test_update_job_containers(self): update_job_containers(event=status_raw_event_with_conditions['object'], status=JobLifeCycle.BUILDING, job_container_name=settings.JOB_CONTAINER_NAME) # Assert it's still 0 because no job was created with that job_uuid assert len(RedisJobContainers.get_containers()) == 0 # Create a job with a specific uuid labels = status_raw_event_with_conditions['object']['metadata']['labels'] ExperimentJobFactory(uuid=labels['job_uuid']) job = ExperimentJob.objects.get(uuid=labels['job_uuid']) update_job_containers(event=status_raw_event_with_conditions['object'], status=JobLifeCycle.BUILDING, job_container_name=settings.JOB_CONTAINER_NAME) # Assert now it has started monitoring the container assert len(RedisJobContainers.get_containers()) == 1 container_id = '539e6a6f4209997094802b0657f90576fe129b7f81697120172836073d9bbd75' assert RedisJobContainers.get_containers() == [container_id] job_uuid, experiment_uuid = RedisJobContainers.get_job(container_id) assert job.uuid.hex == job_uuid assert job.experiment.uuid.hex == experiment_uuid
def test_update_job_containers_with_no_container_statuses(self): update_job_containers(event=status_experiment_job_event['object'], status=JobLifeCycle.BUILDING, job_container_name=settings.CONTAINER_NAME_JOB) assert len(RedisJobContainers.get_containers()) == 0