From f0609653edc9d122bf99f7ad8078d2c0f97523a9 Mon Sep 17 00:00:00 2001 From: Jingwen Xie Date: Sat, 2 Apr 2022 04:33:08 +0000 Subject: [PATCH] Add GCU empty input test to verify functional usage and valid configDB --- .../test_empty_input.py | 41 +++++++++++++++++++ tests/kvmtest.sh | 1 + 2 files changed, 42 insertions(+) create mode 100644 tests/generic_config_updater/test_empty_input.py diff --git a/tests/generic_config_updater/test_empty_input.py b/tests/generic_config_updater/test_empty_input.py new file mode 100644 index 0000000000..839018deee --- /dev/null +++ b/tests/generic_config_updater/test_empty_input.py @@ -0,0 +1,41 @@ +import logging +import pytest + +from tests.generic_config_updater.gu_utils import apply_patch, expect_op_success +from tests.generic_config_updater.gu_utils import generate_tmpfile, delete_tmpfile +from tests.generic_config_updater.gu_utils import create_checkpoint, delete_checkpoint, rollback_or_reload + +logger = logging.getLogger(__name__) + +@pytest.fixture(autouse=True) +def setup_env(duthosts, rand_one_dut_hostname): + """ + Setup/teardown fixture for empty input= + + Args: + duthosts: list of DUTs. + rand_selected_dut: The fixture returns a randomly selected DuT. + """ + duthost = duthosts[rand_one_dut_hostname] + create_checkpoint(duthost) + + yield + + try: + logger.info("Rolled back to original checkpoint") + rollback_or_reload(duthost) + + finally: + delete_checkpoint(duthost) + +def test_tc1_empty_input(duthost): + json_patch = [] + + tmpfile = generate_tmpfile(duthost) + logger.info("tmpfile {}".format(tmpfile)) + + try: + output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile) + expect_op_success(duthost, output) + finally: + delete_tmpfile(duthost, tmpfile) \ No newline at end of file diff --git a/tests/kvmtest.sh b/tests/kvmtest.sh index e8dfb9f1b5..d985caabcf 100755 --- a/tests/kvmtest.sh +++ b/tests/kvmtest.sh @@ -152,6 +152,7 @@ test_t0() { container_checker/test_container_checker.py \ process_monitoring/test_critical_process_monitoring.py \ system_health/test_system_status.py \ + generic_config_updater/test_empty_input.py \ generic_config_updater/test_aaa.py \ generic_config_updater/test_bgpl.py \ generic_config_updater/test_bgp_prefix.py \