new test proc to get source for job

This commit is contained in:
Cameron Dawson 2013-04-26 10:49:59 -07:00
Родитель 9530296084
Коммит 8a097b4d22
4 изменённых файлов: 28 добавлений и 10 удалений

Просмотреть файл

@ -15,6 +15,23 @@
"job_log_urls": {
"sql": "SELECT * FROM `job_log_url` WHERE job_id = ?",
"host": "master_host"
},
"job_source": {
"sql": "SELECT rev.commit_timestamp,
rev.push_timestamp,
rev.comments,
rev.repository_id,
rev.revision
FROM `revision` as rev
LEFT JOIN `revision_map` as revmap
ON rev.id = revmap.revision_id
LEFT JOIN `result_set` as res
ON revmap.result_set_id = res.id
LEFT JOIN `job`
ON job.result_set_id = res.id
WHERE job.id = ?
",
"host": "master_host"
}
}
}

Просмотреть файл

@ -53,7 +53,7 @@ def test_ingest_all_sample_jobs(jm, sample_data):
everything was stored correctly.
"""
job_data = sample_data.job_data[:250]
job_data = sample_data.job_data[:2]
for blob in job_data:
jm.store_job_data(json.dumps(blob))
jobs = jm.process_objects(1)
@ -68,6 +68,7 @@ def test_ingest_all_sample_jobs(jm, sample_data):
# verify the source data
exp_src = clean_source_blob_dict(blob["sources"][0])
act_src = SourceDictBuilder(jm, job_id).as_dict()
assert exp_src == act_src, diff_dict(exp_src, act_src)
complete_count = jm.get_os_dhub().execute(
@ -87,7 +88,12 @@ class SourceDictBuilder(object):
self.job_id = job_id
def as_dict(self):
pass
source = self.jm.get_jobs_dhub().execute(
proc="jobs_test.selects.job_source",
placeholders=[self.job_id],
return_type="iter"
).next()
return unicode_keys(source)
class JobDictBuilder(object):
@ -233,6 +239,8 @@ def unicode_keys(d):
def clean_source_blob_dict(src):
"""Fix a few fields so they're easier to compare"""
src["commit_timestamp"] = long(src["commit_timestamp"])
src["push_timestamp"] = long(src["push_timestamp"])
return src

Просмотреть файл

@ -125,7 +125,7 @@ def test_process_objects_unknown_error(jm, monkeypatch):
assert row_data['processed_state'] == 'ready'
def xtest_ingest_sample_data(jm, sample_data):
def test_ingest_sample_data(jm, sample_data):
"""Process all job structures in the job_data.txt file"""
job_data = sample_data.job_data[:250]
for blob in job_data:
@ -143,9 +143,6 @@ def xtest_ingest_sample_data(jm, sample_data):
job_rows = jm.get_jobs_dhub().execute(
proc="jobs_test.selects.jobs")
import time
time.sleep(60)
complete_count = jm.get_os_dhub().execute(
proc="objectstore_test.counts.complete")[0]["complete_count"]
loading_count = jm.get_os_dhub().execute(

Просмотреть файл

@ -62,10 +62,6 @@ class JobsModel(TreeherderModelBase):
"""Return the job row for this ``job_id``"""
return self.get_row_by_id(self.CT_JOBS, "job", job_id).next()
def get_revision(self, revision_id):
"""Return the revision row for this ``revision_id``"""
return self.get_row_by_id(self.CT_JOBS, "revision", revision_id).next()
##################
#
# Objectstore functionality