From 186a4b648e90951a0881b406840b4b4c5990c708 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Thu, 4 Jan 2024 08:55:26 -0800 Subject: [PATCH] Check for gitea template rendering errors When manually testing the gitea 1.21.3 upgrade tonyb discovered "500" errors on the code search page. The http side reported all 2XX response codes but the page rendered a giant 500. Turns out the problem was in template rendering which produces the giant 500 in the page but doesn't necessarily send a 500 http error code. Test for this automatically on a number of pages by inspecting the page content for 500 status page content. Note this is somewhat fragile because they could change the template content at any time, but it seems better to do this than do nothing at all. Change-Id: I1964be7be87ef5a6e75c6639a4d75d9090a14db8 --- testinfra/test_gitea.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/testinfra/test_gitea.py b/testinfra/test_gitea.py index 0028a8aeec..2616ee0cb2 100644 --- a/testinfra/test_gitea.py +++ b/testinfra/test_gitea.py @@ -111,6 +111,26 @@ def test_partial_project_clone(host): assert "refs/remotes/origin/main" not in cmd.stdout assert cmd.succeeded +def test_no_500_template_content(host): + # We discovered that gitea template rendering errors produce 500 errors + # in the rendered template but not in our http response codes. Check a + # number of pages for 500 errors in the html response. + paths_to_check = [ + '/', + '/opendev/system-config', + '/opendev/system-config/src/branch/master/playbooks/roles/gitea/tasks/main.yaml', + '/explore/repos', + '/explore/users', + '/explore/organizations', + '/explore/code?q=gitea&t=', + ] + for path in paths_to_check: + cmd = host.run('curl --insecure ' + '--resolve gitea99.opendev.org:3081:127.0.0.1 ' + 'https://gitea99.opendev.org:3081' + path) + assert 'status-page-500' not in cmd.stdout + assert 'Internal Server Error' not in cmd.stdout + def test_gitea_screenshots(host): shots = (