def test_basic_root(): """testing basic root properties""" K = KVFS(dict()) attr = K.getattr("/") assert stat.S_ISDIR(attr['st_mode']) dir = list(K.readdir("/")) assert len(dir) == 2 assert '.' in dir assert '..' in dir
def test_truncate(): K = KVFS(dict()) K.create("/blub") K.write("/blub", "hello world") K.truncate("/blub", 5) data = K.read("/blub", 10) assert data == "hello"
def test_used_root(): K = KVFS(dict()) attr = K.getattr("/") assert stat.S_ISDIR(attr['st_mode']) K.mkdir("/bla") K.remove("/bla") K.getattr("/")
def test_hardlink(): msg = "Hello Wörld!" K = KVFS(dict()) K.create("/blub") K.write("/blub", msg) K.link("/bla", "/blub") # This doesn't work if 'write' and 'link' order is changed, # but that problem is a deeper one. msg2 = K.read("/bla", len(msg)) assert msg == msg2, (msg, msg2)
def test_sizes(): msg = "tis is äi dest mässätsch" K = KVFS(dict()) K.create("/blub") attr = K.getattr("/blub") assert attr['st_size'] == 0, attr['st_size'] K.write("/blub", msg) attr = K.getattr("/blub") assert attr['st_size'] == len(msg), (attr['st_size'], len(msg))
def test_basic_readwrite(): msg = "Hello Wörld!" K = KVFS(dict()) K.create("/blub") K.write("/blub", msg, 0) msg2 = K.read("/blub", len(msg), 0) assert msg == msg2, (msg, msg2)
def test_regular_readlink(): K = KVFS(dict()) K.create("/blub") K.readlink("/blub")
def test_noexists_readlink(): K = KVFS(dict()) K.readlink("/blub")
def test_symlink(): K = KVFS(dict()) K.create("/blub") K.symlink("/bla", "/blub") assert stat.S_ISLNK(K.getattr("/bla")['st_mode']) assert K.readlink("/bla") == "/blub"
def test_noexists_remove(): K = KVFS(dict()) K.remove("/blub")
def test_noexists_setattr(): K = KVFS(dict()) K.setattr("/blub", "meta")
def test_noexists_getattr(): K = KVFS(dict()) K.getattr("/blub")
def test_double_mkdir(): K = KVFS(dict()) K.mkdir("/blub") K.mkdir("/blub")
def test_basic_file(): """testing basic file properties""" K = KVFS(dict()) K.create("/blub") assert "blub" in K.readdir("/") attr = K.getattr("/blub") assert stat.S_ISREG(attr['st_mode']) K.remove("/blub") print list(K.readdir("/")) assert not "blub" in K.readdir("/") K.flush()
def test_double_create(): K = KVFS(dict()) K.create("/blub") K.create("/blub")
def test_exists_symlink(): K = KVFS(dict()) K.create("/blub") K.create("/bla") K.symlink("/bla", "/blub")
def test_basic_dir(): """testing basic directory properties""" K = KVFS(dict()) K.mkdir("/bla") assert "bla" in K.readdir("/") assert stat.S_ISDIR(K.getattr("/bla")['st_mode']) dir = list(K.readdir("/bla")) assert '.' in dir assert '..' in dir K.remove("/bla") assert not "bla" in K.readdir("/") K.flush("/")
def test_noexists_rename(): K = KVFS(dict()) K.rename("/blub", "/bla")
def test_dir_operations(): K = KVFS(dict()) assert stat.S_ISDIR(K.getattr("/")['st_mode']) K.mkdir("/bla") assert "bla" in K.readdir("/") K.create("/bla/blub") assert "blub" in K.readdir("/bla") assert stat.S_ISREG(K.getattr("/bla/blub")['st_mode']) K.remove("/bla") assert not "bla" in K.readdir("/") assert stat.S_ISDIR(K.getattr("/")['st_mode'])
def test_noexists_write(): K = KVFS(dict()) K.write("/blub", "bla bla")
def test_dir_write(): K = KVFS(dict()) K.mkdir("/blub") K.write("/blub", "bla bla")
def test_dirs_read(): K = KVFS(dict()) K.mkdir("/blub") K.read("/blub")
def test_rename(): K = KVFS(dict()) K.mkdir("/sub") K.rename("/sub", "/dir") assert "dir" in K.readdir("/") assert not "sub" in K.readdir("/") # and again with changing directory K.create("/dir/sub") assert "sub" in K.readdir("/dir") K.rename("/dir/sub", "/blub") assert "blub" in K.readdir("/") assert not "sub" in K.readdir("/dir")
def test_noexists_truncate(): K = KVFS(dict()) K.truncate("/blub", 5)
print "fsdestroy" def flush(self, path, fh=None): print "flush", path def fsync(self, path, fdatasync, fh=None): print "fsync", path, fdatasync def ftruncate(self, path, len, fh=None): print "ftruncate", path, len def fsyncdir(self, path, fdatasync, fh=None): print "fsyncdir", path, fdatasync if __name__ == "__main__": from kvfs import KVFS from scalaris_dict import scalaris_dict kv = scalaris_dict("http://localhost:8000/jsonrpc.yaws") kv = dict() core = KVFS(kv) import sys if len(sys.argv) < 2: print 'usage: %s <mountpoint> [fuse options]' % sys.argv[0] sys.exit(1) fs = MyFuseFS(core) fs.parse(sys.argv) fs.main() print kv
def test_attributes(): K = KVFS(dict()) K.create("/blub") attr = K.getattr("/blub") assert not 'extended' in attr attr['extended'] = "grins" K.setattr("/blub", attr) attr = K.getattr("/blub") assert 'extended' in attr assert attr['extended'] == "grins" del attr['extended'] K.setattr("/blub", attr) attr = K.getattr("/blub") assert not 'extended' in attr