From 1b0eef49576524532257dff6eb1aae5f7182acbf Mon Sep 17 00:00:00 2001 From: pboguslawski Date: Sat, 24 May 2025 11:06:48 +0200 Subject: [PATCH] Fix TestSSHPushMirror/Normal/Check_mirrored_content test (#7852) On slower CI hardware test `TestSSHPushMirror/Normal/Check_mirrored_content ` may throw an error like ``` === TestSSHPushMirror/Normal/Check_known_host_keys (tests/integration/mirror_push_test.go:312) --- FAIL: TestSSHPushMirror (5.38s) testlogger.go:405: 2025/05/12 15:48:41 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /src/forgejo/tests/gitea-lfs-meta testlogger.go:405: 2025/05/12 15:48:42 ...eb/routing/logger.go:102:func1() [I] router: completed GET /user/login for test-mock:12345, 200 OK in 4.6ms @ auth/auth.go:145(auth.SignIn) testlogger.go:405: 2025/05/12 15:48:42 ...eb/routing/logger.go:102:func1() [I] router: completed POST /user/login for test-mock:12345, 303 See Other in 14.8ms @ auth/auth.go:179(auth.SignInPost) testlogger.go:405: 2025/05/12 15:48:42 ...odels/user/avatar.go:59:GenerateRandomAvatar() [I] New random avatar created: 2 testlogger.go:405: 2025/05/12 15:48:42 ...eb/routing/logger.go:102:func1() [I] router: completed GET /user2/repo2/settings for test-mock:12345, 200 OK in 53.9ms @ setting/setting.go:300(setting.Settings) --- FAIL: TestSSHPushMirror/Normal (2.81s) --- FAIL: TestSSHPushMirror/Normal/Check_mirrored_content (2.26s) testlogger.go:405: 2025/05/12 15:48:43 ...eb/routing/logger.go:102:func1() [I] router: completed GET /user2/repo2 for test-mock:12345, 200 OK in 89.1ms @ repo/view.go:798(repo.Home) testlogger.go:405: 2025/05/12 15:48:43 ...eb/routing/logger.go:102:func1() [I] router: completed GET /api/internal/serv/command/10000/user2/push-mirror-test?mode=2&verb=git-receive-pack for 127.0.0.1:0, 200 OK in 5.2ms @ private/serv.go:79(private.ServCommand) testlogger.go:405: 2025/05/12 15:48:43 ...eb/routing/logger.go:102:func1() [I] router: completed POST /api/internal/hook/pre-receive/user2/push-mirror-test for 127.0.0.1:0, 200 OK in 10.0ms @ private/hook_pre_receive.go:178(private.HookPreReceive) mirror_push_test.go:304: Error Trace: /src/forgejo/tests/integration/integration_test.go:564 /src/forgejo/tests/integration/integration_test.go:228 /src/forgejo/tests/integration/mirror_push_test.go:304 /usr/lib/go-1.24/src/runtime/asm_amd64.s:1700 Error: Not equal: expected: 200 actual : 303 Test: TestSSHPushMirror/Normal/Check_mirrored_content Messages: Request: GET /user2/push-mirror-test mirror_push_test.go:304: Response: See Other. testlogger.go:405: 2025/05/12 15:48:44 ...eb/routing/logger.go:102:func1() [I] router: completed GET /user2/push-mirror-test for test-mock:12345, 303 See Other in 34.7ms @ repo/view.go:798(repo.Home) testlogger.go:405: 2025/05/12 15:48:44 ...eb/routing/logger.go:102:func1() [I] router: completed POST /api/internal/hook/post-receive/user2/push-mirror-test for 127.0.0.1:0, 200 OK in 304.3ms @ private/hook_post_receive.go:35(private.HookPostReceive) testlogger.go:405: 2025/05/12 15:48:44 ...eb/routing/logger.go:102:func1() [I] router: completed POST /api/internal/ssh/10000/update/10000 for 127.0.0.1:0, 200 OK in 6.6ms @ private/key.go:16(private.UpdatePublicKeyInRepo) testlogger.go:405: 2025/05/12 15:48:45 ...eb/routing/logger.go:102:func1() [I] router: completed GET /user2/push-mirror-test for test-mock:12345, 200 OK in 121.0ms @ repo/view.go:798(repo.Home) ``` because it does not allow temporary 303 responses while waiting in `assert.Eventually` for repo to be updated. Fixes: 03508b33a8e890b05d845bbd8ead8672b8f03578 Author-Change-Id: IB#1160889 Signed-off-by: Pawel Boguslawski ## Checklist The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org). ### Tests - I added test coverage for Go changes... - [x] in their respective `*_test.go` for unit tests. - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server. - I added test coverage for JavaScript changes... - [ ] in `web_src/js/*.test.js` if it can be unit tested. - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)). ### Documentation - [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change. - [x] I did not document these changes and I do not expect someone else to do it. ### Release notes - [ ] I do not want this change to show in the release notes. - [ ] I want the title to show in the release notes with a link to this pull request. - [ ] I want the content of the `release-notes/.md` to be be used for the release notes instead of the title. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7852 Reviewed-by: Gusted Reviewed-by: Earl Warren Co-authored-by: pboguslawski Co-committed-by: pboguslawski --- tests/integration/mirror_push_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/mirror_push_test.go b/tests/integration/mirror_push_test.go index 556e534ea3..1377d1eb1b 100644 --- a/tests/integration/mirror_push_test.go +++ b/tests/integration/mirror_push_test.go @@ -301,10 +301,10 @@ func TestSSHPushMirror(t *testing.T) { assert.Eventually(t, func() bool { req = NewRequest(t, "GET", fmt.Sprintf("/%s", pushToRepo.FullName())) - resp = sess.MakeRequest(t, req, http.StatusOK) + resp = sess.MakeRequest(t, req, NoExpectedStatus) htmlDoc = NewHTMLParser(t, resp.Body) - return htmlDoc.Find(".shortsha").Text() == shortSHA + return resp.Code == http.StatusOK && htmlDoc.Find(".shortsha").Text() == shortSHA }, time.Second*30, time.Second) })