Skip to content

Commit

Permalink
Fix OMAP lock test.
Browse files Browse the repository at this point in the history
Fixes ceph#327

Signed-off-by: Gil Bregman <[email protected]>
  • Loading branch information
gbregman committed Nov 19, 2023
1 parent 2616e5f commit 1aa69f5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tests/test_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_create_get_subsys(caplog, config):

for i in range(created_resource_count):
create_resource_by_index(i)
assert "Failed" not in caplog.text
assert "failed" not in caplog.text

caplog.clear()

Expand Down
20 changes: 14 additions & 6 deletions tests/test_omap_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def test_multi_gateway_omap_reread(config, conn, caplog):
assert len(listB) == 1

listA = json.loads(json_format.MessageToJson(
stubB.get_subsystems(get_subsystems_req),
stubA.get_subsystems(get_subsystems_req),
preserving_proto_field_name=True))['subsystems']
assert len(listA) == num_subsystems

Expand Down Expand Up @@ -161,25 +161,31 @@ def test_trying_to_lock_twice(config, image, conn, caplog):
stubA, stubB, gatewayA, gatewayB = conn

with pytest.raises(Exception) as ex:
create_resource_by_index(stubA, 0)
create_resource_by_index(stubB, 1)
create_resource_by_index(stubA, 0, None)
create_resource_by_index(stubB, 1, None)
assert "OMAP file unlock was disabled, will not unlock file" in caplog.text
assert "The OMAP file is locked, will try again in" in caplog.text
assert "Unable to lock OMAP file" in caplog.text
time.sleep(120) # Wait enough time for OMAP lock to be released

def create_resource_by_index(stub, i):
def create_resource_by_index(stub, i, caplog):
bdev = f"{bdev_prefix}{i}"
bdev_req = pb2.create_bdev_req(bdev_name=bdev,
rbd_pool_name=pool,
rbd_image_name=image,
block_size=4096)
ret_bdev = stub.create_bdev(bdev_req)
assert ret_bdev
if caplog != None:
assert f"create_bdev: {bdev}" in caplog.text
assert "create_bdev failed" not in caplog.text
subsystem = f"{subsystem_prefix}{i}"
subsystem_req = pb2.create_subsystem_req(subsystem_nqn=subsystem)
ret_subsystem = stub.create_subsystem(subsystem_req)
assert ret_subsystem
if caplog != None:
assert f"create_subsystem {subsystem}: True" in caplog.text
assert "create_subsystem failed" not in caplog.text
namespace_req = pb2.add_namespace_req(subsystem_nqn=subsystem,
bdev_name=bdev)
ret_namespace = stub.add_namespace(namespace_req)
Expand All @@ -203,10 +209,12 @@ def test_multi_gateway_concurrent_changes(config, image, conn, caplog):
stub = stubA
else:
stub = stubB
create_resource_by_index(stub, i)
assert "Failed" not in caplog.text
create_resource_by_index(stub, i, caplog)
assert "failed" not in caplog.text

# Let the update some time to bring both gateways to the same page
time.sleep(15)
caplog.clear()
cli(["get_subsystems"])
for i in range(created_resource_count):
check_resource_by_index(i, caplog)

0 comments on commit 1aa69f5

Please sign in to comment.