Example #1
0
    def perform_one_service(app, service_manager, service_id):
        log.debug("  test_one_service")
        service_adapter = service_manager.get_service_adapter_for_id(service_id)
        test_jobs = JobDescriptor.get_test_jobs(service_id)

        # Remap the job item output URLs to the output directory.
        for job in test_jobs:
            for job_item in job:
                output_type = job_item['output_type']
                if output_type == 'file_url_put':
                    job_item['output_url'] = remap_file_url(job_item['output_url'])
                else:
                    raise RuntimeError("Bad output type %s for job %s" % (output_type, self))

        log.debug("    Testing jobs")
        job = None
        try:
            exception_caught = False
            for job in test_jobs:
                log.debug("      testing job %s", job)
                service_adapter.perform(job)
        except RuntimeError as exception:
            exception_caught = True
            log.error("    Exception caught %s", exception)
            log.debug("    Error performing %s %s", job, service_adapter)

        assert not exception_caught
Example #2
0
def test_jobs():
    print()
    setup_logging()
    init_test_jobs()
    test_jobs = JobDescriptor.get_test_jobs(ontology.DOCUMENT_SUMMARIZER_ID)
    for job in test_jobs:
        service_id = 0
        if str(job) != "NO_JOB":
            service_id = ontology.DOCUMENT_SUMMARIZER_ID

        job_parameters = {
            'input_type': 'file',
            'input_url': 'http://test.com/inputs/test_input.txt',
            'output_type': 'file_url_put',
            'output_url': 'test_output.txt'
        }
        job_parameters_2 = {
            'input_type': 'file',
            'input_url': 'http://test.com/inputs/test_input.txt',
            'output_type': 'file_url_put',
            'output_url': 'test_output.txt'
        }

        service_id = ontology.DOCUMENT_SUMMARIZER_ID

        # Create a new job descriptor with four sets of parameters.
        job_list = [
            job_parameters, job_parameters, job_parameters, job_parameters
        ]
        new_job = JobDescriptor(ServiceDescriptor(service_id), job_list)

        file_count = 0
        for job_item in new_job:
            if job_item['input_type'] == 'file':
                file_count += 1
            else:
                file_count = 0
        assert (file_count == 4)

        # Cover and test iteration and list item retrieval and length.
        new_job[0] = job_parameters_2
        assert (new_job[0] == job_parameters_2)
        job_count = len(new_job)
        del new_job[1]
        assert (len(new_job) == job_count - 1)

        # Test equality and string conversion functions.
        last_job = new_job
        assert (last_job == new_job)
        assert (str(last_job) == str(new_job))

        test_jobs.append(new_job)
        total_jobs = len(test_jobs)
        test_jobs[0] = new_job
        del test_jobs[total_jobs - 1]

        # Check the string conversion with no ServiceDescriptor...
        new_job = JobDescriptor(None, [job_parameters])
        assert (str(new_job) != "")
Example #3
0
def perform_one_service(app, service_manager, service_id):
    log.debug("  test_one_service")
    service_adapter = service_manager.get_service_adapter_for_id(service_id)
    test_jobs = JobDescriptor.get_test_jobs(service_id)
    log.debug("    Testing jobs")
    job = None
    try:
        exception_caught = False
        for job in test_jobs:
            log.debug("      testing job %s", job)
            service_adapter.perform(job)
    except RuntimeError as exception:
        exception_caught = True
        log.error("    Exception caught %s", exception)
        log.debug("    Error performing %s %s", job, service_adapter)

    assert not exception_caught