diff options
author | Rowan Bohde <rowan.bohde@gmail.com> | 2024-11-14 13:28:46 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-14 19:28:46 +0000 |
commit | 68731c07c52d35b7b44db1c2f5f7a755efcc8c84 (patch) | |
tree | 5357aca5db9027ec978f561c65a496810cb72517 /tests/integration/migration-test | |
parent | 249e67672aea8a5a0ed73bedc655f9dcd37437ea (diff) | |
download | gitea-68731c07c52d35b7b44db1c2f5f7a755efcc8c84.tar.gz gitea-68731c07c52d35b7b44db1c2f5f7a755efcc8c84.zip |
Reduce integration test overhead (#32475)
In profiling integration tests, I found a couple places where per-test
overhead could be reduced:
* Avoiding disk IO by synchronizing instead of deleting & copying test
Git repository data. This saves ~100ms per test on my machine
* When flushing queues in `PrintCurrentTest`, invoke `FlushWithContext`
in a parallel.
---------
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'tests/integration/migration-test')
-rw-r--r-- | tests/integration/migration-test/migration_test.go | 23 |
1 files changed, 1 insertions, 22 deletions
diff --git a/tests/integration/migration-test/migration_test.go b/tests/integration/migration-test/migration_test.go index 40fcf95705..9b61bdfe87 100644 --- a/tests/integration/migration-test/migration_test.go +++ b/tests/integration/migration-test/migration_test.go @@ -64,28 +64,7 @@ func initMigrationTest(t *testing.T) func() { unittest.InitSettings() assert.True(t, len(setting.RepoRootPath) != 0) - assert.NoError(t, util.RemoveAll(setting.RepoRootPath)) - assert.NoError(t, unittest.CopyDir(path.Join(filepath.Dir(setting.AppPath), "tests/gitea-repositories-meta"), setting.RepoRootPath)) - ownerDirs, err := os.ReadDir(setting.RepoRootPath) - if err != nil { - assert.NoError(t, err, "unable to read the new repo root: %v\n", err) - } - for _, ownerDir := range ownerDirs { - if !ownerDir.Type().IsDir() { - continue - } - repoDirs, err := os.ReadDir(filepath.Join(setting.RepoRootPath, ownerDir.Name())) - if err != nil { - assert.NoError(t, err, "unable to read the new repo root: %v\n", err) - } - for _, repoDir := range repoDirs { - _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "objects", "pack"), 0o755) - _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "objects", "info"), 0o755) - _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "refs", "heads"), 0o755) - _ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "refs", "tag"), 0o755) - } - } - + assert.NoError(t, unittest.SyncDirs(path.Join(filepath.Dir(setting.AppPath), "tests/gitea-repositories-meta"), setting.RepoRootPath)) assert.NoError(t, git.InitFull(context.Background())) setting.LoadDBSetting() setting.InitLoggersForTest() |