From 73f90d22ee573c147dd105a0b0048e61d8a661d2 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Mon, 28 Sep 2020 16:33:40 -0700 Subject: [PATCH 01/68] mclagsyncd enhancements as per HLD at Azure/SONIC#596 --- config/main.py | 278 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 278 insertions(+) diff --git a/config/main.py b/config/main.py index 4f3aeb6bb3..d250032bbe 100755 --- a/config/main.py +++ b/config/main.py @@ -336,6 +336,43 @@ def interface_name_is_valid(config_db, interface_name): return True return False +def mclag_domain_id_valid(domain_id): + """Check if the domain id is in acceptable range (between 1 and 4095) + """ + + if domain_id<1 or domain_id>4095: + return False + + return True + +def mclag_ka_session_dep_check(ka, session_tmout): + """Check if the MCLAG Keepalive timer and session timeout values are multiples of each other and keepalive is < session timeout value + """ + if not session_tmout >= ( 3 * ka): + return False, "MCLAG Keepalive:{} Session_timeout:{} values not satisfying session_timeout >= (3 * KA) ".format(session_tmout, ka) + + if session_tmout % ka: + return False, "MCLAG keepalive:{} Session_timeout:{} Values not satisfying session_timeout should be a multiple of KA".format(ka, session_tmout) + + return True, "" + + +def mclag_ka_interval_valid(ka): + """Check if the MCLAG Keepalive timer is in acceptable range (between 1 and 60) + """ + if ka < 1 or ka > 60: + return False, "Keepalive %s not in valid range[1-60]" % ka + return True, "" + +def mclag_session_timeout_valid(session_tmout): + """Check if the MCLAG session timeout in valid range (between 3 and 3600) + """ + if session_tmout < 3 or session_tmout > 3600: + return False, "Session timeout %s not in valid range[3-3600]" % session_tmout + return True, "" + + + def interface_name_to_alias(config_db, interface_name): """Return alias interface name if default name is given as argument """ @@ -3668,6 +3705,247 @@ def delete(ctx): sflow_tbl['global'].pop('agent_id') config_db.set_entry('SFLOW', 'global', sflow_tbl['global']) +###### +# +# 'mclag' group ('config mclag ...') +# +@config.group() +@click.pass_context +def mclag(ctx): + config_db = ConfigDBConnector() + config_db.connect() + ctx.obj = {'db': config_db} + pass + + +#mclag domain add +@mclag.command('add') +@click.argument('domain_id', metavar='', required=True, type=int) +@click.argument('source_ip_addr', metavar='', required=True) +@click.argument('peer_ip_addr', metavar='', required=True) +@click.argument('peer_ifname', metavar='', required=False) +@click.pass_context +def add_mclag_domain(ctx, domain_id, source_ip_addr, peer_ip_addr, peer_ifname): + """Add MCLAG Domain""" + + if not mclag_domain_id_valid(domain_id): + ctx.fail("{} invalid domain ID, valid range is 1 to 4095".format(domain_id)) + if not is_ip4_addr_valid(source_ip_addr, True): + ctx.fail("{} invalid local ip address".format(source_ip_addr)) + if not is_ip4_addr_valid(peer_ip_addr, True): + ctx.fail("{} invalid peer ip address".format(peer_ip_addr)) + + db = ctx.obj['db'] + fvs = {} + fvs['source_ip'] = str(source_ip_addr) + fvs['peer_ip'] = str(peer_ip_addr) + if peer_ifname is not None: + if (peer_ifname.startswith("Ethernet") is False) and (peer_ifname.startswith("PortChannel") is False): + ctx.fail("peer interface is invalid, should be Ethernet interface or portChannel !!") + if (peer_ifname.startswith("Ethernet") is True) and (interface_name_is_valid(peer_ifname) is False): + ctx.fail("peer Ethernet interface name is invalid. it is not present in port table of configDb!!") + if (peer_ifname.startswith("PortChannel")) and (is_portchannel_name_valid(peer_ifname) is False): + ctx.fail("peer PortChannel interface name is invalid !!") + fvs['peer_link'] = str(peer_ifname) + mclag_domain_keys = db.get_table('MCLAG_DOMAIN').keys() + if len(mclag_domain_keys) == 0: + db.set_entry('MCLAG_DOMAIN', domain_id, fvs) + else: + if domain_id in mclag_domain_keys: + db.mod_entry('MCLAG_DOMAIN', domain_id, fvs) + else: + ctx.fail("only one mclag Domain can be configured. Already one domain {} configured ".format(mclag_domain_keys[0])) + + +#mclag domain delete +#MCLAG Domain del involves deletion of associated MCLAG Ifaces also +@mclag.command('del') +@click.argument('domain_id', metavar='', required=True, type=int) +@click.pass_context +def del_mclag_domain(ctx, domain_id): + """Delete MCLAG Domain""" + + if not mclag_domain_id_valid(domain_id): + ctx.fail("{} invalid domain ID, valid range is 1 to 4095".format(domain_id)) + + db = ctx.obj['db'] + entry = db.get_entry('MCLAG_DOMAIN', domain_id) + if entry is None: + ctx.fail("MCLAG Domain {} not configured ".format(domain_id)) + return + + click.echo("MCLAG Domain delete takes care of deleting all associated MCLAG Interfaces") + + #get all MCLAG Interface associated with this domain and delete + interface_table_keys = db.get_table('MCLAG_INTERFACE').keys() + + #delete associated mclag interfaces + for iface_domain_id, iface_name in interface_table_keys: + if (int(iface_domain_id) == domain_id): + db.set_entry('MCLAG_INTERFACE', (iface_domain_id, iface_name), None ) + + #delete mclag domain + db.set_entry('MCLAG_DOMAIN', domain_id, None) + + +#keepalive timeout config +@mclag.command('keepalive-interval') +@click.argument('domain_id', metavar='', required=True) +@click.argument('time_in_secs', metavar='', required=True, type=int) +@click.pass_context +def config_mclag_keepalive_timer(ctx, domain_id, time_in_secs): + """Configure MCLAG Keepalive timer value in secs""" + db = ctx.obj['db'] + + entry = db.get_entry('MCLAG_DOMAIN', domain_id) + if len(entry) == 0: + ctx.fail("MCLAG Domain " + domain_id + " not configured, configure mclag domain first") + + status, error_info = mclag_ka_interval_valid(time_in_secs) + if status is not True: + ctx.fail(error_info) + + session_timeout_value = entry.get('session_timeout') + + if session_timeout_value is None: + # assign default value + int_sess_tmout = 15 + else: + int_sess_tmout = int(session_timeout_value) + + status, error_info = mclag_ka_session_dep_check(time_in_secs, int_sess_tmout) + if status is not True: + ctx.fail(error_info) + + fvs = {} + fvs['keepalive_interval'] = str(time_in_secs) + db.mod_entry('MCLAG_DOMAIN', domain_id, fvs) + + +#session timeout config +@mclag.command('session-timeout') +@click.argument('domain_id', metavar='', required=True) +@click.argument('time_in_secs', metavar='', required=True, type=int) +@click.pass_context +def config_mclag_session_timeout(ctx, domain_id, time_in_secs): + """Configure MCLAG Session timeout value in secs""" + db = ctx.obj['db'] + entry = db.get_entry('MCLAG_DOMAIN', domain_id) + if len(entry) == 0: + ctx.fail("MCLAG Domain " + domain_id + " not configured, configure mclag domain first") + + status, error_info = mclag_session_timeout_valid(time_in_secs) + if status is not True: + ctx.fail(error_info) + + ka = entry.get('keepalive_interval') + if ka is None: + # assign default value + int_ka = 1 + else: + int_ka = int(ka) + + status, error_info = mclag_ka_session_dep_check(int_ka, time_in_secs) + if status is not True: + ctx.fail(error_info) + + fvs = {} + fvs['session_timeout'] = str(time_in_secs) + db.mod_entry('MCLAG_DOMAIN', domain_id, fvs) + + +#mclag interface config +@mclag.group('member') +@click.pass_context +def mclag_member(ctx): + pass + +@mclag_member.command('add') +@click.argument('domain_id', metavar='', required=True) +@click.argument('portchannel_names', metavar='', required=True) +@click.pass_context +def add_mclag_member(ctx, domain_id, portchannel_names): + """Add member MCLAG interfaces from MCLAG Domain""" + db = ctx.obj['db'] + portchannel_list = portchannel_names.split(",") + for portchannel_name in portchannel_list: + if is_portchannel_name_valid(portchannel_name) != True: + ctx.fail("{} is invalid!, name should have prefix '{}' and suffix '{}'" .format(portchannel_name, CFG_PORTCHANNEL_PREFIX, CFG_PORTCHANNEL_NO)) + db.set_entry('MCLAG_INTERFACE', (domain_id, portchannel_name), {'if_type':"PortChannel"} ) + +@mclag_member.command('del') +@click.argument('domain_id', metavar='', required=True) +@click.argument('portchannel_names', metavar='', required=True) +@click.pass_context +def del_mclag_member(ctx, domain_id, portchannel_names): + """Delete member MCLAG interfaces from MCLAG Domain""" + db = ctx.obj['db'] + #split comma seperated portchannel names + portchannel_list = portchannel_names.split(",") + for portchannel_name in portchannel_list: + if is_portchannel_name_valid(portchannel_name) != True: + ctx.fail("{} is invalid!, name should have prefix '{}' and suffix '{}'" .format(portchannel_name, CFG_PORTCHANNEL_PREFIX, CFG_PORTCHANNEL_NO)) + db.set_entry('MCLAG_INTERFACE', (domain_id, portchannel_name), None ) + +#mclag unique ip config +@mclag.group('unique-ip') +@click.pass_context +def mclag_unique_ip(ctx): + """Add unique ip on MCLAG vlan interface""" + pass + +@mclag_unique_ip.command('add') +@click.argument('interface_names', metavar='', required=True) +@click.pass_context +def add_mclag_unique_ip(ctx, interface_names): + """Add unique ip on MCLAG vlan interface""" + db = ctx.obj['db'] + mclag_domain_keys = db.get_table('MCLAG_DOMAIN').keys() + if len(mclag_domain_keys) == 0: + ctx.fail("MCLAG not configured. MCLAG should be configured.") + + #split comma seperated interface names + interface_list = interface_names.split(",") + for interface_name in interface_list: + if not interface_name.startswith("Vlan"): + ctx.fail("{} is invalid!, name should have prefix '{}' and suffix '{}'" .format(interface_name, "Vlan", "vlan id")) + #VRF should be configured after unique IP configuration + intf_vrf = get_intf_vrf_bind_unique_ip(db, interface_name, "VLAN_INTERFACE") + if intf_vrf: + ctx.fail("%s is configured with Non default VRF, remove the VRF configuration and reconfigure after enabling unique IP configuration."%(str(interface_name))) + + #IP should be configured after unique IP configuration + for k,v in db.get_table('VLAN_INTERFACE').iteritems(): + if type(k) == tuple: + (intf_name, ip) = k + if intf_name == interface_name and ip != 0: + ctx.fail("%s is configured with IP %s, remove the IP configuration and reconfigure after enabling unique IP configuration."%(str(intf_name), str(ip))) + db.set_entry('MCLAG_UNIQUE_IP', (interface_name), {'unique_ip':"enable"} ) + +@mclag_unique_ip.command('del') +@click.argument('interface_names', metavar='', required=True) +@click.pass_context +def del_mclag_unique_ip(ctx, interface_names): + """Delete unique ip from MCLAG vlan interface""" + db = ctx.obj['db'] + #split comma seperated interface names + interface_list = interface_names.split(",") + for interface_name in interface_list: + if not interface_name.startswith("Vlan"): + ctx.fail("{} is invalid!, name should have prefix '{}' and suffix '{}'" .format(interface_name, "Vlan", "vlan id")) + #VRF should be configured after removing unique IP configuration + intf_vrf = get_intf_vrf_bind_unique_ip(db, interface_name, "VLAN_INTERFACE") + if intf_vrf: + ctx.fail("%s is configured with Non default VRF, remove the VRF configuration and reconfigure after disabling unique IP configuration."%(str(interface_name))) + #IP should be configured after removing unique IP configuration + for k,v in db.get_table('VLAN_INTERFACE').iteritems(): + if type(k) == tuple: + (intf_name, ip) = k + if intf_name == interface_name and ip != 0: + ctx.fail("%s is configured with IP %s, remove the IP configuration and reconfigure after disabling unique IP configuration."%(str(intf_name), str(ip))) + db.set_entry('MCLAG_UNIQUE_IP', (interface_name), None ) + +####### if __name__ == '__main__': config() From e31a0e42a3154527c370b5986e6b6b09d818f016 Mon Sep 17 00:00:00 2001 From: Tapash Das Date: Tue, 10 Nov 2020 23:19:11 -0800 Subject: [PATCH 02/68] Updated code. --- config/main.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/config/main.py b/config/main.py index d250032bbe..3762a6d00f 100755 --- a/config/main.py +++ b/config/main.py @@ -410,6 +410,16 @@ def interface_ipaddr_dependent_on_interface(config_db, interface_name): data.append(key) return data +def get_intf_vrf_bind_unique_ip(db, interface_name, interface_type): + intfvrf = db.get_table(interface_type) + if interface_name in intfvrf: + if 'vrf_name' in intfvrf[interface_name]: + return intfvrf[interface_name]['vrf_name'] + else: + return "" + else: + return "" + def is_interface_bind_to_vrf(config_db, interface_name): """Get interface if bind to vrf or not """ From 82dedb094bd10af4fc27a5ac1e7c3b73befe7ba7 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 17 Nov 2020 16:29:18 -0800 Subject: [PATCH 03/68] addressed LGTM alert --- config/main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/config/main.py b/config/main.py index 3762a6d00f..1c82ee0e52 100755 --- a/config/main.py +++ b/config/main.py @@ -3725,7 +3725,6 @@ def mclag(ctx): config_db = ConfigDBConnector() config_db.connect() ctx.obj = {'db': config_db} - pass #mclag domain add From 4f6aaeeaad98068f1d7393446341af7811163c31 Mon Sep 17 00:00:00 2001 From: Tapash Das Date: Tue, 24 Nov 2020 08:31:54 -0800 Subject: [PATCH 04/68] Updated code. --- config/main.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/config/main.py b/config/main.py index 1c82ee0e52..38239fc5c3 100755 --- a/config/main.py +++ b/config/main.py @@ -47,6 +47,11 @@ SYSTEMCTL_ACTION_RESTART="restart" SYSTEMCTL_ACTION_RESET_FAILED="reset-failed" +CFG_PORTCHANNEL_PREFIX = "PortChannel" +CFG_PORTCHANNEL_PREFIX_LEN = 11 +CFG_PORTCHANNEL_NAME_TOTAL_LEN_MAX = 15 +CFG_PORTCHANNEL_MAX_VAL = 9999 + DEFAULT_NAMESPACE = '' CFG_LOOPBACK_PREFIX = "Loopback" CFG_LOOPBACK_PREFIX_LEN = len(CFG_LOOPBACK_PREFIX) @@ -410,6 +415,50 @@ def interface_ipaddr_dependent_on_interface(config_db, interface_name): data.append(key) return data +# +# Use this method to validate unicast IPv4 address +# +def is_ip4_addr_valid(addr, display): + v4_invalid_list = [ipaddress.IPv4Address(unicode('0.0.0.0')), ipaddress.IPv4Address(unicode('255.255.255.255'))] + try: + ip = ipaddress.ip_address(unicode(addr)) + if (ip.version == 4): + if (ip.is_reserved): + if display: + click.echo ("{} Not Valid, Reason: IPv4 reserved address range.".format(addr)) + return False + elif (ip.is_multicast): + if display: + click.echo ("{} Not Valid, Reason: IPv4 Multicast address range.".format(addr)) + return False + elif (ip in v4_invalid_list): + if display: + click.echo ("{} Not Valid.".format(addr)) + return False + else: + return True + + else: + if display: + click.echo ("{} Not Valid, Reason: Not an IPv4 address".format(addr)) + return False + + except ValueError: + return False + +def is_portchannel_name_valid(portchannel_name): + """Port Channel name validation + """ + + if portchannel_name[:CFG_PORTCHANNEL_PREFIX_LEN] != CFG_PORTCHANNEL_PREFIX : + return False + if (portchannel_name[CFG_PORTCHANNEL_PREFIX_LEN:].isdigit() is False or + int(portchannel_name[CFG_PORTCHANNEL_PREFIX_LEN:]) > CFG_PORTCHANNEL_MAX_VAL) : + return False + if len(portchannel_name) > CFG_PORTCHANNEL_NAME_TOTAL_LEN_MAX: + return False + return True + def get_intf_vrf_bind_unique_ip(db, interface_name, interface_type): intfvrf = db.get_table(interface_type) if interface_name in intfvrf: @@ -3751,7 +3800,7 @@ def add_mclag_domain(ctx, domain_id, source_ip_addr, peer_ip_addr, peer_ifname): if peer_ifname is not None: if (peer_ifname.startswith("Ethernet") is False) and (peer_ifname.startswith("PortChannel") is False): ctx.fail("peer interface is invalid, should be Ethernet interface or portChannel !!") - if (peer_ifname.startswith("Ethernet") is True) and (interface_name_is_valid(peer_ifname) is False): + if (peer_ifname.startswith("Ethernet") is True) and (interface_name_is_valid(db, peer_ifname) is False): ctx.fail("peer Ethernet interface name is invalid. it is not present in port table of configDb!!") if (peer_ifname.startswith("PortChannel")) and (is_portchannel_name_valid(peer_ifname) is False): ctx.fail("peer PortChannel interface name is invalid !!") From bfac89206dc093d6692114eae84cd297baa2b845 Mon Sep 17 00:00:00 2001 From: Tapash Das <48195098+tapashdas@users.noreply.github.com> Date: Fri, 8 Jan 2021 12:41:10 +0530 Subject: [PATCH 05/68] UT Fix unique IP configuration --- config/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/main.py b/config/main.py index 8db02f8b53..d88bfda05c 100644 --- a/config/main.py +++ b/config/main.py @@ -4457,7 +4457,7 @@ def add_mclag_unique_ip(ctx, interface_names): ctx.fail("%s is configured with Non default VRF, remove the VRF configuration and reconfigure after enabling unique IP configuration."%(str(interface_name))) #IP should be configured after unique IP configuration - for k,v in db.get_table('VLAN_INTERFACE').iteritems(): + for k,v in db.get_table('VLAN_INTERFACE').items(): if type(k) == tuple: (intf_name, ip) = k if intf_name == interface_name and ip != 0: @@ -4480,7 +4480,7 @@ def del_mclag_unique_ip(ctx, interface_names): if intf_vrf: ctx.fail("%s is configured with Non default VRF, remove the VRF configuration and reconfigure after disabling unique IP configuration."%(str(interface_name))) #IP should be configured after removing unique IP configuration - for k,v in db.get_table('VLAN_INTERFACE').iteritems(): + for k,v in db.get_table('VLAN_INTERFACE').items(): if type(k) == tuple: (intf_name, ip) = k if intf_name == interface_name and ip != 0: From 325b50baad5b31b2b5157c5ebf3a653767d64a5b Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 12 Jan 2021 15:49:41 -0800 Subject: [PATCH 06/68] modified ip address validate function for mclag config verication --- config/main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/main.py b/config/main.py index 85f57c7814..78a7285eef 100644 --- a/config/main.py +++ b/config/main.py @@ -4391,10 +4391,10 @@ def add_mclag_domain(ctx, domain_id, source_ip_addr, peer_ip_addr, peer_ifname): if not mclag_domain_id_valid(domain_id): ctx.fail("{} invalid domain ID, valid range is 1 to 4095".format(domain_id)) - if not is_ip4_addr_valid(source_ip_addr, True): - ctx.fail("{} invalid local ip address".format(source_ip_addr)) - if not is_ip4_addr_valid(peer_ip_addr, True): - ctx.fail("{} invalid peer ip address".format(peer_ip_addr)) + if not clicommon.is_ipaddress(source_ip_addr): + ctx.fail("{} invalid local ip address".format(source_ip_addr)) + if not clicommon.is_ipaddress(peer_ip_addr): + ctx.fail("{} invalid peer ip address".format(peer_ip_addr)) db = ctx.obj['db'] fvs = {} From b2b78c222b9b550456e165974fcac605c3b7919a Mon Sep 17 00:00:00 2001 From: Sujin Kang Date: Tue, 2 Mar 2021 09:27:14 -0800 Subject: [PATCH 07/68] Add soft-reboot reboot type (#1453) What I did Add a new reboot named as soft-reboot which can be performed by "kexec -e" How I did it Replace the platform reboot with "kexec -e" for the cold reboot case. How to verify it Verified the reboot on DUT and check the reboot-cause --- scripts/soft-reboot | 227 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 227 insertions(+) create mode 100755 scripts/soft-reboot diff --git a/scripts/soft-reboot b/scripts/soft-reboot new file mode 100755 index 0000000000..52ccdd690b --- /dev/null +++ b/scripts/soft-reboot @@ -0,0 +1,227 @@ +#!/bin/bash +DEVPATH="/usr/share/sonic/device" +REBOOT_CAUSE_FILE="/host/reboot-cause/reboot-cause.txt" +REBOOT_TIME=$(date) +REBOOT_METHOD="/sbin/kexec -e" +LOG_SSD_HEALTH="/usr/local/bin/log_ssd_health" +WATCHDOG_UTIL="/usr/local/bin/watchdogutil" + +EXIT_SUCCESS=0 +EXIT_FAILURE=1 +EXIT_NOT_SUPPORTED=2 +EXIT_FILE_SYSTEM_FULL=3 +EXIT_NEXT_IMAGE_NOT_EXISTS=4 + +# Reboot immediately if we run the kdump capture kernel +VMCORE_FILE=/proc/vmcore +if [ -e $VMCORE_FILE -a -s $VMCORE_FILE ]; then + echo "We have a /proc/vmcore, then we just kdump'ed" + echo "User issued 'kdump' command [User: kdump, Time: ${REBOOT_TIME}]" > ${REBOOT_CAUSE_FILE} + sync + PLATFORM=$(grep -oP 'sonic_platform=\K\S+' /proc/cmdline) + if [ ! -z "${PLATFORM}" -a -x ${DEVPATH}/${PLATFORM}/${PLAT_REBOOT} ]; then + exec ${DEVPATH}/${PLATFORM}/${PLAT_REBOOT} + fi + # If no platform-specific reboot tool, just run /sbin/reboot + /sbin/reboot + echo 1 > /proc/sys/kernel/sysrq + echo b > /proc/sysrq-trigger +fi + +REBOOT_USER=$(logname) +PLATFORM=$(sonic-cfggen -H -v DEVICE_METADATA.localhost.platform) +ASIC_TYPE=$(sonic-cfggen -y /etc/sonic/sonic_version.yml -v asic_type) +VERBOSE=no +EXIT_NEXT_IMAGE_NOT_EXISTS=4 +EXIT_SONIC_INSTALLER_VERIFY_REBOOT=21 +SSD_FW_UPDATE="ssd-fw-upgrade" +REBOOT_SCRIPT_NAME=$(basename $0) +REBOOT_TYPE="${REBOOT_SCRIPT_NAME}" +PLATFORM_PLUGIN="${REBOOT_TYPE}_plugin" +BOOT_TYPE_ARG="soft" +TAG_LATEST=yes + +function debug() +{ + if [[ x"${VERBOSE}" == x"yes" ]]; then + echo `date` $@ + fi + logger "$@" +} + +function tag_images() +{ + if test -f /usr/local/bin/ctrmgr_tools.py + then + if [[ x"${TAG_LATEST}" == x"yes" ]]; then + /usr/local/bin/ctrmgr_tools.py tag-all + fi + fi +} + +function stop_sonic_services() +{ + if [[ x"$ASIC_TYPE" != x"mellanox" ]]; then + debug "Stopping syncd process..." + docker exec -i syncd /usr/bin/syncd_request_shutdown --cold > /dev/null + sleep 3 + fi +} + +function clear_lingering_reboot_config() +{ + # Clear any outstanding warm-reboot config + result=`timeout 10s config warm_restart disable; if [[ $? == 124 ]]; then echo timeout; else echo "code ($?)"; fi` || /bin/true + debug "Cancel warm-reboot: ${result}" + + WARM_DIR="/host/warmboot" + REDIS_FILE=dump.rdb + TIMESTAMP=`date +%Y%m%d-%H%M%S` + if [[ -f ${WARM_DIR}/${REDIS_FILE} ]]; then + mv -f ${WARM_DIR}/${REDIS_FILE} ${WARM_DIR}/${REDIS_FILE}.${TIMESTAMP} || /bin/true + fi + /sbin/kexec -u || /bin/true +} + +SCRIPT=$0 + +function show_help_and_exit() +{ + echo "Usage ${SCRIPT} [options]" + echo " Request rebooting the device. Invoke platform-specific tool when available." + echo " This script will shutdown syncd before rebooting." + echo " " + echo " Available options:" + echo " -h, -? : getting this help" + + exit "${EXIT_SUCCESS}" +} + +function setup_reboot_variables() +{ + # Kernel and initrd image + NEXT_SONIC_IMAGE=$(sonic-installer list | grep "Next: " | cut -d ' ' -f 2) + IMAGE_PATH="/host/image-${NEXT_SONIC_IMAGE#SONiC-OS-}" + if grep -q aboot_platform= /host/machine.conf; then + KERNEL_IMAGE="$(ls $IMAGE_PATH/boot/vmlinuz-*)" + BOOT_OPTIONS="$(cat "$IMAGE_PATH/kernel-cmdline" | tr '\n' ' ') SONIC_BOOT_TYPE=${BOOT_TYPE_ARG}" + elif grep -q onie_platform= /host/machine.conf; then + KERNEL_OPTIONS=$(cat /host/grub/grub.cfg | sed "/$NEXT_SONIC_IMAGE'/,/}/"'!'"g" | grep linux) + KERNEL_IMAGE="/host$(echo $KERNEL_OPTIONS | cut -d ' ' -f 2)" + BOOT_OPTIONS="$(echo $KERNEL_OPTIONS | sed -e 's/\s*linux\s*/BOOT_IMAGE=/') SONIC_BOOT_TYPE=${BOOT_TYPE_ARG}" + else + error "Unknown bootloader. ${REBOOT_TYPE} is not supported." + exit "${EXIT_NOT_SUPPORTED}" + fi + INITRD=$(echo $KERNEL_IMAGE | sed 's/vmlinuz/initrd.img/g') +} + +function load_kernel() { + # Load kernel into the memory + /sbin/kexec -l "$KERNEL_IMAGE" --initrd="$INITRD" --append="$BOOT_OPTIONS" +} + +function reboot_pre_check() +{ + # Make sure that the file system is normal: read-write able + filename="/host/test-`date +%Y%m%d-%H%M%S`" + ERR=0 + touch ${filename} || ERR=$? + if [[ ${ERR} -ne 0 ]]; then + # Continue rebooting in this case, but log the error + VERBOSE=yes debug "Filesystem might be read-only or full ..." + fi + rm ${filename} + + # Verify the next image by sonic-installer + local message=$(sonic-installer verify-next-image 2>&1) + if [ $? -ne 0 ]; then + VERBOSE=yes debug "Failed to verify next image: ${message}" + exit ${EXIT_SONIC_INSTALLER_VERIFY_REBOOT} + fi +} + +function parse_options() +{ + while getopts "h?v" opt; do + case ${opt} in + h|\? ) + show_help_and_exit + ;; + v ) + VERBOSE=yes + ;; + t ) + TAG_LATEST=no + ;; + esac + done +} + +parse_options $@ + +# Exit if not superuser +if [[ "$EUID" -ne 0 ]]; then + echo "This command must be run as root" >&2 + exit "${EXIT_FAILURE}" +fi + +if [ -x ${LOG_SSD_HEALTH} ]; then + debug "Collecting logs to check ssd health before ${REBOOT_TYPE}..." + ${LOG_SSD_HEALTH} +fi + +debug "User requested rebooting device ..." + +setup_reboot_variables +reboot_pre_check + +# Tag remotely deployed images as local +tag_images + +# Stop SONiC services gracefully. +stop_sonic_services + +clear_lingering_reboot_config + +load_kernel + +# Update the reboot cause file to reflect that user issued 'reboot' command +# Upon next boot, the contents of this file will be used to determine the +# cause of the previous reboot +echo "User issued '${REBOOT_SCRIPT_NAME}' command [User: ${REBOOT_USER}, Time: ${REBOOT_TIME}]" > ${REBOOT_CAUSE_FILE} + +sync +sleep 3 +sync + +# sync the current system time to CMOS +if [ -x /sbin/hwclock ]; then + /sbin/hwclock -w || /bin/true +fi + +if [ -x ${DEVPATH}/${PLATFORM}/${SSD_FW_UPDATE} ]; then + debug "updating ssd fw for${REBOOT_TYPE}" + ${DEVPATH}/${PLATFORM}/${SSD_FW_UPDATE} ${REBOOT_TYPE} +fi + +# Enable Watchdog Timer +if [ -x ${WATCHDOG_UTIL} ]; then + debug "Enabling Watchdog before ${REBOOT_TYPE}" + ${WATCHDOG_UTIL} arm +fi + +# Run platform specific reboot plugin +if [ -x ${DEVPATH}/${PLATFORM}/${PLATFORM_PLUGIN} ]; then + debug "Running ${PLATFORM} specific plugin..." + ${DEVPATH}/${PLATFORM}/${PLATFORM_PLUGIN} +fi + +# Reboot: explicitly call Linux "kexec -e" +debug "Rebooting with ${REBOOT_METHOD} to ${NEXT_SONIC_IMAGE} ..." +exec ${REBOOT_METHOD} + +# Should never reach here +error "${REBOOT_TYPE} failed!" +exit "${EXIT_FAILURE}" + From cd0ea5cc45ac99c6163f39300dbe7bcc32902809 Mon Sep 17 00:00:00 2001 From: Shi Su <67605788+shi-su@users.noreply.github.com> Date: Tue, 2 Mar 2021 22:07:15 -0800 Subject: [PATCH 08/68] [warm-reboot] Check if warm restart flag is set when issuing a warm-reboot (#1460) Check if any warm restart flag is set when issuing a warm-reboot. This check avoids starting a warm reboot while another warm restart is in progress. In the scenario where a warm reboot is issued with another warm restart in progress, the warm restart flag may be reset and part of the components have a risk of doing cold reboot. --- scripts/fast-reboot | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/fast-reboot b/scripts/fast-reboot index e0450f802b..13ad66a25e 100755 --- a/scripts/fast-reboot +++ b/scripts/fast-reboot @@ -398,6 +398,19 @@ function save_counters_folder() { fi } +function check_warm_restart_in_progress() { + sonic-db-cli STATE_DB keys "WARM_RESTART_ENABLE_TABLE|*" | while read key ; do + if [[ x"$(sonic-db-cli STATE_DB hget $key enable)" == x"true" ]]; then + if [[ x"${FORCE}" == x"yes" ]]; then + debug "Ignoring warm restart flag for ${key#*|}" + else + echo "Warm restart flag for ${key#*|} is set. Please check if a warm restart for ${key#*|} is in progress." + exit "${EXIT_FAILURE}" + fi + fi + done +} + # main starts here parseOptions $@ @@ -419,6 +432,7 @@ case "$REBOOT_TYPE" in sonic-db-cli STATE_DB SET "FAST_REBOOT|system" "1" "EX" "180" &>/dev/null ;; "warm-reboot") + check_warm_restart_in_progress if [[ "$sonic_asic_type" == "mellanox" ]]; then REBOOT_TYPE="fastfast-reboot" BOOT_TYPE_ARG="fastfast" From 357106fae9d2242f755c0a271194530dba172a23 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Mon, 5 Apr 2021 13:10:35 -0700 Subject: [PATCH 09/68] Added mclag config commands --- config/main.py | 6 + config/mclag.py | 291 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 297 insertions(+) create mode 100644 config/mclag.py diff --git a/config/main.py b/config/main.py index 18eda659d9..e8b2ef39b8 100644 --- a/config/main.py +++ b/config/main.py @@ -35,6 +35,7 @@ from . import vxlan from . import plugins from .config_mgmt import ConfigMgmtDPB +import mclag as mclag_cli # mock masic APIs for unit test try: @@ -876,6 +877,11 @@ def config(ctx): config.add_command(vlan.vlan) config.add_command(vxlan.vxlan) +#add mclag commands +config.add_command(mclag_cli.mclag) +config.add_command(mclag_cli.mclag_member) +config.add_command(mclag_cli.mclag_unique_ip) + @config.command() @click.option('-y', '--yes', is_flag=True, callback=_abort_if_false, expose_value=False, prompt='Existing files will be overwritten, continue?') diff --git a/config/mclag.py b/config/mclag.py new file mode 100644 index 0000000000..1dc5735423 --- /dev/null +++ b/config/mclag.py @@ -0,0 +1,291 @@ +#!/usr/sbin/env python + +import click +import syslog +import re +import swsssdk +import ipaddress + +import utilities_common.cli as clicommon + +def mclag_domain_id_valid(domain_id): + """Check if the domain id is in acceptable range (between 1 and 4095) + """ + + if domain_id<1 or domain_id>4095: + return False + + return True + +def mclag_ka_session_dep_check(ka, session_tmout): + """Check if the MCLAG Keepalive timer and session timeout values are multiples of each other and keepalive is < session timeout value + """ + if not session_tmout >= ( 3 * ka): + return False, "MCLAG Keepalive:{} Session_timeout:{} values not satisfying session_timeout >= (3 * KA) ".format(session_tmout, ka) + + if session_tmout % ka: + return False, "MCLAG keepalive:{} Session_timeout:{} Values not satisfying session_timeout should be a multiple of KA".format(ka, session_tmout) + + return True, "" + + +def mclag_ka_interval_valid(ka): + """Check if the MCLAG Keepalive timer is in acceptable range (between 1 and 60) + """ + if ka < 1 or ka > 60: + return False, "Keepalive %s not in valid range[1-60]" % ka + return True, "" + +def mclag_session_timeout_valid(session_tmout): + """Check if the MCLAG session timeout in valid range (between 3 and 3600) + """ + if session_tmout < 3 or session_tmout > 3600: + return False, "Session timeout %s not in valid range[3-3600]" % session_tmout + return True, "" + + +###### +# +# 'mclag' group ('config mclag ...') +# +@click.group() +@click.pass_context +def mclag(ctx): + config_db = swsssdk.ConfigDBConnector() + config_db.connect() + ctx.obj = {'db': config_db} + + +#mclag domain add +@mclag.command('add') +@click.argument('domain_id', metavar='', required=True, type=int) +@click.argument('source_ip_addr', metavar='', required=True) +@click.argument('peer_ip_addr', metavar='', required=True) +@click.argument('peer_ifname', metavar='', required=False) +@click.pass_context +def add_mclag_domain(ctx, domain_id, source_ip_addr, peer_ip_addr, peer_ifname): + """Add MCLAG Domain""" + + if not mclag_domain_id_valid(domain_id): + ctx.fail("{} invalid domain ID, valid range is 1 to 4095".format(domain_id)) + if not clicommon.is_ipaddress(source_ip_addr): + ctx.fail("{} invalid local ip address".format(source_ip_addr)) + if not clicommon.is_ipaddress(peer_ip_addr): + ctx.fail("{} invalid peer ip address".format(peer_ip_addr)) + + db = ctx.obj['db'] + fvs = {} + fvs['source_ip'] = str(source_ip_addr) + fvs['peer_ip'] = str(peer_ip_addr) + if peer_ifname is not None: + if (peer_ifname.startswith("Ethernet") is False) and (peer_ifname.startswith("PortChannel") is False): + ctx.fail("peer interface is invalid, should be Ethernet interface or portChannel !!") + if (peer_ifname.startswith("Ethernet") is True) and (interface_name_is_valid(db, peer_ifname) is False): + ctx.fail("peer Ethernet interface name is invalid. it is not present in port table of configDb!!") + if (peer_ifname.startswith("PortChannel")) and (is_portchannel_name_valid(peer_ifname) is False): + ctx.fail("peer PortChannel interface name is invalid !!") + fvs['peer_link'] = str(peer_ifname) + mclag_domain_keys = db.get_table('MCLAG_DOMAIN').keys() + if len(mclag_domain_keys) == 0: + db.set_entry('MCLAG_DOMAIN', domain_id, fvs) + else: + if domain_id in mclag_domain_keys: + db.mod_entry('MCLAG_DOMAIN', domain_id, fvs) + else: + ctx.fail("only one mclag Domain can be configured. Already one domain {} configured ".format(mclag_domain_keys[0])) + + +#mclag domain delete +#MCLAG Domain del involves deletion of associated MCLAG Ifaces also +@mclag.command('del') +@click.argument('domain_id', metavar='', required=True, type=int) +@click.pass_context +def del_mclag_domain(ctx, domain_id): + """Delete MCLAG Domain""" + + if not mclag_domain_id_valid(domain_id): + ctx.fail("{} invalid domain ID, valid range is 1 to 4095".format(domain_id)) + + db = ctx.obj['db'] + entry = db.get_entry('MCLAG_DOMAIN', domain_id) + if entry is None: + ctx.fail("MCLAG Domain {} not configured ".format(domain_id)) + return + + click.echo("MCLAG Domain delete takes care of deleting all associated MCLAG Interfaces") + + #get all MCLAG Interface associated with this domain and delete + interface_table_keys = db.get_table('MCLAG_INTERFACE').keys() + + #delete associated mclag interfaces + for iface_domain_id, iface_name in interface_table_keys: + if (int(iface_domain_id) == domain_id): + db.set_entry('MCLAG_INTERFACE', (iface_domain_id, iface_name), None ) + + #delete mclag domain + db.set_entry('MCLAG_DOMAIN', domain_id, None) + + +#keepalive timeout config +@mclag.command('keepalive-interval') +@click.argument('domain_id', metavar='', required=True) +@click.argument('time_in_secs', metavar='', required=True, type=int) +@click.pass_context +def config_mclag_keepalive_timer(ctx, domain_id, time_in_secs): + """Configure MCLAG Keepalive timer value in secs""" + db = ctx.obj['db'] + + entry = db.get_entry('MCLAG_DOMAIN', domain_id) + if len(entry) == 0: + ctx.fail("MCLAG Domain " + domain_id + " not configured, configure mclag domain first") + + status, error_info = mclag_ka_interval_valid(time_in_secs) + if status is not True: + ctx.fail(error_info) + + session_timeout_value = entry.get('session_timeout') + + if session_timeout_value is None: + # assign default value + int_sess_tmout = 15 + else: + int_sess_tmout = int(session_timeout_value) + + status, error_info = mclag_ka_session_dep_check(time_in_secs, int_sess_tmout) + if status is not True: + ctx.fail(error_info) + + fvs = {} + fvs['keepalive_interval'] = str(time_in_secs) + db.mod_entry('MCLAG_DOMAIN', domain_id, fvs) + + +#session timeout config +@mclag.command('session-timeout') +@click.argument('domain_id', metavar='', required=True) +@click.argument('time_in_secs', metavar='', required=True, type=int) +@click.pass_context +def config_mclag_session_timeout(ctx, domain_id, time_in_secs): + """Configure MCLAG Session timeout value in secs""" + db = ctx.obj['db'] + entry = db.get_entry('MCLAG_DOMAIN', domain_id) + if len(entry) == 0: + ctx.fail("MCLAG Domain " + domain_id + " not configured, configure mclag domain first") + + status, error_info = mclag_session_timeout_valid(time_in_secs) + if status is not True: + ctx.fail(error_info) + + ka = entry.get('keepalive_interval') + if ka is None: + # assign default value + int_ka = 1 + else: + int_ka = int(ka) + + status, error_info = mclag_ka_session_dep_check(int_ka, time_in_secs) + if status is not True: + ctx.fail(error_info) + + fvs = {} + fvs['session_timeout'] = str(time_in_secs) + db.mod_entry('MCLAG_DOMAIN', domain_id, fvs) + + +#mclag interface config +@mclag.group('member') +@click.pass_context +def mclag_member(ctx): + pass + +@mclag_member.command('add') +@click.argument('domain_id', metavar='', required=True) +@click.argument('portchannel_names', metavar='', required=True) +@click.pass_context +def add_mclag_member(ctx, domain_id, portchannel_names): + """Add member MCLAG interfaces from MCLAG Domain""" + db = ctx.obj['db'] + entry = db.get_entry('MCLAG_DOMAIN', domain_id) + if len(entry) == 0: + ctx.fail("MCLAG Domain " + domain_id + " not configured, configure mclag domain first") + + portchannel_list = portchannel_names.split(",") + for portchannel_name in portchannel_list: + if is_portchannel_name_valid(portchannel_name) != True: + ctx.fail("{} is invalid!, name should have prefix '{}' and suffix '{}'" .format(portchannel_name, CFG_PORTCHANNEL_PREFIX, CFG_PORTCHANNEL_NO)) + db.set_entry('MCLAG_INTERFACE', (domain_id, portchannel_name), {'if_type':"PortChannel"} ) + +@mclag_member.command('del') +@click.argument('domain_id', metavar='', required=True) +@click.argument('portchannel_names', metavar='', required=True) +@click.pass_context +def del_mclag_member(ctx, domain_id, portchannel_names): + """Delete member MCLAG interfaces from MCLAG Domain""" + db = ctx.obj['db'] + #split comma seperated portchannel names + portchannel_list = portchannel_names.split(",") + for portchannel_name in portchannel_list: + if is_portchannel_name_valid(portchannel_name) != True: + ctx.fail("{} is invalid!, name should have prefix '{}' and suffix '{}'" .format(portchannel_name, CFG_PORTCHANNEL_PREFIX, CFG_PORTCHANNEL_NO)) + db.set_entry('MCLAG_INTERFACE', (domain_id, portchannel_name), None ) + +#mclag unique ip config +@mclag.group('unique-ip') +@click.pass_context +def mclag_unique_ip(ctx): + """Configure Unique IP on MCLAG Vlan interface""" + pass + +@mclag_unique_ip.command('add') +@click.argument('interface_names', metavar='', required=True) +@click.pass_context +def add_mclag_unique_ip(ctx, interface_names): + """Add Unique IP on MCLAG Vlan interface""" + db = ctx.obj['db'] + mclag_domain_keys = db.get_table('MCLAG_DOMAIN').keys() + if len(mclag_domain_keys) == 0: + ctx.fail("MCLAG not configured. MCLAG should be configured.") + + #split comma seperated interface names + interface_list = interface_names.split(",") + for interface_name in interface_list: + if not interface_name.startswith("Vlan"): + ctx.fail("{} is invalid!, name should have prefix '{}' and suffix '{}'" .format(interface_name, "Vlan", "vlan id")) + #VRF should be configured after unique IP configuration + intf_vrf = get_intf_vrf_bind_unique_ip(db, interface_name, "VLAN_INTERFACE") + if intf_vrf: + ctx.fail("%s is configured with Non default VRF, remove the VRF configuration and reconfigure after enabling unique IP configuration."%(str(interface_name))) + + #IP should be configured after unique IP configuration + for k,v in db.get_table('VLAN_INTERFACE').items(): + if type(k) == tuple: + (intf_name, ip) = k + if intf_name == interface_name and ip != 0: + ctx.fail("%s is configured with IP %s, remove the IP configuration and reconfigure after enabling unique IP configuration."%(str(intf_name), str(ip))) + db.set_entry('MCLAG_UNIQUE_IP', (interface_name), {'unique_ip':"enable"} ) + +@mclag_unique_ip.command('del') +@click.argument('interface_names', metavar='', required=True) +@click.pass_context +def del_mclag_unique_ip(ctx, interface_names): + """Delete Unique IP from MCLAG Vlan interface""" + db = ctx.obj['db'] + #split comma seperated interface names + interface_list = interface_names.split(",") + for interface_name in interface_list: + if not interface_name.startswith("Vlan"): + ctx.fail("{} is invalid!, name should have prefix '{}' and suffix '{}'" .format(interface_name, "Vlan", "vlan id")) + #VRF should be configured after removing unique IP configuration + intf_vrf = get_intf_vrf_bind_unique_ip(db, interface_name, "VLAN_INTERFACE") + if intf_vrf: + ctx.fail("%s is configured with Non default VRF, remove the VRF configuration and reconfigure after disabling unique IP configuration."%(str(interface_name))) + #IP should be configured after removing unique IP configuration + for k,v in db.get_table('VLAN_INTERFACE').items(): + if type(k) == tuple: + (intf_name, ip) = k + if intf_name == interface_name and ip != 0: + ctx.fail("%s is configured with IP %s, remove the IP configuration and reconfigure after disabling unique IP configuration."%(str(intf_name), str(ip))) + db.set_entry('MCLAG_UNIQUE_IP', (interface_name), None ) + +####### + From ec65ed81f808d6a2af74e20aa51a79f2b9894d14 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Mon, 5 Apr 2021 13:31:29 -0700 Subject: [PATCH 10/68] removed unwanted imports --- config/mclag.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config/mclag.py b/config/mclag.py index 1dc5735423..aef981df36 100644 --- a/config/mclag.py +++ b/config/mclag.py @@ -1,11 +1,7 @@ #!/usr/sbin/env python import click -import syslog -import re import swsssdk -import ipaddress - import utilities_common.cli as clicommon def mclag_domain_id_valid(domain_id): From eac54611a0224feb0855ced22c93969c16ce5ff5 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Mon, 5 Apr 2021 14:35:21 -0700 Subject: [PATCH 11/68] added mclag tests --- tests/mclag_test.py | 55 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/mclag_test.py diff --git a/tests/mclag_test.py b/tests/mclag_test.py new file mode 100644 index 0000000000..06c32ee802 --- /dev/null +++ b/tests/mclag_test.py @@ -0,0 +1,55 @@ +import os +import traceback + +from click.testing import CliRunner + +import config.main as config +import show.main as show +from utilities_common.db import Db + + +MCLAG_DOMAIN_ID = "123" +MCLAG_SRC_IP = "12.1.1.1" +MCLAG_PEER_IP = "12.1.1.2" +MCLAG_PEER_LINK = "PortChannel12" +MCLAG_INVALID_SRC_IP1 = "12::1111" +MCLAG_INVALID_SRC_IP2 = "224.1.1.1" +MCLAG_INVALID_PEER_IP1 = "12::1112" +MCLAG_INVALID_PEER_IP2 = "224.1.1.2" + +class TestMclag(object): + @classmethod + def setup_class(cls): + os.environ['UTILITIES_UNIT_TESTING'] = "1" + print("SETUP") + + def test_add_mclag_with_invalid_src_ip(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # add mclag with invalid src + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID], [MCLAG_INVALID_SRC_IP1], [MCLAG_PEER_IP], [MCLAG_PEER_LINK], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code != 0 + assert "Error: mclag src ip is invalid'" in result.output + + def test_add_mclag_with_invalid_src_mcast_ip(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # add mclag with invalid src + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID], [MCLAG_INVALID_SRC_IP2], [MCLAG_PEER_IP], [MCLAG_PEER_LINK], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code != 0 + assert "Error: mclag src ip is invalid'" in result.output + + + + @classmethod + def teardown_class(cls): + os.environ['UTILITIES_UNIT_TESTING'] = "0" + print("TEARDOWN") From 6d78d7204939a8ce3db90984360809cd68e98e6c Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 6 Apr 2021 11:45:34 -0700 Subject: [PATCH 12/68] fixed build issue --- config/main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/main.py b/config/main.py index e8b2ef39b8..06e90e1b3c 100644 --- a/config/main.py +++ b/config/main.py @@ -35,7 +35,7 @@ from . import vxlan from . import plugins from .config_mgmt import ConfigMgmtDPB -import mclag as mclag_cli +from . import mclag # mock masic APIs for unit test try: @@ -878,9 +878,9 @@ def config(ctx): config.add_command(vxlan.vxlan) #add mclag commands -config.add_command(mclag_cli.mclag) -config.add_command(mclag_cli.mclag_member) -config.add_command(mclag_cli.mclag_unique_ip) +config.add_command(mclag.mclag) +config.add_command(mclag.mclag_member) +config.add_command(mclag.mclag_unique_ip) @config.command() @click.option('-y', '--yes', is_flag=True, callback=_abort_if_false, From bfa6a7d017782efe1cc958eff63346f027c444ca Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 6 Apr 2021 16:28:32 -0700 Subject: [PATCH 13/68] corrected mclag test --- tests/mclag_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 06c32ee802..6593c834ea 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -47,9 +47,9 @@ def test_add_mclag_with_invalid_src_mcast_ip(self): assert result.exit_code != 0 assert "Error: mclag src ip is invalid'" in result.output - - @classmethod + + @classmethod def teardown_class(cls): os.environ['UTILITIES_UNIT_TESTING'] = "0" print("TEARDOWN") From 77f9ad44105d17746c18035d5b0daa8cadceb486 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 6 Apr 2021 16:28:32 -0700 Subject: [PATCH 14/68] corrected mclag test --- tests/mclag_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 06c32ee802..6593c834ea 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -47,9 +47,9 @@ def test_add_mclag_with_invalid_src_mcast_ip(self): assert result.exit_code != 0 assert "Error: mclag src ip is invalid'" in result.output - - @classmethod + + @classmethod def teardown_class(cls): os.environ['UTILITIES_UNIT_TESTING'] = "0" print("TEARDOWN") From 1292a5fff7ff763cb23d3a06eab2bb97530642c0 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 6 Apr 2021 18:25:16 -0700 Subject: [PATCH 15/68] corrected mclag test case --- tests/mclag_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 6593c834ea..297230f6bd 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -29,7 +29,7 @@ def test_add_mclag_with_invalid_src_ip(self): obj = {'db':db.cfgdb} # add mclag with invalid src - result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID], [MCLAG_INVALID_SRC_IP1], [MCLAG_PEER_IP], [MCLAG_PEER_LINK], obj=obj) + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_SRC_IP1, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) print(result.exit_code) print(result.output) assert result.exit_code != 0 @@ -41,7 +41,7 @@ def test_add_mclag_with_invalid_src_mcast_ip(self): obj = {'db':db.cfgdb} # add mclag with invalid src - result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID], [MCLAG_INVALID_SRC_IP2], [MCLAG_PEER_IP], [MCLAG_PEER_LINK], obj=obj) + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_SRC_IP2, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) print(result.exit_code) print(result.output) assert result.exit_code != 0 From e0c2233a9d547aec95e1f0c155484c38b211c9da Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 6 Apr 2021 20:59:58 -0700 Subject: [PATCH 16/68] updated testcase for mclag --- config/mclag.py | 1 + 1 file changed, 1 insertion(+) diff --git a/config/mclag.py b/config/mclag.py index aef981df36..d8fac3a8fd 100644 --- a/config/mclag.py +++ b/config/mclag.py @@ -3,6 +3,7 @@ import click import swsssdk import utilities_common.cli as clicommon +from .main import is_portchannel_name_valid def mclag_domain_id_valid(domain_id): """Check if the domain id is in acceptable range (between 1 and 4095) From ba99b192470b61e424a248e8c811e9145aac0fac Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 6 Apr 2021 21:56:42 -0700 Subject: [PATCH 17/68] updated mclag config --- config/mclag.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/config/mclag.py b/config/mclag.py index d8fac3a8fd..7a0167aac8 100644 --- a/config/mclag.py +++ b/config/mclag.py @@ -3,7 +3,12 @@ import click import swsssdk import utilities_common.cli as clicommon -from .main import is_portchannel_name_valid + + +CFG_PORTCHANNEL_PREFIX = "PortChannel" +CFG_PORTCHANNEL_PREFIX_LEN = 11 +CFG_PORTCHANNEL_MAX_VAL = 9999 +CFG_PORTCHANNEL_NAME_TOTAL_LEN_MAX = 15 def mclag_domain_id_valid(domain_id): """Check if the domain id is in acceptable range (between 1 and 4095) @@ -41,6 +46,21 @@ def mclag_session_timeout_valid(session_tmout): return True, "" +def is_portchannel_name_valid(portchannel_name): + """Port channel name validation + """ + + # Return True if Portchannel name is PortChannelXXXX (XXXX can be 0-9999) + if portchannel_name[:CFG_PORTCHANNEL_PREFIX_LEN] != CFG_PORTCHANNEL_PREFIX : + return False + if (portchannel_name[CFG_PORTCHANNEL_PREFIX_LEN:].isdigit() is False or + int(portchannel_name[CFG_PORTCHANNEL_PREFIX_LEN:]) > CFG_PORTCHANNEL_MAX_VAL) : + return False + if len(portchannel_name) > CFG_PORTCHANNEL_NAME_TOTAL_LEN_MAX: + return False + return True + + ###### # # 'mclag' group ('config mclag ...') From 2bbfbc65a2ec3c4e1c3fc2b61d3742fdf0814ec4 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 6 Apr 2021 22:36:21 -0700 Subject: [PATCH 18/68] updated mclag test cases --- config/mclag.py | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/config/mclag.py b/config/mclag.py index 7a0167aac8..9ae2e7571f 100644 --- a/config/mclag.py +++ b/config/mclag.py @@ -2,7 +2,7 @@ import click import swsssdk -import utilities_common.cli as clicommon +import ipaddress CFG_PORTCHANNEL_PREFIX = "PortChannel" @@ -60,6 +60,31 @@ def is_portchannel_name_valid(portchannel_name): return False return True +def is_ipv4_addr_valid(addr): + v4_invalid_list = [ipaddress.IPv4Address(unicode('0.0.0.0')), ipaddress.IPv4Address(unicode('255.255.255.255'))] + try: + ip = ipaddress.ip_address(unicode(addr)) + if (ip.version == 4): + if (ip.is_reserved): + click.echo ("{} Not Valid, Reason: IPv4 reserved address range.".format(addr)) + return False + elif (ip.is_multicast): + click.echo ("{} Not Valid, Reason: IPv4 Multicast address range.".format(addr)) + return False + elif (ip in v4_invalid_list): + click.echo ("{} Not Valid.".format(addr)) + return False + else: + return True + + else: + click.echo ("{} Not Valid, Reason: Not an IPv4 address".format(addr)) + return False + + except ValueError: + return False + + ###### # @@ -85,9 +110,9 @@ def add_mclag_domain(ctx, domain_id, source_ip_addr, peer_ip_addr, peer_ifname): if not mclag_domain_id_valid(domain_id): ctx.fail("{} invalid domain ID, valid range is 1 to 4095".format(domain_id)) - if not clicommon.is_ipaddress(source_ip_addr): + if not is_ipv4_addr_valid(source_ip_addr): ctx.fail("{} invalid local ip address".format(source_ip_addr)) - if not clicommon.is_ipaddress(peer_ip_addr): + if not is_ipv4_addr_valid(peer_ip_addr): ctx.fail("{} invalid peer ip address".format(peer_ip_addr)) db = ctx.obj['db'] From 0ccd63f0bf23374ac60d1feb85a02b460cb589a2 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 6 Apr 2021 23:09:11 -0700 Subject: [PATCH 19/68] updated mclag test case --- tests/mclag_test.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 297230f6bd..b61bae9f7f 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -32,8 +32,7 @@ def test_add_mclag_with_invalid_src_ip(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_SRC_IP1, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) print(result.exit_code) print(result.output) - assert result.exit_code != 0 - assert "Error: mclag src ip is invalid'" in result.output + assert result.exit_code != 0, "Error: invalid local ip address" def test_add_mclag_with_invalid_src_mcast_ip(self): runner = CliRunner() @@ -44,8 +43,7 @@ def test_add_mclag_with_invalid_src_mcast_ip(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_SRC_IP2, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) print(result.exit_code) print(result.output) - assert result.exit_code != 0 - assert "Error: mclag src ip is invalid'" in result.output + assert result.exit_code != 0, "Error: invalid local ip address" From c119b406aff0d1c5448a3d0f30aed4b8e1c96fc6 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Wed, 7 Apr 2021 16:25:31 -0700 Subject: [PATCH 20/68] updated mclag test cases --- config/mclag.py | 9 +- tests/mclag_test.py | 232 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 239 insertions(+), 2 deletions(-) diff --git a/config/mclag.py b/config/mclag.py index 9ae2e7571f..7e155ca05d 100644 --- a/config/mclag.py +++ b/config/mclag.py @@ -49,7 +49,6 @@ def mclag_session_timeout_valid(session_tmout): def is_portchannel_name_valid(portchannel_name): """Port channel name validation """ - # Return True if Portchannel name is PortChannelXXXX (XXXX can be 0-9999) if portchannel_name[:CFG_PORTCHANNEL_PREFIX_LEN] != CFG_PORTCHANNEL_PREFIX : return False @@ -86,6 +85,12 @@ def is_ipv4_addr_valid(addr): +def check_if_interface_is_valid(db, interface_name): + from main import interface_name_is_valid + if interface_name_is_valid(db,interface_name) is False: + ctx.fail("Interface name is invalid. Please enter a valid interface name!!") + pass + ###### # # 'mclag' group ('config mclag ...') @@ -122,7 +127,7 @@ def add_mclag_domain(ctx, domain_id, source_ip_addr, peer_ip_addr, peer_ifname): if peer_ifname is not None: if (peer_ifname.startswith("Ethernet") is False) and (peer_ifname.startswith("PortChannel") is False): ctx.fail("peer interface is invalid, should be Ethernet interface or portChannel !!") - if (peer_ifname.startswith("Ethernet") is True) and (interface_name_is_valid(db, peer_ifname) is False): + if (peer_ifname.startswith("Ethernet") is True) and (check_if_interface_is_valid(db, peer_ifname) is False): ctx.fail("peer Ethernet interface name is invalid. it is not present in port table of configDb!!") if (peer_ifname.startswith("PortChannel")) and (is_portchannel_name_valid(peer_ifname) is False): ctx.fail("peer PortChannel interface name is invalid !!") diff --git a/tests/mclag_test.py b/tests/mclag_test.py index b61bae9f7f..1202d89704 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -9,13 +9,26 @@ MCLAG_DOMAIN_ID = "123" +MCLAG_DOMAIN_ID2 = "500" MCLAG_SRC_IP = "12.1.1.1" MCLAG_PEER_IP = "12.1.1.2" +MCLAG_KEEPALIVE_TIMER = "5" +MCLAG_SESSION_TIMEOUT = "10" +MCLAG_MEMBER_PO = "PortChannel10" +MCLAG_UNIQUE_IP_VLAN = "Vlan100" + MCLAG_PEER_LINK = "PortChannel12" MCLAG_INVALID_SRC_IP1 = "12::1111" MCLAG_INVALID_SRC_IP2 = "224.1.1.1" MCLAG_INVALID_PEER_IP1 = "12::1112" MCLAG_INVALID_PEER_IP2 = "224.1.1.2" +MCLAG_INVALID_PEER_LINK1 = "Eth1/3" +MCLAG_INVALID_PEER_LINK2 = "Ethernet257" +MCLAG_INVALID_PEER_LINK3 = "PortChannel123456" +MCLAG_INVALID_KEEPALIVE_TIMER = "11" +MCLAG_INVALID_SESSION_TIMEOUT = "31" + +MCLAG_INVALID_MCLAG_MEMBER = "Ethernet4" class TestMclag(object): @classmethod @@ -45,7 +58,226 @@ def test_add_mclag_with_invalid_src_mcast_ip(self): print(result.output) assert result.exit_code != 0, "Error: invalid local ip address" + def test_add_mclag_with_invalid_peer_ip(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # add mclag with invalid peer ip + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_INVALID_PEER_IP1, MCLAG_PEER_LINK], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code != 0, "Error: invalid local ip address" + + def test_add_mclag_with_invalid_peer_mcast_ip(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # add mclag with invalid peer ip mcast + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_INVALID_PEER_IP2, MCLAG_PEER_LINK], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code != 0, "Error: invalid local ip address" + + def test_add_mclag_with_invalid_peer_link(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # add mclag with invalid peer link + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_INVALID_PEER_LINK1], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code != 0, "Error: invalid peer link" + + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_INVALID_PEER_LINK2], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code != 0, "Error: invalid peer link" + + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_INVALID_PEER_LINK3], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code != 0, "Error: invalid peer link" + + def test_add_mclag_domain(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # add valid mclag domain + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0, "mclag creation failed" + + def test_add_mclag_domain_again(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # add valid mclag domain + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID2, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code != 0, "failed test_mclag_donain_again case" + + def test_mclag_invalid_keepalive_timer(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # configure non multiple keepalive timer + result = runner.invoke(config.config.commands["mclag"].commands["keepalive-interval"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_KEEPALIVE_TIMER], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code != 0, "failed testing of invalid keepalive timer " + + def test_mclag_keepalive_timer(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # configure valid keepalive timer + result = runner.invoke(config.config.commands["mclag"].commands["keepalive-interval"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_KEEPALIVE_TIMER], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0, "failed test for setting valid keepalive timer " + + def test_mclag_invalid_session_timeout(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # configure non multiple session timeout + result = runner.invoke(config.config.commands["mclag"].commands["session-timeout"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_SESSION_TIMEOUT], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code != 0, "failed invalid session timeout setting case" + + def test_mclag_session_timeout(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # configure valid session timeout + result = runner.invoke(config.config.commands["mclag"].commands["session-timeout"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SESSION_TIMEOUT], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0, "failed setting valid session timeout" + + + def test_mclag_add_mclag_member_to_nonexisting_domain(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # add mclag member to non existing domain + result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID2, MCLAG_MEMBER_PO], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code != 0, "testing of adding mclag member to nonexisting domain failed" + + + def test_mclag_add_invalid_member(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # add invaid mclag member Ethernet instead of PortChannel + result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_MCLAG_MEMBER], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code != 0, "testing of adding invalid member failed" + + def test_mclag_add_member(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # add valid mclag member + result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0, "testing of adding valid mclag member failed" + + def test_mclag_del_member(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # del mclag member + result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["del"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0, "testing of deleting valid mclag member failed" + def test_mclag_add_member_again(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # add mclag member + result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0, "testing of adding mclag member again failed" + + def test_mclag_add_unique_ip(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # add mclag unique ip + result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], [MCLAG_UNIQUE_IP_VLAN], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0, "testing of adding unique ip failed" + + def test_mclag_del_unique_ip(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # delete mclag unique ip + result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["del"], [MCLAG_UNIQUE_IP_VLAN], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0, "testing of delete of unique ip failed" + + def test_mclag_del_mclag_domain(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # delete mclag domain + result = runner.invoke(config.config.commands["mclag"].commands["del"], [MCLAG_DOMAIN_ID], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0, "testing of delete of mclag domain failed" + + def test_mclag_not_present_domain(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # delete mclag domain + result = runner.invoke(config.config.commands["mclag"].commands["del"], [MCLAG_DOMAIN_ID], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code != 0, "testing of non-existing delete of mclag domain failed" + + def test_add_unique_ip_for_nonexisting_domain(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # add unique_ip witout mclag domain + result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], [MCLAG_UNIQUE_IP_VLAN], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code != 0, "testing of adding uniqueip nonexisting mclag domain ailed" @classmethod def teardown_class(cls): From 5069580d6d3de677ea346ae3447f7f7615e651e3 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Wed, 7 Apr 2021 16:36:13 -0700 Subject: [PATCH 21/68] fixed alert --- config/mclag.py | 1 - 1 file changed, 1 deletion(-) diff --git a/config/mclag.py b/config/mclag.py index 7e155ca05d..c5b1cd58cc 100644 --- a/config/mclag.py +++ b/config/mclag.py @@ -89,7 +89,6 @@ def check_if_interface_is_valid(db, interface_name): from main import interface_name_is_valid if interface_name_is_valid(db,interface_name) is False: ctx.fail("Interface name is invalid. Please enter a valid interface name!!") - pass ###### # From ea8db7430426490d54155b6f62610a69a7fc6a96 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Wed, 7 Apr 2021 18:03:40 -0700 Subject: [PATCH 22/68] updated mclag test cases --- tests/mclag_test.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 1202d89704..df462e2345 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -129,7 +129,7 @@ def test_mclag_invalid_keepalive_timer(self): obj = {'db':db.cfgdb} # configure non multiple keepalive timer - result = runner.invoke(config.config.commands["mclag"].commands["keepalive-interval"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_KEEPALIVE_TIMER], obj=obj) + result = runner.invoke(config.config.commands["mclag"].commands["keepalive-interval"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_KEEPALIVE_TIMER], obj=obj) print(result.exit_code) print(result.output) assert result.exit_code != 0, "failed testing of invalid keepalive timer " @@ -140,7 +140,7 @@ def test_mclag_keepalive_timer(self): obj = {'db':db.cfgdb} # configure valid keepalive timer - result = runner.invoke(config.config.commands["mclag"].commands["keepalive-interval"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_KEEPALIVE_TIMER], obj=obj) + result = runner.invoke(config.config.commands["mclag"].commands["keepalive-interval"], [MCLAG_DOMAIN_ID, MCLAG_KEEPALIVE_TIMER], obj=obj) print(result.exit_code) print(result.output) assert result.exit_code == 0, "failed test for setting valid keepalive timer " @@ -151,7 +151,7 @@ def test_mclag_invalid_session_timeout(self): obj = {'db':db.cfgdb} # configure non multiple session timeout - result = runner.invoke(config.config.commands["mclag"].commands["session-timeout"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_SESSION_TIMEOUT], obj=obj) + result = runner.invoke(config.config.commands["mclag"].commands["session-timeout"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_SESSION_TIMEOUT], obj=obj) print(result.exit_code) print(result.output) assert result.exit_code != 0, "failed invalid session timeout setting case" @@ -162,7 +162,7 @@ def test_mclag_session_timeout(self): obj = {'db':db.cfgdb} # configure valid session timeout - result = runner.invoke(config.config.commands["mclag"].commands["session-timeout"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SESSION_TIMEOUT], obj=obj) + result = runner.invoke(config.config.commands["mclag"].commands["session-timeout"], [MCLAG_DOMAIN_ID, MCLAG_SESSION_TIMEOUT], obj=obj) print(result.exit_code) print(result.output) assert result.exit_code == 0, "failed setting valid session timeout" From 42cd9e176cfcc1bbee709a3b2d29c71ee740fde8 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Mon, 3 May 2021 18:39:05 -0700 Subject: [PATCH 23/68] updated mclag test cases --- tests/mclag_test.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index df462e2345..628108c34d 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -110,7 +110,7 @@ def test_add_mclag_domain(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) print(result.exit_code) print(result.output) - assert result.exit_code == 0, "mclag creation failed" + assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) def test_add_mclag_domain_again(self): runner = CliRunner() @@ -121,7 +121,7 @@ def test_add_mclag_domain_again(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID2, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) print(result.exit_code) print(result.output) - assert result.exit_code != 0, "failed test_mclag_donain_again case" + assert result.exit_code != 0, "test_mclag_domain_add_again with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) def test_mclag_invalid_keepalive_timer(self): runner = CliRunner() @@ -132,7 +132,7 @@ def test_mclag_invalid_keepalive_timer(self): result = runner.invoke(config.config.commands["mclag"].commands["keepalive-interval"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_KEEPALIVE_TIMER], obj=obj) print(result.exit_code) print(result.output) - assert result.exit_code != 0, "failed testing of invalid keepalive timer " + assert result.exit_code != 0, "failed testing of invalid keepalive timer with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) def test_mclag_keepalive_timer(self): runner = CliRunner() @@ -143,7 +143,7 @@ def test_mclag_keepalive_timer(self): result = runner.invoke(config.config.commands["mclag"].commands["keepalive-interval"], [MCLAG_DOMAIN_ID, MCLAG_KEEPALIVE_TIMER], obj=obj) print(result.exit_code) print(result.output) - assert result.exit_code == 0, "failed test for setting valid keepalive timer " + assert result.exit_code == 0, "failed test for setting valid keepalive timer with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) def test_mclag_invalid_session_timeout(self): runner = CliRunner() @@ -165,7 +165,7 @@ def test_mclag_session_timeout(self): result = runner.invoke(config.config.commands["mclag"].commands["session-timeout"], [MCLAG_DOMAIN_ID, MCLAG_SESSION_TIMEOUT], obj=obj) print(result.exit_code) print(result.output) - assert result.exit_code == 0, "failed setting valid session timeout" + assert result.exit_code == 0, "failed test for setting valid session timeout with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) def test_mclag_add_mclag_member_to_nonexisting_domain(self): @@ -200,7 +200,7 @@ def test_mclag_add_member(self): result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) print(result.exit_code) print(result.output) - assert result.exit_code == 0, "testing of adding valid mclag member failed" + assert result.exit_code == 0, "failed adding valid mclag member with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) def test_mclag_del_member(self): runner = CliRunner() From 2ed541ddaa35c8fc19f5a3085bd1072f3384235b Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Mon, 3 May 2021 19:35:45 -0700 Subject: [PATCH 24/68] updated mclag config --- config/mclag.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/mclag.py b/config/mclag.py index c5b1cd58cc..252acbd544 100644 --- a/config/mclag.py +++ b/config/mclag.py @@ -60,9 +60,9 @@ def is_portchannel_name_valid(portchannel_name): return True def is_ipv4_addr_valid(addr): - v4_invalid_list = [ipaddress.IPv4Address(unicode('0.0.0.0')), ipaddress.IPv4Address(unicode('255.255.255.255'))] + v4_invalid_list = [ipaddress.IPv4Address(str('0.0.0.0')), ipaddress.IPv4Address(str('255.255.255.255'))] try: - ip = ipaddress.ip_address(unicode(addr)) + ip = ipaddress.ip_address(str(addr)) if (ip.version == 4): if (ip.is_reserved): click.echo ("{} Not Valid, Reason: IPv4 reserved address range.".format(addr)) From 03292e86b043788713a1b94206853e57260ed71b Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Mon, 3 May 2021 21:32:52 -0700 Subject: [PATCH 25/68] modified mclag test cases --- tests/mclag_test.py | 104 ++++++++++++++++++++++++++++---------------- 1 file changed, 67 insertions(+), 37 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 628108c34d..89521da628 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -112,12 +112,7 @@ def test_add_mclag_domain(self): print(result.output) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - def test_add_mclag_domain_again(self): - runner = CliRunner() - db = Db() - obj = {'db':db.cfgdb} - - # add valid mclag domain + # add valid mclag domain again result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID2, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) print(result.exit_code) print(result.output) @@ -128,6 +123,13 @@ def test_mclag_invalid_keepalive_timer(self): db = Db() obj = {'db':db.cfgdb} + + # add valid mclag domain + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + # configure non multiple keepalive timer result = runner.invoke(config.config.commands["mclag"].commands["keepalive-interval"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_KEEPALIVE_TIMER], obj=obj) print(result.exit_code) @@ -139,6 +141,13 @@ def test_mclag_keepalive_timer(self): db = Db() obj = {'db':db.cfgdb} + + # add valid mclag domain + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + # configure valid keepalive timer result = runner.invoke(config.config.commands["mclag"].commands["keepalive-interval"], [MCLAG_DOMAIN_ID, MCLAG_KEEPALIVE_TIMER], obj=obj) print(result.exit_code) @@ -150,6 +159,13 @@ def test_mclag_invalid_session_timeout(self): db = Db() obj = {'db':db.cfgdb} + + # add valid mclag domain + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + # configure non multiple session timeout result = runner.invoke(config.config.commands["mclag"].commands["session-timeout"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_SESSION_TIMEOUT], obj=obj) print(result.exit_code) @@ -161,6 +177,12 @@ def test_mclag_session_timeout(self): db = Db() obj = {'db':db.cfgdb} + # add valid mclag domain + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + # configure valid session timeout result = runner.invoke(config.config.commands["mclag"].commands["session-timeout"], [MCLAG_DOMAIN_ID, MCLAG_SESSION_TIMEOUT], obj=obj) print(result.exit_code) @@ -185,6 +207,12 @@ def test_mclag_add_invalid_member(self): db = Db() obj = {'db':db.cfgdb} + # add valid mclag domain + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + # add invaid mclag member Ethernet instead of PortChannel result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_MCLAG_MEMBER], obj=obj) print(result.exit_code) @@ -196,67 +224,69 @@ def test_mclag_add_member(self): db = Db() obj = {'db':db.cfgdb} + + # add valid mclag domain + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + # add valid mclag member result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) - print(result.exit_code) - print(result.output) assert result.exit_code == 0, "failed adding valid mclag member with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - def test_mclag_del_member(self): - runner = CliRunner() - db = Db() - obj = {'db':db.cfgdb} + # add mclag member again + result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0, "testing of adding mclag member again failed" - # del mclag member - result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["del"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) + # delete mclag domain + result = runner.invoke(config.config.commands["mclag"].commands["del"], [MCLAG_DOMAIN_ID], obj=obj) print(result.exit_code) print(result.output) - assert result.exit_code == 0, "testing of deleting valid mclag member failed" + assert result.exit_code == 0, "testing of delete of mclag domain failed" - def test_mclag_add_member_again(self): - runner = CliRunner() - db = Db() - obj = {'db':db.cfgdb} + # add valid mclag domain + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - # add mclag member + # add valid mclag member result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) + assert result.exit_code == 0, "mclag member add with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + # del valid mclag member + result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["del"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) + assert result.exit_code == 0, "mclag member deletion failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + # del mclag member + result = + runner.invoke(config.config.commands["mclag"].commands["member"].commands["del"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_MCLAG_MEMBER], obj=obj) print(result.exit_code) print(result.output) - assert result.exit_code == 0, "testing of adding mclag member again failed" + assert result.exit_code == 0, "testing of deleting valid mclag member failed" + + def test_mclag_add_unique_ip(self): runner = CliRunner() db = Db() obj = {'db':db.cfgdb} + # add valid mclag domain + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + # add mclag unique ip result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], [MCLAG_UNIQUE_IP_VLAN], obj=obj) print(result.exit_code) print(result.output) assert result.exit_code == 0, "testing of adding unique ip failed" - def test_mclag_del_unique_ip(self): - runner = CliRunner() - db = Db() - obj = {'db':db.cfgdb} - # delete mclag unique ip result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["del"], [MCLAG_UNIQUE_IP_VLAN], obj=obj) print(result.exit_code) print(result.output) assert result.exit_code == 0, "testing of delete of unique ip failed" - def test_mclag_del_mclag_domain(self): - runner = CliRunner() - db = Db() - obj = {'db':db.cfgdb} - - # delete mclag domain - result = runner.invoke(config.config.commands["mclag"].commands["del"], [MCLAG_DOMAIN_ID], obj=obj) - print(result.exit_code) - print(result.output) - assert result.exit_code == 0, "testing of delete of mclag domain failed" - def test_mclag_not_present_domain(self): runner = CliRunner() db = Db() From b71f61431fda10a1a3f96e45d27ec3c86a58fc87 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Mon, 3 May 2021 21:40:44 -0700 Subject: [PATCH 26/68] updated mclag test case --- tests/mclag_test.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 89521da628..cafa7c48de 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -258,8 +258,7 @@ def test_mclag_add_member(self): assert result.exit_code == 0, "mclag member deletion failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) # del mclag member - result = - runner.invoke(config.config.commands["mclag"].commands["member"].commands["del"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_MCLAG_MEMBER], obj=obj) + result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["del"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_MCLAG_MEMBER], obj=obj) print(result.exit_code) print(result.output) assert result.exit_code == 0, "testing of deleting valid mclag member failed" From a8d28ef2318f55bbb28fe0018b4745565c681b95 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Mon, 3 May 2021 22:10:30 -0700 Subject: [PATCH 27/68] updated mclag test case --- config/mclag.py | 12 ++++++++++++ tests/mclag_test.py | 18 +++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/config/mclag.py b/config/mclag.py index 252acbd544..dc47411264 100644 --- a/config/mclag.py +++ b/config/mclag.py @@ -9,6 +9,7 @@ CFG_PORTCHANNEL_PREFIX_LEN = 11 CFG_PORTCHANNEL_MAX_VAL = 9999 CFG_PORTCHANNEL_NAME_TOTAL_LEN_MAX = 15 +CFG_PORTCHANNEL_NO="<0-9999>" def mclag_domain_id_valid(domain_id): """Check if the domain id is in acceptable range (between 1 and 4095) @@ -90,6 +91,17 @@ def check_if_interface_is_valid(db, interface_name): if interface_name_is_valid(db,interface_name) is False: ctx.fail("Interface name is invalid. Please enter a valid interface name!!") +def get_intf_vrf_bind_unique_ip(db, interface_name, interface_type): + intfvrf = db.get_table(interface_type) + if interface_name in intfvrf: + if 'vrf_name' in intfvrf[interface_name]: + return intfvrf[interface_name]['vrf_name'] + else: + return "" + else: + return "" + + ###### # # 'mclag' group ('config mclag ...') diff --git a/tests/mclag_test.py b/tests/mclag_test.py index cafa7c48de..203bca5605 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -108,14 +108,10 @@ def test_add_mclag_domain(self): # add valid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) - print(result.exit_code) - print(result.output) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) # add valid mclag domain again result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID2, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) - print(result.exit_code) - print(result.output) assert result.exit_code != 0, "test_mclag_domain_add_again with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) def test_mclag_invalid_keepalive_timer(self): @@ -126,14 +122,10 @@ def test_mclag_invalid_keepalive_timer(self): # add valid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) - print(result.exit_code) - print(result.output) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) # configure non multiple keepalive timer result = runner.invoke(config.config.commands["mclag"].commands["keepalive-interval"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_KEEPALIVE_TIMER], obj=obj) - print(result.exit_code) - print(result.output) assert result.exit_code != 0, "failed testing of invalid keepalive timer with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) def test_mclag_keepalive_timer(self): @@ -166,6 +158,12 @@ def test_mclag_invalid_session_timeout(self): print(result.output) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + # configure valid keepalive timer + result = runner.invoke(config.config.commands["mclag"].commands["keepalive-interval"], [MCLAG_DOMAIN_ID, MCLAG_KEEPALIVE_TIMER], obj=obj) + print(result.exit_code) + print(result.output) + assert result.exit_code == 0, "failed test for setting valid keepalive timer with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + # configure non multiple session timeout result = runner.invoke(config.config.commands["mclag"].commands["session-timeout"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_SESSION_TIMEOUT], obj=obj) print(result.exit_code) @@ -293,9 +291,7 @@ def test_mclag_not_present_domain(self): # delete mclag domain result = runner.invoke(config.config.commands["mclag"].commands["del"], [MCLAG_DOMAIN_ID], obj=obj) - print(result.exit_code) - print(result.output) - assert result.exit_code != 0, "testing of non-existing delete of mclag domain failed" + assert result.exit_code != 0, "testing non-existing domain deletion{}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) def test_add_unique_ip_for_nonexisting_domain(self): runner = CliRunner() From 24ddd8d54e16cafc1b584841966a9553ddfb0e3f Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 4 May 2021 00:13:09 -0700 Subject: [PATCH 28/68] updated mclag test cases --- tests/mclag_test.py | 159 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 156 insertions(+), 3 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 203bca5605..0a421f710c 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -11,6 +11,8 @@ MCLAG_DOMAIN_ID = "123" MCLAG_DOMAIN_ID2 = "500" MCLAG_SRC_IP = "12.1.1.1" +RESERVED_IP = "127.1.1.1" +INVALID_IP = "255.255.255.255" MCLAG_PEER_IP = "12.1.1.2" MCLAG_KEEPALIVE_TIMER = "5" MCLAG_SESSION_TIMEOUT = "10" @@ -25,10 +27,24 @@ MCLAG_INVALID_PEER_LINK1 = "Eth1/3" MCLAG_INVALID_PEER_LINK2 = "Ethernet257" MCLAG_INVALID_PEER_LINK3 = "PortChannel123456" +MCLAG_INVALID_PEER_LINK4 = "Lag111" +MCLAG_INVALID_PEER_LINK5 = "Ethernet123456789" MCLAG_INVALID_KEEPALIVE_TIMER = "11" MCLAG_INVALID_SESSION_TIMEOUT = "31" +MCLAG_INVALID_KEEPALIVE_TIMER_LBOUND = "0" +MCLAG_INVALID_KEEPALIVE_TIMER_UBOUND = "61" +MCLAG_INVALID_SESSION_TMOUT_LBOUND = "2" +MCLAG_INVALID_SESSION_TMOUT_UBOUND = "4000" MCLAG_INVALID_MCLAG_MEMBER = "Ethernet4" +MCLAG_INVALID_PORTCHANNEL1 "portchannel" +MCLAG_INVALID_PORTCHANNEL2 "PortChannelabcd" +MCLAG_INVALID_PORTCHANNEL3 "PortChannel10000" +MCLAG_INVALID_PORTCHANNEL4 "PortChannel1111" + + +MCLAG_UNIQUE_IP_INTF_INVALID1 = "Ethernet100" +MCLAG_UNIQUE_IP_INTF_INVALID2 = "Ethernet100" class TestMclag(object): @classmethod @@ -58,6 +74,11 @@ def test_add_mclag_with_invalid_src_mcast_ip(self): print(result.output) assert result.exit_code != 0, "Error: invalid local ip address" + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, RESERVED_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, INVALID_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + def test_add_mclag_with_invalid_peer_ip(self): runner = CliRunner() db = Db() @@ -69,6 +90,12 @@ def test_add_mclag_with_invalid_peer_ip(self): print(result.output) assert result.exit_code != 0, "Error: invalid local ip address" + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, RESERVED_IP, MCLAG_PEER_LINK], obj=obj) + assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, INVALID, MCLAG_PEER_LINK], obj=obj) + assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + def test_add_mclag_with_invalid_peer_mcast_ip(self): runner = CliRunner() db = Db() @@ -101,6 +128,66 @@ def test_add_mclag_with_invalid_peer_link(self): print(result.output) assert result.exit_code != 0, "Error: invalid peer link" + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_INVALID_PEER_LINK4], obj=obj) + assert result.exit_code != 0, "mclag invalid peer link test case failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_INVALID_PEER_LINK5], obj=obj) + assert result.exit_code != 0, "mclag invalid peer link test case failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + def test_add_invalid_mclag_domain(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # add invalid mclag domain + result = runner.invoke(config.config.commands["mclag"].commands["add"], [0, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + assert result.exit_code != 0, "mclag invalid domain test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + # add invalid mclag domain + result = runner.invoke(config.config.commands["mclag"].commands["add"], [5000, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + assert result.exit_code != 0, "mclag invalid domain test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + + + def test_add_mclag_domain(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # add valid mclag domain + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + # add valid mclag domain again + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID2, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + assert result.exit_code != 0, "test_mclag_domain_add_again with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + def test_add_invalid_mclag_domain(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # add invalid mclag domain + result = runner.invoke(config.config.commands["mclag"].commands["add"], [0, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + assert result.exit_code != 0, "mclag invalid domain test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + # add invalid mclag domain + result = runner.invoke(config.config.commands["mclag"].commands["add"], [5000, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + assert result.exit_code != 0, "mclag invalid domain test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + + + def test_add_mclag_domain(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # add valid mclag domain + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + # add valid mclag domain again + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID2, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + assert result.exit_code != 0, "test_mclag_domain_add_again with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + def test_add_mclag_domain(self): runner = CliRunner() db = Db() @@ -128,6 +215,14 @@ def test_mclag_invalid_keepalive_timer(self): result = runner.invoke(config.config.commands["mclag"].commands["keepalive-interval"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_KEEPALIVE_TIMER], obj=obj) assert result.exit_code != 0, "failed testing of invalid keepalive timer with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + # add invalid keepalive values + result = runner.invoke(config.config.commands["mclag"].commands["keepalive-interval"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_KEEPALIVE_TIMER_LBOUND], obj=obj) + assert result.exit_code != 0, "mclag invalid keepalive failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + # add invalid keepalive values + result = runner.invoke(config.config.commands["mclag"].commands["keepalive-interval"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_KEEPALIVE_TIMER_UBOUND], obj=obj) + assert result.exit_code != 0, "mclag creation keepalive failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + def test_mclag_keepalive_timer(self): runner = CliRunner() db = Db() @@ -169,6 +264,11 @@ def test_mclag_invalid_session_timeout(self): print(result.exit_code) print(result.output) assert result.exit_code != 0, "failed invalid session timeout setting case" + + result = runner.invoke(config.config.commands["mclag"].commands["session-timeout"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_SESSION_TMOUT_LBOUND], obj=obj) + assert result.exit_code != 0, "mclag session timeout invalid failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + result = runner.invoke(config.config.commands["mclag"].commands["session-timeout"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_SESSION_TMOUT_UBOUND], obj=obj) + assert result.exit_code != 0, "mclag session timeout invalid failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) def test_mclag_session_timeout(self): runner = CliRunner() @@ -217,6 +317,22 @@ def test_mclag_add_invalid_member(self): print(result.output) assert result.exit_code != 0, "testing of adding invalid member failed" + # add invaid mclag member Ethernet instead of PortChannel + result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_PORTCHANNEL1], obj=obj) + assert result.exit_code != 0, "mclag invalid member add case failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + # add invaid mclag member Ethernet instead of PortChannel + result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_PORTCHANNEL2], obj=obj) + assert result.exit_code != 0, "mclag invalid member add case failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + # add invaid mclag member Ethernet instead of PortChannel + result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_PORTCHANNEL3], obj=obj) + assert result.exit_code != 0, "mclag invalid member add case failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + # add invaid mclag member Ethernet instead of PortChannel + result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_PORTCHANNEL4], obj=obj) + assert result.exit_code != 0, "mclag invalid member add case failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + def test_mclag_add_member(self): runner = CliRunner() db = Db() @@ -259,7 +375,19 @@ def test_mclag_add_member(self): result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["del"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_MCLAG_MEMBER], obj=obj) print(result.exit_code) print(result.output) - assert result.exit_code == 0, "testing of deleting valid mclag member failed" + assert result.exit_code != 0, "testing of deleting valid mclag member failed" + + result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["del"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_PORTCHANNEL1], obj=obj) + assert result.exit_code != 0, "mclag invalid member del case failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["del"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_PORTCHANNEL2], obj=obj) + assert result.exit_code != 0, "mclag invalid member del case failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["del"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_PORTCHANNEL3], obj=obj) + + result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["del"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_PORTCHANNEL4], obj=obj) + assert result.exit_code != 0, "mclag invalid member del case failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert result.exit_code != 0, "mclag invalid member del case failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) @@ -278,6 +406,16 @@ def test_mclag_add_unique_ip(self): print(result.output) assert result.exit_code == 0, "testing of adding unique ip failed" + # add mclag unique ip for vlan interface which already has ip + result = runner.invoke(config.config.commands["vlan"].commands["add"], ["111"], obj=db) + assert result.exit_code == 0, "add vlan for unique ip failed {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + result = runner.invoke(config.config.commands["interface"].commands["ip"].commands["add"], ["Vlan111", "111.11.11.1/24"], obj=obj) + assert result.exit_code == 0, "ip config for unique ip vlan failed {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], ["Vlan111"], obj=obj) + assert result.exit_code != 0, "unique ip config for vlan with ip address case failed {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + # delete mclag unique ip result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["del"], [MCLAG_UNIQUE_IP_VLAN], obj=obj) print(result.exit_code) @@ -291,7 +429,16 @@ def test_mclag_not_present_domain(self): # delete mclag domain result = runner.invoke(config.config.commands["mclag"].commands["del"], [MCLAG_DOMAIN_ID], obj=obj) - assert result.exit_code != 0, "testing non-existing domain deletion{}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert result.exit_code == 0, "testing non-existing domain deletion{}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + # delete invalid mclag domain + result = runner.invoke(config.config.commands["mclag"].commands["del"], [0], obj=obj) + assert result.exit_code != 0, "mclag invalid domain delete test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + # delete invalid mclag domain + result = runner.invoke(config.config.commands["mclag"].commands["del"], [5000], obj=obj) + assert result.exit_code != 0, "mclag invalid domain delete test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + def test_add_unique_ip_for_nonexisting_domain(self): runner = CliRunner() @@ -302,7 +449,13 @@ def test_add_unique_ip_for_nonexisting_domain(self): result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], [MCLAG_UNIQUE_IP_VLAN], obj=obj) print(result.exit_code) print(result.output) - assert result.exit_code != 0, "testing of adding uniqueip nonexisting mclag domain ailed" + assert result.exit_code != 0, "testing of adding uniqueip nonexisting mclag domain ailed" + + result = + runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], [MCLAG_UNIQUE_IP_INTF_INVALID1], obj=obj) + assert result.exit_code != 0, "mclag invalid unique ip test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], [MCLAG_UNIQUE_IP_INTF_INVALID2], obj=obj) + assert result.exit_code != 0, "mclag invalid unique ip test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) @classmethod def teardown_class(cls): From 685d6f5acfb3909e3f4c953b8e7928a48358b6c4 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 4 May 2021 00:28:33 -0700 Subject: [PATCH 29/68] updated mclag test cases --- tests/mclag_test.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 0a421f710c..c17eecaca3 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -37,10 +37,10 @@ MCLAG_INVALID_SESSION_TMOUT_UBOUND = "4000" MCLAG_INVALID_MCLAG_MEMBER = "Ethernet4" -MCLAG_INVALID_PORTCHANNEL1 "portchannel" -MCLAG_INVALID_PORTCHANNEL2 "PortChannelabcd" -MCLAG_INVALID_PORTCHANNEL3 "PortChannel10000" -MCLAG_INVALID_PORTCHANNEL4 "PortChannel1111" +MCLAG_INVALID_PORTCHANNEL1 = "portchannel" +MCLAG_INVALID_PORTCHANNEL2 = "PortChannelabcd" +MCLAG_INVALID_PORTCHANNEL3 = "PortChannel10000" +MCLAG_INVALID_PORTCHANNEL4 = "PortChannel1111" MCLAG_UNIQUE_IP_INTF_INVALID1 = "Ethernet100" From 6eade6bc61f5736f456e8fd70c9a12f343fe6815 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 4 May 2021 00:50:51 -0700 Subject: [PATCH 30/68] updated mclag test cases --- tests/mclag_test.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index c17eecaca3..69c246e951 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -451,8 +451,7 @@ def test_add_unique_ip_for_nonexisting_domain(self): print(result.output) assert result.exit_code != 0, "testing of adding uniqueip nonexisting mclag domain ailed" - result = - runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], [MCLAG_UNIQUE_IP_INTF_INVALID1], obj=obj) + result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], [MCLAG_UNIQUE_IP_INTF_INVALID1], obj=obj) assert result.exit_code != 0, "mclag invalid unique ip test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], [MCLAG_UNIQUE_IP_INTF_INVALID2], obj=obj) assert result.exit_code != 0, "mclag invalid unique ip test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) From 91c8d46afe369e686683a3198d7deb6d0c7e63ba Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Sun, 16 May 2021 23:17:31 -0700 Subject: [PATCH 31/68] updated mclag test case --- tests/mclag_test.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 69c246e951..149d20b2fe 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -13,6 +13,7 @@ MCLAG_SRC_IP = "12.1.1.1" RESERVED_IP = "127.1.1.1" INVALID_IP = "255.255.255.255" +NOT_IP = "abcd" MCLAG_PEER_IP = "12.1.1.2" MCLAG_KEEPALIVE_TIMER = "5" MCLAG_SESSION_TIMEOUT = "10" @@ -79,6 +80,9 @@ def test_add_mclag_with_invalid_src_mcast_ip(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, INVALID_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, NOT_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + def test_add_mclag_with_invalid_peer_ip(self): runner = CliRunner() db = Db() @@ -94,6 +98,8 @@ def test_add_mclag_with_invalid_peer_ip(self): assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, INVALID, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, NOT_IP, MCLAG_PEER_LINK], obj=obj) + assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) def test_add_mclag_with_invalid_peer_mcast_ip(self): From 12938befbe34afc537586d68d601ee01bd1a7a68 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 18 May 2021 00:43:37 -0700 Subject: [PATCH 32/68] updated mclag test case --- tests/mclag_test.py | 60 +++++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 19 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 149d20b2fe..649ae556d4 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -62,7 +62,8 @@ def test_add_mclag_with_invalid_src_ip(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_SRC_IP1, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) print(result.exit_code) print(result.output) - assert result.exit_code != 0, "Error: invalid local ip address" + assert result.exit_code == 0, "Error: invalid local ip address" + assert "invalid local ip address" in result.output def test_add_mclag_with_invalid_src_mcast_ip(self): runner = CliRunner() @@ -73,15 +74,20 @@ def test_add_mclag_with_invalid_src_mcast_ip(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_SRC_IP2, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) print(result.exit_code) print(result.output) - assert result.exit_code != 0, "Error: invalid local ip address" + assert result.exit_code == 0, "Error: invalid local ip address" + assert "invalid local ip address" in result.output result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, RESERVED_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) - assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert result.exit_code == 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert "invalid local ip address" in result.output + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, INVALID_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) - assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert result.exit_code == 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert "invalid local ip address" in result.output result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, NOT_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) - assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert result.exit_code == 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert "invalid local ip address" in result.output def test_add_mclag_with_invalid_peer_ip(self): runner = CliRunner() @@ -92,14 +98,20 @@ def test_add_mclag_with_invalid_peer_ip(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_INVALID_PEER_IP1, MCLAG_PEER_LINK], obj=obj) print(result.exit_code) print(result.output) - assert result.exit_code != 0, "Error: invalid local ip address" + assert result.exit_code == 0, "Error: invalid local ip address" + assert "invalid peer ip address" in result.output result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, RESERVED_IP, MCLAG_PEER_LINK], obj=obj) - assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert result.exit_code == 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert "invalid peer ip address" in result.output + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, INVALID, MCLAG_PEER_LINK], obj=obj) - assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert result.exit_code == 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert "invalid peer ip address" in result.output + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, NOT_IP, MCLAG_PEER_LINK], obj=obj) - assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert result.exit_code == 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert "invalid peer ip address" in result.output def test_add_mclag_with_invalid_peer_mcast_ip(self): @@ -111,7 +123,8 @@ def test_add_mclag_with_invalid_peer_mcast_ip(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_INVALID_PEER_IP2, MCLAG_PEER_LINK], obj=obj) print(result.exit_code) print(result.output) - assert result.exit_code != 0, "Error: invalid local ip address" + assert result.exit_code == 0, "Error: invalid local ip address" + assert "invalid peer ip address" in result.output def test_add_mclag_with_invalid_peer_link(self): runner = CliRunner() @@ -122,23 +135,28 @@ def test_add_mclag_with_invalid_peer_link(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_INVALID_PEER_LINK1], obj=obj) print(result.exit_code) print(result.output) - assert result.exit_code != 0, "Error: invalid peer link" + assert result.exit_code == 0, "Error: invalid peer link" + assert "invalid " in result.output result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_INVALID_PEER_LINK2], obj=obj) print(result.exit_code) print(result.output) - assert result.exit_code != 0, "Error: invalid peer link" + assert result.exit_code == 0, "Error: invalid peer link" + assert "invalid " in result.output result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_INVALID_PEER_LINK3], obj=obj) print(result.exit_code) print(result.output) - assert result.exit_code != 0, "Error: invalid peer link" + assert result.exit_code == 0, "Error: invalid peer link" + assert "invalid " in result.output result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_INVALID_PEER_LINK4], obj=obj) - assert result.exit_code != 0, "mclag invalid peer link test case failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert result.exit_code == 0, "mclag invalid peer link test case failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert "invalid " in result.output result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_INVALID_PEER_LINK5], obj=obj) - assert result.exit_code != 0, "mclag invalid peer link test case failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert result.exit_code == 0, "mclag invalid peer link test case failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert "invalid " in result.output def test_add_invalid_mclag_domain(self): runner = CliRunner() @@ -147,10 +165,12 @@ def test_add_invalid_mclag_domain(self): # add invalid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [0, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) - assert result.exit_code != 0, "mclag invalid domain test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert result.exit_code == 0, "mclag invalid domain test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert "invalid " in result.output # add invalid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [5000, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) - assert result.exit_code != 0, "mclag invalid domain test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert result.exit_code == 0, "mclag invalid domain test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert "invalid " in result.output @@ -174,10 +194,12 @@ def test_add_invalid_mclag_domain(self): # add invalid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [0, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) - assert result.exit_code != 0, "mclag invalid domain test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert result.exit_code == 0, "mclag invalid domain test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert "invalid " in result.output # add invalid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [5000, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) - assert result.exit_code != 0, "mclag invalid domain test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert result.exit_code == 0, "mclag invalid domain test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert "invalid " in result.output From 29c90a0be319702a35edc66e31cdbc8eed1269de Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 18 May 2021 01:37:25 -0700 Subject: [PATCH 33/68] updated mclag test cases --- tests/mclag_test.py | 73 +++++++++++++-------------------------------- 1 file changed, 21 insertions(+), 52 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 649ae556d4..6797b79549 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -41,7 +41,7 @@ MCLAG_INVALID_PORTCHANNEL1 = "portchannel" MCLAG_INVALID_PORTCHANNEL2 = "PortChannelabcd" MCLAG_INVALID_PORTCHANNEL3 = "PortChannel10000" -MCLAG_INVALID_PORTCHANNEL4 = "PortChannel1111" +MCLAG_INVALID_PORTCHANNEL4 = "PortChannel00111" MCLAG_UNIQUE_IP_INTF_INVALID1 = "Ethernet100" @@ -60,10 +60,7 @@ def test_add_mclag_with_invalid_src_ip(self): # add mclag with invalid src result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_SRC_IP1, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) - print(result.exit_code) - print(result.output) - assert result.exit_code == 0, "Error: invalid local ip address" - assert "invalid local ip address" in result.output + assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) def test_add_mclag_with_invalid_src_mcast_ip(self): runner = CliRunner() @@ -72,22 +69,17 @@ def test_add_mclag_with_invalid_src_mcast_ip(self): # add mclag with invalid src result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_SRC_IP2, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) - print(result.exit_code) - print(result.output) - assert result.exit_code == 0, "Error: invalid local ip address" - assert "invalid local ip address" in result.output + assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, RESERVED_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) - assert result.exit_code == 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert "invalid local ip address" in result.output + assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, INVALID_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) - assert result.exit_code == 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert "invalid local ip address" in result.output + assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, NOT_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) - assert result.exit_code == 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert "invalid local ip address" in result.output + assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) def test_add_mclag_with_invalid_peer_ip(self): runner = CliRunner() @@ -98,20 +90,16 @@ def test_add_mclag_with_invalid_peer_ip(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_INVALID_PEER_IP1, MCLAG_PEER_LINK], obj=obj) print(result.exit_code) print(result.output) - assert result.exit_code == 0, "Error: invalid local ip address" - assert "invalid peer ip address" in result.output + assert result.exit_code != 0, "mclag invalid peer ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, RESERVED_IP, MCLAG_PEER_LINK], obj=obj) - assert result.exit_code == 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert "invalid peer ip address" in result.output + assert result.exit_code != 0, "mclag invalid peer ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, INVALID, MCLAG_PEER_LINK], obj=obj) - assert result.exit_code == 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert "invalid peer ip address" in result.output + assert result.exit_code != 0, "mclag invalid peer ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, NOT_IP, MCLAG_PEER_LINK], obj=obj) - assert result.exit_code == 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert "invalid peer ip address" in result.output + assert result.exit_code != 0, "mclag invalid peer ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) def test_add_mclag_with_invalid_peer_mcast_ip(self): @@ -121,10 +109,7 @@ def test_add_mclag_with_invalid_peer_mcast_ip(self): # add mclag with invalid peer ip mcast result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_INVALID_PEER_IP2, MCLAG_PEER_LINK], obj=obj) - print(result.exit_code) - print(result.output) - assert result.exit_code == 0, "Error: invalid local ip address" - assert "invalid peer ip address" in result.output + assert result.exit_code != 0, "mclag invalid peer ip mcast test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) def test_add_mclag_with_invalid_peer_link(self): runner = CliRunner() @@ -133,30 +118,19 @@ def test_add_mclag_with_invalid_peer_link(self): # add mclag with invalid peer link result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_INVALID_PEER_LINK1], obj=obj) - print(result.exit_code) - print(result.output) - assert result.exit_code == 0, "Error: invalid peer link" - assert "invalid " in result.output + assert result.exit_code != 0, "mclag invalid peer link test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_INVALID_PEER_LINK2], obj=obj) - print(result.exit_code) - print(result.output) - assert result.exit_code == 0, "Error: invalid peer link" - assert "invalid " in result.output + assert result.exit_code != 0, "mclag invalid peer link test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_INVALID_PEER_LINK3], obj=obj) - print(result.exit_code) - print(result.output) - assert result.exit_code == 0, "Error: invalid peer link" - assert "invalid " in result.output + assert result.exit_code != 0, "mclag invalid peer link test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_INVALID_PEER_LINK4], obj=obj) - assert result.exit_code == 0, "mclag invalid peer link test case failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert "invalid " in result.output + assert result.exit_code != 0, "mclag invalid peer link test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_INVALID_PEER_LINK5], obj=obj) - assert result.exit_code == 0, "mclag invalid peer link test case failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert "invalid " in result.output + assert result.exit_code != 0, "mclag invalid peer link test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) def test_add_invalid_mclag_domain(self): runner = CliRunner() @@ -165,12 +139,10 @@ def test_add_invalid_mclag_domain(self): # add invalid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [0, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) - assert result.exit_code == 0, "mclag invalid domain test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert "invalid " in result.output + assert result.exit_code != 0, "mclag invalid domain test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) # add invalid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [5000, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) - assert result.exit_code == 0, "mclag invalid domain test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert "invalid " in result.output + assert result.exit_code != 0, "mclag invalid domain test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) @@ -415,7 +387,6 @@ def test_mclag_add_member(self): result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["del"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_PORTCHANNEL4], obj=obj) assert result.exit_code != 0, "mclag invalid member del case failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert result.exit_code != 0, "mclag invalid member del case failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) @@ -430,16 +401,14 @@ def test_mclag_add_unique_ip(self): # add mclag unique ip result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], [MCLAG_UNIQUE_IP_VLAN], obj=obj) - print(result.exit_code) - print(result.output) - assert result.exit_code == 0, "testing of adding unique ip failed" + assert result.exit_code == 0, "mclag unique ip add with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) # add mclag unique ip for vlan interface which already has ip result = runner.invoke(config.config.commands["vlan"].commands["add"], ["111"], obj=db) assert result.exit_code == 0, "add vlan for unique ip failed {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["interface"].commands["ip"].commands["add"], ["Vlan111", "111.11.11.1/24"], obj=obj) - assert result.exit_code == 0, "ip config for unique ip vlan failed {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert result.exit_code != 0, "ip config for unique ip vlan failed {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], ["Vlan111"], obj=obj) assert result.exit_code != 0, "unique ip config for vlan with ip address case failed {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) From b9a590c0769f1376250cee7345743c59ee3cb56c Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 18 May 2021 01:58:41 -0700 Subject: [PATCH 34/68] updated mclag test cases --- tests/mclag_test.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 6797b79549..6d520ae730 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -11,7 +11,7 @@ MCLAG_DOMAIN_ID = "123" MCLAG_DOMAIN_ID2 = "500" MCLAG_SRC_IP = "12.1.1.1" -RESERVED_IP = "127.1.1.1" +RESERVED_IP = "0.0.0.0" INVALID_IP = "255.255.255.255" NOT_IP = "abcd" MCLAG_PEER_IP = "12.1.1.2" @@ -74,6 +74,7 @@ def test_add_mclag_with_invalid_src_mcast_ip(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, RESERVED_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert "" in result.output result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, INVALID_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) @@ -166,12 +167,10 @@ def test_add_invalid_mclag_domain(self): # add invalid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [0, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) - assert result.exit_code == 0, "mclag invalid domain test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert "invalid " in result.output + assert result.exit_code != 0, "mclag invalid domain test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) # add invalid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [5000, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) - assert result.exit_code == 0, "mclag invalid domain test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert "invalid " in result.output + assert result.exit_code != 0, "mclag invalid domain test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) @@ -415,9 +414,7 @@ def test_mclag_add_unique_ip(self): # delete mclag unique ip result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["del"], [MCLAG_UNIQUE_IP_VLAN], obj=obj) - print(result.exit_code) - print(result.output) - assert result.exit_code == 0, "testing of delete of unique ip failed" + assert result.exit_code == 0, "mclag unique ip delete case failed {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) def test_mclag_not_present_domain(self): runner = CliRunner() From 7628b1b356a3d0db6f2671230dd0df6873c5ba1d Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 18 May 2021 02:12:23 -0700 Subject: [PATCH 35/68] updated mclag test cases --- tests/mclag_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 6d520ae730..24a4cd4ff4 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -96,7 +96,7 @@ def test_add_mclag_with_invalid_peer_ip(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, RESERVED_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "mclag invalid peer ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, INVALID, MCLAG_PEER_LINK], obj=obj) + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, INVALID_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "mclag invalid peer ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, NOT_IP, MCLAG_PEER_LINK], obj=obj) @@ -410,7 +410,7 @@ def test_mclag_add_unique_ip(self): assert result.exit_code != 0, "ip config for unique ip vlan failed {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], ["Vlan111"], obj=obj) - assert result.exit_code != 0, "unique ip config for vlan with ip address case failed {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert result.exit_code == 0, "unique ip config for vlan with ip address case failed {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) # delete mclag unique ip result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["del"], [MCLAG_UNIQUE_IP_VLAN], obj=obj) From 3b38f8bcf1944646fdffb1e94002d57c30ec0e02 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 1 Jun 2021 02:30:57 -0700 Subject: [PATCH 36/68] updated mclag test cases --- tests/mclag_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 24a4cd4ff4..04c19e02e5 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -8,6 +8,7 @@ from utilities_common.db import Db + MCLAG_DOMAIN_ID = "123" MCLAG_DOMAIN_ID2 = "500" MCLAG_SRC_IP = "12.1.1.1" From b468b817da0f4c955eeb194392152f86f1dabbde Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 15 Jun 2021 01:05:10 -0700 Subject: [PATCH 37/68] updated mclag test case --- tests/mclag_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 04c19e02e5..75a17f4dfe 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -134,6 +134,7 @@ def test_add_mclag_with_invalid_peer_link(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_INVALID_PEER_LINK5], obj=obj) assert result.exit_code != 0, "mclag invalid peer link test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + # def test_add_invalid_mclag_domain(self): runner = CliRunner() db = Db() From 80bdcfc24c98ddfbc35a9a64b1cfc949b504a6dc Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 15 Jun 2021 01:51:15 -0700 Subject: [PATCH 38/68] updated mclag test cases --- tests/mclag_test.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 75a17f4dfe..04c19e02e5 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -134,7 +134,6 @@ def test_add_mclag_with_invalid_peer_link(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_INVALID_PEER_LINK5], obj=obj) assert result.exit_code != 0, "mclag invalid peer link test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - # def test_add_invalid_mclag_domain(self): runner = CliRunner() db = Db() From 0604e90f3333893a9cac03be5a9913272b774a74 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Fri, 25 Jun 2021 22:18:04 -0700 Subject: [PATCH 39/68] updated mclag test cases --- tests/mclag_test.py | 115 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 113 insertions(+), 2 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 04c19e02e5..ec0a916e4b 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -10,6 +10,8 @@ MCLAG_DOMAIN_ID = "123" +MCLAG_INVALID_DOMAIN_ID1 = "-1" +MCLAG_INVALID_DOMAIN_ID2 = "5000" MCLAG_DOMAIN_ID2 = "500" MCLAG_SRC_IP = "12.1.1.1" RESERVED_IP = "0.0.0.0" @@ -19,6 +21,7 @@ MCLAG_KEEPALIVE_TIMER = "5" MCLAG_SESSION_TIMEOUT = "10" MCLAG_MEMBER_PO = "PortChannel10" +MCLAG_MEMBER_PO2 = "PortChannel20" MCLAG_UNIQUE_IP_VLAN = "Vlan100" MCLAG_PEER_LINK = "PortChannel12" @@ -157,8 +160,7 @@ def test_add_mclag_domain(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - # add valid mclag domain again - result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID2, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + # add valid mclag domain agai = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID2, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "test_mclag_domain_add_again with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) def test_add_invalid_mclag_domain(self): @@ -367,6 +369,12 @@ def test_mclag_add_member(self): result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) assert result.exit_code == 0, "mclag member add with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + # add valid mclag member2 + result = + runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2], obj=obj) + assert result.exit_code == 0, "mclag member add with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + # del valid mclag member result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["del"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) assert result.exit_code == 0, "mclag member deletion failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) @@ -451,6 +459,109 @@ def test_add_unique_ip_for_nonexisting_domain(self): runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], [MCLAG_UNIQUE_IP_INTF_INVALID2], obj=obj) assert result.exit_code != 0, "mclag invalid unique ip test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) +def test_add_mclag_with_invalid_domain_id(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # add mclag with invalid domain_id + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_INVALID_DOMAIN_ID1, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_INVALID_DOMAIN_ID2, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + +def test_del_mclag_with_invalid_domain_id(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # del mclag with invalid domain_id + result = runner.invoke(config.config.commands["mclag"].commands["del"], [MCLAG_INVALID_DOMAIN_ID1], obj=obj) + assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + result = runner.invoke(config.config.commands["mclag"].commands["del"], [MCLAG_INVALID_DOMAIN_ID2], obj=obj) + assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + result = runner.invoke(config.config.commands["mclag"].commands["del"], [MCLAG_DOMAIN_ID2], obj=obj) + assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + + + def test_modify_mclag_domain(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # add mclag domain entry in db + db.cfgdb.set_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID, {"source_ip": MCLAG_SRC_IP}) + + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + # add valid mclag domain again + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID2, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + assert result.exit_code != 0, "test_mclag_domain_add_again with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + def test_del_mclag_domain_with_members(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # add valid mclag domain + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + # add valid mclag member + result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) + assert result.exit_code == 0, "mclag member add with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + # add valid mclag member2 + result = + runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2], obj=obj) + assert result.exit_code == 0, "mclag member add with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + # delete mclag domain + result = runner.invoke(config.config.commands["mclag"].commands["del"], [MCLAG_DOMAIN_ID], obj=obj) + assert result.exit_code == 0, "testing non-existing domain deletion{}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + + def test_mclag_keepalive_for_non_existent_domain(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # configure keepalive timer for non-existing domain + result = runner.invoke(config.config.commands["mclag"].commands["keepalive-interval"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_KEEPALIVE_TIMER], obj=obj) + assert result.exit_code != 0, "failed testing of keepalive timer for nonexisting domain {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + + def test_mclag_keepalive_config_with_nondefault_sess_tmout(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + # add valid mclag domain + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + #configure valid session timeout + result = runner.invoke(config.config.commands["mclag"].commands["session-timeout"], [MCLAG_DOMAIN_ID, MCLAG_SESSION_TIMEOUT], obj=obj) + assert result.exit_code == 0, "failed test for setting valid keepalive timer with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + # configure valid keepalive timer + result = runner.invoke(config.config.commands["mclag"].commands["keepalive-interval"], [MCLAG_DOMAIN_ID, MCLAG_KEEPALIVE_TIMER], obj=obj) + assert result.exit_code == 0, "failed test for setting valid keepalive timer with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + + def test_mclag_session_tmout_for_nonexistent_domain(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + result = runner.invoke(config.config.commands["mclag"].commands["session-timeout"], [MCLAG_DOMAIN_ID, MCLAG_SESSION_TIMEOUT], obj=obj) + assert result.exit_code != 0, "failed test for session timeout with non existent dmain code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + @classmethod def teardown_class(cls): os.environ['UTILITIES_UNIT_TESTING'] = "0" From cbd88df4494d86a762d865df24face48dcd8ced9 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Fri, 25 Jun 2021 22:44:24 -0700 Subject: [PATCH 40/68] updated mclag test cases --- tests/mclag_test.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index ec0a916e4b..bfd273bd7f 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -370,8 +370,7 @@ def test_mclag_add_member(self): assert result.exit_code == 0, "mclag member add with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) # add valid mclag member2 - result = - runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2], obj=obj) + result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2], obj=obj) assert result.exit_code == 0, "mclag member add with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) From a3c2381ee84911a2d64ad07a1bd303392afddb3e Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Fri, 25 Jun 2021 22:58:24 -0700 Subject: [PATCH 41/68] updated mclag test cases --- tests/mclag_test.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index bfd273bd7f..6d9ab30430 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -271,7 +271,7 @@ def test_mclag_invalid_session_timeout(self): assert result.exit_code != 0, "mclag session timeout invalid failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["mclag"].commands["session-timeout"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_SESSION_TMOUT_UBOUND], obj=obj) assert result.exit_code != 0, "mclag session timeout invalid failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - + def test_mclag_session_timeout(self): runner = CliRunner() db = Db() @@ -458,7 +458,7 @@ def test_add_unique_ip_for_nonexisting_domain(self): runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], [MCLAG_UNIQUE_IP_INTF_INVALID2], obj=obj) assert result.exit_code != 0, "mclag invalid unique ip test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) -def test_add_mclag_with_invalid_domain_id(self): + def test_add_mclag_with_invalid_domain_id(self): runner = CliRunner() db = Db() obj = {'db':db.cfgdb} @@ -470,7 +470,7 @@ def test_add_mclag_with_invalid_domain_id(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_INVALID_DOMAIN_ID2, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) -def test_del_mclag_with_invalid_domain_id(self): + def test_del_mclag_with_invalid_domain_id(self): runner = CliRunner() db = Db() obj = {'db':db.cfgdb} @@ -486,7 +486,7 @@ def test_del_mclag_with_invalid_domain_id(self): - def test_modify_mclag_domain(self): + def test_modify_mclag_domain(self): runner = CliRunner() db = Db() obj = {'db':db.cfgdb} @@ -528,7 +528,7 @@ def test_mclag_keepalive_for_non_existent_domain(self): runner = CliRunner() db = Db() obj = {'db':db.cfgdb} - + # configure keepalive timer for non-existing domain result = runner.invoke(config.config.commands["mclag"].commands["keepalive-interval"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_KEEPALIVE_TIMER], obj=obj) assert result.exit_code != 0, "failed testing of keepalive timer for nonexisting domain {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) From 605538e5da6a46427c3a28b84a66070c0cae6058 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Fri, 25 Jun 2021 23:06:01 -0700 Subject: [PATCH 42/68] updated mclag test cases --- tests/mclag_test.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 6d9ab30430..a1e625345a 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -515,8 +515,7 @@ def test_del_mclag_domain_with_members(self): assert result.exit_code == 0, "mclag member add with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) # add valid mclag member2 - result = - runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2], obj=obj) + result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2], obj=obj) assert result.exit_code == 0, "mclag member add with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) # delete mclag domain From 968094b99254015258d9769b04616c82a6381d7a Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Fri, 25 Jun 2021 23:44:40 -0700 Subject: [PATCH 43/68] updated mclag test cases --- tests/mclag_test.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index a1e625345a..af1f74fdba 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -19,7 +19,7 @@ NOT_IP = "abcd" MCLAG_PEER_IP = "12.1.1.2" MCLAG_KEEPALIVE_TIMER = "5" -MCLAG_SESSION_TIMEOUT = "10" +MCLAG_SESSION_TIMEOUT = "20" MCLAG_MEMBER_PO = "PortChannel10" MCLAG_MEMBER_PO2 = "PortChannel20" MCLAG_UNIQUE_IP_VLAN = "Vlan100" @@ -477,12 +477,12 @@ def test_del_mclag_with_invalid_domain_id(self): # del mclag with invalid domain_id result = runner.invoke(config.config.commands["mclag"].commands["del"], [MCLAG_INVALID_DOMAIN_ID1], obj=obj) - assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert result.exit_code != 0, "mclag invalid domain id test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["mclag"].commands["del"], [MCLAG_INVALID_DOMAIN_ID2], obj=obj) - assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert result.exit_code == 0, "mclag invalid domain id test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["mclag"].commands["del"], [MCLAG_DOMAIN_ID2], obj=obj) - assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert result.exit_code != 0, "mclag invalid domain id test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) @@ -495,7 +495,8 @@ def test_modify_mclag_domain(self): db.cfgdb.set_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID, {"source_ip": MCLAG_SRC_IP}) result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) - assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert result.exit_code != 0, "mclag add domain peer ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + # add valid mclag domain again result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID2, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) From 79493dc6a033273acac122a6af3a5adb430e1d33 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Fri, 25 Jun 2021 23:54:52 -0700 Subject: [PATCH 44/68] updated mclag test cases --- tests/mclag_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index af1f74fdba..5a4893c08f 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -480,7 +480,7 @@ def test_del_mclag_with_invalid_domain_id(self): assert result.exit_code != 0, "mclag invalid domain id test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["mclag"].commands["del"], [MCLAG_INVALID_DOMAIN_ID2], obj=obj) - assert result.exit_code == 0, "mclag invalid domain id test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert result.exit_code != 0, "mclag invalid domain id test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["mclag"].commands["del"], [MCLAG_DOMAIN_ID2], obj=obj) assert result.exit_code != 0, "mclag invalid domain id test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) From 1abcced5faf7b4ba2aa4cb2f27d0acc1232c4fcc Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Sat, 26 Jun 2021 00:06:39 -0700 Subject: [PATCH 45/68] updated mclag test cases --- tests/mclag_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 5a4893c08f..17b7e5eb15 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -482,7 +482,7 @@ def test_del_mclag_with_invalid_domain_id(self): result = runner.invoke(config.config.commands["mclag"].commands["del"], [MCLAG_INVALID_DOMAIN_ID2], obj=obj) assert result.exit_code != 0, "mclag invalid domain id test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["mclag"].commands["del"], [MCLAG_DOMAIN_ID2], obj=obj) - assert result.exit_code != 0, "mclag invalid domain id test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert result.exit_code == 0, "mclag invalid domain id test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) From a98a96880ce3d1d37aa9848020cbc751de8dff87 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Sat, 26 Jun 2021 07:53:51 -0700 Subject: [PATCH 46/68] updated mclag test case --- tests/mclag_test.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 17b7e5eb15..547f547793 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -13,6 +13,7 @@ MCLAG_INVALID_DOMAIN_ID1 = "-1" MCLAG_INVALID_DOMAIN_ID2 = "5000" MCLAG_DOMAIN_ID2 = "500" +MCLAG_DOMAIN_ID3 = "1000" MCLAG_SRC_IP = "12.1.1.1" RESERVED_IP = "0.0.0.0" INVALID_IP = "255.255.255.255" @@ -424,6 +425,21 @@ def test_mclag_add_unique_ip(self): result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["del"], [MCLAG_UNIQUE_IP_VLAN], obj=obj) assert result.exit_code == 0, "mclag unique ip delete case failed {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + def test_mclag_add_unique_ip_non_default_vrf(): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + result = runner.invoke(config.config.commands["vlan"].commands["add"], ["1001"], obj=db) + assert result.exit_code == 0, "add vlan for unique ip failed {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + db.cfgdb.set_entry("VLAN_INTERFACE", "Vlan1001", {"vrf_name": "vrf-red"}) + + # add mclag unique ip for non-default vrf + result = + runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], ["Vlan1001"], obj=obj) + assert result.exit_code != 0, "mclag unique ip add with non default vlan interface{}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + def test_mclag_not_present_domain(self): runner = CliRunner() db = Db() @@ -481,7 +497,7 @@ def test_del_mclag_with_invalid_domain_id(self): result = runner.invoke(config.config.commands["mclag"].commands["del"], [MCLAG_INVALID_DOMAIN_ID2], obj=obj) assert result.exit_code != 0, "mclag invalid domain id test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - result = runner.invoke(config.config.commands["mclag"].commands["del"], [MCLAG_DOMAIN_ID2], obj=obj) + result = runner.invoke(config.config.commands["mclag"].commands["del"], [MCLAG_DOMAIN_ID3], obj=obj) assert result.exit_code == 0, "mclag invalid domain id test case with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) @@ -502,6 +518,16 @@ def test_modify_mclag_domain(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID2, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "test_mclag_domain_add_again with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + + def test_add_mclag_domain_no_peer_link(self): + runner = CliRunner() + db = Db() + obj = {'db':db.cfgdb} + + + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, ""], obj=obj) + assert result.exit_code != 0, "mclag add domain peer ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + def test_del_mclag_domain_with_members(self): runner = CliRunner() db = Db() From 64dae65382b7c26bcaca1a5f644e31274c35667a Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Sat, 26 Jun 2021 20:33:35 -0700 Subject: [PATCH 47/68] updated mclag test cases --- tests/mclag_test.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 547f547793..c3469a32fd 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -436,8 +436,7 @@ def test_mclag_add_unique_ip_non_default_vrf(): db.cfgdb.set_entry("VLAN_INTERFACE", "Vlan1001", {"vrf_name": "vrf-red"}) # add mclag unique ip for non-default vrf - result = - runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], ["Vlan1001"], obj=obj) + result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], ["Vlan1001"], obj=obj) assert result.exit_code != 0, "mclag unique ip add with non default vlan interface{}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) def test_mclag_not_present_domain(self): From 5b191443bc28853209660d24ae1985ad25e87896 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Sat, 26 Jun 2021 20:44:29 -0700 Subject: [PATCH 48/68] updated mclag test case --- tests/mclag_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index c3469a32fd..1387d4e83a 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -425,7 +425,7 @@ def test_mclag_add_unique_ip(self): result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["del"], [MCLAG_UNIQUE_IP_VLAN], obj=obj) assert result.exit_code == 0, "mclag unique ip delete case failed {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - def test_mclag_add_unique_ip_non_default_vrf(): + def test_mclag_add_unique_ip_non_default_vrf(self): runner = CliRunner() db = Db() obj = {'db':db.cfgdb} From 791d8060cc224d1ff4156b0366301a5b6aa02bde Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Sat, 10 Jul 2021 00:11:42 -0700 Subject: [PATCH 49/68] updated mclag config to use swsscommon instead of swssdk --- config/mclag.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/mclag.py b/config/mclag.py index dc47411264..d6070fb232 100644 --- a/config/mclag.py +++ b/config/mclag.py @@ -1,7 +1,7 @@ #!/usr/sbin/env python import click -import swsssdk +from swsscommon.swsscommon import ConfigDBConnector import ipaddress From 36bb6264147307db834ad80eb8182969e3de7972 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Sat, 10 Jul 2021 00:26:03 -0700 Subject: [PATCH 50/68] updated mclag config to use swsscommon --- config/mclag.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/mclag.py b/config/mclag.py index d6070fb232..07d1e5cd2e 100644 --- a/config/mclag.py +++ b/config/mclag.py @@ -109,7 +109,7 @@ def get_intf_vrf_bind_unique_ip(db, interface_name, interface_type): @click.group() @click.pass_context def mclag(ctx): - config_db = swsssdk.ConfigDBConnector() + config_db = ConfigDBConnector() config_db.connect() ctx.obj = {'db': config_db} From 8e76e2f1e80a6c21682582ba2a0fc902ea75ef43 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Mon, 12 Jul 2021 00:04:30 -0700 Subject: [PATCH 51/68] updated mclag config script file --- config/mclag.py | 1 - 1 file changed, 1 deletion(-) diff --git a/config/mclag.py b/config/mclag.py index 07d1e5cd2e..2d05954ef4 100644 --- a/config/mclag.py +++ b/config/mclag.py @@ -4,7 +4,6 @@ from swsscommon.swsscommon import ConfigDBConnector import ipaddress - CFG_PORTCHANNEL_PREFIX = "PortChannel" CFG_PORTCHANNEL_PREFIX_LEN = 11 CFG_PORTCHANNEL_MAX_VAL = 9999 From 147f31c193b5616f7c03038befa1dfaa83aad451 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 13 Jul 2021 15:58:27 -0700 Subject: [PATCH 52/68] fixed mclag test cases to verify config db --- tests/mclag_test.py | 106 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 88 insertions(+), 18 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 1387d4e83a..97c5003859 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -26,6 +26,7 @@ MCLAG_UNIQUE_IP_VLAN = "Vlan100" MCLAG_PEER_LINK = "PortChannel12" +MCLAG_PEER_LINK2 = "PortChannel13" MCLAG_INVALID_SRC_IP1 = "12::1111" MCLAG_INVALID_SRC_IP2 = "224.1.1.1" MCLAG_INVALID_PEER_IP1 = "12::1112" @@ -58,6 +59,34 @@ def setup_class(cls): os.environ['UTILITIES_UNIT_TESTING'] = "1" print("SETUP") + def verify_mclag_domain_cfg(domain_id, src_ip="", peer_ip="", peer_link=""): + mclag_cfg = db.cfgdb.get_table('MCLAG_DOMAIN') + keys = [ (k, v) for k, v in mclag_cfg if k == domain_id] + if len(keys) == 0: + return False + if src_ip is not None: + if db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) != {"source_ip": src_ip}: + return False + if peer_ip is not None: + if db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) != {"peer_ip": peer_ip} + return False + if peer_link is not None: + if db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) != {"peer_link": peer_link} + return False + return True + + def verify_mclag_interface(domain_id, intf_str) + mclag_intf = db.cfgdb.get_table('MCLAG_INTERFACE') + nkeys = 0 + for k, v in mclag_intf: + if k == intf_str: + nkeys = nkeys + 1; + if k == domain_id: + nkeys = nkeys + 1; + if nkeys == 2 + return True + return False + def test_add_mclag_with_invalid_src_ip(self): runner = CliRunner() db = Db() @@ -163,6 +192,8 @@ def test_add_mclag_domain(self): # add valid mclag domain agai = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID2, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "test_mclag_domain_add_again with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + #verify config db for the mclag domain config + assert verify_mclag_domain_cfg(MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" def test_add_invalid_mclag_domain(self): runner = CliRunner() @@ -186,26 +217,17 @@ def test_add_mclag_domain(self): # add valid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + #verify config db for the mclag domain config + assert verify_mclag_domain_cfg(MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" # add valid mclag domain again result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID2, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "test_mclag_domain_add_again with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + #verify config db for the mclag domain config + assert verify_mclag_domain_cfg(MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" - def test_add_mclag_domain(self): - runner = CliRunner() - db = Db() - obj = {'db':db.cfgdb} - - # add valid mclag domain - result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) - assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - - # add valid mclag domain again - result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID2, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) - assert result.exit_code != 0, "test_mclag_domain_add_again with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - - def test_mclag_invalid_keepalive_timer(self): - runner = CliRunner() + def test_mclag_invalid_keepalive_timer(self): + runner = CliRunner() db = Db() obj = {'db':db.cfgdb} @@ -213,6 +235,9 @@ def test_mclag_invalid_keepalive_timer(self): # add valid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"source_ip": MCLAG_SRC_IP} + assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"peer_ip": MCLAG_PEER_IP} + assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"peer_link": MCLAG_PEER_LINK} # configure non multiple keepalive timer result = runner.invoke(config.config.commands["mclag"].commands["keepalive-interval"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_KEEPALIVE_TIMER], obj=obj) @@ -237,12 +262,16 @@ def test_mclag_keepalive_timer(self): print(result.exit_code) print(result.output) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"source_ip": MCLAG_SRC_IP} + assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"peer_ip": MCLAG_PEER_IP} + assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"peer_link": MCLAG_PEER_LINK} # configure valid keepalive timer result = runner.invoke(config.config.commands["mclag"].commands["keepalive-interval"], [MCLAG_DOMAIN_ID, MCLAG_KEEPALIVE_TIMER], obj=obj) print(result.exit_code) print(result.output) assert result.exit_code == 0, "failed test for setting valid keepalive timer with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"keepalive_interval": MCLAG_KEEPALIVE_TIMER} def test_mclag_invalid_session_timeout(self): runner = CliRunner() @@ -261,6 +290,7 @@ def test_mclag_invalid_session_timeout(self): print(result.exit_code) print(result.output) assert result.exit_code == 0, "failed test for setting valid keepalive timer with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"keepalive_interval": MCLAG_KEEPALIVE_TIMER} # configure non multiple session timeout result = runner.invoke(config.config.commands["mclag"].commands["session-timeout"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_SESSION_TIMEOUT], obj=obj) @@ -289,12 +319,16 @@ def test_mclag_session_timeout(self): print(result.exit_code) print(result.output) assert result.exit_code == 0, "failed test for setting valid session timeout with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"session_timeout": MCLAG_SESSION_TIMEOUT} def test_mclag_add_mclag_member_to_nonexisting_domain(self): runner = CliRunner() db = Db() obj = {'db':db.cfgdb} + mclag_cfg = db.cfgdb.get_table('MCLAG_DOMAIN') + keys = [ (k, v) for k, v in mclag_cfg if k == MCLAG_DOMAIN_ID2 ] + assert len(keys) == 0, "found mclag domain which is not expected" # add mclag member to non existing domain result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID2, MCLAG_MEMBER_PO], obj=obj) @@ -313,6 +347,9 @@ def test_mclag_add_invalid_member(self): print(result.exit_code) print(result.output) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"source_ip": MCLAG_SRC_IP} + assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"peer_ip": MCLAG_PEER_IP} + assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"peer_link": MCLAG_PEER_LINK} # add invaid mclag member Ethernet instead of PortChannel result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_MCLAG_MEMBER], obj=obj) @@ -345,10 +382,14 @@ def test_mclag_add_member(self): # add valid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"source_ip": MCLAG_SRC_IP} + assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"peer_ip": MCLAG_PEER_IP} + assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"peer_link": MCLAG_PEER_LINK} # add valid mclag member result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) assert result.exit_code == 0, "failed adding valid mclag member with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert verify_mclag_interface(MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == True, "mclag member not present" # add mclag member again result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) @@ -361,23 +402,29 @@ def test_mclag_add_member(self): print(result.exit_code) print(result.output) assert result.exit_code == 0, "testing of delete of mclag domain failed" + assert verify_mclag_interface(MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == False, "mclag member not deleted" + assert verify_mclag_domain_cfg(MCLAG_DOMAIN_ID) == False, "mclag domain not deleted" # add valid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert verify_mclag_domain_cfg(MCLAG_DOMAIN_ID) == True, "mclag domain not present" # add valid mclag member result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) assert result.exit_code == 0, "mclag member add with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert verify_mclag_interface(MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == True, "mclag member not present" # add valid mclag member2 result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2], obj=obj) assert result.exit_code == 0, "mclag member add with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert verify_mclag_interface(MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2) == True, "mclag member not present" # del valid mclag member result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["del"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) assert result.exit_code == 0, "mclag member deletion failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert verify_mclag_interface(MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == False, "mclag member not deleted " # del mclag member result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["del"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_MCLAG_MEMBER], obj=obj) @@ -406,10 +453,15 @@ def test_mclag_add_unique_ip(self): # add valid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert verify_mclag_domain_cfg(MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" # add mclag unique ip result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], [MCLAG_UNIQUE_IP_VLAN], obj=obj) assert result.exit_code == 0, "mclag unique ip add with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + unique_ip = db.cfgdb.get_table('MCLAG_UNIQUE_IP') + keys = [ (k, v) for k, v in unique_ip if k == MCLAG_UNIQUE_IP_VLAN ] + assert len(keys) != 0, "unique ip not conifgured" + # add mclag unique ip for vlan interface which already has ip result = runner.invoke(config.config.commands["vlan"].commands["add"], ["111"], obj=db) @@ -420,10 +472,16 @@ def test_mclag_add_unique_ip(self): result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], ["Vlan111"], obj=obj) assert result.exit_code == 0, "unique ip config for vlan with ip address case failed {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + unique_ip = db.cfgdb.get_table('MCLAG_UNIQUE_IP') + keys = [ (k, v) for k, v in unique_ip if k == 'Vlan{}'.format(111) ] + assert len(keys) == 0, "unique ip present config shouldn't be allowed" # delete mclag unique ip result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["del"], [MCLAG_UNIQUE_IP_VLAN], obj=obj) assert result.exit_code == 0, "mclag unique ip delete case failed {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + unique_ip = db.cfgdb.get_table('MCLAG_UNIQUE_IP') + keys = [ (k, v) for k, v in unique_ip if k == MCLAG_UNIQUE_IP_VLAN ] + assert len(keys) == 0, "unique ip not conifgured" def test_mclag_add_unique_ip_non_default_vrf(self): runner = CliRunner() @@ -438,7 +496,10 @@ def test_mclag_add_unique_ip_non_default_vrf(self): # add mclag unique ip for non-default vrf result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], ["Vlan1001"], obj=obj) assert result.exit_code != 0, "mclag unique ip add with non default vlan interface{}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - + unique_ip = db.cfgdb.get_table('MCLAG_UNIQUE_IP') + keys = [ (k, v) for k, v in unique_ip if k == 'Vlan{}'.format(1001) ] + assert len(keys) == 0, "non default vrf unique ip goes through, config shouldn't be allowed" + def test_mclag_not_present_domain(self): runner = CliRunner() db = Db() @@ -511,11 +572,13 @@ def test_modify_mclag_domain(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "mclag add domain peer ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert verify_mclag_domain_cfg(MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" - # add valid mclag domain again - result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID2, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) + # modify mclag config + result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "test_mclag_domain_add_again with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert verify_mclag_domain_cfg(MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK2) == True, "mclag config not modified" def test_add_mclag_domain_no_peer_link(self): @@ -526,6 +589,7 @@ def test_add_mclag_domain_no_peer_link(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, ""], obj=obj) assert result.exit_code != 0, "mclag add domain peer ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert verify_mclag_domain_cfg(MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP) == True, "mclag config not found" def test_del_mclag_domain_with_members(self): runner = CliRunner() @@ -535,18 +599,24 @@ def test_del_mclag_domain_with_members(self): # add valid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert verify_mclag_domain_cfg(MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" # add valid mclag member result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) assert result.exit_code == 0, "mclag member add with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert verify_mclag_interface(MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == True, "mclag member not present" # add valid mclag member2 result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2], obj=obj) assert result.exit_code == 0, "mclag member add with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert verify_mclag_interface(MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2) == True, "mclag member not present" # delete mclag domain result = runner.invoke(config.config.commands["mclag"].commands["del"], [MCLAG_DOMAIN_ID], obj=obj) assert result.exit_code == 0, "testing non-existing domain deletion{}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) + assert verify_mclag_interface(MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2) == False, "mclag member not deleted" + assert verify_mclag_interface(MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == False, "mclag member not deleted" + assert verify_mclag_domain_cfg(MCLAG_DOMAIN_ID) == False, "mclag domain not present" def test_mclag_keepalive_for_non_existent_domain(self): From 1848e0246d37da09a67262186fb0de714de5437f Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 13 Jul 2021 16:47:57 -0700 Subject: [PATCH 53/68] updated mclag test case with config db verify function --- tests/mclag_test.py | 56 ++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 97c5003859..8c18e174b2 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -59,23 +59,27 @@ def setup_class(cls): os.environ['UTILITIES_UNIT_TESTING'] = "1" print("SETUP") - def verify_mclag_domain_cfg(domain_id, src_ip="", peer_ip="", peer_link=""): + def verify_mclag_domain_cfg(db, domain_id, src_ip="", peer_ip="", peer_link=""): mclag_cfg = db.cfgdb.get_table('MCLAG_DOMAIN') keys = [ (k, v) for k, v in mclag_cfg if k == domain_id] if len(keys) == 0: return False + mclag_entry = db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) if src_ip is not None: - if db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) != {"source_ip": src_ip}: + temp = mclag_entry.has_key("source_ip") + if temp != src_ip: return False if peer_ip is not None: - if db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) != {"peer_ip": peer_ip} + temp = mclag_entry.has_key("peer_ip") + if temp != peer_ip: return False if peer_link is not None: - if db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) != {"peer_link": peer_link} - return False + temp = mclag_entry.has_key("peer_link") + if temp != peer_link: + return False return True - def verify_mclag_interface(domain_id, intf_str) + def verify_mclag_interface(db, domain_id, intf_str) mclag_intf = db.cfgdb.get_table('MCLAG_INTERFACE') nkeys = 0 for k, v in mclag_intf: @@ -193,7 +197,7 @@ def test_add_mclag_domain(self): # add valid mclag domain agai = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID2, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "test_mclag_domain_add_again with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) #verify config db for the mclag domain config - assert verify_mclag_domain_cfg(MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" + assert verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" def test_add_invalid_mclag_domain(self): runner = CliRunner() @@ -218,13 +222,13 @@ def test_add_mclag_domain(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) #verify config db for the mclag domain config - assert verify_mclag_domain_cfg(MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" + assert verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" # add valid mclag domain again result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID2, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "test_mclag_domain_add_again with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) #verify config db for the mclag domain config - assert verify_mclag_domain_cfg(MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" + assert verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" def test_mclag_invalid_keepalive_timer(self): runner = CliRunner() @@ -389,7 +393,7 @@ def test_mclag_add_member(self): # add valid mclag member result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) assert result.exit_code == 0, "failed adding valid mclag member with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_interface(MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == True, "mclag member not present" + assert verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == True, "mclag member not present" # add mclag member again result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) @@ -402,29 +406,29 @@ def test_mclag_add_member(self): print(result.exit_code) print(result.output) assert result.exit_code == 0, "testing of delete of mclag domain failed" - assert verify_mclag_interface(MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == False, "mclag member not deleted" - assert verify_mclag_domain_cfg(MCLAG_DOMAIN_ID) == False, "mclag domain not deleted" + assert verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == False, "mclag member not deleted" + assert verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID) == False, "mclag domain not deleted" # add valid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_domain_cfg(MCLAG_DOMAIN_ID) == True, "mclag domain not present" + assert verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID) == True, "mclag domain not present" # add valid mclag member result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) assert result.exit_code == 0, "mclag member add with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_interface(MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == True, "mclag member not present" + assert verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == True, "mclag member not present" # add valid mclag member2 result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2], obj=obj) assert result.exit_code == 0, "mclag member add with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_interface(MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2) == True, "mclag member not present" + assert verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2) == True, "mclag member not present" # del valid mclag member result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["del"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) assert result.exit_code == 0, "mclag member deletion failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_interface(MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == False, "mclag member not deleted " + assert verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == False, "mclag member not deleted " # del mclag member result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["del"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_MCLAG_MEMBER], obj=obj) @@ -453,7 +457,7 @@ def test_mclag_add_unique_ip(self): # add valid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_domain_cfg(MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" + assert verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" # add mclag unique ip result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], [MCLAG_UNIQUE_IP_VLAN], obj=obj) @@ -572,13 +576,13 @@ def test_modify_mclag_domain(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "mclag add domain peer ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_domain_cfg(MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" + assert verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" # modify mclag config result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "test_mclag_domain_add_again with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_domain_cfg(MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK2) == True, "mclag config not modified" + assert verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK2) == True, "mclag config not modified" def test_add_mclag_domain_no_peer_link(self): @@ -589,7 +593,7 @@ def test_add_mclag_domain_no_peer_link(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, ""], obj=obj) assert result.exit_code != 0, "mclag add domain peer ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_domain_cfg(MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP) == True, "mclag config not found" + assert verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP) == True, "mclag config not found" def test_del_mclag_domain_with_members(self): runner = CliRunner() @@ -599,24 +603,24 @@ def test_del_mclag_domain_with_members(self): # add valid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_domain_cfg(MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" + assert verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" # add valid mclag member result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) assert result.exit_code == 0, "mclag member add with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_interface(MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == True, "mclag member not present" + assert verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == True, "mclag member not present" # add valid mclag member2 result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2], obj=obj) assert result.exit_code == 0, "mclag member add with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_interface(MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2) == True, "mclag member not present" + assert verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2) == True, "mclag member not present" # delete mclag domain result = runner.invoke(config.config.commands["mclag"].commands["del"], [MCLAG_DOMAIN_ID], obj=obj) assert result.exit_code == 0, "testing non-existing domain deletion{}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_interface(MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2) == False, "mclag member not deleted" - assert verify_mclag_interface(MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == False, "mclag member not deleted" - assert verify_mclag_domain_cfg(MCLAG_DOMAIN_ID) == False, "mclag domain not present" + assert verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2) == False, "mclag member not deleted" + assert verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == False, "mclag member not deleted" + assert verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID) == False, "mclag domain not present" def test_mclag_keepalive_for_non_existent_domain(self): From 6f8c74fb6ed2d0050afdf035484b239b73316b42 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 13 Jul 2021 17:00:16 -0700 Subject: [PATCH 54/68] fixed build issue --- tests/mclag_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 8c18e174b2..d5101c675c 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -79,7 +79,7 @@ def verify_mclag_domain_cfg(db, domain_id, src_ip="", peer_ip="", peer_link=""): return False return True - def verify_mclag_interface(db, domain_id, intf_str) + def verify_mclag_interface(db, domain_id, intf_str): mclag_intf = db.cfgdb.get_table('MCLAG_INTERFACE') nkeys = 0 for k, v in mclag_intf: From e3760347ad18bceda3ebafc181d9add15cfc6beb Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 13 Jul 2021 17:09:04 -0700 Subject: [PATCH 55/68] fixed build issue --- tests/mclag_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index d5101c675c..003ad6677e 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -87,8 +87,8 @@ def verify_mclag_interface(db, domain_id, intf_str): nkeys = nkeys + 1; if k == domain_id: nkeys = nkeys + 1; - if nkeys == 2 - return True + if nkeys == 2: + return True return False def test_add_mclag_with_invalid_src_ip(self): From a4c0a85d9233dce6f18c30f7da071e28fcbb3d23 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 13 Jul 2021 17:16:49 -0700 Subject: [PATCH 56/68] fixed build issue --- tests/mclag_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 003ad6677e..0cad020159 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -230,8 +230,8 @@ def test_add_mclag_domain(self): #verify config db for the mclag domain config assert verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" - def test_mclag_invalid_keepalive_timer(self): - runner = CliRunner() + def test_mclag_invalid_keepalive_timer(self): + runner = CliRunner() db = Db() obj = {'db':db.cfgdb} From 26fd9790fe887c172bbba101a8e5ce16ddd17565 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 13 Jul 2021 17:34:20 -0700 Subject: [PATCH 57/68] fixed build issue --- tests/mclag_test.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 0cad020159..ec8bde8473 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -59,7 +59,7 @@ def setup_class(cls): os.environ['UTILITIES_UNIT_TESTING'] = "1" print("SETUP") - def verify_mclag_domain_cfg(db, domain_id, src_ip="", peer_ip="", peer_link=""): + def verify_mclag_domain_cfg(self, db, domain_id, src_ip="", peer_ip="", peer_link=""): mclag_cfg = db.cfgdb.get_table('MCLAG_DOMAIN') keys = [ (k, v) for k, v in mclag_cfg if k == domain_id] if len(keys) == 0: @@ -79,7 +79,7 @@ def verify_mclag_domain_cfg(db, domain_id, src_ip="", peer_ip="", peer_link=""): return False return True - def verify_mclag_interface(db, domain_id, intf_str): + def verify_mclag_interface(self, db, domain_id, intf_str): mclag_intf = db.cfgdb.get_table('MCLAG_INTERFACE') nkeys = 0 for k, v in mclag_intf: @@ -239,9 +239,7 @@ def test_mclag_invalid_keepalive_timer(self): # add valid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"source_ip": MCLAG_SRC_IP} - assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"peer_ip": MCLAG_PEER_IP} - assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"peer_link": MCLAG_PEER_LINK} + assert verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" # configure non multiple keepalive timer result = runner.invoke(config.config.commands["mclag"].commands["keepalive-interval"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_KEEPALIVE_TIMER], obj=obj) From ba901c6808fda9762686a5126200d58ff8999a1b Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 13 Jul 2021 17:39:11 -0700 Subject: [PATCH 58/68] fixed build issue --- tests/mclag_test.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index ec8bde8473..6824783d21 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -197,7 +197,7 @@ def test_add_mclag_domain(self): # add valid mclag domain agai = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID2, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "test_mclag_domain_add_again with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) #verify config db for the mclag domain config - assert verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" + assert self.verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" def test_add_invalid_mclag_domain(self): runner = CliRunner() @@ -222,13 +222,13 @@ def test_add_mclag_domain(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) #verify config db for the mclag domain config - assert verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" + assert self.verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" # add valid mclag domain again result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID2, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "test_mclag_domain_add_again with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) #verify config db for the mclag domain config - assert verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" + assert self.verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" def test_mclag_invalid_keepalive_timer(self): runner = CliRunner() @@ -239,7 +239,7 @@ def test_mclag_invalid_keepalive_timer(self): # add valid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" + assert self.verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" # configure non multiple keepalive timer result = runner.invoke(config.config.commands["mclag"].commands["keepalive-interval"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_KEEPALIVE_TIMER], obj=obj) @@ -391,7 +391,7 @@ def test_mclag_add_member(self): # add valid mclag member result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) assert result.exit_code == 0, "failed adding valid mclag member with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == True, "mclag member not present" + assert self.verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == True, "mclag member not present" # add mclag member again result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) @@ -404,29 +404,29 @@ def test_mclag_add_member(self): print(result.exit_code) print(result.output) assert result.exit_code == 0, "testing of delete of mclag domain failed" - assert verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == False, "mclag member not deleted" - assert verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID) == False, "mclag domain not deleted" + assert self.verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == False, "mclag member not deleted" + assert self.verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID) == False, "mclag domain not deleted" # add valid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID) == True, "mclag domain not present" + assert self.verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID) == True, "mclag domain not present" # add valid mclag member result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) assert result.exit_code == 0, "mclag member add with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == True, "mclag member not present" + assert self.verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == True, "mclag member not present" # add valid mclag member2 result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2], obj=obj) assert result.exit_code == 0, "mclag member add with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2) == True, "mclag member not present" + assert self.verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2) == True, "mclag member not present" # del valid mclag member result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["del"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) assert result.exit_code == 0, "mclag member deletion failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == False, "mclag member not deleted " + assert self.verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == False, "mclag member not deleted " # del mclag member result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["del"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_MCLAG_MEMBER], obj=obj) @@ -455,7 +455,7 @@ def test_mclag_add_unique_ip(self): # add valid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" + assert self.verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" # add mclag unique ip result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], [MCLAG_UNIQUE_IP_VLAN], obj=obj) @@ -574,13 +574,13 @@ def test_modify_mclag_domain(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "mclag add domain peer ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" + assert self.verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" # modify mclag config result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "test_mclag_domain_add_again with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK2) == True, "mclag config not modified" + assert self.verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK2) == True, "mclag config not modified" def test_add_mclag_domain_no_peer_link(self): @@ -591,7 +591,7 @@ def test_add_mclag_domain_no_peer_link(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, ""], obj=obj) assert result.exit_code != 0, "mclag add domain peer ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP) == True, "mclag config not found" + assert self.verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP) == True, "mclag config not found" def test_del_mclag_domain_with_members(self): runner = CliRunner() @@ -601,24 +601,24 @@ def test_del_mclag_domain_with_members(self): # add valid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" + assert self.verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" # add valid mclag member result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) assert result.exit_code == 0, "mclag member add with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == True, "mclag member not present" + assert self.verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == True, "mclag member not present" # add valid mclag member2 result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2], obj=obj) assert result.exit_code == 0, "mclag member add with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2) == True, "mclag member not present" + assert self.verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2) == True, "mclag member not present" # delete mclag domain result = runner.invoke(config.config.commands["mclag"].commands["del"], [MCLAG_DOMAIN_ID], obj=obj) assert result.exit_code == 0, "testing non-existing domain deletion{}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2) == False, "mclag member not deleted" - assert verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == False, "mclag member not deleted" - assert verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID) == False, "mclag domain not present" + assert self.verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO2) == False, "mclag member not deleted" + assert self.verify_mclag_interface(db, MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO) == False, "mclag member not deleted" + assert self.verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID) == False, "mclag domain not present" def test_mclag_keepalive_for_non_existent_domain(self): From c47e5de7cb6e91ca291b41a152a4860feb1d652d Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 13 Jul 2021 18:22:14 -0700 Subject: [PATCH 59/68] fixed build issue --- tests/mclag_test.py | 49 +++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 6824783d21..51d311d4b6 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -60,22 +60,26 @@ def setup_class(cls): print("SETUP") def verify_mclag_domain_cfg(self, db, domain_id, src_ip="", peer_ip="", peer_link=""): - mclag_cfg = db.cfgdb.get_table('MCLAG_DOMAIN') - keys = [ (k, v) for k, v in mclag_cfg if k == domain_id] - if len(keys) == 0: + keys = db.cfgdb.get_keys('MCLAG_DOMAIN') + key_found = False + for k in keys: + if k == domain_id: + key_found = True + if key_found is False: return False + mclag_entry = db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) if src_ip is not None: temp = mclag_entry.has_key("source_ip") - if temp != src_ip: + if temp is not None and temp != src_ip: return False if peer_ip is not None: temp = mclag_entry.has_key("peer_ip") - if temp != peer_ip: + if temp is not None and temp != peer_ip: return False if peer_link is not None: temp = mclag_entry.has_key("peer_link") - if temp != peer_link: + if temp is not None and temp != peer_link: return False return True @@ -264,9 +268,7 @@ def test_mclag_keepalive_timer(self): print(result.exit_code) print(result.output) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"source_ip": MCLAG_SRC_IP} - assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"peer_ip": MCLAG_PEER_IP} - assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"peer_link": MCLAG_PEER_LINK} + assert self.verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" # configure valid keepalive timer result = runner.invoke(config.config.commands["mclag"].commands["keepalive-interval"], [MCLAG_DOMAIN_ID, MCLAG_KEEPALIVE_TIMER], obj=obj) @@ -292,7 +294,10 @@ def test_mclag_invalid_session_timeout(self): print(result.exit_code) print(result.output) assert result.exit_code == 0, "failed test for setting valid keepalive timer with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"keepalive_interval": MCLAG_KEEPALIVE_TIMER} + mclag_entry = db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) + temp = mclag_entry.has_key("keepalive_interval") + assert temp is not None, "session timeout not found" + assert temp != MCLAG_KEEPALIVE_TIMER, "keepalive timer value not set" # configure non multiple session timeout result = runner.invoke(config.config.commands["mclag"].commands["session-timeout"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_SESSION_TIMEOUT], obj=obj) @@ -321,7 +326,10 @@ def test_mclag_session_timeout(self): print(result.exit_code) print(result.output) assert result.exit_code == 0, "failed test for setting valid session timeout with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"session_timeout": MCLAG_SESSION_TIMEOUT} + mclag_entry = db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) + temp = mclag_entry.has_key("session_timeout") + assert temp is not None, "session timeout not found" + assert temp != MCLAG_SESSION_TIMEOUT, "keepalive timer value not set" def test_mclag_add_mclag_member_to_nonexisting_domain(self): @@ -349,9 +357,7 @@ def test_mclag_add_invalid_member(self): print(result.exit_code) print(result.output) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"source_ip": MCLAG_SRC_IP} - assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"peer_ip": MCLAG_PEER_IP} - assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"peer_link": MCLAG_PEER_LINK} + assert self.verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" # add invaid mclag member Ethernet instead of PortChannel result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_MCLAG_MEMBER], obj=obj) @@ -384,9 +390,7 @@ def test_mclag_add_member(self): # add valid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"source_ip": MCLAG_SRC_IP} - assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"peer_ip": MCLAG_PEER_IP} - assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"peer_link": MCLAG_PEER_LINK} + assert self.verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" # add valid mclag member result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) @@ -460,8 +464,7 @@ def test_mclag_add_unique_ip(self): # add mclag unique ip result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], [MCLAG_UNIQUE_IP_VLAN], obj=obj) assert result.exit_code == 0, "mclag unique ip add with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - unique_ip = db.cfgdb.get_table('MCLAG_UNIQUE_IP') - keys = [ (k, v) for k, v in unique_ip if k == MCLAG_UNIQUE_IP_VLAN ] + keys = db.cfgdb.get_keys('MCLAG_UNIQUE_IP') assert len(keys) != 0, "unique ip not conifgured" @@ -474,15 +477,14 @@ def test_mclag_add_unique_ip(self): result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], ["Vlan111"], obj=obj) assert result.exit_code == 0, "unique ip config for vlan with ip address case failed {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - unique_ip = db.cfgdb.get_table('MCLAG_UNIQUE_IP') - keys = [ (k, v) for k, v in unique_ip if k == 'Vlan{}'.format(111) ] + keys = db.cfgdb.get_keys('MCLAG_UNIQUE_IP') assert len(keys) == 0, "unique ip present config shouldn't be allowed" # delete mclag unique ip result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["del"], [MCLAG_UNIQUE_IP_VLAN], obj=obj) assert result.exit_code == 0, "mclag unique ip delete case failed {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) unique_ip = db.cfgdb.get_table('MCLAG_UNIQUE_IP') - keys = [ (k, v) for k, v in unique_ip if k == MCLAG_UNIQUE_IP_VLAN ] + keys = db.cfgdb.get_keys('MCLAG_UNIQUE_IP') assert len(keys) == 0, "unique ip not conifgured" def test_mclag_add_unique_ip_non_default_vrf(self): @@ -498,8 +500,7 @@ def test_mclag_add_unique_ip_non_default_vrf(self): # add mclag unique ip for non-default vrf result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], ["Vlan1001"], obj=obj) assert result.exit_code != 0, "mclag unique ip add with non default vlan interface{}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - unique_ip = db.cfgdb.get_table('MCLAG_UNIQUE_IP') - keys = [ (k, v) for k, v in unique_ip if k == 'Vlan{}'.format(1001) ] + keys = db.cfgdb.get_keys('MCLAG_UNIQUE_IP') assert len(keys) == 0, "non default vrf unique ip goes through, config shouldn't be allowed" def test_mclag_not_present_domain(self): From 489c5b3d1d8c4677251ecd27334d8b62b0899bca Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Tue, 13 Jul 2021 23:35:10 -0700 Subject: [PATCH 60/68] fixed build issue --- tests/mclag_test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 51d311d4b6..e4c8a20e07 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -70,15 +70,15 @@ def verify_mclag_domain_cfg(self, db, domain_id, src_ip="", peer_ip="", peer_lin mclag_entry = db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) if src_ip is not None: - temp = mclag_entry.has_key("source_ip") + temp = mclag_entry["source_ip"] if temp is not None and temp != src_ip: return False if peer_ip is not None: - temp = mclag_entry.has_key("peer_ip") + temp = mclag_entry["peer_ip"] if temp is not None and temp != peer_ip: return False if peer_link is not None: - temp = mclag_entry.has_key("peer_link") + temp = mclag_entry["peer_link"] if temp is not None and temp != peer_link: return False return True From d5db6f83eb5732454f2baa9b46cc7fda9160c978 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Wed, 14 Jul 2021 01:27:40 -0700 Subject: [PATCH 61/68] updated test case --- tests/mclag_test.py | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index e4c8a20e07..7a87c35ec0 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -70,15 +70,15 @@ def verify_mclag_domain_cfg(self, db, domain_id, src_ip="", peer_ip="", peer_lin mclag_entry = db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) if src_ip is not None: - temp = mclag_entry["source_ip"] + temp = mclag_entry.get("source_ip") if temp is not None and temp != src_ip: return False - if peer_ip is not None: - temp = mclag_entry["peer_ip"] + if peer_ip is not None + temp = mclag_entry.get("peer_ip") if temp is not None and temp != peer_ip: return False if peer_link is not None: - temp = mclag_entry["peer_link"] + temp = mclag_entry.get("peer_link") if temp is not None and temp != peer_link: return False return True @@ -275,17 +275,6 @@ def test_mclag_keepalive_timer(self): print(result.exit_code) print(result.output) assert result.exit_code == 0, "failed test for setting valid keepalive timer with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) == {"keepalive_interval": MCLAG_KEEPALIVE_TIMER} - - def test_mclag_invalid_session_timeout(self): - runner = CliRunner() - db = Db() - obj = {'db':db.cfgdb} - - - # add valid mclag domain - result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) - print(result.exit_code) print(result.output) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) @@ -295,7 +284,7 @@ def test_mclag_invalid_session_timeout(self): print(result.output) assert result.exit_code == 0, "failed test for setting valid keepalive timer with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) mclag_entry = db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) - temp = mclag_entry.has_key("keepalive_interval") + temp = mclag_entry.get("keepalive_interval") assert temp is not None, "session timeout not found" assert temp != MCLAG_KEEPALIVE_TIMER, "keepalive timer value not set" @@ -327,7 +316,7 @@ def test_mclag_session_timeout(self): print(result.output) assert result.exit_code == 0, "failed test for setting valid session timeout with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) mclag_entry = db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) - temp = mclag_entry.has_key("session_timeout") + temp = mclag_entry.get("session_timeout") assert temp is not None, "session timeout not found" assert temp != MCLAG_SESSION_TIMEOUT, "keepalive timer value not set" @@ -478,14 +467,13 @@ def test_mclag_add_unique_ip(self): result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["add"], ["Vlan111"], obj=obj) assert result.exit_code == 0, "unique ip config for vlan with ip address case failed {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) keys = db.cfgdb.get_keys('MCLAG_UNIQUE_IP') - assert len(keys) == 0, "unique ip present config shouldn't be allowed" + assert "Vlan111" in keys, "unique ip present config shouldn't be allowed" # delete mclag unique ip result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["del"], [MCLAG_UNIQUE_IP_VLAN], obj=obj) assert result.exit_code == 0, "mclag unique ip delete case failed {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - unique_ip = db.cfgdb.get_table('MCLAG_UNIQUE_IP') keys = db.cfgdb.get_keys('MCLAG_UNIQUE_IP') - assert len(keys) == 0, "unique ip not conifgured" + assert MCLAG_UNIQUE_IP_VLAN in keys, "unique ip not conifgured" def test_mclag_add_unique_ip_non_default_vrf(self): runner = CliRunner() From 59bb70245895abe55de9bdba81d25dda09cd61a5 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Wed, 14 Jul 2021 01:35:02 -0700 Subject: [PATCH 62/68] updatrd mclag test case --- tests/mclag_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 7a87c35ec0..fa4cbdea1d 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -73,7 +73,7 @@ def verify_mclag_domain_cfg(self, db, domain_id, src_ip="", peer_ip="", peer_lin temp = mclag_entry.get("source_ip") if temp is not None and temp != src_ip: return False - if peer_ip is not None + if peer_ip is not None: temp = mclag_entry.get("peer_ip") if temp is not None and temp != peer_ip: return False From a506c737d3563774cf7f8bd07f79db2534ef9373 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Wed, 14 Jul 2021 01:44:46 -0700 Subject: [PATCH 63/68] updated mclag test case --- tests/mclag_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index fa4cbdea1d..0346bec58a 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -284,7 +284,7 @@ def test_mclag_keepalive_timer(self): print(result.output) assert result.exit_code == 0, "failed test for setting valid keepalive timer with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) mclag_entry = db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) - temp = mclag_entry.get("keepalive_interval") + temp = mclag_entry.get("keepalive_interval") assert temp is not None, "session timeout not found" assert temp != MCLAG_KEEPALIVE_TIMER, "keepalive timer value not set" From de8ba455129aec0627df7577d2482ba0f5b5cccb Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Wed, 14 Jul 2021 02:21:48 -0700 Subject: [PATCH 64/68] updated mclag test case --- tests/mclag_test.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 0346bec58a..e5d35cabd5 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -84,16 +84,10 @@ def verify_mclag_domain_cfg(self, db, domain_id, src_ip="", peer_ip="", peer_lin return True def verify_mclag_interface(self, db, domain_id, intf_str): - mclag_intf = db.cfgdb.get_table('MCLAG_INTERFACE') - nkeys = 0 - for k, v in mclag_intf: - if k == intf_str: - nkeys = nkeys + 1; - if k == domain_id: - nkeys = nkeys + 1; - if nkeys == 2: - return True - return False + keys = db.cfgdb.get_entry('MCLAG_INTERFACE', (domain_id, intf_str)) + if len(keys) != 0: + return True + return False def test_add_mclag_with_invalid_src_ip(self): runner = CliRunner() @@ -286,7 +280,7 @@ def test_mclag_keepalive_timer(self): mclag_entry = db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) temp = mclag_entry.get("keepalive_interval") assert temp is not None, "session timeout not found" - assert temp != MCLAG_KEEPALIVE_TIMER, "keepalive timer value not set" + assert temp == MCLAG_KEEPALIVE_TIMER, "keepalive timer value not set" # configure non multiple session timeout result = runner.invoke(config.config.commands["mclag"].commands["session-timeout"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_SESSION_TIMEOUT], obj=obj) @@ -318,7 +312,7 @@ def test_mclag_session_timeout(self): mclag_entry = db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) temp = mclag_entry.get("session_timeout") assert temp is not None, "session timeout not found" - assert temp != MCLAG_SESSION_TIMEOUT, "keepalive timer value not set" + assert temp == MCLAG_SESSION_TIMEOUT, "keepalive timer value not set" def test_mclag_add_mclag_member_to_nonexisting_domain(self): @@ -473,7 +467,7 @@ def test_mclag_add_unique_ip(self): result = runner.invoke(config.config.commands["mclag"].commands["unique-ip"].commands["del"], [MCLAG_UNIQUE_IP_VLAN], obj=obj) assert result.exit_code == 0, "mclag unique ip delete case failed {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) keys = db.cfgdb.get_keys('MCLAG_UNIQUE_IP') - assert MCLAG_UNIQUE_IP_VLAN in keys, "unique ip not conifgured" + assert MCLAG_UNIQUE_IP_VLAN not in keys, "unique ip not conifgured" def test_mclag_add_unique_ip_non_default_vrf(self): runner = CliRunner() @@ -580,7 +574,7 @@ def test_add_mclag_domain_no_peer_link(self): result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, ""], obj=obj) assert result.exit_code != 0, "mclag add domain peer ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert self.verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP) == True, "mclag config not found" + assert self.verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP) == False, "mclag config not found" def test_del_mclag_domain_with_members(self): runner = CliRunner() From 7c27d18be510f40369db4a299d3a065317474cf7 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Wed, 14 Jul 2021 02:35:29 -0700 Subject: [PATCH 65/68] updated mclag test case --- tests/mclag_test.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index e5d35cabd5..9e9434b9a4 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -60,15 +60,10 @@ def setup_class(cls): print("SETUP") def verify_mclag_domain_cfg(self, db, domain_id, src_ip="", peer_ip="", peer_link=""): - keys = db.cfgdb.get_keys('MCLAG_DOMAIN') - key_found = False - for k in keys: - if k == domain_id: - key_found = True - if key_found is False: - return False - mclag_entry = db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) + if len(mclag_entry) == 0: + return False + if src_ip is not None: temp = mclag_entry.get("source_ip") if temp is not None and temp != src_ip: From 95293dbcce8bbf62818c384c5cc621ea0cf99af3 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Wed, 14 Jul 2021 02:48:56 -0700 Subject: [PATCH 66/68] updated mclag test case --- tests/mclag_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 9e9434b9a4..695be962d5 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -392,7 +392,7 @@ def test_mclag_add_member(self): # add valid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) - assert self.verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID) == True, "mclag domain not present" + assert self.verify_mclag_domain_cfg(db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found" # add valid mclag member result = runner.invoke(config.config.commands["mclag"].commands["member"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_MEMBER_PO], obj=obj) From 379b60e0653a0c79a6ea6bd83b8c13f431ec2b97 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Wed, 14 Jul 2021 07:34:42 -0700 Subject: [PATCH 67/68] updated mclag test case --- tests/mclag_test.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/mclag_test.py b/tests/mclag_test.py index 695be962d5..2d10c0ae07 100644 --- a/tests/mclag_test.py +++ b/tests/mclag_test.py @@ -8,7 +8,6 @@ from utilities_common.db import Db - MCLAG_DOMAIN_ID = "123" MCLAG_INVALID_DOMAIN_ID1 = "-1" MCLAG_INVALID_DOMAIN_ID2 = "5000" From f95967c77a5296427f0f2f4c5cc486cf0e923d84 Mon Sep 17 00:00:00 2001 From: sabarivel sakthivel Date: Thu, 15 Jul 2021 17:05:37 -0700 Subject: [PATCH 68/68] addressed review comments --- config/mclag.py | 1 - 1 file changed, 1 deletion(-) diff --git a/config/mclag.py b/config/mclag.py index 2d05954ef4..2ab0d0ca75 100644 --- a/config/mclag.py +++ b/config/mclag.py @@ -1,4 +1,3 @@ -#!/usr/sbin/env python import click from swsscommon.swsscommon import ConfigDBConnector