def METHOD_NAME(target_sat):
    """Create an async task and set its start time and last report time to two days ago.
    After the test finishes, the task is cancelled.
    """
    template_id = (
        target_sat.api.JobTemplate()
        .search(query={'search': 'name="Run Command - Script Default"'})[0]
        .id
    )
    job = target_sat.api.JobInvocation().run(
        synchronous=False,
        data={
            'job_template_id': template_id,
            'organization': DEFAULT_ORG,
            'location': DEFAULT_LOC,
            'inputs': {
                'command': 'sleep 300',
            },
            'targeting_type': 'static_query',
            'search_query': f'name = {target_sat.hostname}',
            'password': settings.server.ssh_password,
        },
    )
    sql_date_2_days_ago = "now() - INTERVAL \'2 days\'"
    result = target_sat.execute(
        "su - postgres -c \"psql foreman postgres <<EOF\n"
        "UPDATE foreman_tasks_tasks "
        f"SET start_at = {sql_date_2_days_ago}, "
        f" started_at = {sql_date_2_days_ago}, "
        f" state_updated_at = {sql_date_2_days_ago} "
        f"WHERE id=\'{job['task']['id']}\';\nEOF\n\" "
    )
    assert 'UPDATE 1' in result.stdout, f'Failed to age task {job["task"]["id"]}: {result.stderr}'
    yield job
    result = target_sat.api.ForemanTask().bulk_cancel(data={"task_ids": [job['task']['id']]})
    assert 'cancelled' in result