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

Adding a new test file for mcg cli commands validation with bucket list command verification #11046

Merged
merged 4 commits into from
Dec 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions tests/functional/object/mcg/test_mcg_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import pytest

import logging

from ocs_ci.framework.pytest_customization.marks import (
tier2,
red_squad,
mcg,
)
from ocs_ci.framework.testlib import MCGTest

logger = logging.getLogger(__name__)


@mcg
@red_squad
@tier2
class TestMcgCli(MCGTest):
"""
Tests for mcg cli commands validation
"""

@pytest.mark.parametrize(
argnames="count",
argvalues=[
pytest.param(3),
],
)
sagihirshfeld marked this conversation as resolved.
Show resolved Hide resolved
def test_bucket_list_command(
self,
count,
mcg_obj,
bucket_factory,
):
"""
Test proper output of MCG CLI bucket list command.
The method does the following:
1) runs this command to count the number of existing buckets
2) creates number of buckets
3) runs bucket list command again
4) verifies that the number of current buckets equals the number of previously existing and the added ones

Args:
count (int): number of buckets to create

"""
bucket_lst_res = mcg_obj.exec_mcg_cmd("bucket list").stdout.split("\n")
bucket_names = [name.strip() for name in bucket_lst_res if name][
1:
] # get rid of empty strings and the title
sagihirshfeld marked this conversation as resolved.
Show resolved Hide resolved
existing_buckets_num = len(bucket_names)
logger.info(f"{existing_buckets_num} bucket(s) exist")

logger.info(f"Creating {count} buckets")
buckets = bucket_factory(count)
created_bucket_names = (b.name for b in buckets)
logger.info("Buckets " + ", ".join(created_bucket_names) + " created")

bucket_lst_res = mcg_obj.exec_mcg_cmd("bucket list").stdout.split("\n")
bucket_names = [name.strip() for name in bucket_lst_res if name][
1:
] # get rid of empty strings and the title
sagihirshfeld marked this conversation as resolved.
Show resolved Hide resolved
current_buckets_num = len(bucket_names)
assert current_buckets_num == existing_buckets_num + count, (
f"'bucket list' command shows"
f" {current_buckets_num} buckets"
f" expected {existing_buckets_num + count}."
)
logger.info("'bucket list' command finished successfully")
Loading