MM-26757 Run server tests on non-default port (#15075)
* run server tests on port randomly selected by the kernel
Этот коммит содержится в:
@@ -15,6 +15,10 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
UnitTestListeningPort = ":0"
|
||||||
|
)
|
||||||
|
|
||||||
type ServerTestHelper struct {
|
type ServerTestHelper struct {
|
||||||
disableConfigWatch bool
|
disableConfigWatch bool
|
||||||
interruptChan chan os.Signal
|
interruptChan chan os.Signal
|
||||||
@@ -56,6 +60,9 @@ func TestRunServerSuccess(t *testing.T) {
|
|||||||
configStore, err := config.NewMemoryStore()
|
configStore, err := config.NewMemoryStore()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// Use non-default listening port in case another server instance is already running.
|
||||||
|
*configStore.Get().ServiceSettings.ListenAddress = UnitTestListeningPort
|
||||||
|
|
||||||
err = runServer(configStore, th.disableConfigWatch, false, th.interruptChan)
|
err = runServer(configStore, th.disableConfigWatch, false, th.interruptChan)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
@@ -104,6 +111,9 @@ func TestRunServerSystemdNotification(t *testing.T) {
|
|||||||
configStore, err := config.NewMemoryStore()
|
configStore, err := config.NewMemoryStore()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// Use non-default listening port in case another server instance is already running.
|
||||||
|
*configStore.Get().ServiceSettings.ListenAddress = UnitTestListeningPort
|
||||||
|
|
||||||
// Start and stop the server
|
// Start and stop the server
|
||||||
err = runServer(configStore, th.disableConfigWatch, false, th.interruptChan)
|
err = runServer(configStore, th.disableConfigWatch, false, th.interruptChan)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -125,6 +135,9 @@ func TestRunServerNoSystemd(t *testing.T) {
|
|||||||
configStore, err := config.NewMemoryStore()
|
configStore, err := config.NewMemoryStore()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// Use non-default listening port in case another server instance is already running.
|
||||||
|
*configStore.Get().ServiceSettings.ListenAddress = UnitTestListeningPort
|
||||||
|
|
||||||
err = runServer(configStore, th.disableConfigWatch, false, th.interruptChan)
|
err = runServer(configStore, th.disableConfigWatch, false, th.interruptChan)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user