X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/88c26c6b2dd8752ec1ff8196f4af11369ea6adbb..5c0c6c7daa4f38b26efa7db4e53a0016b45f6416:/sdk/cwl/tests/test_fsaccess.py diff --git a/sdk/cwl/tests/test_fsaccess.py b/sdk/cwl/tests/test_fsaccess.py index 43956617a1..d52e948710 100644 --- a/sdk/cwl/tests/test_fsaccess.py +++ b/sdk/cwl/tests/test_fsaccess.py @@ -1,3 +1,7 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: Apache-2.0 + import functools import mock import sys @@ -26,3 +30,79 @@ class TestFsAccess(unittest.TestCase): self.assertEqual(1, cr.call_count) c3 = cache.get("99999999999999999999999999999992+99") self.assertEqual(2, cr.call_count) + + @mock.patch("arvados.collection.CollectionReader") + def test_collection_cache_limit(self, cr): + cache = CollectionCache(mock.MagicMock(), mock.MagicMock(), 4) + cr().manifest_text.return_value = 'x' * 524289 + self.assertEqual(0, cache.total) + c1 = cache.get("99999999999999999999999999999991+99") + self.assertIn("99999999999999999999999999999991+99", cache.collections) + self.assertNotIn("99999999999999999999999999999992+99", cache.collections) + self.assertEqual((524289*128)*1, cache.total) + + c2 = cache.get("99999999999999999999999999999992+99") + self.assertIn("99999999999999999999999999999991+99", cache.collections) + self.assertIn("99999999999999999999999999999992+99", cache.collections) + self.assertEqual((524289*128)*2, cache.total) + + c1 = cache.get("99999999999999999999999999999991+99") + self.assertIn("99999999999999999999999999999991+99", cache.collections) + self.assertIn("99999999999999999999999999999992+99", cache.collections) + self.assertEqual((524289*128)*2, cache.total) + + c3 = cache.get("99999999999999999999999999999993+99") + self.assertIn("99999999999999999999999999999991+99", cache.collections) + self.assertIn("99999999999999999999999999999992+99", cache.collections) + self.assertEqual((524289*128)*3, cache.total) + + c4 = cache.get("99999999999999999999999999999994+99") + self.assertIn("99999999999999999999999999999991+99", cache.collections) + self.assertNotIn("99999999999999999999999999999992+99", cache.collections) + self.assertEqual((524289*128)*3, cache.total) + + c5 = cache.get("99999999999999999999999999999995+99") + self.assertNotIn("99999999999999999999999999999991+99", cache.collections) + self.assertNotIn("99999999999999999999999999999992+99", cache.collections) + self.assertEqual((524289*128)*3, cache.total) + + + @mock.patch("arvados.collection.CollectionReader") + def test_collection_cache_limit2(self, cr): + cache = CollectionCache(mock.MagicMock(), mock.MagicMock(), 4) + cr().manifest_text.return_value = 'x' * 524287 + self.assertEqual(0, cache.total) + c1 = cache.get("99999999999999999999999999999991+99") + self.assertIn("99999999999999999999999999999991+99", cache.collections) + self.assertNotIn("99999999999999999999999999999992+99", cache.collections) + self.assertEqual((524287*128)*1, cache.total) + + c2 = cache.get("99999999999999999999999999999992+99") + self.assertIn("99999999999999999999999999999991+99", cache.collections) + self.assertIn("99999999999999999999999999999992+99", cache.collections) + self.assertEqual((524287*128)*2, cache.total) + + c1 = cache.get("99999999999999999999999999999991+99") + self.assertIn("99999999999999999999999999999991+99", cache.collections) + self.assertIn("99999999999999999999999999999992+99", cache.collections) + self.assertEqual((524287*128)*2, cache.total) + + c3 = cache.get("99999999999999999999999999999993+99") + self.assertIn("99999999999999999999999999999991+99", cache.collections) + self.assertIn("99999999999999999999999999999992+99", cache.collections) + self.assertEqual((524287*128)*3, cache.total) + + c4 = cache.get("99999999999999999999999999999994+99") + self.assertIn("99999999999999999999999999999991+99", cache.collections) + self.assertIn("99999999999999999999999999999992+99", cache.collections) + self.assertEqual((524287*128)*4, cache.total) + + c5 = cache.get("99999999999999999999999999999995+99") + self.assertIn("99999999999999999999999999999991+99", cache.collections) + self.assertNotIn("99999999999999999999999999999992+99", cache.collections) + self.assertEqual((524287*128)*4, cache.total) + + c6 = cache.get("99999999999999999999999999999996+99") + self.assertNotIn("99999999999999999999999999999991+99", cache.collections) + self.assertNotIn("99999999999999999999999999999992+99", cache.collections) + self.assertEqual((524287*128)*4, cache.total)