Remove wait group for onboarding complete code (#19580)
* remove wait group for onboarding complete code
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
59a34bfc53
Коммит
a3c1507563
@@ -869,17 +869,32 @@ func TestCompleteOnboarding(t *testing.T) {
|
|||||||
CheckOKStatus(t, resp)
|
CheckOKStatus(t, resp)
|
||||||
})
|
})
|
||||||
|
|
||||||
installedPlugins, resp, err := th.SystemAdminClient.GetPlugins()
|
received := make(chan struct{})
|
||||||
require.NoError(t, err)
|
|
||||||
CheckOKStatus(t, resp)
|
|
||||||
|
|
||||||
found := false
|
go func() {
|
||||||
for _, p := range installedPlugins.Active {
|
for {
|
||||||
if p.Id == "testplugin2" {
|
installedPlugins, resp, err := th.SystemAdminClient.GetPlugins()
|
||||||
found = true
|
if err != nil || resp.StatusCode != http.StatusOK {
|
||||||
|
time.Sleep(500 * time.Millisecond)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, p := range installedPlugins.Active {
|
||||||
|
if p.Id == "testplugin2" {
|
||||||
|
received <- struct{}{}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
time.Sleep(500 * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-received:
|
||||||
|
break
|
||||||
|
case <-time.After(15 * time.Second):
|
||||||
|
require.Fail(t, "timed out waiting testplugin2 to be installed and enabled ")
|
||||||
}
|
}
|
||||||
|
|
||||||
require.True(t, found, "testplugin2 should have been installed and enabled")
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ package app
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
@@ -23,12 +22,9 @@ func (a *App) CompleteOnboarding(c *request.Context, request *model.CompleteOnbo
|
|||||||
|
|
||||||
pluginContext := pluginContext(c)
|
pluginContext := pluginContext(c)
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
|
||||||
for _, pluginID := range request.InstallPlugins {
|
for _, pluginID := range request.InstallPlugins {
|
||||||
wg.Add(1)
|
|
||||||
|
|
||||||
go func(id string) {
|
go func(id string) {
|
||||||
defer wg.Done()
|
|
||||||
installRequest := &model.InstallMarketplacePluginRequest{
|
installRequest := &model.InstallMarketplacePluginRequest{
|
||||||
Id: id,
|
Id: id,
|
||||||
}
|
}
|
||||||
@@ -68,8 +64,6 @@ func (a *App) CompleteOnboarding(c *request.Context, request *model.CompleteOnbo
|
|||||||
return model.NewAppError("setFirstAdminCompleteSetup", "api.error_set_first_admin_complete_setup", nil, err.Error(), http.StatusInternalServerError)
|
return model.NewAppError("setFirstAdminCompleteSetup", "api.error_set_first_admin_complete_setup", nil, err.Error(), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
|
||||||
wg.Wait()
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user