github.com/yasker/longhorn-engine@v0.0.0-20160621014712-6ed6cfca0729/integration/data/test_basic_ops.py (about) 1 import random 2 3 import pytest 4 import cattle 5 6 import common 7 from common import dev # NOQA 8 from common import SIZE, read_dev, write_dev 9 10 11 def test_basic_rw(dev): # NOQA 12 for i in range(0, 10): 13 offset = random.randint(0, SIZE - 256) 14 length = random.randint(0, 256) 15 data = common.random_string(length) 16 common.verify_data(dev, offset, data) 17 18 19 # See also BUG: https://github.com/rancher/longhorn/issues/131 20 def test_beyond_boundary(dev): # NOQA 21 # check write at the boundary 22 data = common.random_string(128) 23 common.verify_data(dev, SIZE - 128, data) 24 25 # out of bounds 26 with pytest.raises(cattle.ApiError) as err: 27 write_dev(dev, SIZE, "1") 28 assert 'EOF' in str(err.value) 29 with pytest.raises(cattle.ApiError) as err: 30 read_dev(dev, SIZE, 1) 31 assert 'EOF' in str(err.value) 32 33 # normal writes to verify controller/replica survival 34 for i in range(0, 10): 35 offset = random.randint(0, SIZE - 256) 36 length = random.randint(0, 256) 37 data = common.random_string(length) 38 common.verify_data(dev, offset, data)