X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/95e5ccacf6c1193b313fa90a6d39baafa2ba67d8..91d40ffe727119f7661e734f9535fd9005880e98:/lib/controller/server_test.go diff --git a/lib/controller/server_test.go b/lib/controller/server_test.go index 7742cf4eae..4f3d4a5683 100644 --- a/lib/controller/server_test.go +++ b/lib/controller/server_test.go @@ -5,28 +5,20 @@ package controller import ( - "bytes" + "context" + "net" "net/http" "os" "path/filepath" + "time" - "git.curoverse.com/arvados.git/sdk/go/arvados" - "git.curoverse.com/arvados.git/sdk/go/httpserver" - "github.com/Sirupsen/logrus" + "git.arvados.org/arvados.git/sdk/go/arvados" + "git.arvados.org/arvados.git/sdk/go/arvadostest" + "git.arvados.org/arvados.git/sdk/go/ctxlog" + "git.arvados.org/arvados.git/sdk/go/httpserver" check "gopkg.in/check.v1" ) -// logWriter is an io.Writer that writes by calling a "write log" -// function, typically (*check.C)Log(). -type logWriter struct { - logfunc func(...interface{}) -} - -func (tl *logWriter) Write(buf []byte) (int, error) { - tl.logfunc(string(bytes.TrimRight(buf, "\n"))) - return len(buf), nil -} - func integrationTestCluster() *arvados.Cluster { cfg, err := arvados.GetConfig(filepath.Join(os.Getenv("WORKSPACE"), "tmp", "arvados.yml")) if err != nil { @@ -42,27 +34,28 @@ func integrationTestCluster() *arvados.Cluster { // Return a new unstarted controller server, using the Rails API // provided by the integration-testing environment. func newServerFromIntegrationTestEnv(c *check.C) *httpserver.Server { - log := logrus.New() - log.Formatter = &logrus.JSONFormatter{} - log.Out = &logWriter{c.Log} - - nodeProfile := arvados.NodeProfile{ - Controller: arvados.SystemServiceInstance{Listen: ":"}, - RailsAPI: arvados.SystemServiceInstance{Listen: os.Getenv("ARVADOS_TEST_API_HOST"), TLS: true, Insecure: true}, - } - handler := &Handler{Cluster: &arvados.Cluster{ - ClusterID: "zzzzz", - PostgreSQL: integrationTestCluster().PostgreSQL, - NodeProfiles: map[string]arvados.NodeProfile{ - "*": nodeProfile, + log := ctxlog.TestLogger(c) + ctx := ctxlog.Context(context.Background(), log) + handler := &Handler{ + Cluster: &arvados.Cluster{ + ClusterID: "zzzzz", + PostgreSQL: integrationTestCluster().PostgreSQL, }, - }, NodeProfile: &nodeProfile} + BackgroundContext: ctx, + } + handler.Cluster.TLS.Insecure = true + handler.Cluster.Collections.BlobSigning = true + handler.Cluster.Collections.BlobSigningKey = arvadostest.BlobSigningKey + handler.Cluster.Collections.BlobSigningTTL = arvados.Duration(time.Hour * 24 * 14) + arvadostest.SetServiceURL(&handler.Cluster.Services.RailsAPI, "https://"+os.Getenv("ARVADOS_TEST_API_HOST")) + arvadostest.SetServiceURL(&handler.Cluster.Services.Controller, "http://localhost:/") srv := &httpserver.Server{ Server: http.Server{ - Handler: httpserver.AddRequestIDs(httpserver.LogRequests(log, handler)), + BaseContext: func(net.Listener) context.Context { return ctx }, + Handler: httpserver.AddRequestIDs(httpserver.LogRequests(handler)), }, - Addr: nodeProfile.Controller.Listen, + Addr: ":", } return srv }