[ARVADOS] updated: 1.3.0-1459-gf248e1966

Git user git at public.curoverse.com
Fri Aug 9 19:27:45 UTC 2019


Summary of changes:
 services/keepproxy/keepproxy.go      | 22 ++++++++++-----
 services/keepproxy/keepproxy_test.go | 52 +++++++++++++++++++++---------------
 2 files changed, 45 insertions(+), 29 deletions(-)

       via  f248e19664fec1268e2a736d698acfbd6147016e (commit)
      from  47d4b25da3ee62b641aa3026adf38adc22b3b65c (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 f248e19664fec1268e2a736d698acfbd6147016e
Author: Eric Biagiotti <ebiagiotti at veritasgenetics.com>
Date:   Fri Aug 9 15:27:38 2019 -0400

    14715: Fixes keepproxy tests
    
    Arvados-DCO-1.1-Signed-off-by: Eric Biagiotti <ebiagiotti at veritasgenetics.com>

diff --git a/services/keepproxy/keepproxy.go b/services/keepproxy/keepproxy.go
index f75079565..f2a89e58e 100644
--- a/services/keepproxy/keepproxy.go
+++ b/services/keepproxy/keepproxy.go
@@ -27,9 +27,9 @@ import (
 	"git.curoverse.com/arvados.git/sdk/go/httpserver"
 	"git.curoverse.com/arvados.git/sdk/go/keepclient"
 	"github.com/coreos/go-systemd/daemon"
+	"github.com/ghodss/yaml"
 	"github.com/gorilla/mux"
 	log "github.com/sirupsen/logrus"
-	"gopkg.in/yaml.v2"
 )
 
 var version = "dev"
@@ -97,6 +97,14 @@ func main() {
 
 	log.Printf("keepproxy %s started", version)
 
+	if err := run(logger, cluster); err != nil {
+		log.Fatal(err)
+	}
+
+	log.Println("shutting down")
+}
+
+func run(logger log.FieldLogger, cluster *arvados.Cluster) error {
 	client, err := arvados.NewClientFromConfig(cluster)
 	if err != nil {
 		log.Fatal(err)
@@ -125,9 +133,11 @@ func main() {
 	for listen = range cluster.Services.Keepproxy.InternalURLs {
 		break
 	}
-	listener, err := net.Listen("tcp", listen.Host)
-	if err != nil {
-		log.Fatalf("listen(%s): %s", listen.Host, err)
+
+	var lErr error
+	listener, lErr = net.Listen("tcp", listen.Host)
+	if lErr != nil {
+		log.Fatalf("listen(%s): %s", listen.Host, lErr)
 	}
 
 	if _, err := daemon.SdNotify(false, "READY=1"); err != nil {
@@ -148,9 +158,7 @@ func main() {
 
 	// Start serving requests.
 	router = MakeRESTRouter(kc, time.Duration(cluster.API.KeepServiceRequestTimeout), cluster.SystemRootToken)
-	http.Serve(listener, httpserver.AddRequestIDs(httpserver.LogRequests(router)))
-
-	log.Println("shutting down")
+	return http.Serve(listener, httpserver.AddRequestIDs(httpserver.LogRequests(router)))
 }
 
 type ApiTokenCache struct {
diff --git a/services/keepproxy/keepproxy_test.go b/services/keepproxy/keepproxy_test.go
index 440bf5b8a..5f19c8c1f 100644
--- a/services/keepproxy/keepproxy_test.go
+++ b/services/keepproxy/keepproxy_test.go
@@ -13,15 +13,17 @@ import (
 	"math/rand"
 	"net/http"
 	"net/http/httptest"
-	"os"
 	"strings"
 	"sync"
 	"testing"
 	"time"
 
+	"git.curoverse.com/arvados.git/lib/config"
+	"git.curoverse.com/arvados.git/sdk/go/arvados"
 	"git.curoverse.com/arvados.git/sdk/go/arvadosclient"
 	"git.curoverse.com/arvados.git/sdk/go/arvadostest"
 	"git.curoverse.com/arvados.git/sdk/go/keepclient"
+	log "github.com/sirupsen/logrus"
 
 	. "gopkg.in/check.v1"
 )
@@ -96,14 +98,20 @@ func (s *NoKeepServerSuite) TearDownSuite(c *C) {
 	arvadostest.StopAPI()
 }
 
-func runProxy(c *C, args []string, bogusClientToken bool) *keepclient.KeepClient {
-	args = append([]string{"keepproxy"}, args...)
-	os.Args = append(args, "-listen=:0")
+func runProxy(c *C, bogusClientToken bool) *keepclient.KeepClient {
+	cfg, err := config.NewLoader(nil, nil).Load()
+	c.Assert(err, Equals, nil)
+	cluster, err := cfg.GetCluster("")
+	c.Assert(err, Equals, nil)
+
+	cluster.Services.Keepproxy.InternalURLs = map[arvados.URL]arvados.ServiceInstance{arvados.URL{Host: ":0"}: arvados.ServiceInstance{}}
+
 	listener = nil
-	go main()
+	go run(log.New(), cluster)
 	waitForListener()
 
-	arv, err := arvadosclient.MakeArvadosClient()
+	client := arvados.NewClientFromEnv()
+	arv, err := arvadosclient.New(client)
 	c.Assert(err, Equals, nil)
 	if bogusClientToken {
 		arv.ApiToken = "bogus-token"
@@ -119,7 +127,7 @@ func runProxy(c *C, args []string, bogusClientToken bool) *keepclient.KeepClient
 }
 
 func (s *ServerRequiredSuite) TestResponseViaHeader(c *C) {
-	runProxy(c, nil, false)
+	runProxy(c, false)
 	defer closeListener()
 
 	req, err := http.NewRequest("POST",
@@ -145,7 +153,7 @@ func (s *ServerRequiredSuite) TestResponseViaHeader(c *C) {
 }
 
 func (s *ServerRequiredSuite) TestLoopDetection(c *C) {
-	kc := runProxy(c, nil, false)
+	kc := runProxy(c, false)
 	defer closeListener()
 
 	sr := map[string]string{
@@ -163,7 +171,7 @@ func (s *ServerRequiredSuite) TestLoopDetection(c *C) {
 }
 
 func (s *ServerRequiredSuite) TestStorageClassesHeader(c *C) {
-	kc := runProxy(c, nil, false)
+	kc := runProxy(c, false)
 	defer closeListener()
 
 	// Set up fake keepstore to record request headers
@@ -190,7 +198,7 @@ func (s *ServerRequiredSuite) TestStorageClassesHeader(c *C) {
 }
 
 func (s *ServerRequiredSuite) TestDesiredReplicas(c *C) {
-	kc := runProxy(c, nil, false)
+	kc := runProxy(c, false)
 	defer closeListener()
 
 	content := []byte("TestDesiredReplicas")
@@ -207,7 +215,7 @@ func (s *ServerRequiredSuite) TestDesiredReplicas(c *C) {
 }
 
 func (s *ServerRequiredSuite) TestPutWrongContentLength(c *C) {
-	kc := runProxy(c, nil, false)
+	kc := runProxy(c, false)
 	defer closeListener()
 
 	content := []byte("TestPutWrongContentLength")
@@ -246,7 +254,7 @@ func (s *ServerRequiredSuite) TestPutWrongContentLength(c *C) {
 }
 
 func (s *ServerRequiredSuite) TestManyFailedPuts(c *C) {
-	kc := runProxy(c, nil, false)
+	kc := runProxy(c, false)
 	defer closeListener()
 	router.(*proxyHandler).timeout = time.Nanosecond
 
@@ -273,7 +281,7 @@ func (s *ServerRequiredSuite) TestManyFailedPuts(c *C) {
 }
 
 func (s *ServerRequiredSuite) TestPutAskGet(c *C) {
-	kc := runProxy(c, nil, false)
+	kc := runProxy(c, false)
 	defer closeListener()
 
 	hash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
@@ -350,7 +358,7 @@ func (s *ServerRequiredSuite) TestPutAskGet(c *C) {
 }
 
 func (s *ServerRequiredSuite) TestPutAskGetForbidden(c *C) {
-	kc := runProxy(c, nil, true)
+	kc := runProxy(c, true)
 	defer closeListener()
 
 	hash := fmt.Sprintf("%x+3", md5.Sum([]byte("bar")))
@@ -376,7 +384,7 @@ func (s *ServerRequiredSuite) TestPutAskGetForbidden(c *C) {
 }
 
 func (s *ServerRequiredSuite) TestCorsHeaders(c *C) {
-	runProxy(c, nil, false)
+	runProxy(c, false)
 	defer closeListener()
 
 	{
@@ -407,7 +415,7 @@ func (s *ServerRequiredSuite) TestCorsHeaders(c *C) {
 }
 
 func (s *ServerRequiredSuite) TestPostWithoutHash(c *C) {
-	runProxy(c, nil, false)
+	runProxy(c, false)
 	defer closeListener()
 
 	{
@@ -450,7 +458,7 @@ func (s *ServerRequiredSuite) TestStripHint(c *C) {
 //   With a valid but non-existing prefix (expect "\n")
 //   With an invalid prefix (expect error)
 func (s *ServerRequiredSuite) TestGetIndex(c *C) {
-	kc := runProxy(c, nil, false)
+	kc := runProxy(c, false)
 	defer closeListener()
 
 	// Put "index-data" blocks
@@ -513,7 +521,7 @@ func (s *ServerRequiredSuite) TestGetIndex(c *C) {
 }
 
 func (s *ServerRequiredSuite) TestCollectionSharingToken(c *C) {
-	kc := runProxy(c, nil, false)
+	kc := runProxy(c, false)
 	defer closeListener()
 	hash, _, err := kc.PutB([]byte("shareddata"))
 	c.Check(err, IsNil)
@@ -526,7 +534,7 @@ func (s *ServerRequiredSuite) TestCollectionSharingToken(c *C) {
 }
 
 func (s *ServerRequiredSuite) TestPutAskGetInvalidToken(c *C) {
-	kc := runProxy(c, nil, false)
+	kc := runProxy(c, false)
 	defer closeListener()
 
 	// Put a test block
@@ -563,7 +571,7 @@ func (s *ServerRequiredSuite) TestPutAskGetInvalidToken(c *C) {
 }
 
 func (s *ServerRequiredSuite) TestAskGetKeepProxyConnectionError(c *C) {
-	kc := runProxy(c, nil, false)
+	kc := runProxy(c, false)
 	defer closeListener()
 
 	// Point keepproxy at a non-existent keepstore
@@ -589,7 +597,7 @@ func (s *ServerRequiredSuite) TestAskGetKeepProxyConnectionError(c *C) {
 }
 
 func (s *NoKeepServerSuite) TestAskGetNoKeepServerError(c *C) {
-	kc := runProxy(c, nil, false)
+	kc := runProxy(c, false)
 	defer closeListener()
 
 	hash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
@@ -612,7 +620,7 @@ func (s *NoKeepServerSuite) TestAskGetNoKeepServerError(c *C) {
 }
 
 func (s *ServerRequiredSuite) TestPing(c *C) {
-	kc := runProxy(c, nil, false)
+	kc := runProxy(c, false)
 	defer closeListener()
 
 	rtr := MakeRESTRouter(kc, 10*time.Second, arvadostest.ManagementToken)

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list