1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
10 "git.arvados.org/arvados.git/lib/config"
11 "git.arvados.org/arvados.git/sdk/go/arvados"
12 "git.arvados.org/arvados.git/sdk/go/ctxlog"
13 "github.com/jmoiron/sqlx"
14 check "gopkg.in/check.v1"
17 // TestMissedCollections exercises EachCollection's sanity check:
18 // #collections processed >= #old collections that exist in database
20 func (s *integrationSuite) TestMissedCollections(c *check.C) {
21 cfg, err := config.NewLoader(nil, ctxlog.TestLogger(c)).Load()
22 c.Assert(err, check.IsNil)
23 cluster, err := cfg.GetCluster("")
24 c.Assert(err, check.IsNil)
25 db, err := sqlx.Open("postgres", cluster.PostgreSQL.Connection.String())
26 c.Assert(err, check.IsNil)
28 defer db.Exec(`delete from collections where uuid = 'zzzzz-4zz18-404040404040404'`)
30 err = EachCollection(context.Background(), db, s.client, func(coll arvados.Collection) error {
33 _, err := db.Exec(`insert into collections (uuid, created_at, updated_at, modified_at) values ('zzzzz-4zz18-404040404040404', '2002-02-02T02:02:02Z', '2002-02-02T02:02:02Z', '2002-02-02T02:02:02Z')`)
38 c.Check(err, check.ErrorMatches, `Retrieved .* collections .* but server now reports .* collections.*`)