Merge branch 'master' into 13937-keepstore-prometheus
[arvados.git] / lib / controller / server_test.go
index 2ad9222447ec81c9e1cc655781351f6a36ac4fd1..ae89c3d7ea4d073fa44885f193af138f81b85508 100644 (file)
@@ -7,37 +7,38 @@ package controller
 import (
        "net/http"
        "os"
+       "path/filepath"
 
        "git.curoverse.com/arvados.git/sdk/go/arvados"
+       "git.curoverse.com/arvados.git/sdk/go/ctxlog"
        "git.curoverse.com/arvados.git/sdk/go/httpserver"
-       "github.com/Sirupsen/logrus"
        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(buf))
-       return len(buf), nil
+func integrationTestCluster() *arvados.Cluster {
+       cfg, err := arvados.GetConfig(filepath.Join(os.Getenv("WORKSPACE"), "tmp", "arvados.yml"))
+       if err != nil {
+               panic(err)
+       }
+       cc, err := cfg.GetCluster("zzzzz")
+       if err != nil {
+               panic(err)
+       }
+       return cc
 }
 
 // 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}
+       log := ctxlog.TestLogger(c)
 
        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",
+               ClusterID:  "zzzzz",
+               PostgreSQL: integrationTestCluster().PostgreSQL,
                NodeProfiles: map[string]arvados.NodeProfile{
                        "*": nodeProfile,
                },