1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
13 "git.curoverse.com/arvados.git/sdk/go/arvados"
14 "git.curoverse.com/arvados.git/sdk/go/httpserver"
15 "github.com/sirupsen/logrus"
16 check "gopkg.in/check.v1"
19 // logWriter is an io.Writer that writes by calling a "write log"
20 // function, typically (*check.C)Log().
21 type logWriter struct {
22 logfunc func(...interface{})
25 func (tl *logWriter) Write(buf []byte) (int, error) {
26 tl.logfunc(string(bytes.TrimRight(buf, "\n")))
30 func integrationTestCluster() *arvados.Cluster {
31 cfg, err := arvados.GetConfig(filepath.Join(os.Getenv("WORKSPACE"), "tmp", "arvados.yml"))
35 cc, err := cfg.GetCluster("zzzzz")
42 // Return a new unstarted controller server, using the Rails API
43 // provided by the integration-testing environment.
44 func newServerFromIntegrationTestEnv(c *check.C) *httpserver.Server {
46 log.Formatter = &logrus.JSONFormatter{}
47 log.Out = &logWriter{c.Log}
49 nodeProfile := arvados.NodeProfile{
50 Controller: arvados.SystemServiceInstance{Listen: ":"},
51 RailsAPI: arvados.SystemServiceInstance{Listen: os.Getenv("ARVADOS_TEST_API_HOST"), TLS: true, Insecure: true},
53 handler := &Handler{Cluster: &arvados.Cluster{
55 PostgreSQL: integrationTestCluster().PostgreSQL,
56 NodeProfiles: map[string]arvados.NodeProfile{
59 }, NodeProfile: &nodeProfile}
61 srv := &httpserver.Server{
63 Handler: httpserver.AddRequestIDs(httpserver.LogRequests(log, handler)),
65 Addr: nodeProfile.Controller.Listen,