test: run integration tests on random ports and speed up slow tests (#39842)

Integration test processes now get their own work directory, config file
and random ports, so several runs can execute in parallel on one
machine. The slowest tests also lose fixed sleeps and needlessly
expensive setup, with their assertions kept.

- Batch PostgreSQL sequence resets, the main per-test fixture cost there
- Cheap hashing params in hash and OAuth2 fixture tests, full-cost
vectors stay
- Single fetch for negative Actions runner assertions instead of 1s
polls
- Queue flushes and backdated timestamps instead of sleeps
- In-memory SQLite test journal, tmpfs for PostgreSQL in CI
- E2E instance writes SSH keys into its work directory instead of
`~/.ssh/authorized_keys`
This commit is contained in:
silverwind authored and GitHub committed 2026-10-18 12:56:04 +00:00
1 parent d0c35bcd58
commit 1031e34987
42 files changed
+219 -179

No files matched your search

@@ -5,7 +5,6 @@ package archiver
import (
"testing"
"time"
repo_model "gitea.dev/models/repo"
"gitea.dev/models/unittest"
@@ -106,9 +105,6 @@ func TestArchive_Basic(t *testing.T) {
// count.
doArchive(t.Context(), zipReq)
// Sleep two seconds to make sure the queue doesn't change.
time.Sleep(2 * time.Second)
zipReq2, err := NewRequest(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo, firstCommit+".zip", nil)
assert.NoError(t, err)
// This zipReq should match what's sitting in the queue, as we haven't
+3 -6
View File
@@ -52,19 +52,16 @@ func TestTeam_RemoveRepository(t *testing.T) {
func TestDeleteOwnerRepositoriesDirectly(t *testing.T) {
unittest.PrepareTestEnv(t)
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
assert.NoError(t, repo_service.DeleteOwnerRepositoriesDirectly(t.Context(), user))
t.Run("RejectedInTransaction", func(t *testing.T) {
unittest.PrepareTestEnv(t)
err := db.WithTx(t.Context(), func(ctx context.Context) error {
return repo_service.DeleteRepositoryDirectly(ctx, 1)
})
assert.ErrorContains(t, err, "must not be called within a transaction")
unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
})
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
assert.NoError(t, repo_service.DeleteOwnerRepositoriesDirectly(t.Context(), user))
}
func TestDeleteRepositoryDirectlyPurgesRepoScopedRows(t *testing.T) {