Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for by-id path #1518

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

katlapinka
Copy link
Contributor

Original PR:
#931

Needs:
Open-CAS/test-framework#14

@katlapinka katlapinka force-pushed the kasiat/test-by-id-path branch from fbe1fa4 to fd2a534 Compare September 13, 2024 06:48
@pep8speaks
Copy link

pep8speaks commented Sep 13, 2024

Hello @katlapinka! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2024-11-14 10:27:04 UTC

@katlapinka katlapinka force-pushed the kasiat/test-by-id-path branch from fd2a534 to 42958a2 Compare September 13, 2024 06:49
Deixx
Deixx previously approved these changes Sep 13, 2024
"""
title: Test for adding core with by-id path.
description: |
Check if OpenCAS accepts by-id path to disks added as cores.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent x 4

- Cores are added to cache with the same path as given
"""
with TestRun.step("Prepare partitions for cache and for cores."):
cache_dev = TestRun.disks['cache']
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cache_dev = TestRun.disks["cache"]

cache_dev = TestRun.disks['cache']
cache_dev.create_partitions([Size(200, Unit.MebiByte)])
cache_part = cache_dev.partitions[0]
core_dev = TestRun.disks['core']
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

core_dev = TestRun.disks["core"]

Comment on lines 44 to 45
for i in range(cores_number):
cache.add_core(core_dev.partitions[i])
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    for core_dev_part in core_dev.partitions:
        cache.add_core(core_dev_part)

if added_cores_number != cores_number:
TestRun.fail(f"Expected {cores_number} cores, got {added_cores_number}!")

for i, core in enumerate(added_cores):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about
'for a,b in zip(added_cores, core_dev.partitions):'

if listed_cores_number != cores_number:
TestRun.fail(f"Expected {cores_number} cores, got {listed_cores_number}!")

for core in listed_cores:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small refactor for that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

def create_init_config(cache, cores, paths):
init_conf = InitConfig()

def _add_core(core, path):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if creating function to use it once, few lines after definition is best practice


if len(core_pool_list) != 0:
TestRun.error(f"No cores expected in core pool. Got {core_pool_list}")
else:
TestRun.LOGGER.info("Core pool is ok")

expected_caches_paths = set([active_cache_path, standby_cache_path])
expected_caches_paths = {active_cache_path, standby_cache_path}
caches_paths = {c["device"] for c in caches_list}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure that this is cache path?


if len(core_pool_list) != 0:
TestRun.error(f"No cores expected in core pool. Got {core_pool_list}")
else:
TestRun.LOGGER.info("Core pool is ok")

expected_caches_paths = set([active_cache_path, standby_cache_path])
expected_caches_paths = {active_cache_path, standby_cache_path}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if active_cache_path is correct naming for cache_disk_path

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume those names gives us more info what are there caches than "first_cache" and "second_cache" names

f"Expected the following devices as caches "
f"{expected_caches_paths}. Got {caches_paths}"
)
else:
TestRun.LOGGER.info("Caches are ok")

expected_core_paths = set([active_core_path])
expected_core_paths = {active_core_path}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if active_core_path is correct naming for core_disk_path

@katlapinka katlapinka force-pushed the kasiat/test-by-id-path branch from 431d18f to 51499a7 Compare November 14, 2024 10:26
Signed-off-by: Katarzyna Treder <[email protected]>
@katlapinka katlapinka force-pushed the kasiat/test-by-id-path branch from 51499a7 to 68ef9f9 Compare November 14, 2024 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants