-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a lock for GRPC calls to prevent corruption and exceptions on gat…
…eway restart. Fixes #255 Signed-off-by: Gil Bregman <[email protected]>
- Loading branch information
Showing
3 changed files
with
139 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import pytest | ||
import time | ||
from control.server import GatewayServer | ||
from control.cli import main as cli | ||
import logging | ||
import warnings | ||
|
||
# Set up a logger | ||
logger = logging.getLogger(__name__) | ||
image = "mytestdevimage" | ||
pool = "rbd" | ||
bdev_prefix = "Ceph0" | ||
subsystem_prefix = "nqn.2016-06.io.spdk:cnode" | ||
created_resource_count = 300 | ||
get_subsys_count = 200 | ||
|
||
def create_resource_by_index(i): | ||
bdev = f"{bdev_prefix}_{i}" | ||
cli(["create_bdev", "-i", image, "-p", pool, "-b", bdev]) | ||
subsystem = f"{subsystem_prefix}{i}" | ||
cli(["create_subsystem", "-n", subsystem ]) | ||
cli(["add_namespace", "-n", subsystem, "-b", bdev]) | ||
|
||
@pytest.mark.filterwarnings("error::pytest.PytestUnhandledThreadExceptionWarning") | ||
def test_create_get_subsys(caplog, config): | ||
with GatewayServer(config) as gateway: | ||
time.sleep(1) | ||
gateway.serve() | ||
|
||
for i in range(created_resource_count): | ||
create_resource_by_index(i) | ||
assert "Failed" not in caplog.text | ||
|
||
gateway.server.stop(grace=1) | ||
|
||
time.sleep(2) | ||
caplog.clear() | ||
|
||
# restart the gateway here | ||
with GatewayServer(config) as gateway: | ||
time.sleep(1) | ||
gateway.serve() | ||
|
||
text_before = caplog.text | ||
logger.info(f"{text_before=}") | ||
|
||
for i in range(get_subsys_count): | ||
cli(["get_subsystems"]) | ||
assert "Exception" not in caplog.text | ||
time.sleep(1) | ||
|
||
time.sleep(10) | ||
text_after = caplog.text | ||
logger.info(f"{text_after=}") |