X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/2ab1b540a710fd454f33e9ba22db601e67f3d217..b3b8d695afb1a7624ece94f4c5dcdd671030374e:/services/ws/event_source_test.go diff --git a/services/ws/event_source_test.go b/services/ws/event_source_test.go index b157cfa0eb..ac5d130d61 100644 --- a/services/ws/event_source_test.go +++ b/services/ws/event_source_test.go @@ -1,12 +1,18 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + package main import ( "database/sql" "fmt" + "os" + "path/filepath" "sync" "time" - "git.curoverse.com/arvados.git/sdk/go/config" + "git.curoverse.com/arvados.git/sdk/go/arvados" check "gopkg.in/check.v1" ) @@ -14,30 +20,20 @@ var _ = check.Suite(&eventSourceSuite{}) type eventSourceSuite struct{} -func testDBConfig() pgConfig { - var railsDB struct { - Test struct { - Database string - Username string - Password string - Host string - } - } - err := config.LoadFile(&railsDB, "../api/config/database.yml") +func testDBConfig() arvados.PostgreSQLConnection { + cfg, err := arvados.GetConfig(filepath.Join(os.Getenv("WORKSPACE"), "tmp", "arvados.yml")) if err != nil { panic(err) } - cfg := pgConfig{ - "dbname": railsDB.Test.Database, - "host": railsDB.Test.Host, - "password": railsDB.Test.Password, - "user": railsDB.Test.Username, + cc, err := cfg.GetCluster("zzzzz") + if err != nil { + panic(err) } - return cfg + return cc.PostgreSQL.Connection } func testDB() *sql.DB { - db, err := sql.Open("postgres", testDBConfig().ConnectionString()) + db, err := sql.Open("postgres", testDBConfig().String()) if err != nil { panic(err) } @@ -48,7 +44,7 @@ func (*eventSourceSuite) TestEventSource(c *check.C) { cfg := testDBConfig() db := testDB() pges := &pgEventSource{ - DataSource: cfg.ConnectionString(), + DataSource: cfg.String(), QueueSize: 4, } go pges.Run() @@ -105,4 +101,6 @@ func (*eventSourceSuite) TestEventSource(c *check.C) { case <-time.After(10 * time.Second): c.Fatal("timed out") } + + c.Check(pges.DBHealth(), check.IsNil) }