X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/2db0c3a44d8f12e3a566c796bdecaa1de150b155..bd5f21b6a567248d05126d78bab091555764a052:/services/ws/event_source_test.go diff --git a/services/ws/event_source_test.go b/services/ws/event_source_test.go index b157cfa0eb..b7b8ac3006 100644 --- a/services/ws/event_source_test.go +++ b/services/ws/event_source_test.go @@ -1,4 +1,8 @@ -package main +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +package ws import ( "database/sql" @@ -6,7 +10,9 @@ import ( "sync" "time" - "git.curoverse.com/arvados.git/sdk/go/config" + "git.arvados.org/arvados.git/sdk/go/arvados" + "git.arvados.org/arvados.git/sdk/go/ctxlog" + "github.com/prometheus/client_golang/prometheus" 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(arvados.DefaultConfigFile) 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,8 +44,10 @@ func (*eventSourceSuite) TestEventSource(c *check.C) { cfg := testDBConfig() db := testDB() pges := &pgEventSource{ - DataSource: cfg.ConnectionString(), + DataSource: cfg.String(), QueueSize: 4, + Logger: ctxlog.TestLogger(c), + Reg: prometheus.NewRegistry(), } go pges.Run() sinks := make([]eventSink, 18) @@ -105,4 +103,6 @@ func (*eventSourceSuite) TestEventSource(c *check.C) { case <-time.After(10 * time.Second): c.Fatal("timed out") } + + c.Check(pges.DBHealth(), check.IsNil) }