Migrate to stateless app.App (#17542)
* add request context * move initialialization to server * use app interface instead of global app functions * remove app context from webconn * cleanup * remove duplicated services * move context to separate package * remove finalize init method and move content to NewServer function * restart workers and schedulers after adding license for tests * reflect review comments Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c09369f14a
Коммит
5ea06e51d0
@@ -527,7 +527,7 @@ func TestPluginSync(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
defer fileReader.Close()
|
||||
|
||||
_, appErr := th.App.WriteFile(fileReader, th.App.getBundleStorePath("testplugin"))
|
||||
_, appErr := th.App.WriteFile(fileReader, getBundleStorePath("testplugin"))
|
||||
checkNoError(t, appErr)
|
||||
|
||||
appErr = th.App.SyncPlugins()
|
||||
@@ -545,7 +545,7 @@ func TestPluginSync(t *testing.T) {
|
||||
*cfg.PluginSettings.RequirePluginSignature = false
|
||||
})
|
||||
|
||||
appErr := th.App.RemoveFile(th.App.getBundleStorePath("testplugin"))
|
||||
appErr := th.App.RemoveFile(getBundleStorePath("testplugin"))
|
||||
checkNoError(t, appErr)
|
||||
|
||||
appErr = th.App.SyncPlugins()
|
||||
@@ -565,7 +565,7 @@ func TestPluginSync(t *testing.T) {
|
||||
pluginFileReader, err := os.Open(filepath.Join(path, "testplugin.tar.gz"))
|
||||
require.NoError(t, err)
|
||||
defer pluginFileReader.Close()
|
||||
_, appErr := th.App.WriteFile(pluginFileReader, th.App.getBundleStorePath("testplugin"))
|
||||
_, appErr := th.App.WriteFile(pluginFileReader, getBundleStorePath("testplugin"))
|
||||
checkNoError(t, appErr)
|
||||
|
||||
appErr = th.App.SyncPlugins()
|
||||
@@ -583,7 +583,7 @@ func TestPluginSync(t *testing.T) {
|
||||
signatureFileReader, err := os.Open(filepath.Join(path, "testplugin2.tar.gz.sig"))
|
||||
require.NoError(t, err)
|
||||
defer signatureFileReader.Close()
|
||||
_, appErr := th.App.WriteFile(signatureFileReader, th.App.getSignatureStorePath("testplugin"))
|
||||
_, appErr := th.App.WriteFile(signatureFileReader, getSignatureStorePath("testplugin"))
|
||||
checkNoError(t, appErr)
|
||||
|
||||
appErr = th.App.SyncPlugins()
|
||||
@@ -607,7 +607,7 @@ func TestPluginSync(t *testing.T) {
|
||||
signatureFileReader, err := os.Open(filepath.Join(path, "testplugin.tar.gz.sig"))
|
||||
require.NoError(t, err)
|
||||
defer signatureFileReader.Close()
|
||||
_, appErr = th.App.WriteFile(signatureFileReader, th.App.getSignatureStorePath("testplugin"))
|
||||
_, appErr = th.App.WriteFile(signatureFileReader, getSignatureStorePath("testplugin"))
|
||||
checkNoError(t, appErr)
|
||||
|
||||
appErr = th.App.SyncPlugins()
|
||||
@@ -648,7 +648,7 @@ func TestSyncPluginsActiveState(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
defer fileReader.Close()
|
||||
|
||||
_, appErr := th.App.WriteFile(fileReader, th.App.getBundleStorePath("testplugin"))
|
||||
_, appErr := th.App.WriteFile(fileReader, getBundleStorePath("testplugin"))
|
||||
checkNoError(t, appErr)
|
||||
|
||||
// Sync with file store so the plugin environment has access to this plugin.
|
||||
@@ -691,6 +691,7 @@ func TestPluginPanicLogs(t *testing.T) {
|
||||
t.Run("should panic", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
tearDown, _, _ := SetAppEnvironmentWithPlugins(t, []string{
|
||||
`
|
||||
package main
|
||||
@@ -713,7 +714,7 @@ func TestPluginPanicLogs(t *testing.T) {
|
||||
plugin.ClientMain(&MyPlugin{})
|
||||
}
|
||||
`,
|
||||
}, th.App, th.App.NewPluginAPI)
|
||||
}, th.App, th.NewPluginAPI)
|
||||
|
||||
post := &model.Post{
|
||||
UserId: th.BasicUser.Id,
|
||||
@@ -721,7 +722,7 @@ func TestPluginPanicLogs(t *testing.T) {
|
||||
Message: "message_",
|
||||
CreateAt: model.GetMillis() - 10000,
|
||||
}
|
||||
_, err := th.App.CreatePost(post, th.BasicChannel, false, true)
|
||||
_, err := th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
|
||||
assert.Nil(t, err)
|
||||
// We shutdown plugins first so that the read on the log buffer is race-free.
|
||||
th.App.Srv().ShutDownPlugins()
|
||||
@@ -771,7 +772,7 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
*cfg.PluginSettings.EnableRemoteMarketplace = false
|
||||
})
|
||||
|
||||
plugins := th.App.processPrepackagedPlugins(prepackagedPluginsDir)
|
||||
plugins := th.App.Srv().processPrepackagedPlugins(prepackagedPluginsDir)
|
||||
require.Len(t, plugins, 1)
|
||||
require.Equal(t, plugins[0].Manifest.Id, "testplugin")
|
||||
require.Empty(t, plugins[0].Signature, 0)
|
||||
@@ -798,7 +799,7 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
|
||||
env := th.App.GetPluginsEnvironment()
|
||||
|
||||
plugins := th.App.processPrepackagedPlugins(prepackagedPluginsDir)
|
||||
plugins := th.App.Srv().processPrepackagedPlugins(prepackagedPluginsDir)
|
||||
require.Len(t, plugins, 1)
|
||||
require.Equal(t, plugins[0].Manifest.Id, "testplugin")
|
||||
require.Empty(t, plugins[0].Signature, 0)
|
||||
@@ -831,7 +832,7 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
err = testlib.CopyFile(testPlugin2SignaturePath, filepath.Join(prepackagedPluginsDir, "testplugin2.tar.gz.sig"))
|
||||
require.NoError(t, err)
|
||||
|
||||
plugins := th.App.processPrepackagedPlugins(prepackagedPluginsDir)
|
||||
plugins := th.App.Srv().processPrepackagedPlugins(prepackagedPluginsDir)
|
||||
require.Len(t, plugins, 2)
|
||||
require.Contains(t, []string{"testplugin", "testplugin2"}, plugins[0].Manifest.Id)
|
||||
require.NotEmpty(t, plugins[0].Signature)
|
||||
@@ -880,7 +881,7 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
err = testlib.CopyFile(testPlugin2SignaturePath, filepath.Join(prepackagedPluginsDir, "testplugin2.tar.gz.sig"))
|
||||
require.NoError(t, err)
|
||||
|
||||
plugins := th.App.processPrepackagedPlugins(prepackagedPluginsDir)
|
||||
plugins := th.App.Srv().processPrepackagedPlugins(prepackagedPluginsDir)
|
||||
require.Len(t, plugins, 2)
|
||||
require.Contains(t, []string{"testplugin", "testplugin2"}, plugins[0].Manifest.Id)
|
||||
require.NotEmpty(t, plugins[0].Signature)
|
||||
@@ -917,7 +918,7 @@ func TestProcessPrepackagedPlugins(t *testing.T) {
|
||||
err = testlib.CopyFile(testPlugin2SignaturePath, filepath.Join(prepackagedPluginsDir, "testplugin2.tar.gz.sig"))
|
||||
require.NoError(t, err)
|
||||
|
||||
plugins := th.App.processPrepackagedPlugins(prepackagedPluginsDir)
|
||||
plugins := th.App.Srv().processPrepackagedPlugins(prepackagedPluginsDir)
|
||||
require.Len(t, plugins, 2)
|
||||
require.Contains(t, []string{"testplugin", "testplugin2"}, plugins[0].Manifest.Id)
|
||||
require.NotEmpty(t, plugins[0].Signature)
|
||||
|
||||
Ссылка в новой задаче
Block a user