From 1aa69f5dcfa2765dc830c011c74c10ff014ab691 Mon Sep 17 00:00:00 2001 From: Gil Bregman Date: Sun, 19 Nov 2023 15:50:36 +0200 Subject: [PATCH] Fix OMAP lock test. Fixes #327 Signed-off-by: Gil Bregman --- tests/test_grpc.py | 2 +- tests/test_omap_lock.py | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/tests/test_grpc.py b/tests/test_grpc.py index e92a11e37..76acd6e21 100644 --- a/tests/test_grpc.py +++ b/tests/test_grpc.py @@ -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() diff --git a/tests/test_omap_lock.py b/tests/test_omap_lock.py index cd48e08ba..7fb6e1f03 100644 --- a/tests/test_omap_lock.py +++ b/tests/test_omap_lock.py @@ -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 @@ -161,14 +161,14 @@ 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, @@ -176,10 +176,16 @@ def create_resource_by_index(stub, i): 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) @@ -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)