Skip to content
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
27 changes: 27 additions & 0 deletions tests/generic_config_updater/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import pytest

from tests.common.utilities import skip_release
from tests.generic_config_updater.gu_utils import apply_patch
from tests.generic_config_updater.gu_utils import generate_tmpfile, delete_tmpfile

@pytest.fixture(autouse=True)
def ignore_expected_loganalyzer_exceptions(duthost, loganalyzer):
Expand Down Expand Up @@ -53,3 +55,28 @@ def cfg_facts(duthosts, rand_one_dut_hostname):
"""
duthost = duthosts[rand_one_dut_hostname]
return duthost.config_facts(host=duthost.hostname, source="persistent")['ansible_facts']


@pytest.fixture(scope="module", autouse=True)
def verify_configdb_with_empty_input(duthost):
"""Fail immediately if empty input test failure

Args:
duthost: Hostname of DUT.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

duthost is not a hostname. It's an ansible host object that can be used to interact with the DUT device.

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.

Suggest @wen587 to fix the comment in another PR.

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.


Returns:
None.
"""
json_patch = []
tmpfile = generate_tmpfile(duthost)

try:
output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile)
if output['rc'] or "Patch applied successfully" not in output['stdout']:
pytest.fail(
"SETUP FAILURE: ConfigDB fail to validate Yang. rc:{} msg:{}"
.format(output['rc'], output['stdout'])
)

finally:
delete_tmpfile(duthost, tmpfile)