From ab573c84c7dda38de075706916b0a1e730c884d5 Mon Sep 17 00:00:00 2001 From: Aeneas Date: Wed, 14 Jun 2017 13:01:09 +0200 Subject: [PATCH] all: resolve failing test and data race (#501) --- cmd/root_test.go | 4 ++++ health/handler.go | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/root_test.go b/cmd/root_test.go index b466dfd94aa..92003e47e17 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -19,6 +19,7 @@ func TestExecute(t *testing.T) { var osArgs = make([]string, len(os.Args)) var path = filepath.Join(os.TempDir(), fmt.Sprintf("hydra-%s.yml", uuid.New())) os.Setenv("DATABASE_URL", "memory") + os.Setenv("FORCE_ROOT_CLIENT_CREDENTIALS", "admin:pw") copy(osArgs, os.Args) for _, c := range []struct { @@ -32,10 +33,13 @@ func TestExecute(t *testing.T) { _, err := os.Stat(path) if err != nil { t.Logf("Could not stat path %s because %s", path, err) + } else { + time.Sleep(time.Second * 5) } return err != nil }, }, + {args: []string{"connect", "--id", "admin", "--secret", "pw", "--url", "https://127.0.0.1:4444/"}}, {args: []string{"clients", "create", "--id", "foobarbaz"}}, {args: []string{"clients", "create", "--id", "public-foo", "--is-public"}}, {args: []string{"clients", "delete", "foobarbaz"}}, diff --git a/health/handler.go b/health/handler.go index c930f038209..5cda193b652 100644 --- a/health/handler.go +++ b/health/handler.go @@ -27,7 +27,7 @@ func (h *Handler) SetRoutes(r *httprouter.Router) { func (h *Handler) Health(rw http.ResponseWriter, r *http.Request, _ httprouter.Params) { h.Metrics.Update() - h.Metrics.RLock() - defer h.Metrics.RUnlock() + h.Metrics.Lock() + defer h.Metrics.Unlock() h.H.Write(rw, r, h.Metrics) }