diff --git a/tests/jobs_test.json b/tests/jobs_test.json index 765b1f6ba..f08caf0e9 100644 --- a/tests/jobs_test.json +++ b/tests/jobs_test.json @@ -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" } } } diff --git a/tests/model/derived/test_jobs_model.py b/tests/model/derived/test_jobs_model.py index 90020d648..f1c98cefe 100644 --- a/tests/model/derived/test_jobs_model.py +++ b/tests/model/derived/test_jobs_model.py @@ -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 diff --git a/tests/model/derived/test_objectstore_model.py b/tests/model/derived/test_objectstore_model.py index 677fac7ea..8bd0f1250 100644 --- a/tests/model/derived/test_objectstore_model.py +++ b/tests/model/derived/test_objectstore_model.py @@ -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( diff --git a/treeherder/model/derived/jobs.py b/treeherder/model/derived/jobs.py index 24cb06345..81c5cd667 100644 --- a/treeherder/model/derived/jobs.py +++ b/treeherder/model/derived/jobs.py @@ -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