コード例 #1
0
def test_elasticsearch_doc_request_body(test_project, eleven_jobs_stored):
    """
    Test the request body is created correctly
    """
    bug_id = 12345678
    job_id = 1

    classification_timestamp = int(time())
    who = "*****@*****.**"

    req = ElasticsearchDocRequest(test_project, job_id, bug_id, classification_timestamp, who)
    req.generate_request_body()

    expected = {
        "buildname": "39643b5073cfb9473042884bfd3ced0289b3d7dd",
        "machinename": "bld-linux64-ec2-132",
        "os": "b2g-emu-jb",
        # I'm using the request time date here, as start time is not
        # available for pending jobs
        "date": "2013-11-13",
        "type": "B2G Emulator Image Build",
        "buildtype": "debug",
        "starttime": "1384353553",
        "tree": test_project,
        "rev": "45f8637cb9f78f19cb8463ff174e81756805d8cf",
        "bug": str(bug_id),
        "who": who,
        "timestamp": str(classification_timestamp),
        "treeherder_job_id": job_id,
    }
    assert req.body == expected, diff(expected, req.body)
コード例 #2
0
def test_elasticsearch_doc_request_body(test_project, eleven_jobs_stored):
    """
    Test the request body is created correctly
    """
    bug_id = 12345678
    job_id = 1

    classification_timestamp = int(time())
    who = "*****@*****.**"

    req = ElasticsearchDocRequest(test_project, job_id, bug_id,
                                  classification_timestamp, who)
    req.generate_request_body()

    expected = {
        "buildname": "39643b5073cfb9473042884bfd3ced0289b3d7dd",
        "machinename": "bld-linux64-ec2-132",
        "os": "b2g-emu-jb",
        # I'm using the request time date here, as start time is not
        # available for pending jobs
        "date": "2013-11-13",
        "type": "B2G Emulator Image Build",
        "buildtype": "debug",
        "starttime": "1384353553",
        "tree": test_project,
        "rev": "45f8637cb9f78f19cb8463ff174e81756805d8cf",
        "bug": str(bug_id),
        "who": who,
        "timestamp": str(classification_timestamp),
        "treeherder_job_id": job_id,
    }
    assert req.body == expected, diff(expected, req.body)
コード例 #3
0
def test_elasticsearch_doc_request_body(test_project, eleven_jobs_stored):
    """
    Test the request body is created correctly
    """
    bug_id = 12345678
    job_id = 1
    sample_artifact = {"build_id": 39953854, "buildername": "b2g_emulator_vm mozilla-inbound opt test crashtest-2"}
    placeholders = [[job_id, "buildapi", "json", zlib.compress(json.dumps(sample_artifact)), job_id, "buildapi"]]
    with ArtifactsModel(test_project) as artifacts_model:
        artifacts_model.store_job_artifact(placeholders)

    classification_timestamp = int(time())
    who = "*****@*****.**"

    req = ElasticsearchDocRequest(test_project, job_id, bug_id, classification_timestamp, who)
    req.generate_request_body()

    expected = {
        "buildname": "b2g_emulator_vm mozilla-inbound opt test crashtest-2",
        "machinename": "bld-linux64-ec2-132",
        "os": "b2g-emu-jb",
        # I'm using the request time date here, as start time is not
        # available for pending jobs
        "date": "2013-11-13",
        "type": "B2G Emulator Image Build",
        "buildtype": "debug",
        "starttime": "1384353553",
        "tree": test_project,
        "rev": "45f8637cb9f78f19cb8463ff174e81756805d8cf",
        "bug": str(bug_id),
        "who": who,
        "timestamp": str(classification_timestamp),
        "treeherder_job_id": job_id,
    }
    assert req.body == expected, diff(expected, req.body)
コード例 #4
0
def submit_elasticsearch_doc(project, job_id, bug_id, classification_timestamp, who):
    """
    Mirror the classification to Elasticsearch using a post request, until
    OrangeFactor is rewritten to use Treeherder's API directly.
    """
    newrelic.agent.add_custom_parameter("project", project)
    newrelic.agent.add_custom_parameter("job_id", job_id)
    newrelic.agent.add_custom_parameter("bug_id", bug_id)
    req = ElasticsearchDocRequest(project, job_id, bug_id, classification_timestamp, who)
    req.generate_request_body()
    req.send_request()
