[ARVADOS] created: dc929c778e967d626bf065554e1403f002f7cf03
Git user
git at public.curoverse.com
Wed Jul 26 16:30:44 EDT 2017
at dc929c778e967d626bf065554e1403f002f7cf03 (commit)
commit dc929c778e967d626bf065554e1403f002f7cf03
Author: radhika <radhika at curoverse.com>
Date: Wed Jul 26 16:30:14 2017 -0400
11906: add /_health/ping to arv-git-httpd
Arvados-DCO-1.1-Signed-off-by: Radhika Chippada <radhika at curoverse.com>
diff --git a/services/arv-git-httpd/integration_test.go b/services/arv-git-httpd/integration_test.go
index 6a2b640..10c69ee 100644
--- a/services/arv-git-httpd/integration_test.go
+++ b/services/arv-git-httpd/integration_test.go
@@ -77,9 +77,10 @@ func (s *IntegrationSuite) SetUpTest(c *check.C) {
APIHost: arvadostest.APIHost(),
Insecure: true,
},
- Listen: ":0",
- GitCommand: "/usr/bin/git",
- RepoRoot: s.tmpRepoRoot,
+ Listen: ":0",
+ GitCommand: "/usr/bin/git",
+ RepoRoot: s.tmpRepoRoot,
+ ManagementToken: arvadostest.ManagementToken,
}
}
diff --git a/services/arv-git-httpd/main.go b/services/arv-git-httpd/main.go
index bee0269..79a3eb3 100644
--- a/services/arv-git-httpd/main.go
+++ b/services/arv-git-httpd/main.go
@@ -18,11 +18,12 @@ import (
// Server configuration
type Config struct {
- Client arvados.Client
- Listen string
- GitCommand string
- RepoRoot string
- GitoliteHome string
+ Client arvados.Client
+ Listen string
+ GitCommand string
+ RepoRoot string
+ GitoliteHome string
+ ManagementToken string
}
var theConfig = defaultConfig()
@@ -49,6 +50,10 @@ func main() {
cfgPath := flag.String("config", defaultCfgPath, "Configuration file `path`.")
dumpConfig := flag.Bool("dump-config", false, "write current configuration to stdout and exit (useful for migrating from command line flags to config file)")
+
+ flag.StringVar(&theConfig.ManagementToken, "management-token", theConfig.ManagementToken,
+ "Authorization token to be included in all health check requests.")
+
flag.Usage = usage
flag.Parse()
diff --git a/services/arv-git-httpd/server.go b/services/arv-git-httpd/server.go
index 8a7819a..8f0d90f 100644
--- a/services/arv-git-httpd/server.go
+++ b/services/arv-git-httpd/server.go
@@ -7,6 +7,7 @@ package main
import (
"net/http"
+ "git.curoverse.com/arvados.git/sdk/go/health"
"git.curoverse.com/arvados.git/sdk/go/httpserver"
)
@@ -17,6 +18,10 @@ type server struct {
func (srv *server) Start() error {
mux := http.NewServeMux()
mux.Handle("/", &authHandler{handler: newGitHandler()})
+ mux.Handle("/_health/", &health.Handler{
+ Token: theConfig.ManagementToken,
+ Prefix: "/_health/",
+ })
srv.Handler = mux
srv.Addr = theConfig.Listen
return srv.Server.Start()
diff --git a/services/arv-git-httpd/server_test.go b/services/arv-git-httpd/server_test.go
index 4533601..b4fc532 100644
--- a/services/arv-git-httpd/server_test.go
+++ b/services/arv-git-httpd/server_test.go
@@ -5,9 +5,13 @@
package main
import (
+ "net/http"
+ "net/http/httptest"
"os"
"os/exec"
+ "git.curoverse.com/arvados.git/sdk/go/arvadostest"
+
check "gopkg.in/check.v1"
)
@@ -104,3 +108,16 @@ func (s *GitSuite) makeArvadosRepo(c *check.C) {
c.Log(string(msg))
c.Assert(err, check.Equals, nil)
}
+
+func (s *GitSuite) TestHealthCheckPing(c *check.C) {
+ req, err := http.NewRequest("GET",
+ "http://"+s.testServer.Addr+"/_health/ping",
+ nil)
+ c.Assert(err, check.Equals, nil)
+ req.Header.Set("Authorization", "Bearer "+arvadostest.ManagementToken)
+
+ resp := httptest.NewRecorder()
+ s.testServer.Handler.ServeHTTP(resp, req)
+ c.Check(resp.Code, check.Equals, 200)
+ c.Check(resp.Body.String(), check.Matches, `{"health":"OK"}\n`)
+}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list