diff --git a/cmd/all-in-one/.nocover b/cmd/all-in-one/.nocover deleted file mode 100644 index 8ab06f28b67..00000000000 --- a/cmd/all-in-one/.nocover +++ /dev/null @@ -1 +0,0 @@ -main is not testable diff --git a/cmd/all-in-one/all_in_one_test.go b/cmd/all-in-one/all_in_one_test.go index f5186001976..95b7ea9bac8 100644 --- a/cmd/all-in-one/all_in_one_test.go +++ b/cmd/all-in-one/all_in_one_test.go @@ -75,7 +75,10 @@ func healthCheck(t *testing.T) { require.Eventuallyf( t, func() bool { - _, err := http.Get(queryAddr + "/") + resp, err := http.Get(queryAddr + "/") + if err == nil { + resp.Body.Close() + } return err == nil }, 10*time.Second, @@ -85,14 +88,23 @@ func healthCheck(t *testing.T) { t.Logf("Server detected at %s", queryAddr) } -func checkWebUI(t *testing.T) { - resp, err := http.Get(queryAddr + "/") +func httpGet(t *testing.T, url string) (*http.Response, []byte) { + req, err := http.NewRequest(http.MethodGet, url, nil) + require.NoError(t, err) + req.Close = true // avoid persistent connections which leak goroutines + + resp, err := httpClient.Do(req) require.NoError(t, err) - require.NotNil(t, resp) defer resp.Body.Close() - assert.Equal(t, http.StatusOK, resp.StatusCode) + bodyBytes, err := io.ReadAll(resp.Body) require.NoError(t, err) + + return resp, bodyBytes +} + +func checkWebUI(t *testing.T) { + _, bodyBytes := httpGet(t, queryAddr+"/") body := string(bodyBytes) t.Run("Static_files", func(t *testing.T) { pattern := regexp.MustCompile(`