Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
6 changes: 6 additions & 0 deletions pfcwd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from tabulate import tabulate
from utilities_common import multi_asic as multi_asic_util
from utilities_common import constants
from utilities_common.general import load_db_config
from sonic_py_common import logger

SYSLOG_IDENTIFIER = "config"
Expand Down Expand Up @@ -62,7 +63,12 @@
@click.group()
def cli():
""" SONiC PFC Watchdog """
initialize_db_config()

def initialize_db_config():
# Initialize db config here for UT coverage
load_db_config()
return
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Our code coverage requirement is 80%, so need return here to pass coverage check.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Prefer keep code cleaner, and fix the test infra.

Copy link
Copy Markdown
Contributor

@qiluo-msft qiluo-msft Jun 30, 2022

Choose a reason for hiding this comment

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

I am okay to override coverage check force merge and suppress coverage checker in of this PR as long as there is an issue tracking the coverage issue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will improve code and try fix test infra later.

Copy link
Copy Markdown
Contributor Author

@liuh-80 liuh-80 Jul 1, 2022

Choose a reason for hiding this comment

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

I checked the code coverage of some other script, the @click.group() of those script are all not covered, for example piceutil, so will try cover the cli() and if not work will change coverage rate to 50%

image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This seems a known issue in click: pallets/click#267
Will try use subprocess.check_output to cover code in cli().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I try different solution but all failed, so change code coverage threshold to 50%.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Revert the code coverage threshold change for force merge.


def get_all_queues(db, namespace=None, display=constants.DISPLAY_ALL):
queue_names = db.get_all(db.COUNTERS_DB, 'COUNTERS_QUEUE_NAME_MAP')
Expand Down
6 changes: 6 additions & 0 deletions tests/pfcwd_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,12 @@ def test_pfcwd_pfc_not_enabled_masic(self, mock_os):
# same as original config
assert result.output == show_pfc_config_all

@patch('pfcwd.main.os')
def test_pfcwd_cli(self, mock_os):
import pfcwd.main as pfcwd
# test initialize db config without exception
pfcwd.initialize_db_config()

@classmethod
def teardown_class(cls):
print("TEARDOWN")
Expand Down