Esempio n. 1
0
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
Esempio n. 2
0
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"
Esempio n. 3
0
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("/")
Esempio n. 4
0
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)
Esempio n. 5
0
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))
Esempio n. 6
0
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)
Esempio n. 7
0
def test_regular_readlink():
	K = KVFS(dict())
	K.create("/blub")
	K.readlink("/blub")
Esempio n. 8
0
def test_noexists_readlink():
	K = KVFS(dict())
	K.readlink("/blub")
Esempio n. 9
0
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"
Esempio n. 10
0
def test_noexists_remove():
	K = KVFS(dict())
	K.remove("/blub")
Esempio n. 11
0
def test_noexists_setattr():
	K = KVFS(dict())
	K.setattr("/blub", "meta")
Esempio n. 12
0
def test_noexists_getattr():
	K = KVFS(dict())
	K.getattr("/blub")
Esempio n. 13
0
def test_double_mkdir():
	K = KVFS(dict())
	K.mkdir("/blub")
	K.mkdir("/blub")
Esempio n. 14
0
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()
Esempio n. 15
0
def test_double_create():
	K = KVFS(dict())
	K.create("/blub")
	K.create("/blub")
Esempio n. 16
0
def test_exists_symlink():
	K = KVFS(dict())
	K.create("/blub")
	K.create("/bla")
	K.symlink("/bla", "/blub")
Esempio n. 17
0
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("/")
Esempio n. 18
0
def test_noexists_rename():
	K = KVFS(dict())
	K.rename("/blub", "/bla")
Esempio n. 19
0
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'])
Esempio n. 20
0
def test_noexists_write():
	K = KVFS(dict())
	K.write("/blub", "bla bla")		
Esempio n. 21
0
def test_dir_write():
	K = KVFS(dict())
	K.mkdir("/blub")
	K.write("/blub", "bla bla")	
Esempio n. 22
0
def test_dirs_read():
	K = KVFS(dict())
	K.mkdir("/blub")
	K.read("/blub")
Esempio n. 23
0
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")
Esempio n. 24
0
def test_noexists_truncate():
	K = KVFS(dict())
	K.truncate("/blub", 5)
Esempio n. 25
0
        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
Esempio n. 26
0
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