21720: removed material-ui-pickers, built replacement
[arvados.git] / services / keep-balance / collection_test.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 package keepbalance
6
7 import (
8         "context"
9
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"
15 )
16
17 // TestMissedCollections exercises EachCollection's sanity check:
18 // #collections processed >= #old collections that exist in database
19 // after processing.
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)
27
28         defer db.Exec(`delete from collections where uuid = 'zzzzz-4zz18-404040404040404'`)
29         insertedOld := false
30         err = EachCollection(context.Background(), db, s.client, func(coll arvados.Collection) error {
31                 if !insertedOld {
32                         insertedOld = true
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')`)
34                         return err
35                 }
36                 return nil
37         }, nil)
38         c.Check(err, check.ErrorMatches, `Retrieved .* collections .* but server now reports .* collections.*`)
39 }