def test_write_attr(context): wop = context.write_op_create() wop.setxattr('x', b'y') wop.write_full(b'bar') context.write_op_operate('foo', wop) assert b'y' == context.get_xattr('foo', 'x')
def test_write_attr_cmp_eq_fail(context): context.write_full('foo', b'Hello world!') context.set_xattr('foo', 'version', b'3.14') wop = context.write_op_create() wop.cmpxattr('version', rados.CmpXattrOp.eq, b'2.71') with pytest.raises(rados.Canceled): context.write_op_operate('foo', wop)
def test_write_append(context): context.write_full('foo', b'bar') wop = context.write_op_create() wop.append(b'baz') context.write_op_operate('foo', wop) assert b'barbaz' == context.read('foo')
def test_write_create_fail(context): context.write_full('foo', b'bar') wop = context.write_op_create() wop.create(True) wop.write_full(b'bar') with pytest.raises(rados.ObjectExists): context.write_op_operate('foo', wop)
def test_write_assert(context): context.write_full('foo', b'bar') wop = context.write_op_create() wop.assert_exists() wop.write_full(b'baz') context.write_op_operate('foo', wop) assert b'baz' == context.read('foo')
def test_write_remove(context): context.write_full('foo', b'bar') wop = context.write_op_create() wop.assert_exists() wop.remove() context.write_op_operate('foo', wop) with pytest.raises(rados.ObjectNotFound): context.read('foo')
def test_write_attr_cmp_eq(context): context.write_full('foo', b'Hello world!') context.set_xattr('foo', 'version', b'3.14') wop = context.write_op_create() wop.cmpxattr('version', rados.CmpXattrOp.eq, b'3.14') wop.write_full(b'bar') context.write_op_operate('foo', wop) assert b'bar' == context.read('foo')
def test_write_create(context): try: context.remove('foo') except rados.ObjectNotFound: pass wop = context.write_op_create() wop.create(True) wop.write_full(b'bar') context.write_op_operate('foo', wop) assert b'bar' == context.read('foo')
def test_write_assert_fail(context): try: context.remove('foo') except rados.ObjectNotFound: pass wop = context.write_op_create() wop.assert_exists() wop.write_full(b'baz') with pytest.raises(rados.ObjectNotFound): context.write_op_operate('foo', wop)
def test_omap_write(context): try: context.remove('foo') except rados.ObjectNotFound: pass wop = context.write_op_create() wop.omap_set({'Hello': b'world!'}) context.write_op_operate('foo', wop) assert {'Hello': b'world!'} == dict(context.omap_iter('foo'))
def test_write_completion_safe(context): wop = context.write_op_create() wop.write_full(b'bar') def safe_cb(completion): safe_cb.called = True safe_cb.called = False com = rados.Completion(context, onsafe=safe_cb) context.aio_write_op_operate('foo', wop, com) com.wait_for_safe_and_cb() assert safe_cb.called
def test_omap_sequence(context): try: context.remove('foo') except rados.ObjectNotFound: pass kv = {"test_id:{}".format(i): str(i).encode('utf-8') for i in range(9, -1, -1)} wop = context.write_op_create() wop.omap_set(kv) context.write_op_operate('foo', wop) omaplist = context.omap_iter('foo') for i, (k, v) in enumerate(omaplist): assert 'test_id:{}'.format(i) == k assert str(i).encode('utf-8') == v
def test_write_simple(context): wop = context.write_op_create() wop.write_full(b'bar') context.write_op_operate('foo', wop) assert b'bar' == context.read('foo')