From 5ee888097155a70a14291e9bc7f1b757f13b7f98 Mon Sep 17 00:00:00 2001 From: Jonathan Eads Date: Mon, 2 Jun 2014 13:48:58 -0700 Subject: [PATCH] added explicit disconnect --- tests/e2e/conftest.py | 5 +- tests/etl/test_bugzilla.py | 3 + tests/etl/test_buildapi.py | 2 + tests/etl/test_common.py | 4 +- tests/etl/test_pulse_consumer.py | 4 + tests/etl/test_pushlog.py | 2 + tests/log_parser/test_job_artifact_builder.py | 17 +- .../test_log_view_artifact_builder.py | 50 ++--- tests/log_parser/test_tasks.py | 5 +- tests/model/derived/test_jobs_model.py | 6 + tests/test_utils.py | 178 +----------------- tests/webapp/api/test_artifact_api.py | 5 + tests/webapp/api/test_bug_job_map_api.py | 11 ++ tests/webapp/api/test_jobs_api.py | 3 + tests/webapp/api/test_note_api.py | 12 ++ tests/webapp/api/test_objectstore_api.py | 2 + tests/webapp/api/test_resultset_api.py | 6 + tests/webapp/conftest.py | 2 + 18 files changed, 101 insertions(+), 216 deletions(-) diff --git a/tests/e2e/conftest.py b/tests/e2e/conftest.py index 4127810a4..c056287e0 100644 --- a/tests/e2e/conftest.py +++ b/tests/e2e/conftest.py @@ -86,11 +86,11 @@ def completed_jobs_stored( test_utils.post_collection(jm.project, tjc) - @pytest.fixture def completed_jobs_loaded(jm, completed_jobs_stored): jm.process_objects(1, raise_errors=True) + jm.disconnect() @pytest.fixture def mock_send_request(monkeypatch, jm): @@ -110,7 +110,8 @@ def mock_send_request(monkeypatch, jm): str(signed_uri), params=th_collection.get_collection_data() ) + response.getcode = lambda: response.status_int return response - monkeypatch.setattr(TreeherderRequest, 'send', _send) \ No newline at end of file + monkeypatch.setattr(TreeherderRequest, 'send', _send) diff --git a/tests/etl/test_bugzilla.py b/tests/etl/test_bugzilla.py index 304ba9424..32d86064c 100644 --- a/tests/etl/test_bugzilla.py +++ b/tests/etl/test_bugzilla.py @@ -35,6 +35,9 @@ def test_bz_api_process(mock_extract, refdata): proc='refdata_test.selects.test_bugscache', return_type='tuple' ) + + refdata.disconnect() + # the number of rows inserted should equal to the number of bugs assert len(row_data) == 10 diff --git a/tests/etl/test_buildapi.py b/tests/etl/test_buildapi.py index 1dacd7d6d..fcdcaecd9 100644 --- a/tests/etl/test_buildapi.py +++ b/tests/etl/test_buildapi.py @@ -58,5 +58,7 @@ def test_ingest_pending_jobs(jm, initial_data, stored_obj = jm.get_jobs_dhub().execute( proc="jobs_test.selects.jobs") + jm.disconnect() + assert len(stored_obj) == 1 diff --git a/tests/etl/test_common.py b/tests/etl/test_common.py index e5f2032d6..69d249571 100644 --- a/tests/etl/test_common.py +++ b/tests/etl/test_common.py @@ -2,7 +2,7 @@ from django.conf import settings -def test_get_revision_hash(jm, initial_data, +def test_get_revision_hash(initial_data, result_set_stored, mock_get_remote_content): """That the correct revision_hash is retrieved is the revision exists""" from treeherder.etl import common @@ -12,7 +12,7 @@ def test_get_revision_hash(jm, initial_data, assert resultset[project][revision]['revision_hash'] == result_set_stored[0]['revision_hash'] -def test_get_revision_hash_none(jm, mock_get_remote_content, +def test_get_revision_hash_none(mock_get_remote_content, initial_data, result_set_stored): """Test that none is returned if the revision doesn't exist""" from treeherder.etl import common diff --git a/tests/etl/test_pulse_consumer.py b/tests/etl/test_pulse_consumer.py index 05603e7f0..2df9efd35 100644 --- a/tests/etl/test_pulse_consumer.py +++ b/tests/etl/test_pulse_consumer.py @@ -62,6 +62,8 @@ def test_load_data(sample_data, jm, mock_post_json_data, stored_obj = jm.get_os_dhub().execute( proc="objectstore_test.selects.all") + jm.disconnect() + assert len(stored_obj) == 1 @@ -91,4 +93,6 @@ def test_load_data_missing_attribute(sample_data, jm, mock_post_json_data, initi stored_obj = jm.get_os_dhub().execute( proc="objectstore_test.selects.all") + jm.disconnect() + assert len(stored_obj) == 0 diff --git a/tests/etl/test_pushlog.py b/tests/etl/test_pushlog.py index 8c38252b8..0b18ecc52 100644 --- a/tests/etl/test_pushlog.py +++ b/tests/etl/test_pushlog.py @@ -24,3 +24,5 @@ def test_ingest_hg_pushlog(jm, initial_data, test_base_dir, ) assert len(revisions_stored) == 15 + + jm.disconnect() diff --git a/tests/log_parser/test_job_artifact_builder.py b/tests/log_parser/test_job_artifact_builder.py index 04e4fec90..48bcffacb 100644 --- a/tests/log_parser/test_job_artifact_builder.py +++ b/tests/log_parser/test_job_artifact_builder.py @@ -36,48 +36,47 @@ def do_test(log): # assert act == exp, json.dumps(act, indent=4) -def test_crashtest_passing(jm, initial_data): +def test_crashtest_passing(initial_data): """Process a job with a single log reference.""" do_test("mozilla-central_fedora-b2g_test-crashtest-1-bm54-tests1-linux-build50") - -def test_opt_test_failing(jm, initial_data): +def test_opt_test_failing(initial_data): """Process log with printlines and errors""" do_test("mozilla-central_mountainlion_test-mochitest-2-bm80-tests1-macosx-build138") -def test_build_failing(jm, initial_data): +def test_build_failing(initial_data): """Process a job with a single log reference.""" do_test("mozilla-central-macosx64-debug-bm65-build1-build15") -def test_mochitest_debug_passing(jm, initial_data): +def test_mochitest_debug_passing(initial_data): """Process a job with a single log reference.""" do_test("mozilla-central_mountainlion-debug_test-mochitest-2-bm80-tests1-macosx-build93") -def test_mochitest_pass(jm, initial_data): +def test_mochitest_pass(initial_data): """Process a job with a single log reference.""" do_test("mozilla-central_mountainlion_test-mochitest-2-bm77-tests1-macosx-build141") -def test_mochitest_fail(jm, initial_data): +def test_mochitest_fail(initial_data): """Process a job with a single log reference.""" do_test("mozilla-esr17_xp_test_pgo-mochitest-browser-chrome-bm74-tests1-windows-build12") -def test_mochitest_process_crash(jm, initial_data): +def test_mochitest_process_crash(initial_data): """Test a mochitest log that has PROCESS-CRASH """ do_test("mozilla-inbound_ubuntu64_vm-debug_test-mochitest-other-bm53-tests1-linux-build122") -def test_jetpack_fail(jm, initial_data): +def test_jetpack_fail(initial_data): """Process a job with a single log reference.""" do_test("ux_ubuntu32_vm_test-jetpack-bm67-tests1-linux-build16") diff --git a/tests/log_parser/test_log_view_artifact_builder.py b/tests/log_parser/test_log_view_artifact_builder.py index 4e9d2173e..8dbfbb36a 100644 --- a/tests/log_parser/test_log_view_artifact_builder.py +++ b/tests/log_parser/test_log_view_artifact_builder.py @@ -52,14 +52,14 @@ def do_test(log, check_errors=True): # assert act == exp, json.dumps(act, indent=4) -def test_crashtest_passing(jm, initial_data): +def test_crashtest_passing(initial_data): """Process a job with a single log reference.""" do_test( "mozilla-central_fedora-b2g_test-crashtest-1-bm54-tests1-linux-build50" ) -def test_mochitest_pass(jm, initial_data): +def test_mochitest_pass(initial_data): """Process a job with a single log reference.""" do_test( @@ -68,7 +68,7 @@ def test_mochitest_pass(jm, initial_data): @slow -def test_mochitest_fail(jm, initial_data): +def test_mochitest_fail(initial_data): """Process a job with a single log reference.""" do_test( @@ -76,7 +76,7 @@ def test_mochitest_fail(jm, initial_data): ) -def test_mochitest_process_crash(jm, initial_data): +def test_mochitest_process_crash(initial_data): """Test a mochitest log that has PROCESS-CRASH """ do_test( @@ -84,7 +84,7 @@ def test_mochitest_process_crash(jm, initial_data): ) @slow -def test_jetpack_fail(jm, initial_data): +def test_jetpack_fail(initial_data): """Process a job with a single log reference.""" do_test( @@ -93,7 +93,7 @@ def test_jetpack_fail(jm, initial_data): @slow -def test_crash_1(jm, initial_data): +def test_crash_1(initial_data): """Test from old log parser""" do_test( "crash-1" @@ -101,7 +101,7 @@ def test_crash_1(jm, initial_data): @slow -def test_crash_2(jm, initial_data): +def test_crash_2(initial_data): """Test from old log parser""" do_test( "crash-2" @@ -109,7 +109,7 @@ def test_crash_2(jm, initial_data): @slow -def test_crash_mac_1(jm, initial_data): +def test_crash_mac_1(initial_data): """Test from old log parser""" do_test( "crash-mac-1" @@ -117,7 +117,7 @@ def test_crash_mac_1(jm, initial_data): @slow -def test_crashtest_timeout(jm, initial_data): +def test_crashtest_timeout(initial_data): """Test from old log parser""" do_test( "crashtest-timeout" @@ -125,7 +125,7 @@ def test_crashtest_timeout(jm, initial_data): @slow -def test_jsreftest_fail(jm, initial_data): +def test_jsreftest_fail(initial_data): """Test from old log parser""" do_test( "jsreftest-fail" @@ -133,7 +133,7 @@ def test_jsreftest_fail(jm, initial_data): @slow -def test_jsreftest_timeout_crash(jm, initial_data): +def test_jsreftest_timeout_crash(initial_data): """Test from old log parser""" do_test( "jsreftest-timeout-crash" @@ -141,7 +141,7 @@ def test_jsreftest_timeout_crash(jm, initial_data): @slow -def test_leaks_1(jm, initial_data): +def test_leaks_1(initial_data): """Test from old log parser""" do_test( "leaks-1" @@ -149,7 +149,7 @@ def test_leaks_1(jm, initial_data): @slow -def test_mochitest_test_end(jm, initial_data): +def test_mochitest_test_end(initial_data): """Test from old log parser""" do_test( "mochitest-test-end" @@ -157,7 +157,7 @@ def test_mochitest_test_end(jm, initial_data): @slow -def test_multiple_timeouts(jm, initial_data): +def test_multiple_timeouts(initial_data): """Test from old log parser""" do_test( "multiple-timeouts" @@ -165,7 +165,7 @@ def test_multiple_timeouts(jm, initial_data): @slow -def test_opt_objc_exception(jm, initial_data): +def test_opt_objc_exception(initial_data): """Test from old log parser""" do_test( "opt-objc-exception" @@ -173,7 +173,7 @@ def test_opt_objc_exception(jm, initial_data): @slow -def test_reftest_fail_crash(jm, initial_data): +def test_reftest_fail_crash(initial_data): """Test from old log parser""" do_test( "reftest-fail-crash" @@ -181,7 +181,7 @@ def test_reftest_fail_crash(jm, initial_data): @slow -def test_reftest_jserror(jm, initial_data): +def test_reftest_jserror(initial_data): """Test from old log parser""" do_test( "reftest-jserror" @@ -189,7 +189,7 @@ def test_reftest_jserror(jm, initial_data): @slow -def test_reftest_opt_fail(jm, initial_data): +def test_reftest_opt_fail(initial_data): """Test from old log parser""" do_test( "reftest-opt-fail" @@ -197,7 +197,7 @@ def test_reftest_opt_fail(jm, initial_data): @slow -def test_reftest_timeout(jm, initial_data): +def test_reftest_timeout(initial_data): """Test from old log parser""" do_test( "reftest-timeout" @@ -205,35 +205,35 @@ def test_reftest_timeout(jm, initial_data): @slow -def test_tinderbox_exception(jm, initial_data): +def test_tinderbox_exception(initial_data): """Test from old log parser""" do_test( "tinderbox-exception" ) -def test_xpcshell_crash(jm, initial_data): +def test_xpcshell_crash(initial_data): """Test from old log parser""" do_test( "xpcshell-crash" ) -def test_xpcshell_multiple(jm, initial_data): +def test_xpcshell_multiple(initial_data): """Test from old log parser""" do_test( "xpcshell-multiple" ) -def test_xpcshell_timeout(jm, initial_data): +def test_xpcshell_timeout(initial_data): """Test from old log parser""" do_test( "xpcshell-timeout" ) @slow -def test_check_errors_false(jm, initial_data, monkeypatch): +def test_check_errors_false(initial_data, monkeypatch): """ensure that parse_line is not called on the error parser.""" mock_pl = MagicMock(name="parse_line") @@ -245,7 +245,7 @@ def test_check_errors_false(jm, initial_data, monkeypatch): ) assert mock_pl.called is False -def test_check_errors_true(jm, initial_data, monkeypatch): +def test_check_errors_true(initial_data, monkeypatch): """ensure that parse_line is called on the error parser.""" mock_pl = MagicMock(name="parse_line") diff --git a/tests/log_parser/test_tasks.py b/tests/log_parser/test_tasks.py index 8a2a3ba51..57e14651d 100644 --- a/tests/log_parser/test_tasks.py +++ b/tests/log_parser/test_tasks.py @@ -8,7 +8,7 @@ from treeherder.log_parser.parsers import ErrorParser @pytest.fixture -def jobs_with_local_log(jm, initial_data): +def jobs_with_local_log(initial_data): log = "mozilla-central_fedora-b2g_test-crashtest-1-bm54-tests1-linux-build50" sample_data = SampleData() url = "file://{0}".format( @@ -48,6 +48,9 @@ def test_parse_log(jm, initial_data, jobs_with_local_log, sample_resultset, mock placeholders=[job_id] ) + jm.disconnect() + # we must have at least 2 artifacts: one for the log viewer and another one # for the job artifact panel + assert len(job_artifacts) >= 2 diff --git a/tests/model/derived/test_jobs_model.py b/tests/model/derived/test_jobs_model.py index 7d1a6a276..7d83d0fba 100644 --- a/tests/model/derived/test_jobs_model.py +++ b/tests/model/derived/test_jobs_model.py @@ -17,6 +17,8 @@ def test_unicode(jm): """Unicode representation of a ``JobModel`` is the project name.""" assert unicode(jm) == unicode(jm.project) + jm.disconnect() + def test_disconnect(jm): """test that your model disconnects""" @@ -45,6 +47,7 @@ def test_ingest_single_sample_job(jm, refdata, sample_data, initial_data, test_utils.do_job_ingestion(jm, refdata, job_data, sample_resultset) jm.disconnect() + refdata.disconnect() def test_ingest_all_sample_jobs(jm, refdata, sample_data, initial_data, sample_resultset, mock_log_parser): """ @@ -58,6 +61,7 @@ def test_ingest_all_sample_jobs(jm, refdata, sample_data, initial_data, sample_r test_utils.do_job_ingestion(jm, refdata, job_data, sample_resultset) jm.disconnect() + refdata.disconnect() def test_cycle_all_data(jm, refdata, sample_data, initial_data, sample_resultset, mock_log_parser): """ @@ -88,6 +92,7 @@ def test_cycle_all_data(jm, refdata, sample_data, initial_data, sample_resultset jobs_after = jm.get_dhub(jm.CT_JOBS).execute(proc="jobs_test.selects.jobs") jm.disconnect() + refdata.disconnect() assert len(jobs_before) == job_count @@ -141,6 +146,7 @@ def test_cycle_one_job(jm, refdata, sample_data, initial_data, sample_resultset, assert len(jobs_count_after_delete) == 0 jm.disconnect() + refdata.disconnect() def test_bad_date_value_ingestion(jm, initial_data, mock_log_parser): """ diff --git a/tests/test_utils.py b/tests/test_utils.py index ddf20f0b6..4d14795d3 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -304,6 +304,7 @@ def verify_artifacts(jm, artifacts_ref): assert artifacts[key]['type'] == artifacts_ref[key]['type'] assert json.loads(artifacts[key]['blob']) == artifacts_ref[key]['blob'] + def verify_coalesced(jm, coalesced_job_guids, coalesced_replacements): coalesced_job_guid_list = coalesced_job_guids.keys() @@ -344,183 +345,6 @@ def load_exp(filename): return {} -class SourceDictBuilder(object): - """Given a ``job_id``, rebuild the dictionary the source came from.""" - - def __init__(self, jm, job_guid): - self.jm = jm - self.job_guid = job_guid - job_data = self.jm.get_jobs_dhub().execute( - proc="jobs_test.selects.row_by_guid", - placeholders=[self.job_guid], - return_type="iter" - ).next() - self.job_id = job_data['id'] - - def as_dict(self): - - source = self.jm.get_jobs_dhub().execute( - proc="jobs_test.selects.job_source", - placeholders=[self.job_id], - return_type="iter" - ).next() - - source["repository"] = self._get_repository( - source["repository_id"]) - del(source["repository_id"]) - - return unicode_keys(source) - - def _get_repository(self, obj_id): - obj = self.jm.refdata_model.get_row_by_id( - "repository", - obj_id, - ).get_column_data("name") - return obj - - -class JobDictBuilder(object): - """Given a ``job_id``, rebuild the dictionary the job came from.""" - - def __init__(self, jm, job_guid): - self.jm = jm - self.job_guid = job_guid - job_data = self.jm.get_jobs_dhub().execute( - proc="jobs_test.selects.row_by_guid", - placeholders=[self.job_guid], - return_type="iter" - ).next() - self.job_id = job_data['id'] - - def as_dict(self): - job = self.jm.get_job(self.job_id) - - job["artifact"] = self._get_artifact() - job["log_references"] = self._get_logs() - - job["option_collection"] = self._get_option_collection( - job["option_collection_hash"]) - del(job["option_collection_hash"]) - - job["machine_platform"] = self._get_machine_platform( - job["machine_platform_id"]) - del(job["machine_platform_id"]) - - job["build_platform"] = self._get_build_platform( - job["build_platform_id"]) - del(job["build_platform_id"]) - - job["machine"] = self._get_machine( - job["machine_id"]) - del(job["machine_id"]) - del(job["machine_name"]) - - job["product_name"] = self._get_product( - job["product_id"]) - del(job["product_id"]) - - job["name"] = self._get_name( - job["job_type_id"]) - del(job["job_type_id"]) - - del(job["id"]) - del(job["active_status"]) - del(job["result_set_id"]) - - if not job["job_coalesced_to_guid"]: - del(job["job_coalesced_to_guid"]) - - return unicode_keys(job) - - def _get_option_collection(self, option_collection_hash): - """ - Needs to work with hash. Get row by id won't work anymore. - probably need to a new getter where it gets the option id - but the hash means there's possibly more than one option. - maybe I need mauro to make a splitter get method? - """ - option_iter = self.jm.refdata_model.get_option_names( - option_collection_hash) - options = {} - for name_dict in option_iter: - options[name_dict["name"]] = True - - return options - - def _get_machine_platform(self, obj_id): - obj = self.jm.refdata_model.get_row_by_id( - "machine_platform", - obj_id, - ).next() - del(obj["active_status"]) - del(obj["id"]) - return unicode_keys(obj) - - def _get_build_platform(self, obj_id): - obj = self.jm.refdata_model.get_row_by_id( - "build_platform", - obj_id, - ).next() - del(obj["active_status"]) - del(obj["id"]) - return unicode_keys(obj) - - def _get_machine(self, obj_id): - obj = self.jm.refdata_model.get_row_by_id( - "machine", - obj_id, - ).get_column_data("name") - return obj - - def _get_product(self, obj_id): - obj = self.jm.refdata_model.get_row_by_id( - "product", - obj_id, - ).get_column_data("name") - return obj - - def _get_name(self, obj_id): - job_type = self.jm.refdata_model.get_row_by_id( - "job_type", - obj_id, - ).next() - return job_type['name'] - - def _get_logs(self): - logs = self.jm.get_jobs_dhub().execute( - proc="jobs_test.selects.job_log_urls", - placeholders=[self.job_id], - key_column="id", - return_type='dict', - ) - - log_values = [] - for log in logs.values(): - del(log["active_status"]) - del(log["id"]) - del(log["job_id"]) - log_values.append(unicode_keys(log)) - - return log_values - - def _get_artifact(self): - artifact = self.jm.get_jobs_dhub().execute( - proc="jobs_test.selects.job_artifact", - placeholders=[self.job_id], - key_column="id", - return_type='dict', - ) - if not len(artifact): - artifact = {} - else: - artifact = artifact[self.job_id] - del(artifact["active_status"]) - del(artifact["id"]) - del(artifact["job_id"]) - - return unicode_keys(artifact) - - def unicode_keys(d): return dict([(unicode(k), v) for k, v in d.items()]) diff --git a/tests/webapp/api/test_artifact_api.py b/tests/webapp/api/test_artifact_api.py index 754fa19a2..dcc4fa8ea 100644 --- a/tests/webapp/api/test_artifact_api.py +++ b/tests/webapp/api/test_artifact_api.py @@ -31,6 +31,8 @@ def test_artifact_detail(webapp, eleven_jobs_processed, sample_artifacts, jm): "name" ]) + jm.disconnect() + def test_artifact_detail_not_found(webapp, jm): """ @@ -44,6 +46,7 @@ def test_artifact_detail_not_found(webapp, jm): ) assert resp.status_int == 404 + jm.disconnect() def test_artifact_detail_bad_project(webapp, jm): """ @@ -58,3 +61,5 @@ def test_artifact_detail_bad_project(webapp, jm): assert resp.status_int == 404 assert resp.json == {"detail": "No project with name foo"} + jm.disconnect() + diff --git a/tests/webapp/api/test_bug_job_map_api.py b/tests/webapp/api/test_bug_job_map_api.py index ab870904e..c6eb12563 100644 --- a/tests/webapp/api/test_bug_job_map_api.py +++ b/tests/webapp/api/test_bug_job_map_api.py @@ -25,6 +25,8 @@ def test_create_bug_job_map_no_auth(eleven_jobs_processed, jm): assert resp.status_code == 403 + jm.disconnect() + def test_create_bug_job_map(eleven_jobs_processed, mock_message_broker, jm): """ @@ -52,6 +54,8 @@ def test_create_bug_job_map(eleven_jobs_processed, mock_message_broker, jm): assert (bug_job_map_obj,) == jm.get_bug_job_map_list(0, 1) + jm.disconnect() + def test_create_bug_job_map_dup(eleven_jobs_processed, mock_message_broker, jm): """ @@ -84,6 +88,7 @@ def test_create_bug_job_map_dup(eleven_jobs_processed, mock_message_broker, jm): assert (bug_job_map_obj,) == jm.get_bug_job_map_list(0, 1) + jm.disconnect() def test_bug_job_map_list(webapp, jm, eleven_jobs_processed): """ @@ -107,6 +112,8 @@ def test_bug_job_map_list(webapp, jm, eleven_jobs_processed): for i, v in enumerate(expected): assert v == resp.json[i] + jm.disconnect() + def test_bug_job_map_detail(webapp, jm, eleven_jobs_processed): """ test retrieving a list of bug_job_map @@ -129,6 +136,7 @@ def test_bug_job_map_detail(webapp, jm, eleven_jobs_processed): assert resp.json == {"job_id": job_id, "bug_id": bug_id, "type": "manual"} + jm.disconnect() def test_bug_job_map_delete(webapp, eleven_jobs_processed, jm, mock_message_broker): @@ -160,6 +168,7 @@ def test_bug_job_map_delete(webapp, eleven_jobs_processed, content = json.loads(resp.content) assert content == {"message": "Bug job map deleted"} + jm.disconnect() def test_bug_job_map_delete_no_auth(jm, eleven_jobs_processed): """ @@ -184,3 +193,5 @@ def test_bug_job_map_delete_no_auth(jm, eleven_jobs_processed): ) assert resp.status_code == 403 + + jm.disconnect() diff --git a/tests/webapp/api/test_jobs_api.py b/tests/webapp/api/test_jobs_api.py index a848a8333..adc313ba2 100644 --- a/tests/webapp/api/test_jobs_api.py +++ b/tests/webapp/api/test_jobs_api.py @@ -104,6 +104,8 @@ def test_job_detail(webapp, eleven_jobs_processed, sample_artifacts, jm): assert isinstance(resp.json, dict) assert resp.json["id"] == job["id"] + jm.disconnect() + def test_job_detail_bad_project(webapp, eleven_jobs_processed, jm): """ @@ -117,6 +119,7 @@ def test_job_detail_bad_project(webapp, eleven_jobs_processed, jm): webapp.get(badurl, status=404) + jm.disconnect() def test_job_detail_not_found(webapp, jm): """ diff --git a/tests/webapp/api/test_note_api.py b/tests/webapp/api/test_note_api.py index 4522d21f0..50158fcd9 100644 --- a/tests/webapp/api/test_note_api.py +++ b/tests/webapp/api/test_note_api.py @@ -17,6 +17,7 @@ def test_note_list(webapp, sample_notes, jm): assert isinstance(resp.json, list) note_list = resp.json + assert set(note_list[0].keys()) == set([ 'note_timestamp', 'job_id', @@ -56,6 +57,8 @@ def test_note_list(webapp, sample_notes, jm): "act": note_list }) + jm.disconnect() + def test_note_detail(webapp, sample_notes, jm): """ @@ -83,6 +86,8 @@ def test_note_detail(webapp, sample_notes, jm): 'id' ]) + jm.disconnect() + def test_note_detail_not_found(webapp, jm): """ @@ -96,6 +101,7 @@ def test_note_detail_not_found(webapp, jm): ) assert resp.status_int == 404 + jm.disconnect() def test_note_detail_bad_project(webapp, jm): """ @@ -110,6 +116,7 @@ def test_note_detail_bad_project(webapp, jm): assert resp.status_int == 404 assert resp.json == {"detail": "No project with name foo"} + jm.disconnect() def test_create_note(webapp, eleven_jobs_processed, mock_message_broker, jm): """ @@ -149,6 +156,7 @@ def test_create_note(webapp, eleven_jobs_processed, mock_message_broker, jm): u'id': 1 } + jm.disconnect() def test_create_note_no_auth(eleven_jobs_processed, jm): """ @@ -169,6 +177,8 @@ def test_create_note_no_auth(eleven_jobs_processed, jm): assert resp.status_code == 403 + jm.disconnect() + def test_delete_note(webapp, sample_notes, mock_message_broker, jm): """ test creating a single note via endpoint @@ -189,3 +199,5 @@ def test_delete_note(webapp, sample_notes, mock_message_broker, jm): assert resp.status_code == 200, resp assert len(new_notes) == len(notes)-1 + + jm.disconnect() diff --git a/tests/webapp/api/test_objectstore_api.py b/tests/webapp/api/test_objectstore_api.py index 7d09d8e79..12f5a3e24 100644 --- a/tests/webapp/api/test_objectstore_api.py +++ b/tests/webapp/api/test_objectstore_api.py @@ -32,6 +32,8 @@ def test_objectstore_create(job_sample, jm): assert stored_objs[0]['job_guid'] == job_sample["job"]["job_guid"] + jm.disconnect() + def test_objectstore_list(webapp, eleven_jobs_stored, jm): """ diff --git a/tests/webapp/api/test_resultset_api.py b/tests/webapp/api/test_resultset_api.py index 58d6acadc..78ebbce91 100644 --- a/tests/webapp/api/test_resultset_api.py +++ b/tests/webapp/api/test_resultset_api.py @@ -115,6 +115,7 @@ def test_resultset_list_empty_rs_still_show(webapp, initial_data, assert resp.status_int == 200 assert len(resp.json['results']) == 10 + jm.disconnect() def test_resultset_list_filter_by_revision(webapp, eleven_jobs_processed, jm): """ @@ -179,6 +180,8 @@ def test_resultset_list_filter_by_date(webapp, initial_data, u'startdate': u'2013-08-10'} ) + jm.disconnect() + def test_resultset_list_without_jobs(webapp, initial_data, sample_resultset, jm): @@ -207,6 +210,7 @@ def test_resultset_list_without_jobs(webapp, initial_data, u'repository': u'test_treeherder' } + jm.disconnect() def test_resultset_detail(webapp, eleven_jobs_processed, jm): """ @@ -281,6 +285,8 @@ def test_resultset_create(sample_resultset, jm, initial_data): assert len(stored_objs) == 1 assert stored_objs[0]['revision_hash'] == sample_resultset[0]['revision_hash'] + jm.disconnect() + def test_resultset_with_bad_secret(sample_resultset, jm, initial_data): trsc = TreeherderResultSetCollection() diff --git a/tests/webapp/conftest.py b/tests/webapp/conftest.py index 46097df8c..fe73f994e 100644 --- a/tests/webapp/conftest.py +++ b/tests/webapp/conftest.py @@ -73,6 +73,7 @@ def sample_artifacts(jm, sample_data): jm.load_job_data(jobs) + @pytest.fixture def sample_notes(jm, sample_data, eleven_jobs_processed): """provide 11 jobs with job notes.""" @@ -87,3 +88,4 @@ def sample_notes(jm, sample_data, eleven_jobs_processed): "kellyclarkson", "you look like a man-o-lantern" ) +