[ARVADOS] updated: 63218507eec156df91f80c86ee05d680d67b8336

Git user git at public.curoverse.com
Mon Oct 2 17:17:51 EDT 2017


Summary of changes:
 sdk/go/health/aggregator.go      |  1 +
 sdk/go/health/aggregator_test.go | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

       via  63218507eec156df91f80c86ee05d680d67b8336 (commit)
      from  91db2d8fd32bc3f6c2a26ffc37f6591b1e5f380b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 63218507eec156df91f80c86ee05d680d67b8336
Author: Tom Clegg <tclegg at veritasgenetics.com>
Date:   Mon Oct 2 17:17:29 2017 -0400

    12260: Test case for one unhealthy service.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg at veritasgenetics.com>

diff --git a/sdk/go/health/aggregator.go b/sdk/go/health/aggregator.go
index 6993187..5c46c1a 100644
--- a/sdk/go/health/aggregator.go
+++ b/sdk/go/health/aggregator.go
@@ -38,6 +38,7 @@ func (agg *Aggregator) setup() {
 }
 
 func (agg *Aggregator) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
+	agg.setupOnce.Do(agg.setup)
 	sendErr := func(statusCode int, err error) {
 		resp.WriteHeader(statusCode)
 		json.NewEncoder(resp).Encode(map[string]interface{}{"error": err})
diff --git a/sdk/go/health/aggregator_test.go b/sdk/go/health/aggregator_test.go
index 2cb7122..eb6adc8 100644
--- a/sdk/go/health/aggregator_test.go
+++ b/sdk/go/health/aggregator_test.go
@@ -4,6 +4,7 @@ import (
 	"encoding/json"
 	"net/http"
 	"net/http/httptest"
+	"strings"
 
 	"git.curoverse.com/arvados.git/sdk/go/arvados"
 	"git.curoverse.com/arvados.git/sdk/go/arvadostest"
@@ -56,6 +57,29 @@ func (s *AggregatorSuite) TestEmptyConfig(c *check.C) {
 	s.checkOK(c)
 }
 
+type unhealthyHandler struct{}
+
+func (*unhealthyHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
+	resp.Write([]byte(`{"health":"ERROR"}`))
+}
+
+func (s *AggregatorSuite) TestUnhealthy(c *check.C) {
+	srv := httptest.NewServer(&unhealthyHandler{})
+	defer srv.Close()
+
+	var port string
+	if parts := strings.Split(srv.URL, ":"); len(parts) < 3 {
+		panic(srv.URL)
+	} else {
+		port = parts[len(parts)-1]
+	}
+	s.handler.Config.Clusters["zzzzz"].SystemNodes["localhost"] = arvados.SystemNode{
+		Keepstore: arvados.Keepstore{Listen: ":" + port},
+	}
+	s.handler.ServeHTTP(s.resp, s.req)
+	s.checkUnhealthy(c)
+}
+
 func (s *AggregatorSuite) checkError(c *check.C) {
 	c.Check(s.resp.Code, check.Not(check.Equals), http.StatusOK)
 	var body map[string]interface{}
@@ -64,6 +88,14 @@ func (s *AggregatorSuite) checkError(c *check.C) {
 	c.Check(body["health"], check.Not(check.Equals), "OK")
 }
 
+func (s *AggregatorSuite) checkUnhealthy(c *check.C) {
+	c.Check(s.resp.Code, check.Equals, http.StatusOK)
+	var body map[string]interface{}
+	err := json.NewDecoder(s.resp.Body).Decode(&body)
+	c.Check(err, check.IsNil)
+	c.Check(body["health"], check.Equals, "ERROR")
+}
+
 func (s *AggregatorSuite) checkOK(c *check.C) {
 	c.Check(s.resp.Code, check.Equals, http.StatusOK)
 	var body map[string]interface{}

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list