2015-04-28 03:25:59 +03:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, you can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
2015-05-01 01:03:12 +03:00
|
|
|
from treeherder import client
|
2015-04-28 03:25:59 +03:00
|
|
|
|
|
|
|
from treeherder.etl.oauth_utils import OAuthCredentials
|
|
|
|
from treeherder.model.derived import JobsModel
|
|
|
|
|
|
|
|
|
|
|
|
def test_post_job_with_parsed_log(test_project, result_set_stored,
|
2015-05-14 23:47:06 +03:00
|
|
|
mock_post_collection):
|
2015-04-28 03:25:59 +03:00
|
|
|
"""
|
|
|
|
test submitting a job with a pre-parsed log gets the right job_log_url
|
|
|
|
parse_status value.
|
|
|
|
"""
|
|
|
|
|
|
|
|
credentials = OAuthCredentials.get_credentials(test_project)
|
|
|
|
|
2015-05-01 01:03:12 +03:00
|
|
|
tjc = client.TreeherderJobCollection()
|
|
|
|
tj = client.TreeherderJob({
|
2015-04-28 03:25:59 +03:00
|
|
|
'project': test_project,
|
|
|
|
'revision_hash': result_set_stored[0]['revision_hash'],
|
|
|
|
'job': {
|
|
|
|
'job_guid': 'd22c74d4aa6d2a1dcba96d95dccbd5fdca70cf33',
|
|
|
|
'state': 'completed',
|
|
|
|
'log_references': [{
|
|
|
|
'url': 'http://ftp.mozilla.org/pub/mozilla.org/spidermonkey/...',
|
|
|
|
'name': 'builbot_text',
|
|
|
|
'parse_status': 'parsed'
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
tjc.add(tj)
|
|
|
|
|
2015-05-14 23:47:06 +03:00
|
|
|
cli = client.TreeherderClient(protocol='http', host='localhost')
|
2015-04-28 03:25:59 +03:00
|
|
|
|
|
|
|
# Post the request to treeherder
|
2015-05-14 23:47:06 +03:00
|
|
|
cli.post_collection(test_project, credentials['consumer_key'],
|
|
|
|
credentials['consumer_secret'], tjc)
|
|
|
|
|
|
|
|
# assume if there were no exceptions we're ok
|
2015-04-28 03:25:59 +03:00
|
|
|
|
|
|
|
with JobsModel(test_project) as jm:
|
|
|
|
jm.process_objects(10)
|
|
|
|
|
|
|
|
job_ids = [x['id'] for x in jm.get_job_list(0, 20)]
|
|
|
|
job_log_list = jm.get_job_log_url_list(job_ids)
|
|
|
|
|
|
|
|
assert len(job_log_list) == 1
|
|
|
|
assert job_log_list[0]['parse_status'] == 'parsed'
|