aboutsummaryrefslogtreecommitdiffstats
path: root/models/migrations/base/tests.go
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-11-15 23:45:07 +0800
committerGitHub <noreply@github.com>2024-11-15 23:45:07 +0800
commitecbb03dc6d0e0565663dff977a4fc3d40a1e0c1e (patch)
tree662c4fe1755d323811c3fd3abcb81e256a86326e /models/migrations/base/tests.go
parenta0c0cb3a2c426e39b91e7301c94ddc3a988c8607 (diff)
downloadgitea-ecbb03dc6d0e0565663dff977a4fc3d40a1e0c1e.tar.gz
gitea-ecbb03dc6d0e0565663dff977a4fc3d40a1e0c1e.zip
Improve testing and try to fix MySQL hanging (#32515)
By some CI fine tunes (`run tests`), SQLite & MSSQL could complete in about 12~13 minutes (before > 14), MySQL could complete in 18 minutes (before: about 23 or even > 30) Major changes: 1. use tmpfs for MySQL storage 1. run `make test-mysql` instead of `make integration-test-coverage` because the code coverage is not really used at the moment. 1. refactor testlogger to make it more reliable and be able to report stuck stacktrace 1. do not requeue failed items when a queue is being flushed (failed items would keep failing and make flush uncompleted) 1. reduce the file sizes for testing 1. use math ChaCha20 random data instead of crypot/rand (for testing purpose only) 1. no need to `DeleteRepository` in `TestLinguist` 1. other related refactoring to make code easier to maintain
Diffstat (limited to 'models/migrations/base/tests.go')
-rw-r--r--models/migrations/base/tests.go15
1 files changed, 5 insertions, 10 deletions
diff --git a/models/migrations/base/tests.go b/models/migrations/base/tests.go
index 95d8f07934..ddf9a544da 100644
--- a/models/migrations/base/tests.go
+++ b/models/migrations/base/tests.go
@@ -15,7 +15,6 @@ import (
"code.gitea.io/gitea/models/unittest"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/git"
- "code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/testlogger"
@@ -91,12 +90,11 @@ func PrepareTestEnv(t *testing.T, skip int, syncModels ...any) (*xorm.Engine, fu
}
func MainTest(m *testing.M) {
- log.RegisterEventWriter("test", testlogger.NewTestLoggerWriter)
+ testlogger.Init()
giteaRoot := base.SetupGiteaRoot()
if giteaRoot == "" {
- fmt.Println("Environment variable $GITEA_ROOT not set")
- os.Exit(1)
+ testlogger.Fatalf("Environment variable $GITEA_ROOT not set\n")
}
giteaBinary := "gitea"
if runtime.GOOS == "windows" {
@@ -104,8 +102,7 @@ func MainTest(m *testing.M) {
}
setting.AppPath = filepath.Join(giteaRoot, giteaBinary)
if _, err := os.Stat(setting.AppPath); err != nil {
- fmt.Printf("Could not find gitea binary at %s\n", setting.AppPath)
- os.Exit(1)
+ testlogger.Fatalf("Could not find gitea binary at %s\n", setting.AppPath)
}
giteaConf := os.Getenv("GITEA_CONF")
@@ -122,8 +119,7 @@ func MainTest(m *testing.M) {
tmpDataPath, err := os.MkdirTemp("", "data")
if err != nil {
- fmt.Printf("Unable to create temporary data path %v\n", err)
- os.Exit(1)
+ testlogger.Fatalf("Unable to create temporary data path %v\n", err)
}
setting.CustomPath = filepath.Join(setting.AppWorkPath, "custom")
@@ -131,8 +127,7 @@ func MainTest(m *testing.M) {
unittest.InitSettings()
if err = git.InitFull(context.Background()); err != nil {
- fmt.Printf("Unable to InitFull: %v\n", err)
- os.Exit(1)
+ testlogger.Fatalf("Unable to InitFull: %v\n", err)
}
setting.LoadDBSetting()
setting.InitLoggersForTest()