diff --git a/tests/generic_config_updater/conftest.py b/tests/generic_config_updater/conftest.py index 056fefcae5e..60ec4bc11e3 100644 --- a/tests/generic_config_updater/conftest.py +++ b/tests/generic_config_updater/conftest.py @@ -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): @@ -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. + + 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)