From fe30be60c2ba09a8611e8a438836dbaa42289846 Mon Sep 17 00:00:00 2001 From: donny-wong <141858744+donny-wong@users.noreply.github.com> Date: Mon, 23 Sep 2024 21:34:19 -0400 Subject: [PATCH 1/3] Haskell Tests - allow displaying of compilation errors (#554) --- Changelog.md | 3 +++ .../testers/haskell/haskell_tester.py | 18 ++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Changelog.md b/Changelog.md index c0d622f2..1936f169 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,9 @@ # CHANGELOG All notable changes to this project will be documented here. +## [unreleased] +- Haskell Tests - allow displaying of compilation errors (#554) + ## [v2.5.1] - Ensure all Haskell test cases still run within same file when there are failed test cases (#543) diff --git a/server/autotest_server/testers/haskell/haskell_tester.py b/server/autotest_server/testers/haskell/haskell_tester.py index 0cbbe99a..9c4a9d78 100644 --- a/server/autotest_server/testers/haskell/haskell_tester.py +++ b/server/autotest_server/testers/haskell/haskell_tester.py @@ -120,16 +120,14 @@ def run_haskell_tests(self) -> Dict[str, List[Dict[str, Union[int, str]]]]: subprocess.run(cmd, stdout=subprocess.DEVNULL, universal_newlines=True, check=True) with tempfile.NamedTemporaryFile(mode="w+", dir=this_dir) as sf: cmd = ["stack", "runghc", *STACK_OPTIONS, "--", f"-i={haskell_lib}", f.name, f"--stats={sf.name}"] - try: - subprocess.run( - cmd, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, universal_newlines=True, check=True - ) - except subprocess.CalledProcessError as e: - if e.returncode == 1: - pass - else: - raise Exception(e) - results[test_file] = self._parse_test_results(csv.reader(sf)) + out = subprocess.run( + cmd, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, universal_newlines=True, check=False + ) + r = self._parse_test_results(csv.reader(sf)) + if r: + results[test_file] = r + else: + raise Exception(out.stderr) return results @Tester.run_decorator From e0c236c0e45fd48896de2a9b6675b87fe87be19f Mon Sep 17 00:00:00 2001 From: donny-wong <141858744+donny-wong@users.noreply.github.com> Date: Tue, 24 Sep 2024 16:53:07 -0400 Subject: [PATCH 2/3] Add status API route for monitoring server status (#555) --- Changelog.md | 1 + client/autotest_client/__init__.py | 5 +++++ client/autotest_client/tests/test_flask_app.py | 13 +++++++++++++ 3 files changed, 19 insertions(+) diff --git a/Changelog.md b/Changelog.md index 1936f169..8398024f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented here. ## [unreleased] - Haskell Tests - allow displaying of compilation errors (#554) +- Add status api for monitoring if Gunicorn is down (#555) ## [v2.5.1] - Ensure all Haskell test cases still run within same file when there are failed test cases (#543) diff --git a/client/autotest_client/__init__.py b/client/autotest_client/__init__.py index 87455aae..d9b73068 100644 --- a/client/autotest_client/__init__.py +++ b/client/autotest_client/__init__.py @@ -319,3 +319,8 @@ def cancel_tests(settings_id, **_kw): for id_, job in zip(test_ids, _get_jobs(test_ids, settings_id)): result[id_] = job if job is None else job.cancel() return jsonify(success=True) + + +@app.route("/status", methods=["GET"]) +def status(): + return jsonify(success=True) diff --git a/client/autotest_client/tests/test_flask_app.py b/client/autotest_client/tests/test_flask_app.py index 87a6c081..5fca42af 100644 --- a/client/autotest_client/tests/test_flask_app.py +++ b/client/autotest_client/tests/test_flask_app.py @@ -38,3 +38,16 @@ def test_api_key_set(self, response): def test_credentials_set(self, response, fake_redis_conn, credentials): assert json.loads(fake_redis_conn.hget("autotest:user_credentials", response.json["api_key"])) == credentials + + +class TestStatus: + + @pytest.fixture + def response(self, client): + return client.get("/status") + + def test_status_code(self, response): + assert response.status_code == 200 + + def test_success(self, response): + assert response.json["success"] is True From 9a6e8c24f96887d01c27a25e33358bc0b3430cd3 Mon Sep 17 00:00:00 2001 From: Samuel Maldonado Date: Tue, 1 Oct 2024 11:53:04 -0400 Subject: [PATCH 3/3] changelog: update changelog --- Changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 8398024f..dcb7525c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,7 +1,7 @@ # CHANGELOG All notable changes to this project will be documented here. -## [unreleased] +## [v2.5.2] - Haskell Tests - allow displaying of compilation errors (#554) - Add status api for monitoring if Gunicorn is down (#555)