14287: Fix non-federated case in list handler.
authorTom Clegg <tclegg@veritasgenetics.com>
Thu, 31 Oct 2019 15:33:30 +0000 (11:33 -0400)
committerTom Clegg <tclegg@veritasgenetics.com>
Thu, 31 Oct 2019 15:33:30 +0000 (11:33 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>

lib/controller/federation/list.go
lib/controller/federation/list_test.go

index 414870d24f5c42912785c4b29efa1fe4f91ec786..6ba184c471a1f4df37493520d7df9c46c7fcfaf7 100644 (file)
@@ -139,6 +139,13 @@ func (conn *Conn) splitListRequest(ctx context.Context, opts arvados.ListOptions
                }
        }
 
+       if matchAllFilters == nil {
+               // Not filtering by UUID at all; just query the local
+               // cluster.
+               _, err := fn(ctx, conn.cluster.ClusterID, conn.local, opts)
+               return err
+       }
+
        // Collate UUIDs in matchAllFilters by remote cluster ID --
        // e.g., todoByRemote["aaaaa"]["aaaaa-4zz18-000000000000000"]
        // will be true -- and count the total number of UUIDs we're
index b28609c2d5e961ea2c38188c9f13e91f941bc87f..e9e8950b992e498d072d87be18cfd8737c312f39 100644 (file)
@@ -117,6 +117,9 @@ func (cl *collectionLister) CollectionList(ctx context.Context, options arvados.
                if cl.MaxPageSize > 0 && len(resp.Items) >= cl.MaxPageSize {
                        break
                }
+               if options.Limit >= 0 && len(resp.Items) >= options.Limit {
+                       break
+               }
                if cl.matchFilters(c, options.Filters) {
                        resp.Items = append(resp.Items, c)
                }
@@ -173,6 +176,15 @@ type listTrial struct {
        expectStatus int
 }
 
+func (s *CollectionListSuite) TestCollectionListNoUUIDFilters(c *check.C) {
+       s.test(c, listTrial{
+               count:       "none",
+               limit:       1,
+               expectUUIDs: []string{s.uuids[0][0]},
+               expectCalls: []int{1, 0, 0},
+       })
+}
+
 func (s *CollectionListSuite) TestCollectionListOneLocal(c *check.C) {
        s.test(c, listTrial{
                count:       "none",
@@ -433,6 +445,6 @@ func (s *CollectionListSuite) test(c *check.C, trial listTrial) {
                        continue
                }
                opts := calls[0].Options.(arvados.ListOptions)
-               c.Check(opts.Limit, check.Equals, -1)
+               c.Check(opts.Limit, check.Equals, trial.limit)
        }
 }