13431: Adds test confirming that keepproxy propagates X-Keep-Storage-Classes
authorLucas Di Pentima <ldipentima@veritasgenetics.com>
Tue, 5 Jun 2018 18:22:18 +0000 (15:22 -0300)
committerLucas Di Pentima <ldipentima@veritasgenetics.com>
Tue, 5 Jun 2018 18:22:18 +0000 (15:22 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima@veritasgenetics.com>

services/keepproxy/keepproxy_test.go

index 65e22e3b3ed3d761530089a33d2cd712dc9550b4..9b58c394b58750c0c2944fe3a252f5fc1b113699 100644 (file)
@@ -162,6 +162,36 @@ func (s *ServerRequiredSuite) TestLoopDetection(c *C) {
        c.Check(err, ErrorMatches, `.*loop detected.*`)
 }
 
+func (s *ServerRequiredSuite) TestStorageClassesHeader(c *C) {
+       kc := runProxy(c, nil, false)
+       defer closeListener()
+
+       // Set up fake keepstore to record request headers
+       var hdr http.Header
+       ts := httptest.NewServer(http.HandlerFunc(
+               func(w http.ResponseWriter, r *http.Request) {
+                       hdr = r.Header
+                       http.Error(w, "Error", http.StatusInternalServerError)
+               }))
+       defer ts.Close()
+
+       // Point keepproxy router's keepclient to the fake keepstore
+       sr := map[string]string{
+               TestProxyUUID: ts.URL,
+       }
+       router.(*proxyHandler).KeepClient.SetServiceRoots(sr, sr, sr)
+
+       // Set up client to ask for storage classes to keepproxy
+       kc.StorageClasses = []string{"secure"}
+       content := []byte("Very important data")
+       _, _, err := kc.PutB(content)
+       c.Check(err, NotNil)
+       // errNotFound, _ := err.(*keepclient.ErrNotFound)
+       // c.Check(errNotFound.Temporary(), Equals, true)
+       // c.Assert(err, ErrorMatches, ".*connection refused.*")
+       c.Check(hdr.Get("X-Keep-Storage-Classes"), Equals, "secure")
+}
+
 func (s *ServerRequiredSuite) TestDesiredReplicas(c *C) {
        kc := runProxy(c, nil, false)
        defer closeListener()