bind to localhost:0 for tests (#22839)
* bind to localhost:0 for tests Explicitly bind to `localhost:0` instead of just `:0` to avoid binding to all available interfaces and in turn avoid triggering firewall warnings on MacOS. * fix Playbooks to use dynamic port * TestMetrics: handle ipv4 localhost too * TestMetrics: linting
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
7325c38c39
Коммит
4b7f6cb974
@@ -143,8 +143,8 @@ func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer boo
|
||||
*memoryConfig.AnnouncementSettings.AdminNoticesEnabled = false
|
||||
*memoryConfig.AnnouncementSettings.UserNoticesEnabled = false
|
||||
*memoryConfig.MetricsSettings.Enable = true
|
||||
*memoryConfig.ServiceSettings.ListenAddress = ":0"
|
||||
*memoryConfig.MetricsSettings.ListenAddress = ":0"
|
||||
*memoryConfig.ServiceSettings.ListenAddress = "localhost:0"
|
||||
*memoryConfig.MetricsSettings.ListenAddress = "localhost:0"
|
||||
configStore.Set(memoryConfig)
|
||||
|
||||
ps, err := New(ServiceConfig{
|
||||
|
||||
@@ -112,6 +112,7 @@ func TestMetrics(t *testing.T) {
|
||||
|
||||
require.NotNil(t, th.Service.metrics)
|
||||
metricsAddr := strings.Replace(th.Service.metrics.listenAddr, "[::]", "http://localhost", 1)
|
||||
metricsAddr = strings.Replace(metricsAddr, "127.0.0.1", "http://localhost", 1)
|
||||
|
||||
resp, err := http.Get(metricsAddr)
|
||||
require.NoError(t, err)
|
||||
|
||||
Ссылка в новой задаче
Block a user