diff --git a/tests/bgp/test_bgp_bbr.py b/tests/bgp/test_bgp_bbr.py index e741bdc7ed8..37bf8460496 100644 --- a/tests/bgp/test_bgp_bbr.py +++ b/tests/bgp/test_bgp_bbr.py @@ -22,6 +22,7 @@ from tests.common.utilities import wait_until, delete_running_config from tests.common.gu_utils import apply_patch, expect_op_success from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic pytestmark = [ @@ -75,6 +76,7 @@ def add_bbr_config_to_running_config(duthost, status): } } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -97,6 +99,7 @@ def config_bbr_by_gcu(duthost, status): "value": "{}".format(status) } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) diff --git a/tests/bgp/test_bgp_bbr_default_state.py b/tests/bgp/test_bgp_bbr_default_state.py index bf6019c671b..5e8e8b0181c 100644 --- a/tests/bgp/test_bgp_bbr_default_state.py +++ b/tests/bgp/test_bgp_bbr_default_state.py @@ -11,6 +11,7 @@ from tests.common.utilities import delete_running_config from tests.common.gu_utils import apply_patch, expect_op_success from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic from tests.common.config_reload import config_reload @@ -54,6 +55,7 @@ def add_bbr_config_to_running_config(duthost, status): } } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) try: @@ -73,6 +75,7 @@ def config_bbr_by_gcu(duthost, status): "value": "{}".format(status) } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) try: diff --git a/tests/bgp/test_bgp_dual_asn.py b/tests/bgp/test_bgp_dual_asn.py index 9ad279d95f2..1da0b4864fd 100644 --- a/tests/bgp/test_bgp_dual_asn.py +++ b/tests/bgp/test_bgp_dual_asn.py @@ -15,6 +15,7 @@ from tests.generic_config_updater.test_bgp_speaker import get_bgp_speaker_runningconfig from tests.common.gu_utils import apply_patch, expect_op_success from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic from tests.common.gu_utils import ( create_checkpoint, delete_checkpoint, @@ -367,6 +368,7 @@ def bgp_peer_range_add_config( } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -402,6 +404,7 @@ def bgp_peer_range_delete_config( {"op": "remove", "path": "/BGP_PEER_RANGE/{}".format(ip_range_name)}, {"op": "remove", "path": "/BGP_PEER_RANGE/{}".format(ipv6_range_name)}, ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) diff --git a/tests/common/gu_utils.py b/tests/common/gu_utils.py index 3bf7da0d5bf..a52a2a46cf6 100644 --- a/tests/common/gu_utils.py +++ b/tests/common/gu_utils.py @@ -19,6 +19,8 @@ BASE_DIR = os.path.dirname(os.path.realpath(__file__)) FILES_DIR = os.path.join(BASE_DIR, "files") TMP_DIR = '/tmp' +HOST_NAME = "/localhost" +ASIC_PREFIX = "/asic" def generate_tmpfile(duthost): @@ -33,6 +35,36 @@ def delete_tmpfile(duthost, tmpfile): duthost.file(path=tmpfile, state='absent') +def format_json_patch_for_multiasic(duthost, json_data, is_asic_specific=False): + if is_asic_specific: + return json_data + + json_patch = [] + if duthost.is_multi_asic: + num_asic = duthost.facts.get('num_asic') + + for operation in json_data: + path = operation["path"] + if path.startswith(HOST_NAME) and ASIC_PREFIX in path: + json_patch.append(operation) + else: + template = { + "op": operation["op"], + "path": "{}{}".format(HOST_NAME, path) + } + + if operation["op"] in ["add", "replace", "test"]: + template["value"] = operation["value"] + json_patch.append(template.copy()) + for asic_index in range(num_asic): + asic_ns = "{}{}".format(ASIC_PREFIX, asic_index) + template["path"] = "{}{}".format(asic_ns, path) + json_patch.append(template.copy()) + json_data = json_patch + + return json_data + + def apply_patch(duthost, json_data, dest_file): """Run apply-patch on target duthost diff --git a/tests/generic_config_updater/gu_utils.py b/tests/generic_config_updater/gu_utils.py index 6032b26145f..6203adaaaf6 100644 --- a/tests/generic_config_updater/gu_utils.py +++ b/tests/generic_config_updater/gu_utils.py @@ -2,6 +2,7 @@ import logging import json from tests.common.gu_utils import apply_patch, generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic BASE_DIR = os.path.dirname(os.path.realpath(__file__)) @@ -39,6 +40,7 @@ def load_and_apply_json_patch(duthost, file_name, setup): with open(os.path.join(TEMPLATES_DIR, file_name)) as file: json_patch = json.load(file) + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) duts_to_apply = [duthost] outputs = [] if setup["is_dualtor"]: diff --git a/tests/generic_config_updater/test_aaa.py b/tests/generic_config_updater/test_aaa.py index 52bdaeffa57..802895ab1ea 100644 --- a/tests/generic_config_updater/test_aaa.py +++ b/tests/generic_config_updater/test_aaa.py @@ -5,6 +5,7 @@ from tests.common.fixtures.tacacs import get_aaa_sub_options_value from tests.common.gu_utils import apply_patch, expect_op_success, expect_op_failure from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic from tests.common.gu_utils import create_checkpoint, delete_checkpoint, rollback_or_reload pytestmark = [ @@ -168,6 +169,7 @@ def aaa_tc1_add_config(duthost): "value": aaa_config } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -206,6 +208,7 @@ def aaa_tc1_replace(duthost): "value": "tacacs+" } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -243,6 +246,7 @@ def aaa_tc1_add_duplicate(duthost): "value": "tacacs+" } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -269,6 +273,7 @@ def aaa_tc1_remove(duthost): "path": "/AAA" } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -313,6 +318,7 @@ def tacacs_global_tc2_add_config(duthost): } } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -352,6 +358,7 @@ def tacacs_global_tc2_invalid_input(duthost): } } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -375,6 +382,7 @@ def tacacs_global_tc2_duplicate_input(duthost): } } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -400,6 +408,7 @@ def tacacs_global_tc2_remove(duthost): "path": "/TACPLUS" } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -443,6 +452,7 @@ def tacacs_server_tc3_add_init(duthost): } } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -481,6 +491,7 @@ def tacacs_server_tc3_add_max(duthost): } json_patch.append(patch) + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -521,6 +532,7 @@ def tacacs_server_tc3_replace_invalid(duthost): } } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -542,6 +554,7 @@ def tacacs_server_tc3_add_duplicate(duthost): "value": TACACS_SERVER_OPTION } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -566,6 +579,7 @@ def tacacs_server_tc3_remove(duthost): "path": "/TACPLUS_SERVER" } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) diff --git a/tests/generic_config_updater/test_bgp_prefix.py b/tests/generic_config_updater/test_bgp_prefix.py index 3f40de54ed9..84f26560239 100644 --- a/tests/generic_config_updater/test_bgp_prefix.py +++ b/tests/generic_config_updater/test_bgp_prefix.py @@ -5,6 +5,7 @@ from tests.common.helpers.assertions import pytest_assert from tests.common.gu_utils import apply_patch, expect_op_failure, expect_op_success from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic from tests.common.gu_utils import create_checkpoint, delete_checkpoint, rollback_or_reload pytestmark = [ @@ -115,6 +116,7 @@ def bgp_prefix_tc1_add_config(duthost, community, community_table): } } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -155,6 +157,7 @@ def bgp_prefix_tc1_xfail(duthost, community_table): "value": prefixes_v4 } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -182,6 +185,7 @@ def bgp_prefix_tc1_replace(duthost, community, community_table): "value": PREFIXES_V4_DUMMY } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -215,6 +219,7 @@ def bgp_prefix_tc1_remove(duthost, community): "path": "/BGP_ALLOWED_PREFIXES" } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) diff --git a/tests/generic_config_updater/test_bgp_sentinel.py b/tests/generic_config_updater/test_bgp_sentinel.py index be35f1a13b4..bfcb14852c7 100644 --- a/tests/generic_config_updater/test_bgp_sentinel.py +++ b/tests/generic_config_updater/test_bgp_sentinel.py @@ -6,6 +6,7 @@ from tests.common.helpers.assertions import pytest_assert from tests.common.gu_utils import apply_patch, expect_op_success from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic from tests.common.gu_utils import create_checkpoint, delete_checkpoint, rollback_or_reload @@ -129,6 +130,7 @@ def bgp_sentinel_tc1_add_config(duthost, lo_intf_ips): } } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -168,6 +170,7 @@ def bgp_sentinel_tc1_add_dummy_ip_range(duthost): "value": "{}".format(DUMMY_IP_RANGE_V6) } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -201,6 +204,7 @@ def bgp_sentinel_tc1_rm_dummy_ip_range(duthost): "path": "/BGP_SENTINELS/{}/ip_range/1".format(BGPSENTINEL_V6) } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -235,6 +239,7 @@ def bgp_sentinel_tc1_replace_src_address(duthost): "value": "{}".format(DUMMY_SRC_ADDRESS_V6) } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) diff --git a/tests/generic_config_updater/test_bgp_speaker.py b/tests/generic_config_updater/test_bgp_speaker.py index 6dcdeda193d..5bd456c3c3c 100644 --- a/tests/generic_config_updater/test_bgp_speaker.py +++ b/tests/generic_config_updater/test_bgp_speaker.py @@ -6,6 +6,7 @@ from tests.common.helpers.assertions import pytest_assert from tests.common.gu_utils import apply_patch, expect_op_success from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic from tests.common.gu_utils import create_checkpoint, delete_checkpoint, rollback_or_reload pytestmark = [ @@ -144,6 +145,7 @@ def bgp_speaker_tc1_add_config(duthost, lo_intf_ips, vlan_intf_ip_ranges): } } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -183,6 +185,7 @@ def bgp_speaker_tc1_add_dummy_ip_range(duthost): "value": "{}".format(DUMMY_IP_RANGE_V6) } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -215,6 +218,7 @@ def bgp_speaker_tc1_rm_dummy_ip_range(duthost): "path": "/BGP_PEER_RANGE/{}/ip_range/1".format(BGPSPEAKER_V6) } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -249,6 +253,7 @@ def bgp_speaker_tc1_replace_src_address(duthost): "value": "{}".format(DUMMY_SRC_ADDRESS_V6) } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) diff --git a/tests/generic_config_updater/test_bgpl.py b/tests/generic_config_updater/test_bgpl.py index b42ad26e662..3d8e164bcd8 100644 --- a/tests/generic_config_updater/test_bgpl.py +++ b/tests/generic_config_updater/test_bgpl.py @@ -7,6 +7,7 @@ from tests.common.helpers.generators import generate_ip_through_default_route from tests.common.gu_utils import apply_patch, expect_op_success from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic from tests.common.gu_utils import create_checkpoint, delete_checkpoint, rollback_or_reload pytestmark = [ @@ -113,6 +114,7 @@ def bgpmon_tc1_add_init(duthost, bgpmon_setup_info): } } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -146,6 +148,7 @@ def bgpmon_tc1_add_duplicate(duthost, bgpmon_setup_info): } } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -170,6 +173,7 @@ def bgpmon_tc1_admin_change(duthost, bgpmon_setup_info): "value": "down" } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -212,6 +216,7 @@ def bgpmon_tc1_ip_change(duthost, bgpmon_setup_info): } } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -234,6 +239,7 @@ def bgpmon_tc1_remove(duthost): "path": "/BGP_MONITORS" } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) diff --git a/tests/generic_config_updater/test_cacl.py b/tests/generic_config_updater/test_cacl.py index 2631db44598..fc37c28ef0f 100644 --- a/tests/generic_config_updater/test_cacl.py +++ b/tests/generic_config_updater/test_cacl.py @@ -6,6 +6,7 @@ from tests.common.helpers.assertions import pytest_assert from tests.common.gu_utils import apply_patch, expect_op_success, expect_res_success, expect_op_failure from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic from tests.common.gu_utils import create_checkpoint, delete_checkpoint, rollback_or_reload # Test on t0 topo to verify functionality and to choose predefined variable @@ -158,6 +159,7 @@ def cacl_tc1_add_new_table(duthost, protocol): } } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -193,6 +195,7 @@ def cacl_tc1_add_duplicate_table(duthost, protocol): } } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -252,6 +255,7 @@ def cacl_tc1_replace_table_variable(duthost, protocol): } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -298,6 +302,7 @@ def cacl_tc1_add_invalid_table(duthost, protocol): tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) try: output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile) @@ -315,6 +320,7 @@ def cacl_tc1_remove_unexisted_table(duthost): "path": "/ACL_RULE/SSH_ONLY_UNEXISTED" } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -338,6 +344,7 @@ def cacl_tc1_remove_table(duthost, protocol): "path": "/ACL_TABLE/{}".format(table_name) } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -399,6 +406,7 @@ def cacl_tc2_add_init_rule(duthost, protocol): } } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -456,6 +464,7 @@ def cacl_tc2_add_duplicate_rule(duthost, protocol): } } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -495,6 +504,7 @@ def cacl_tc2_replace_rule(duthost, protocol): "value": "8.8.8.8/32" } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -537,6 +547,7 @@ def cacl_tc2_add_rule_to_unexisted_table(duthost): } } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -565,6 +576,7 @@ def cacl_tc2_remove_table_before_rule(duthost, protocol): "path": "/ACL_TABLE/{}".format(table) } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -593,6 +605,7 @@ def cacl_tc2_remove_unexist_rule(duthost, protocol): "path": "/ACL_RULE/{}|TEST_DROP2".format(table) } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) try: @@ -611,6 +624,7 @@ def cacl_tc2_remove_rule(duthost): "path": "/ACL_RULE" } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -651,6 +665,7 @@ def cacl_external_client_add_new_table(duthost): } } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) diff --git a/tests/generic_config_updater/test_dhcp_relay.py b/tests/generic_config_updater/test_dhcp_relay.py index 9dca17b1cb4..32d0fd5f2e9 100644 --- a/tests/generic_config_updater/test_dhcp_relay.py +++ b/tests/generic_config_updater/test_dhcp_relay.py @@ -7,6 +7,7 @@ utils_vlan_intfs_dict_add, utils_create_test_vlans # noqa F401 from tests.common.gu_utils import apply_patch, expect_op_success, expect_res_success, expect_op_failure from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic from tests.common.gu_utils import create_checkpoint, delete_checkpoint, rollback_or_reload, rollback pytestmark = [ @@ -257,6 +258,7 @@ def test_dhcp_relay_tc1_rm_nonexist(rand_selected_dut, vlan_intfs_list): "op": "remove", "path": "/VLAN/Vlan" + str(vlan_intfs_list[0]) + "/dhcp_servers/5" }] + dhcp_rm_nonexist_json = format_json_patch_for_multiasic(duthost=rand_selected_dut, json_data=dhcp_rm_nonexist_json) tmpfile = generate_tmpfile(rand_selected_dut) logger.info("tmpfile {}".format(tmpfile)) @@ -277,6 +279,7 @@ def test_dhcp_relay_tc2_add_exist(rand_selected_dut, vlan_intfs_list): "path": "/VLAN/Vlan" + str(vlan_intfs_list[0]) + "/dhcp_servers/0", "value": "192.0." + str(vlan_intfs_list[0]) + ".1" }] + dhcp_add_exist_json = format_json_patch_for_multiasic(duthost=rand_selected_dut, json_data=dhcp_add_exist_json) tmpfile = generate_tmpfile(rand_selected_dut) logger.info("tmpfile {}".format(tmpfile)) @@ -316,6 +319,7 @@ def test_dhcp_relay_tc3_add_and_rm(rand_selected_dut, vlan_intfs_list): "path": "/VLAN/Vlan" + str(vlan_intfs_list[0]) + "/dhcp_servers/4", "value": "192.0." + str(vlan_intfs_list[0]) + ".5" }] + dhcp_add_rm_json = format_json_patch_for_multiasic(duthost=rand_selected_dut, json_data=dhcp_add_rm_json) tmpfile = generate_tmpfile(rand_selected_dut) logger.info("tmpfile {}".format(tmpfile)) @@ -360,6 +364,7 @@ def test_dhcp_relay_tc4_replace(rand_selected_dut, vlan_intfs_list): "path": "/VLAN/Vlan" + str(vlan_intfs_list[0]) + "/dhcp_servers/0", "value": "192.0." + str(vlan_intfs_list[0]) + ".8" }] + dhcp_replace_json = format_json_patch_for_multiasic(duthost=rand_selected_dut, json_data=dhcp_replace_json) tmpfile = generate_tmpfile(rand_selected_dut) logger.info("tmpfile {}".format(tmpfile)) diff --git a/tests/generic_config_updater/test_ecn_config_update.py b/tests/generic_config_updater/test_ecn_config_update.py index a3459253981..bdb2dbb56d5 100644 --- a/tests/generic_config_updater/test_ecn_config_update.py +++ b/tests/generic_config_updater/test_ecn_config_update.py @@ -7,6 +7,7 @@ from tests.common.helpers.dut_utils import verify_orchagent_running_or_assert from tests.common.gu_utils import apply_patch, expect_op_success, expect_op_failure from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic from tests.common.gu_utils import create_checkpoint, delete_checkpoint, rollback_or_reload from tests.common.gu_utils import is_valid_platform_and_version @@ -107,6 +108,7 @@ def test_ecn_config_updates(duthost, ensure_dut_readiness, configdb_field, opera "path": "/WRED_PROFILE/AZURE_LOSSLESS/{}".format(field), "value": "{}".format(value)}) + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) try: output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile) if is_valid_platform_and_version(duthost, "WRED_PROFILE", "ECN tuning", operation): diff --git a/tests/generic_config_updater/test_eth_interface.py b/tests/generic_config_updater/test_eth_interface.py index 7d63aaf8a95..c8a6a5a1525 100644 --- a/tests/generic_config_updater/test_eth_interface.py +++ b/tests/generic_config_updater/test_eth_interface.py @@ -7,6 +7,7 @@ from tests.common.helpers.assertions import pytest_assert from tests.common.gu_utils import apply_patch, expect_op_success, expect_op_failure from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic from tests.common.gu_utils import create_checkpoint, delete_checkpoint, rollback_or_reload from tests.common.utilities import wait_until @@ -146,6 +147,7 @@ def test_remove_lanes(duthosts, rand_one_dut_hostname, ensure_dut_readiness): "path": "/PORT/Ethernet0/lanes" } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -173,6 +175,7 @@ def test_replace_lanes(duthosts, rand_one_dut_hostname, ensure_dut_readiness): "value": "{}".format(update_lanes) } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -198,6 +201,7 @@ def test_replace_mtu(duthosts, rand_one_dut_hostname, ensure_dut_readiness): "value": "{}".format(target_mtu) } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -222,6 +226,7 @@ def test_toggle_pfc_asym(duthosts, rand_one_dut_hostname, ensure_dut_readiness, "value": "{}".format(pfc_asym) } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -247,6 +252,7 @@ def test_replace_fec(duthosts, rand_one_dut_hostname, ensure_dut_readiness, fec) "value": "{}".format(fec) } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -277,6 +283,7 @@ def test_update_invalid_index(duthosts, rand_one_dut_hostname, ensure_dut_readin "value": "abc1" } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -315,6 +322,7 @@ def test_update_valid_index(duthosts, rand_one_dut_hostname, ensure_dut_readines "value": "{}".format(list(interfaces.values())[0]) } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -337,6 +345,7 @@ def test_update_speed(duthosts, rand_one_dut_hostname, ensure_dut_readiness): "value": "{}".format(speed) } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -364,6 +373,7 @@ def test_update_description(duthosts, rand_one_dut_hostname, ensure_dut_readines "value": "Updated description" } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -385,6 +395,7 @@ def test_eth_interface_admin_change(duthosts, rand_one_dut_hostname, admin_statu "value": "{}".format(admin_status) } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) diff --git a/tests/generic_config_updater/test_incremental_qos.py b/tests/generic_config_updater/test_incremental_qos.py index 7282f251b6f..741d35302d6 100644 --- a/tests/generic_config_updater/test_incremental_qos.py +++ b/tests/generic_config_updater/test_incremental_qos.py @@ -9,6 +9,7 @@ from tests.common.gu_utils import apply_patch, expect_op_success, \ expect_op_failure # noqa F401 from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic from tests.common.gu_utils import create_checkpoint, delete_checkpoint, rollback_or_reload from tests.common.gu_utils import is_valid_platform_and_version from tests.common.mellanox_data import is_mellanox_device @@ -236,6 +237,7 @@ def test_incremental_qos_config_updates(duthost, tbinfo, ensure_dut_readiness, c "path": "/BUFFER_POOL/{}".format(configdb_field), "value": "{}".format(value) }] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) try: output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile) diff --git a/tests/generic_config_updater/test_ip_bgp.py b/tests/generic_config_updater/test_ip_bgp.py index 70b9f318b67..9e3ec8b1c44 100644 --- a/tests/generic_config_updater/test_ip_bgp.py +++ b/tests/generic_config_updater/test_ip_bgp.py @@ -6,6 +6,7 @@ from tests.common.helpers.assertions import pytest_assert from tests.common.gu_utils import apply_patch, expect_op_success, expect_op_failure from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic from tests.common.gu_utils import create_checkpoint, delete_checkpoint, rollback_or_reload logger = logging.getLogger(__name__) @@ -76,6 +77,7 @@ def add_deleted_ip_neighbor(duthost, ip_version=6): "value": ip_neighbor_config } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -100,6 +102,7 @@ def add_duplicate_ip_neighbor(duthost, ip_version=6): "value": ip_neighbor_config } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -132,6 +135,7 @@ def invalid_ip_neighbor(duthost, ip_version=6): "value": {} } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -157,6 +161,7 @@ def ip_neighbor_admin_change(duthost, ip_version=6): "value": "down" } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -183,6 +188,7 @@ def delete_ip_neighbor(duthost, ip_version=6): "path": "/BGP_NEIGHBOR/{}".format(ip_neighbor_address) } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) diff --git a/tests/generic_config_updater/test_kubernetes_config.py b/tests/generic_config_updater/test_kubernetes_config.py index 51d4234141d..a36dfeba5ab 100644 --- a/tests/generic_config_updater/test_kubernetes_config.py +++ b/tests/generic_config_updater/test_kubernetes_config.py @@ -5,6 +5,7 @@ from tests.common.helpers.assertions import pytest_assert from tests.common.gu_utils import apply_patch, expect_op_success, expect_op_failure from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic from tests.common.gu_utils import create_checkpoint, delete_checkpoint, rollback_or_reload @@ -265,6 +266,7 @@ def k8s_config_update(duthost, test_data): for num, (json_patch, target_config, target_table, expected_result) in enumerate(test_data): tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) try: output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile) diff --git a/tests/generic_config_updater/test_lo_interface.py b/tests/generic_config_updater/test_lo_interface.py index 2b04831e87f..04e56711132 100644 --- a/tests/generic_config_updater/test_lo_interface.py +++ b/tests/generic_config_updater/test_lo_interface.py @@ -5,6 +5,7 @@ from tests.common.helpers.assertions import pytest_assert from tests.common.gu_utils import apply_patch, expect_op_success, expect_op_failure from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic from tests.common.gu_utils import create_checkpoint, delete_checkpoint, rollback_or_reload from tests.common.gu_utils import create_path, check_show_ip_intf, check_vrf_route_for_intf @@ -111,6 +112,7 @@ def lo_interface_tc1_add_init(duthost, lo_intf): } } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -156,6 +158,7 @@ def lo_interface_tc1_add_duplicate(duthost, lo_intf): "value": {} } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -205,6 +208,7 @@ def lo_interface_tc1_xfail(duthost, lo_intf): "value": {} } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -258,6 +262,7 @@ def lo_interface_tc1_replace(duthost, lo_intf): "value": {} } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -283,6 +288,7 @@ def lo_interface_tc1_remove(duthost, lo_intf): "path": "/LOOPBACK_INTERFACE" } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -325,6 +331,7 @@ def setup_vrf_config(duthost, lo_intf): "value": "Vrf_01" } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -377,6 +384,7 @@ def test_lo_interface_tc2_vrf_change(rand_selected_dut, lo_intf): "value": "Vrf_02" } ] + json_patch = format_json_patch_for_multiasic(duthost=rand_selected_dut, json_data=json_patch) tmpfile = generate_tmpfile(rand_selected_dut) logger.info("tmpfile {}".format(tmpfile)) diff --git a/tests/generic_config_updater/test_mgmt_interface.py b/tests/generic_config_updater/test_mgmt_interface.py index e5d9a220a55..cc31f4127b0 100644 --- a/tests/generic_config_updater/test_mgmt_interface.py +++ b/tests/generic_config_updater/test_mgmt_interface.py @@ -5,6 +5,7 @@ from tests.common.helpers.assertions import pytest_assert from tests.common.gu_utils import apply_patch, create_path from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic from tests.common.gu_utils import create_checkpoint, delete_checkpoint, rollback_or_reload from tests.common.utilities import wait_for_file_changed, FORCED_MGMT_ROUTE_PRIORITY @@ -56,6 +57,7 @@ def update_forced_mgmt_route(duthost, interface_address, interface_key, routes): else: json_patch[0]["op"] = "add" + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) try: output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile) diff --git a/tests/generic_config_updater/test_mmu_dynamic_threshold_config_update.py b/tests/generic_config_updater/test_mmu_dynamic_threshold_config_update.py index 0d80da1ed65..d9d38397f6a 100644 --- a/tests/generic_config_updater/test_mmu_dynamic_threshold_config_update.py +++ b/tests/generic_config_updater/test_mmu_dynamic_threshold_config_update.py @@ -7,6 +7,7 @@ from tests.common.helpers.dut_utils import verify_orchagent_running_or_assert from tests.common.gu_utils import apply_patch, expect_op_success from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic from tests.common.gu_utils import create_checkpoint, delete_checkpoint, rollback_or_reload pytestmark = [ @@ -122,6 +123,7 @@ def test_dynamic_th_config_updates(duthost, ensure_dut_readiness, operation, ski } json_patch.append(individual_patch) + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {} created for json patch of updating dynamic threshold and operation: {}" .format(tmpfile, operation)) diff --git a/tests/generic_config_updater/test_monitor_config.py b/tests/generic_config_updater/test_monitor_config.py index 860a5676558..a184fe52d70 100644 --- a/tests/generic_config_updater/test_monitor_config.py +++ b/tests/generic_config_updater/test_monitor_config.py @@ -4,6 +4,7 @@ from tests.common.helpers.assertions import pytest_assert from tests.common.gu_utils import apply_patch, expect_op_success, expect_res_success from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic from tests.common.gu_utils import create_checkpoint, delete_checkpoint, rollback, rollback_or_reload pytestmark = [ @@ -194,6 +195,7 @@ def monitor_config_add_config(duthost, get_valid_acl_ports): } } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) diff --git a/tests/generic_config_updater/test_ntp.py b/tests/generic_config_updater/test_ntp.py index c8cd298d2d6..0affb39827f 100644 --- a/tests/generic_config_updater/test_ntp.py +++ b/tests/generic_config_updater/test_ntp.py @@ -6,6 +6,7 @@ from tests.common.helpers.assertions import pytest_assert from tests.common.gu_utils import apply_patch, expect_op_failure, expect_op_success from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic from tests.common.gu_utils import create_checkpoint, delete_checkpoint, rollback_or_reload from tests.common.utilities import wait_until @@ -115,6 +116,7 @@ def ntp_server_tc1_add_config(duthost): } } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) json_patch_bc = [ { @@ -125,6 +127,7 @@ def ntp_server_tc1_add_config(duthost): } } ] + json_patch_bc = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch_bc) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -169,6 +172,7 @@ def ntp_server_tc1_xfail(duthost): "value": {} } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -199,6 +203,7 @@ def ntp_server_tc1_replace(duthost): } } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) json_patch_bc = [ { @@ -211,6 +216,7 @@ def ntp_server_tc1_replace(duthost): "value": {} } ] + json_patch_bc = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch_bc) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -245,6 +251,7 @@ def ntp_server_tc1_remove(duthost): "path": "/NTP_SERVER" } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) diff --git a/tests/generic_config_updater/test_pfcwd_interval.py b/tests/generic_config_updater/test_pfcwd_interval.py index fd6d8d16ec6..0a7e095aaef 100644 --- a/tests/generic_config_updater/test_pfcwd_interval.py +++ b/tests/generic_config_updater/test_pfcwd_interval.py @@ -6,6 +6,7 @@ from tests.common.utilities import wait_until from tests.common.gu_utils import apply_patch, expect_op_success, expect_op_failure from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic from tests.common.gu_utils import create_checkpoint, delete_checkpoint, rollback_or_reload from tests.common.gu_utils import is_valid_platform_and_version @@ -164,6 +165,7 @@ def test_pfcwd_interval_config_updates(duthost, ensure_dut_readiness, oper, "path": "/PFC_WD/GLOBAL/POLL_INTERVAL", "value": "{}".format(value) }] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) try: output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile) diff --git a/tests/generic_config_updater/test_pfcwd_status.py b/tests/generic_config_updater/test_pfcwd_status.py index 76f5828d6b5..c522c800ef4 100644 --- a/tests/generic_config_updater/test_pfcwd_status.py +++ b/tests/generic_config_updater/test_pfcwd_status.py @@ -9,6 +9,7 @@ from tests.common.helpers.dut_utils import verify_orchagent_running_or_assert from tests.common.gu_utils import apply_patch, expect_op_success, expect_op_failure from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic from tests.common.gu_utils import create_checkpoint, delete_checkpoint, rollback_or_reload from tests.common.gu_utils import is_valid_platform_and_version @@ -213,6 +214,7 @@ def test_stop_pfcwd(duthost, extract_pfcwd_config, ensure_dut_readiness, port): exp_str = interface break + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) try: tmpfile = generate_tmpfile(duthost) output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile) @@ -256,6 +258,7 @@ def test_start_pfcwd(duthost, extract_pfcwd_config, ensure_dut_readiness, stop_p exp_str = interface break + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) try: tmpfile = generate_tmpfile(duthost) output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile) diff --git a/tests/generic_config_updater/test_pg_headroom_update.py b/tests/generic_config_updater/test_pg_headroom_update.py index 16a0b2e6f0c..d72ab4b1fbc 100644 --- a/tests/generic_config_updater/test_pg_headroom_update.py +++ b/tests/generic_config_updater/test_pg_headroom_update.py @@ -7,6 +7,7 @@ from tests.common.helpers.dut_utils import verify_orchagent_running_or_assert from tests.common.gu_utils import apply_patch, expect_op_success, expect_op_failure from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic from tests.common.gu_utils import create_checkpoint, delete_checkpoint, rollback_or_reload from tests.common.gu_utils import is_valid_platform_and_version, get_asic_name @@ -103,6 +104,7 @@ def test_pg_headroom_update(duthost, ensure_dut_readiness, operation, skip_when_ "path": "/BUFFER_PROFILE/{}/xoff".format(profile_name), "value": "{}".format(value)}) + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) try: output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile) if is_valid_platform_and_version(duthost, "BUFFER_PROFILE", "PG headroom modification", operation): diff --git a/tests/generic_config_updater/test_portchannel_interface.py b/tests/generic_config_updater/test_portchannel_interface.py index f7f8e0b29c4..a81021fc744 100644 --- a/tests/generic_config_updater/test_portchannel_interface.py +++ b/tests/generic_config_updater/test_portchannel_interface.py @@ -6,6 +6,7 @@ from tests.common.helpers.assertions import pytest_require from tests.common.gu_utils import apply_patch, expect_op_success, expect_op_failure from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic from tests.common.gu_utils import create_checkpoint, delete_checkpoint, rollback_or_reload from tests.common.gu_utils import create_path, check_show_ip_intf @@ -99,6 +100,7 @@ def portchannel_interface_tc1_add_duplicate(duthost, portchannel_table): "value": {} } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -143,6 +145,7 @@ def portchannel_interface_tc1_xfail(duthost): "value": {} } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -185,6 +188,7 @@ def portchannel_interface_tc1_add_and_rm(duthost, portchannel_table): "value": {} } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -263,6 +267,7 @@ def portchannel_interface_tc2_replace(duthost): } json_patch.append(patch) + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -287,6 +292,7 @@ def portchannel_interface_tc2_incremental(duthost): "value": "Description for PortChannel101" } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) diff --git a/tests/generic_config_updater/test_syslog.py b/tests/generic_config_updater/test_syslog.py index 47bbecb484a..6e1907c5744 100644 --- a/tests/generic_config_updater/test_syslog.py +++ b/tests/generic_config_updater/test_syslog.py @@ -4,6 +4,7 @@ from tests.common.helpers.assertions import pytest_assert from tests.common.gu_utils import apply_patch, expect_res_success, expect_op_failure, expect_op_success from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic from tests.common.gu_utils import create_checkpoint, delete_checkpoint, rollback_or_reload pytestmark = [ @@ -125,6 +126,7 @@ def syslog_server_tc1_add_init(duthost): } } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -162,6 +164,7 @@ def syslog_server_tc1_add_duplicate(duthost): "value": {} } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -205,6 +208,7 @@ def syslog_server_tc1_xfail(duthost): "value": {} } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -245,6 +249,7 @@ def syslog_server_tc1_replace(duthost): "value": {} } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -276,6 +281,7 @@ def syslog_server_tc1_remove(duthost): "path": "/SYSLOG_SERVER" } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) diff --git a/tests/generic_config_updater/test_vlan_interface.py b/tests/generic_config_updater/test_vlan_interface.py index b0f697534b4..1b4372c308f 100644 --- a/tests/generic_config_updater/test_vlan_interface.py +++ b/tests/generic_config_updater/test_vlan_interface.py @@ -7,6 +7,7 @@ from tests.common.helpers.assertions import pytest_assert from tests.common.gu_utils import apply_patch, expect_op_success, expect_op_failure from tests.common.gu_utils import generate_tmpfile, delete_tmpfile +from tests.common.gu_utils import format_json_patch_for_multiasic from tests.common.gu_utils import create_checkpoint, delete_checkpoint, rollback_or_reload from tests.common.gu_utils import create_path, check_show_ip_intf @@ -148,6 +149,7 @@ def vlan_interface_tc1_add_duplicate(duthost, vlan_info): "value": {} } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) logger.info("json patch {}".format(json_patch)) @@ -233,6 +235,7 @@ def vlan_interface_tc1_xfail(duthost, vlan_info): "value": {} } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -304,6 +307,7 @@ def vlan_interface_tc1_add_new(duthost): } } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -362,6 +366,7 @@ def vlan_interface_tc1_replace(duthost, vlan_info): "value": {} } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -387,6 +392,7 @@ def vlan_interface_tc1_remove(duthost, vlan_info): "path": "/VLAN_INTERFACE" } ] + json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch) tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) @@ -430,6 +436,7 @@ def test_vlan_interface_tc2_incremental_change(rand_selected_dut): "value": "incremental test for Vlan{}".format(EXIST_VLAN_ID) } ] + json_patch = format_json_patch_for_multiasic(duthost=rand_selected_dut, json_data=json_patch) tmpfile = generate_tmpfile(rand_selected_dut) logger.info("tmpfile {}".format(tmpfile))