Esempio n. 1
0
def test_placement_exclusive_job(exclusive_host, peloton_client):
    excl_constraint = task_pb2.Constraint(
        type=1,  # Label constraint
        labelConstraint=task_pb2.LabelConstraint(
            kind=2,  # Host
            condition=2,  # Equal
            requirement=1,
            label=peloton_pb2.Label(
                key="peloton/exclusive", value="exclusive-test-label"
            ),
        ),
    )
    # Set number of instances to be a few more than what can run on
    # a single exclusive host
    job = Job(
        client=peloton_client,
        job_file="long_running_job.yaml",
        config=IntegrationTestConfig(max_retry_attempts=100, sleep_time_sec=2),
        options=[with_constraint(excl_constraint), with_instance_count(6)],
    )
    job.job_config.defaultConfig.command.value = "sleep 10"
    job.create()
    job.wait_for_state()

    # check that all of them ran on exclusive host
    task_infos = job.list_tasks().value
    for instance_id, task_info in task_infos.items():
        assert "exclusive" in task_info.runtime.host
Esempio n. 2
0
def test_placement_strategy_spread():
    job = Job(
        job_file="test_task.yaml",
        options=[with_instance_count(3)])
    job.job_config.placementStrategy = job_pb2.PLACEMENT_STRATEGY_SPREAD_JOB
    job.create()
    job.wait_for_state()

    # check all of them ran on different hosts
    hosts = set()
    task_infos = job.list_tasks().value
    for instance_id, task_info in task_infos.items():
        assert task_info.runtime.host not in hosts
        hosts.add(task_info.runtime.host)
Esempio n. 3
0
def test_placement_non_exclusive_job(exclusive_host):
    # Set number of instances to be a few more than what can run on
    # 2 (non-exclusive) hosts
    job = Job(job_file='long_running_job.yaml',
              config=IntegrationTestConfig(max_retry_attempts=100,
                                           sleep_time_sec=2),
              options=[with_instance_count(12)])
    job.job_config.defaultConfig.command.value = "sleep 10"
    job.create()
    job.wait_for_state()

    # check that none of them ran on exclusive host
    task_infos = job.list_tasks().value
    for instance_id, task_info in task_infos.items():
        assert "exclusive" not in task_info.runtime.host
Esempio n. 4
0
def test_placement_strategy_pack():
    job = Job(
        job_file="test_task.yaml",
        options=[with_instance_count(5)])
    job.job_config.placementStrategy = job_pb2.PLACEMENT_STRATEGY_PACK_HOST
    job.create()
    job.wait_for_state()

    # check all of them ran on same host
    the_host = ""
    task_infos = job.list_tasks().value
    for instance_id, task_info in task_infos.items():
        if the_host:
            assert task_info.runtime.host == the_host
        the_host = task_info.runtime.host
Esempio n. 5
0
def test_placement_strategy_pack():
    job = Job(job_file="test_task.yaml", options=[with_instance_count(5)])
    """
    TODO Uncomment next line after peloton-client changes
    #job.job_config.placementStrategy = "PLACEMENT_STRATEGY_PACK_HOST"
    """
    job.create()
    job.wait_for_state()

    # check all of them ran on same host
    the_host = ""
    task_infos = job.list_tasks().value
    for instance_id, task_info in task_infos.items():
        if the_host:
            assert task_info.runtime.host == the_host
        the_host = task_info.runtime.host