16263: Adds unit test case confirming 'limit' bug.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Wed, 25 Mar 2020 19:35:18 +0000 (16:35 -0300)
committerPeter Amstutz <peter.amstutz@curii.com>
Mon, 13 Apr 2020 15:27:03 +0000 (11:27 -0400)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

lib/controller/federation/list_test.go
lib/controller/federation/user_test.go

index ce84378a3cbb79d7a4ae894f966bc627bef2b08d..e6d2816f610417e9c980ba539930532da768fc7c 100644 (file)
@@ -58,7 +58,7 @@ 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 {
+               if options.Limit >= 0 && int64(len(resp.Items)) >= options.Limit {
                        break
                }
                if cl.matchFilters(c, options.Filters) {
@@ -115,8 +115,8 @@ func (s *CollectionListSuite) SetUpTest(c *check.C) {
 
 type listTrial struct {
        count        string
-       limit        int
-       offset       int
+       limit        int64
+       offset       int64
        order        []string
        filters      []arvados.Filter
        selectfields []string
@@ -314,7 +314,7 @@ func (s *CollectionListSuite) TestCollectionListMultiSiteWithCount(c *check.C) {
 }
 
 func (s *CollectionListSuite) TestCollectionListMultiSiteWithLimit(c *check.C) {
-       for _, limit := range []int{0, 1, 2} {
+       for _, limit := range []int64{0, 1, 2} {
                s.test(c, listTrial{
                        count: "none",
                        limit: limit,
index c087273afef5e7607bb4f78388e521b94a1e6dfa..c55ec24d494eb3ce7df5b3960e23be409759bc7e 100644 (file)
@@ -7,6 +7,7 @@ package federation
 import (
        "encoding/json"
        "errors"
+       "math"
        "net/url"
        "os"
        "strings"
@@ -32,6 +33,7 @@ func (s *UserSuite) TestLoginClusterUserList(c *check.C) {
        for _, updateFail := range []bool{false, true} {
                for _, opts := range []arvados.ListOptions{
                        {Offset: 0, Limit: -1, Select: nil},
+                       {Offset: 0, Limit: math.MaxInt64, Select: nil},
                        {Offset: 1, Limit: 1, Select: nil},
                        {Offset: 0, Limit: 2, Select: []string{"uuid"}},
                        {Offset: 0, Limit: 2, Select: []string{"uuid", "email"}},
@@ -45,6 +47,9 @@ func (s *UserSuite) TestLoginClusterUserList(c *check.C) {
                                s.fed.local = rpc.NewConn(s.cluster.ClusterID, spy.URL, true, rpc.PassthroughTokenProvider)
                        }
                        userlist, err := s.fed.UserList(s.ctx, opts)
+                       if err != nil {
+                               c.Logf("... UserList failed %q", err)
+                       }
                        if updateFail && err == nil {
                                // All local updates fail, so the only
                                // cases expected to succeed are the