[ARVADOS] updated: 0940739d41d71154937354696634a2989a9db9fc

Git user git at public.curoverse.com
Tue Jun 6 15:14:20 EDT 2017


Summary of changes:
 services/keep-web/cache_test.go | 49 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 services/keep-web/cache_test.go

       via  0940739d41d71154937354696634a2989a9db9fc (commit)
      from  6fef82432952b78f61c7be80820e88804b3a47d7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 0940739d41d71154937354696634a2989a9db9fc
Author: Tom Clegg <tom at curoverse.com>
Date:   Tue Jun 6 15:12:53 2017 -0400

    11809: Add unit test for cache.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curoverse.com>

diff --git a/services/keep-web/cache_test.go b/services/keep-web/cache_test.go
new file mode 100644
index 0000000..ef3a760
--- /dev/null
+++ b/services/keep-web/cache_test.go
@@ -0,0 +1,49 @@
+package main
+
+import (
+	"git.curoverse.com/arvados.git/sdk/go/arvadosclient"
+	"git.curoverse.com/arvados.git/sdk/go/arvadostest"
+	"gopkg.in/check.v1"
+)
+
+func (s *UnitSuite) TestCache(c *check.C) {
+	arv, err := arvadosclient.MakeArvadosClient()
+	c.Assert(err, check.Equals, nil)
+
+	cache := DefaultConfig().Cache
+
+	// Hit the same collection 5 times using the same token. Only
+	// the first req should cause an API call; the next 4 should
+	// hit all caches.
+	arv.ApiToken = arvadostest.AdminToken
+	for i := 0; i < 5; i++ {
+		coll, err := cache.Get(arv, arvadostest.FooCollection, false)
+		c.Check(err, check.Equals, nil)
+		c.Assert(coll, check.NotNil)
+		c.Check(coll["portable_data_hash"], check.Equals, arvadostest.FooPdh)
+		c.Check(coll["manifest_text"].(string)[:2], check.Equals, ". ")
+	}
+	c.Check(cache.Stats().Requests, check.Equals, uint64(5))
+	c.Check(cache.Stats().CollectionHits, check.Equals, uint64(4))
+	c.Check(cache.Stats().PermissionHits, check.Equals, uint64(4))
+	c.Check(cache.Stats().PDHHits, check.Equals, uint64(4))
+	c.Check(cache.Stats().APICalls, check.Equals, uint64(1))
+
+	// Hit the same collection 2 more times, this time requesting
+	// it by PDH and using a different token. The first req should
+	// miss the permission cache. Both reqs should hit the
+	// Collection cache and skip the API lookup.
+	arv.ApiToken = arvadostest.ActiveToken
+	for i := 0; i < 2; i++ {
+		coll, err := cache.Get(arv, arvadostest.FooPdh, false)
+		c.Check(err, check.Equals, nil)
+		c.Assert(coll, check.NotNil)
+		c.Check(coll["portable_data_hash"], check.Equals, arvadostest.FooPdh)
+		c.Check(coll["manifest_text"].(string)[:2], check.Equals, ". ")
+	}
+	c.Check(cache.Stats().Requests, check.Equals, uint64(7))
+	c.Check(cache.Stats().CollectionHits, check.Equals, uint64(6))
+	c.Check(cache.Stats().PermissionHits, check.Equals, uint64(5))
+	c.Check(cache.Stats().PDHHits, check.Equals, uint64(4))
+	c.Check(cache.Stats().APICalls, check.Equals, uint64(2))
+}

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list