Don't use global app for api / api4 tests (#7528)
* don't use global app for api / api4 tests * put sleep back. we're gonna have to do some goroutine wrangling * fix oauth test config assumptions * jobs package, i'm comin' for you next * app test fix * try increasing sleep a little
Этот коммит содержится в:
коммит произвёл
George Goldberg
родитель
b84736e9b6
Коммит
9bc7af0c57
34
app/app.go
34
app/app.go
@@ -7,6 +7,7 @@ import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/mattermost-server/einterfaces"
|
||||
ejobs "github.com/mattermost/mattermost-server/einterfaces/jobs"
|
||||
@@ -44,15 +45,46 @@ var globalApp App = App{
|
||||
Jobs: &jobs.JobServer{},
|
||||
}
|
||||
|
||||
var appCount = 0
|
||||
var initEnterprise sync.Once
|
||||
|
||||
func Global() *App {
|
||||
var UseGlobalApp = true
|
||||
|
||||
// New creates a new App. You must call Shutdown when you're done with it.
|
||||
// XXX: Doesn't necessarily create a new App yet.
|
||||
func New() *App {
|
||||
appCount++
|
||||
|
||||
if !UseGlobalApp {
|
||||
if appCount > 1 {
|
||||
panic("Only one App should exist at a time. Did you forget to call Shutdown()?")
|
||||
}
|
||||
app := &App{
|
||||
Jobs: &jobs.JobServer{},
|
||||
}
|
||||
app.initEnterprise()
|
||||
return app
|
||||
}
|
||||
|
||||
initEnterprise.Do(func() {
|
||||
globalApp.initEnterprise()
|
||||
})
|
||||
return &globalApp
|
||||
}
|
||||
|
||||
func (a *App) Shutdown() {
|
||||
appCount--
|
||||
if appCount == 0 {
|
||||
// XXX: This is to give all of our runaway goroutines time to complete.
|
||||
// We should wrangle them up and remove this.
|
||||
time.Sleep(time.Second)
|
||||
|
||||
if a.Srv != nil {
|
||||
a.StopServer()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var accountMigrationInterface func(*App) einterfaces.AccountMigrationInterface
|
||||
|
||||
func RegisterAccountMigrationInterface(f func(*App) einterfaces.AccountMigrationInterface) {
|
||||
|
||||
Ссылка в новой задаче
Block a user