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
This commit is contained in:
Clark Boylan 2024-01-04 08:55:26 -08:00
parent cd74ebc2bf
commit 186a4b648e
1 changed files with 20 additions and 0 deletions

View File

@ -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 = (