10666: Added version information to arv-mount & nodemanager
[arvados.git] / services / fuse / tests / test_cache.py
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 import arvados
6 import arvados.collection
7 import arvados_fuse
8 import arvados_fuse.command
9 import json
10 import logging
11 import os
12 import tempfile
13 import unittest
14
15 from .integration_test import IntegrationTest
16 from .mount_test_base import MountTestBase
17
18 class CacheTest(IntegrationTest):
19     mnt_args = ["--by-id", "--directory-cache=0"]
20
21     @IntegrationTest.mount(argv=mnt_args)
22     def test_cache_spill(self):
23         pdh = []
24         for i in range(0, 8):
25             cw = arvados.collection.Collection()
26             f = cw.open("blurg%i" % i, "w")
27             f.write("bloop%i" % i)
28
29             cw.mkdirs("dir%i" % i)
30             f = cw.open("dir%i/blurg" % i, "w")
31             f.write("dirbloop%i" % i)
32
33             cw.save_new()
34             pdh.append(cw.portable_data_hash())
35         self.pool_test(self.mnt, pdh)
36
37     @staticmethod
38     def _test_cache_spill(self, mnt, pdh):
39         for i,v in enumerate(pdh):
40             j = os.path.join(mnt, "by_id", v, "blurg%i" % i)
41             self.assertTrue(os.path.exists(j))
42             j = os.path.join(mnt, "by_id", v, "dir%i/blurg" % i)
43             self.assertTrue(os.path.exists(j))
44
45         for i,v in enumerate(pdh):
46             j = os.path.join(mnt, "by_id", v, "blurg%i" % i)
47             self.assertTrue(os.path.exists(j))
48             j = os.path.join(mnt, "by_id", v, "dir%i/blurg" % i)
49             self.assertTrue(os.path.exists(j))