コード例 #5
0
def submit_elasticsearch_doc(project, job_id, bug_id, classification_timestamp, who):
    """
    Mirror the classification to Elasticsearch using a post request, until
    OrangeFactor is rewritten to use Treeherder's API directly.
    """
    try:
        req = ElasticsearchDocRequest(project, job_id, bug_id, classification_timestamp, who)
        req.generate_request_body()
        req.send_request()
    except Exception as e:
        # Initially retry after 1 minute, then for each subsequent retry
        # lengthen the retry time by another minute.
        submit_elasticsearch_doc.retry(exc=e, countdown=(1 + submit_elasticsearch_doc.request.retries) * 60)
        # this exception will be raised once the number of retries
        # exceeds max_retries
        raise
コード例 #6
0
def test_elasticsearch_doc_request_body(test_project, eleven_jobs_stored):
    """
    Test the request body is created correctly
    """
    bug_id = 12345678
    job_id = 1
    sample_artifact = {
        "build_id": 39953854,
        "buildername": "b2g_emulator_vm mozilla-inbound opt test crashtest-2"
    }
    placeholders = [[
        job_id, "buildapi", "json",
        json.dumps(sample_artifact), job_id, "buildapi"
    ]]
    with ArtifactsModel(test_project) as artifacts_model:
        artifacts_model.store_job_artifact(placeholders)

    classification_timestamp = int(time())
    who = "*****@*****.**"

    req = ElasticsearchDocRequest(test_project, job_id, bug_id,
                                  classification_timestamp, who)
    req.generate_request_body()

    expected = {
        "buildname": "b2g_emulator_vm mozilla-inbound opt test crashtest-2",
        "machinename": "bld-linux64-ec2-132",
        "os": "b2g-emu-jb",
        # I'm using the request time date here, as start time is not
        # available for pending jobs
        "date": "2013-11-13",
        "type": "B2G Emulator Image Build",
        "buildtype": "debug",
        "starttime": "1384353553",
        "tree": "test_treeherder",
        "rev": "cdfe03e77e66",
        "bug": str(bug_id),
        "who": who,
        "timestamp": str(classification_timestamp),
        "treeherder_job_id": job_id,
    }
    assert req.body == expected, diff(expected, req.body)
コード例 #7
0
def test_elasticsearch_doc_request_body(test_project, eleven_jobs_processed):
    """
    Test the request body is created correctly
    """
    bug_id = 12345678
    job_id = 1
    sample_artifact = {
        "build_id": 39953854,
        "buildername": "b2g_emulator_vm mozilla-inbound opt test crashtest-2"
    }
    placeholders = [
        [job_id, "buildapi", "json",
         json.dumps(sample_artifact), job_id, "buildapi"]
    ]
    with ArtifactsModel(test_project) as artifacts_model:
        artifacts_model.store_job_artifact(placeholders)

    submit_timestamp = int(time())
    who = "*****@*****.**"

    req = ElasticsearchDocRequest(test_project, job_id, bug_id, submit_timestamp, who)
    req.generate_request_body()

    expected = {
        "buildname": "b2g_emulator_vm mozilla-inbound opt test crashtest-2",
        "machinename": "bld-linux64-ec2-132",
        "os": "b2g-emu-jb",
        # I'm using the request time date here, as start time is not
        # available for pending jobs
        "date": "2013-11-13",
        "type": "B2G Emulator Image Build",
        "buildtype": "debug",
        "starttime": "1384353553",
        "logfile": "00000000",
        "tree": "test_treeherder",
        "rev": "cdfe03e77e66",
        "bug": str(bug_id),
        "who": who,
        "timestamp": str(submit_timestamp)
    }
    assert req.body == expected, diff(expected, req.body)
コード例 #8
0
def submit_elasticsearch_doc(project, job_id, bug_id, classification_timestamp, who):
    """
    Mirror the classification to Elasticsearch using a post request, until
    OrangeFactor is rewritten to use Treeherder's API directly.
    """
    newrelic.agent.add_custom_parameter("project", project)
    newrelic.agent.add_custom_parameter("job_id", str(job_id))
    newrelic.agent.add_custom_parameter("bug_id", str(bug_id))
    req = ElasticsearchDocRequest(project, job_id, bug_id, classification_timestamp, who)
    req.generate_request_body()
    req.send_request()
コード例 #9
0
def submit_elasticsearch_doc(project, job_id, bug_id, classification_timestamp, who):
    """
    Mirror the classification to Elasticsearch using a post request, until
    OrangeFactor is rewritten to use Treeherder's API directly.
    """
    try:
        req = ElasticsearchDocRequest(project, job_id, bug_id, classification_timestamp, who)
        req.generate_request_body()
        req.send_request()
    except Exception as e:
        # Initially retry after 1 minute, then for each subsequent retry
        # lengthen the retry time by another minute.
        submit_elasticsearch_doc.retry(exc=e, countdown=(1 + submit_elasticsearch_doc.request.retries) * 60)
        # this exception will be raised once the number of retries
        # exceeds max_retries
        raise