Skip to content

Commit 2d9d7f3

Browse files
committed
testcases: introduce get_exported_shares() helper function
Avoid directly accessing the test_info dict and use helper function instead. This will allow us to modify the test_info.yml with minimal disruption. Signed-off-by: Sachin Prabhu <[email protected]>
1 parent 706edaa commit 2d9d7f3

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed

testcases/consistency/test_consistency.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ def generate_consistency_check(
6161
if not test_info_file:
6262
return []
6363
arr = []
64-
for ipaddr in test_info_file["public_interfaces"]:
65-
for share_name in test_info_file["exported_sharenames"]:
66-
arr.append((ipaddr, share_name))
64+
for share in testhelper.get_exported_shares(test_info):
65+
s = testhelper.get_share(test_info, share)
66+
arr.append((s["server"], s["name"]))
6767
return arr
6868

6969

testcases/containers/test_containers.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,11 @@ def containers_check(ipaddr: str, share_name: str, test: str) -> None:
6666

6767

6868
def generate_containers_test() -> typing.List[typing.Tuple[str, str, str]]:
69-
# Use the first given public_interface for our tests
70-
ipaddr = test_info["public_interfaces"][0]
7169
arr = []
72-
for share_name in test_info["exported_sharenames"]:
70+
for share_name in testhelper.get_exported_shares(test_info):
71+
server = testhelper.get_share(test_info, share_name)["server"]
7372
for test in container_tests.keys():
74-
arr.append((ipaddr, share_name, test))
73+
arr.append((server, share_name, test))
7574
return arr
7675

7776

testcases/misc/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ def setup_mount(
4646

4747

4848
def gen_params() -> typing.List[typing.Any]:
49-
ipaddr = test_info["public_interfaces"][0]
50-
exported_sharenames = test_info.get("exported_sharenames", [])
49+
exported_sharenames = testhelper.get_exported_shares(test_info)
5150
arr = []
5251
for share_name in exported_sharenames:
52+
server = testhelper.get_share(test_info, share_name)["server"]
5353
arr.append(
54-
pytest.param((ipaddr, share_name), id=f"{ipaddr}-{share_name}")
54+
pytest.param((server, share_name), id=f"{server}-{share_name}")
5555
)
5656
return arr
5757

testcases/smbtorture/test_smbtorture.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def list_smbtorture_tests():
114114
def generate_smbtorture_tests() -> typing.List[typing.Tuple[str, str]]:
115115
smbtorture_info = list_smbtorture_tests()
116116
arr = []
117-
for share_name in test_info.get("exported_sharenames", []):
117+
for share_name in testhelper.get_exported_shares(test_info):
118118
for torture_test in smbtorture_info:
119119
arr.append((share_name, torture_test))
120120
return arr

testhelper/testhelper.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,14 @@ def get_premounted_shares(test_info: dict) -> typing.List[Path]:
8787
"""
8888
premounted_shares = test_info.get("premounted_shares", [])
8989
return [Path(mnt) for mnt in premounted_shares]
90+
91+
92+
def get_exported_shares(test_info: dict) -> typing.List[str]:
93+
"""Get the list of exported shares
94+
95+
Parameters:
96+
test_info: Dict containing the parsed yaml file.
97+
Returns:
98+
list of exported shares
99+
"""
100+
return test_info.get("exported_sharenames", [])

0 commit comments

Comments
 (0)