diff options
85 files changed, 982 insertions, 2811 deletions
diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c index c78e740ec9..fe77e7e250 100644 --- a/bgpd/bgp_dump.c +++ b/bgpd/bgp_dump.c @@ -845,8 +845,7 @@ void bgp_dump_init(void) memset(&bgp_dump_routes, 0, sizeof(bgp_dump_routes)); bgp_dump_obuf = - stream_new((BGP_STANDARD_MESSAGE_MAX_PACKET_SIZE * 2) - + BGP_DUMP_MSG_HEADER + BGP_DUMP_HEADER_SIZE); + stream_new(BGP_MAX_PACKET_SIZE + BGP_MAX_PACKET_SIZE_OVERFLOW); install_node(&bgp_dump_node); diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 4441e86fbb..4813874748 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -3838,6 +3838,12 @@ bool bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi, (type == ZEBRA_ROUTE_BGP && stype == BGP_ROUTE_STATIC) ? true : false; + /* If `bgp allow-martian-nexthop` is turned on, return next-hop + * as good. + */ + if (bgp->allow_martian) + return false; + /* * Only validated for unicast and multicast currently. * Also valid for EVPN where the nexthop is an IP address. @@ -8338,30 +8344,7 @@ static int bgp_aggregate_unset(struct vty *vty, const char *prefix_str, /* Unlock aggregate address configuration. */ bgp_dest_set_bgp_aggregate_info(dest, NULL); - if (aggregate->community) - community_free(&aggregate->community); - - hash_clean_and_free(&aggregate->community_hash, - bgp_aggr_community_remove); - - if (aggregate->ecommunity) - ecommunity_free(&aggregate->ecommunity); - - hash_clean_and_free(&aggregate->ecommunity_hash, - bgp_aggr_ecommunity_remove); - - if (aggregate->lcommunity) - lcommunity_free(&aggregate->lcommunity); - - hash_clean_and_free(&aggregate->lcommunity_hash, - bgp_aggr_lcommunity_remove); - - if (aggregate->aspath) - aspath_free(aggregate->aspath); - - hash_clean_and_free(&aggregate->aspath_hash, bgp_aggr_aspath_remove); - - bgp_aggregate_free(aggregate); + bgp_free_aggregate_info(aggregate); bgp_dest_unlock_node(dest); bgp_dest_unlock_node(dest); @@ -8545,6 +8528,34 @@ DEFPY(aggregate_addressv4, aggregate_addressv4_cmd, match_med != NULL, suppress_map); } +void bgp_free_aggregate_info(struct bgp_aggregate *aggregate) +{ + if (aggregate->community) + community_free(&aggregate->community); + + hash_clean_and_free(&aggregate->community_hash, + bgp_aggr_community_remove); + + if (aggregate->ecommunity) + ecommunity_free(&aggregate->ecommunity); + + hash_clean_and_free(&aggregate->ecommunity_hash, + bgp_aggr_ecommunity_remove); + + if (aggregate->lcommunity) + lcommunity_free(&aggregate->lcommunity); + + hash_clean_and_free(&aggregate->lcommunity_hash, + bgp_aggr_lcommunity_remove); + + if (aggregate->aspath) + aspath_free(aggregate->aspath); + + hash_clean_and_free(&aggregate->aspath_hash, bgp_aggr_aspath_remove); + + bgp_aggregate_free(aggregate); +} + DEFPY(aggregate_addressv6, aggregate_addressv6_cmd, "[no] aggregate-address X:X::X:X/M$prefix [{" "as-set$as_set_s" diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h index b48e8eda11..a64144b625 100644 --- a/bgpd/bgp_route.h +++ b/bgpd/bgp_route.h @@ -661,6 +661,7 @@ extern void bgp_process_queue_init(struct bgp *bgp); extern void bgp_route_init(void); extern void bgp_route_finish(void); extern void bgp_cleanup_routes(struct bgp *); +extern void bgp_free_aggregate_info(struct bgp_aggregate *aggregate); extern void bgp_announce_route(struct peer *peer, afi_t afi, safi_t safi, bool force); extern void bgp_stop_announce_route_timer(struct peer_af *paf); diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 4bbbced806..a436490ba1 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -11036,10 +11036,10 @@ static char *bgp_peer_description_stripped(char *desc, uint32_t size) { static char stripped[BUFSIZ]; uint32_t i = 0; - uint32_t last_space = 0; + uint32_t last_space = size; while (i < size) { - if (*(desc + i) == 0) { + if (*(desc + i) == '\0') { stripped[i] = '\0'; return stripped; } @@ -11049,10 +11049,7 @@ static char *bgp_peer_description_stripped(char *desc, uint32_t size) i++; } - if (last_space > size) - stripped[size + 1] = '\0'; - else - stripped[last_space] = '\0'; + stripped[last_space] = '\0'; return stripped; } diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 3d659d48d4..96b1f3e00f 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -834,6 +834,13 @@ bool bgp_zebra_nexthop_set(union sockunion *local, union sockunion *remote, peer->bgp->vrf_id); } + /* Handle peerings via loopbacks. For instance, peer between + * 127.0.0.1 and 127.0.0.2. In short, allow peering with self + * via 127.0.0.0/8. + */ + if (!ifp && cmd_allow_reserved_ranges_get()) + ifp = if_get_vrf_loopback(peer->bgp->vrf_id); + if (!ifp) { /* * BGP views do not currently get proper data diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 43885883ea..9d7a1f967e 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -3844,6 +3844,23 @@ int bgp_delete(struct bgp *bgp) #ifdef ENABLE_BGP_VNC rfapi_delete(bgp); #endif + + /* Free memory allocated with aggregate address configuration. */ + FOREACH_AFI_SAFI (afi, safi) { + struct bgp_aggregate *aggregate = NULL; + + for (struct bgp_dest *dest = + bgp_table_top(bgp->aggregate[afi][safi]); + dest; dest = bgp_route_next(dest)) { + aggregate = bgp_dest_get_bgp_aggregate_info(dest); + if (aggregate == NULL) + continue; + + bgp_dest_set_bgp_aggregate_info(dest, NULL); + bgp_free_aggregate_info(aggregate); + } + } + bgp_cleanup_routes(bgp); for (afi = 0; afi < AFI_MAX; ++afi) { @@ -5677,11 +5694,8 @@ void peer_on_policy_change(struct peer *peer, afi_t afi, safi_t safi, if (bgp_soft_reconfig_in(peer, afi, safi)) return; - if (CHECK_FLAG(peer->af_flags[afi][safi], - PEER_FLAG_SOFT_RECONFIG)) - bgp_soft_reconfig_in(peer, afi, safi); - else if (CHECK_FLAG(peer->cap, PEER_CAP_REFRESH_OLD_RCV) || - CHECK_FLAG(peer->cap, PEER_CAP_REFRESH_NEW_RCV)) + if (CHECK_FLAG(peer->cap, PEER_CAP_REFRESH_OLD_RCV) || + CHECK_FLAG(peer->cap, PEER_CAP_REFRESH_NEW_RCV)) bgp_route_refresh_send(peer, afi, safi, 0, 0, 0, BGP_ROUTE_REFRESH_NORMAL); } diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index e6da79fafb..4b8e07a9c4 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -127,7 +127,6 @@ void rfapiCheckRouteCount(void) struct agg_node *rn; int holddown_count = 0; - int local_count = 0; int imported_count = 0; int remote_count = 0; @@ -146,9 +145,7 @@ void rfapiCheckRouteCount(void) ++holddown_count; } else { - if (RFAPI_LOCAL_BI(bpi)) { - ++local_count; - } else { + if (!RFAPI_LOCAL_BI(bpi)) { if (RFAPI_DIRECT_IMPORT_BI( bpi)) { ++imported_count; diff --git a/bgpd/rfapi/rfapi_rib.c b/bgpd/rfapi/rfapi_rib.c index 4dc3139ed1..be9d30768c 100644 --- a/bgpd/rfapi/rfapi_rib.c +++ b/bgpd/rfapi/rfapi_rib.c @@ -116,7 +116,6 @@ void rfapiRibCheckCounts( struct bgp *bgp = bgp_get_default(); uint32_t t_pfx_active = 0; - uint32_t t_pfx_deleted = 0; uint32_t t_ri_active = 0; uint32_t t_ri_deleted = 0; @@ -131,7 +130,6 @@ void rfapiRibCheckCounts( afi_t afi; uint32_t pfx_active = 0; - uint32_t pfx_deleted = 0; for (afi = AFI_IP; afi < AFI_MAX; ++afi) { @@ -156,8 +154,6 @@ void rfapiRibCheckCounts( if (dsl) { ri_deleted = skiplist_count(dsl); t_ri_deleted += ri_deleted; - ++pfx_deleted; - ++t_pfx_deleted; } } for (rn = agg_route_top(rfd->rib_pending[afi]); rn; @@ -2303,10 +2299,6 @@ void rfapiRibShowResponses(void *stream, struct prefix *pfx_match, int printedheader = 0; int routes_total = 0; int nhs_total = 0; - int prefixes_total = 0; - int prefixes_displayed = 0; - int nves_total = 0; - int nves_with_routes = 0; int nves_displayed = 0; int routes_displayed = 0; int nhs_displayed = 0; @@ -2326,10 +2318,6 @@ void rfapiRibShowResponses(void *stream, struct prefix *pfx_match, int printednve = 0; afi_t afi; - ++nves_total; - if (rfd->rib_prefix_count) - ++nves_with_routes; - for (afi = AFI_IP; afi < AFI_MAX; ++afi) { struct agg_node *rn; @@ -2355,14 +2343,11 @@ void rfapiRibShowResponses(void *stream, struct prefix *pfx_match, routes_total++; nhs_total += skiplist_count(sl); - ++prefixes_total; if (pfx_match && !prefix_match(pfx_match, p) && !prefix_match(p, pfx_match)) continue; - ++prefixes_displayed; - if (!printedheader) { ++printedheader; diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c index 94c77d826e..2877c29c20 100644 --- a/bgpd/rfapi/rfapi_vty.c +++ b/bgpd/rfapi/rfapi_vty.c @@ -822,11 +822,6 @@ int rfapiShowVncQueries(void *stream, struct prefix *pfx_match) const char *vty_newline; int printedheader = 0; - - int nves_total = 0; - int nves_with_queries = 0; - int nves_displayed = 0; - int queries_total = 0; int queries_displayed = 0; @@ -850,15 +845,9 @@ int rfapiShowVncQueries(void *stream, struct prefix *pfx_match) struct agg_node *rn; int printedquerier = 0; - - ++nves_total; - - if (rfd->mon - || (rfd->mon_eth && skiplist_count(rfd->mon_eth))) { - ++nves_with_queries; - } else { + if (!rfd->mon && + !(rfd->mon_eth && skiplist_count(rfd->mon_eth))) continue; - } /* * IP Queries @@ -904,8 +893,6 @@ int rfapiShowVncQueries(void *stream, struct prefix *pfx_match) fp(out, "%-15s %-15s", buf_vn, buf_un); printedquerier = 1; - - ++nves_displayed; } else fp(out, "%-15s %-15s", "", ""); buf_remain[0] = 0; @@ -978,8 +965,6 @@ int rfapiShowVncQueries(void *stream, struct prefix *pfx_match) fp(out, "%-15s %-15s", buf_vn, buf_un); printedquerier = 1; - - ++nves_displayed; } else fp(out, "%-15s %-15s", "", ""); buf_remain[0] = 0; diff --git a/bgpd/rfapi/vnc_import_bgp.c b/bgpd/rfapi/vnc_import_bgp.c index 19ac6f353d..3fcc0e6f5f 100644 --- a/bgpd/rfapi/vnc_import_bgp.c +++ b/bgpd/rfapi/vnc_import_bgp.c @@ -1986,8 +1986,6 @@ void vnc_import_bgp_exterior_add_route_interior( if (RFAPI_HAS_MONITOR_EXTERIOR(rn_interior)) { - int count = 0; /* debugging */ - vnc_zlog_debug_verbose( "%s: has exterior monitor; ext src: %p", __func__, RFAPI_MONITOR_EXTERIOR(rn_interior)->source); @@ -2011,9 +2009,6 @@ void vnc_import_bgp_exterior_add_route_interior( struct attr new_attr; uint32_t label = 0; - - ++count; /* debugging */ - assert(bpi_exterior); assert(pfx_exterior); diff --git a/doc/manpages/vtysh.rst b/doc/manpages/vtysh.rst index af527bea40..396fcfc66e 100644 --- a/doc/manpages/vtysh.rst +++ b/doc/manpages/vtysh.rst @@ -67,6 +67,15 @@ OPTIONS available for the vtysh command: Display a usage message on standard output and exit. +.. option:: -t, --timestamp + + Print a timestamp before going to shell or reading the configuration file. + +.. option:: --no-fork + + When used in conjunction with ``-b``, prevents vtysh from forking children to handle configuring each target daemon. + + ENVIRONMENT VARIABLES ===================== VTYSH_PAGER diff --git a/doc/user/basic.rst b/doc/user/basic.rst index 254dad8303..337cfff937 100644 --- a/doc/user/basic.rst +++ b/doc/user/basic.rst @@ -349,6 +349,10 @@ Basic Config Commands Allow using IPv4 reserved (Class E) IP ranges for daemons. E.g.: setting IPv4 addresses for interfaces or allowing reserved ranges in BGP next-hops. + If you need multiple FRR instances (or FRR + any other daemon) running in a + single router and peering via 127.0.0.0/8, it's also possible to use this + knob if turned on. + Default: off. .. _sample-config-file: diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c index dd442840d0..d53d43ad0e 100644 --- a/isisd/isis_pdu.c +++ b/isisd/isis_pdu.c @@ -1654,12 +1654,14 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa) if (idrp == ISO9542_ESIS) { flog_err(EC_LIB_DEVELOPMENT, "No support for ES-IS packet IDRP=%hhx", idrp); + pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type); return ISIS_ERROR; } if (idrp != ISO10589_ISIS) { flog_err(EC_ISIS_PACKET, "Not an IS-IS packet IDRP=%hhx", idrp); + pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type); return ISIS_ERROR; } @@ -1670,6 +1672,7 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa) isis_notif_version_skew(circuit, version1, raw_pdu, sizeof(raw_pdu)); #endif /* ifndef FABRICD */ + pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type); return ISIS_WARNING; } @@ -1693,12 +1696,14 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa) isis_notif_id_len_mismatch(circuit, id_len, raw_pdu, sizeof(raw_pdu)); #endif /* ifndef FABRICD */ + pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type); return ISIS_ERROR; } uint8_t expected_length; if (pdu_size(pdu_type, &expected_length)) { zlog_warn("Unsupported ISIS PDU %hhu", pdu_type); + pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type); return ISIS_WARNING; } @@ -1706,6 +1711,7 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa) flog_err(EC_ISIS_PACKET, "Expected fixed header length = %hhu but got %hhu", expected_length, length); + pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type); return ISIS_ERROR; } @@ -1713,6 +1719,7 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa) flog_err( EC_ISIS_PACKET, "PDU is too short to contain fixed header of given PDU type."); + pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type); return ISIS_ERROR; } @@ -1723,12 +1730,14 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa) isis_notif_version_skew(circuit, version2, raw_pdu, sizeof(raw_pdu)); #endif /* ifndef FABRICD */ + pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type); return ISIS_WARNING; } if (circuit->is_passive) { zlog_warn("Received ISIS PDU on passive circuit %s", circuit->interface->name); + pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type); return ISIS_WARNING; } @@ -1747,6 +1756,7 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa) isis_notif_max_area_addr_mismatch(circuit, max_area_addrs, raw_pdu, sizeof(raw_pdu)); #endif /* ifndef FABRICD */ + pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type); return ISIS_ERROR; } @@ -1754,17 +1764,24 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa) case L1_LAN_HELLO: case L2_LAN_HELLO: case P2P_HELLO: - if (fabricd && pdu_type != P2P_HELLO) + if (fabricd && pdu_type != P2P_HELLO) { + pdu_counter_count(circuit->area->pdu_drop_counters, + pdu_type); return ISIS_ERROR; + } + retval = process_hello(pdu_type, circuit, ssnpa); break; case L1_LINK_STATE: case L2_LINK_STATE: case FS_LINK_STATE: - if (fabricd - && pdu_type != L2_LINK_STATE - && pdu_type != FS_LINK_STATE) + if (fabricd && pdu_type != L2_LINK_STATE && + pdu_type != FS_LINK_STATE) { + pdu_counter_count(circuit->area->pdu_drop_counters, + pdu_type); return ISIS_ERROR; + } + retval = process_lsp(pdu_type, circuit, ssnpa, max_area_addrs); break; case L1_COMPLETE_SEQ_NUM: @@ -1774,9 +1791,13 @@ int isis_handle_pdu(struct isis_circuit *circuit, uint8_t *ssnpa) retval = process_snp(pdu_type, circuit, ssnpa); break; default: + pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type); return ISIS_ERROR; } + if (retval != ISIS_OK) + pdu_counter_count(circuit->area->pdu_drop_counters, pdu_type); + return retval; } diff --git a/isisd/isis_te.c b/isisd/isis_te.c index 45d763fd69..c0b5f35f47 100644 --- a/isisd/isis_te.c +++ b/isisd/isis_te.c @@ -1075,9 +1075,21 @@ static int lsp_to_subnet_cb(const struct prefix *prefix, uint32_t metric, } if (!std) prefix_copy(&p, prefix); - else + else { + /* Remove old subnet if any before prefix adjustment */ + subnet = ls_find_subnet(args->ted, *prefix); + if (subnet) { + if (args->export) { + subnet->status = DELETE; + isis_te_export(LS_MSG_TYPE_PREFIX, subnet); + } + te_debug(" |- Remove subnet with prefix %pFX", + &subnet->key); + ls_subnet_del_all(args->ted, subnet); + } te_debug(" |- Adjust prefix %pFX with local address to: %pFX", prefix, &p); + } /* Search existing Subnet in TED ... */ subnet = ls_find_subnet(args->ted, p); @@ -1085,6 +1097,7 @@ static int lsp_to_subnet_cb(const struct prefix *prefix, uint32_t metric, if (!subnet) { ls_pref = ls_prefix_new(vertex->node->adv, p); subnet = ls_subnet_add(args->ted, ls_pref); + /* Stop processing if we are unable to create a new subnet */ if (!subnet) return LSP_ITER_CONTINUE; } diff --git a/isisd/isisd.c b/isisd/isisd.c index d216d100e1..c6369a884e 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -2503,6 +2503,9 @@ static void common_isis_summary_vty(struct vty *vty, struct isis *isis) vty_out(vty, " RX counters per PDU type:\n"); pdu_counter_print(vty, " ", area->pdu_rx_counters); + vty_out(vty, " Drop counters per PDU type:\n"); + pdu_counter_print(vty, " ", area->pdu_drop_counters); + vty_out(vty, " Advertise high metrics: %s\n", area->advertise_high_metrics ? "Enabled" : "Disabled"); diff --git a/isisd/isisd.h b/isisd/isisd.h index a06dc46a38..0b1f1cb620 100644 --- a/isisd/isisd.h +++ b/isisd/isisd.h @@ -232,6 +232,7 @@ struct isis_area { pdu_counter_t pdu_tx_counters; pdu_counter_t pdu_rx_counters; + pdu_counter_t pdu_drop_counters; uint64_t lsp_rxmt_count; /* Area counters */ diff --git a/lib/getopt.c b/lib/getopt.c deleted file mode 100644 index 9d0a311310..0000000000 --- a/lib/getopt.c +++ /dev/null @@ -1,1011 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* Getopt for GNU. - * NOTE: getopt is now part of the C library, so if you don't know what - * "Keep this file name-space clean" means, talk to drepper@gnu.org - * before changing it! - * - * Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98 - * Free Software Foundation, Inc. - * - * NOTE: The canonical source of this file is maintained with the GNU C Library. - * Bugs can be reported to bug-glibc@gnu.org. - */ - -/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. - Ditto for AIX 3.2 and <stdlib.h>. */ -#ifndef _NO_PROTO -# define _NO_PROTO -#endif - -#include <zebra.h> - -#if !defined __STDC__ || !__STDC__ -/* This is a separate conditional since some stdc systems - reject `defined (const)'. */ -#ifndef const -# define const -#endif -#endif - -#include <stdio.h> - -/* Comment out all this code if we are using the GNU C Library, and are not - actually compiling the library itself. This code is part of the GNU C - Library, but also included in many other GNU distributions. Compiling - and linking in this code is a waste when using the GNU C library - (especially if it is a shared library). Rather than having every GNU - program understand `configure --with-gnu-libc' and omit the object files, - it is simpler to just do this in the source for each such file. */ - -#define GETOPT_INTERFACE_VERSION 2 -#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 -#include <gnu-versions.h> -#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION -# define ELIDE_CODE -#endif -#endif - -#ifndef ELIDE_CODE - - -/* This needs to come after some library #include - to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ -/* Don't include stdlib.h for non-GNU C libraries because some of them - contain conflicting prototypes for getopt. */ -#include <stdlib.h> -#include <unistd.h> -#endif /* GNU C library. */ - -#ifdef VMS -#include <unixlib.h> -#if HAVE_STRING_H - 0 -#include <string.h> -#endif -#endif - -#ifndef _ -/* This is for other GNU distributions with internationalized messages. - When compiling libc, the _ macro is predefined. */ -#ifdef HAVE_LIBINTL_H -#include <libintl.h> -# define _(msgid) gettext (msgid) -#else -# define _(msgid) (msgid) -#endif -#endif - -/* This version of `getopt' appears to the caller like standard Unix `getopt' - but it behaves differently for the user, since it allows the user - to intersperse the options with the other arguments. - - As `getopt' works, it permutes the elements of ARGV so that, - when it is done, all the options precede everything else. Thus - all application programs are extended to handle flexible argument order. - - Setting the environment variable POSIXLY_CORRECT disables permutation. - Then the behavior is completely standard. - - GNU application programs can use a third alternative mode in which - they can distinguish the relative order of options and other arguments. */ - -#include "getopt.h" - -/* For communication from `getopt' to the caller. - When `getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when `ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ - -char *optarg = NULL; - -/* Index in ARGV of the next element to be scanned. - This is used for communication to and from the caller - and for communication between successive calls to `getopt'. - - On entry to `getopt', zero means this is the first call; initialize. - - When `getopt' returns -1, this is the index of the first of the - non-option elements that the caller should itself scan. - - Otherwise, `optind' communicates from one call to the next - how much of ARGV has been scanned so far. */ - -/* 1003.2 says this must be 1 before any call. */ -int optind = 1; - -/* Formerly, initialization of getopt depended on optind==0, which - causes problems with re-calling getopt as programs generally don't - know that. */ - -int __getopt_initialized = 0; - -/* The next char to be scanned in the option-element - in which the last option character we returned was found. - This allows us to pick up the scan where we left off. - - If this is zero, or a null string, it means resume the scan - by advancing to the next ARGV-element. */ - -static char *nextchar; - -/* Callers store zero here to inhibit the error message - for unrecognized options. */ - -int opterr = 1; - -/* Set to an option character which was unrecognized. - This must be initialized on some systems to avoid linking in the - system's own getopt implementation. */ - -int optopt = '?'; - -/* Describe how to deal with options that follow non-option ARGV-elements. - - If the caller did not specify anything, - the default is REQUIRE_ORDER if the environment variable - POSIXLY_CORRECT is defined, PERMUTE otherwise. - - REQUIRE_ORDER means don't recognize them as options; - stop option processing when the first non-option is seen. - This is what Unix does. - This mode of operation is selected by either setting the environment - variable POSIXLY_CORRECT, or using `+' as the first character - of the list of option characters. - - PERMUTE is the default. We permute the contents of ARGV as we scan, - so that eventually all the non-options are at the end. This allows options - to be given in any order, even with programs that were not written to - expect this. - - RETURN_IN_ORDER is an option available to programs that were written - to expect options and other ARGV-elements in any order and that care about - the ordering of the two. We describe each non-option ARGV-element - as if it were the argument of an option with character code 1. - Using `-' as the first character of the list of option characters - selects this mode of operation. - - The special argument `--' forces an end of option-scanning regardless - of the value of `ordering'. In the case of RETURN_IN_ORDER, only - `--' can cause `getopt' to return -1 with `optind' != ARGC. */ - -static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; - -/* Value of POSIXLY_CORRECT environment variable. */ -static char *posixly_correct; - -#ifdef __GNU_LIBRARY__ -/* We want to avoid inclusion of string.h with non-GNU libraries - because there are many ways it can cause trouble. - On some systems, it contains special magic macros that don't work - in GCC. */ -#include <string.h> -# define my_index strchr -#else - -#if HAVE_STRING_H -#include <string.h> -#else -#include <strings.h> -#endif - -/* Avoid depending on library functions or files - whose names are inconsistent. */ - -#ifndef getenv -extern char *getenv(const char *); -#endif - -static char *my_index(const char *str, int chr) -{ - while (*str) { - if (*str == chr) - return (char *)str; - str++; - } - return 0; -} - -/* If using GCC, we can safely declare strlen this way. - If not using GCC, it is ok not to declare it. */ -#ifdef __GNUC__ -/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. - That was relevant to code that was here before. */ -#if (!defined __STDC__ || !__STDC__) && !defined strlen -/* gcc with -traditional declares the built-in strlen to return int, - and has done so at least since version 2.4.5. -- rms. */ -extern int strlen(const char *); -#endif /* not __STDC__ */ -#endif /* __GNUC__ */ - -#endif /* not __GNU_LIBRARY__ */ - -/* Handle permutation of arguments. */ - -/* Describe the part of ARGV that contains non-options that have - been skipped. `first_nonopt' is the index in ARGV of the first of them; - `last_nonopt' is the index after the last of them. */ - -static int first_nonopt; -static int last_nonopt; - -#ifdef _LIBC -/* Bash 2.0 gives us an environment variable containing flags - indicating ARGV elements that should not be considered arguments. */ - -/* Defined in getopt_init.c */ -extern char *__getopt_nonoption_flags; - -static int nonoption_flags_max_len; -static int nonoption_flags_len; - -static int original_argc; -static char *const *original_argv; - -/* Make sure the environment variable bash 2.0 puts in the environment - is valid for the getopt call we must make sure that the ARGV passed - to getopt is that one passed to the process. */ -static void __attribute__((unused)) -store_args_and_env(int argc, char *const *argv) -{ - /* XXX This is no good solution. We should rather copy the args so - that we can compare them later. But we must not use malloc(3). */ - original_argc = argc; - original_argv = argv; -} -#ifdef text_set_element -text_set_element(__libc_subinit, store_args_and_env); -#endif /* text_set_element */ - -#define SWAP_FLAGS(ch1, ch2) \ - if (nonoption_flags_len > 0) { \ - char __tmp = __getopt_nonoption_flags[ch1]; \ - __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ - __getopt_nonoption_flags[ch2] = __tmp; \ - } -#else /* !_LIBC */ -# define SWAP_FLAGS(ch1, ch2) -#endif /* _LIBC */ - -/* Exchange two adjacent subsequences of ARGV. - One subsequence is elements [first_nonopt,last_nonopt) - which contains all the non-options that have been skipped so far. - The other is elements [last_nonopt,optind), which contains all - the options processed since those non-options were skipped. - - `first_nonopt' and `last_nonopt' are relocated so that they describe - the new indices of the non-options in ARGV after they are moved. */ - -#if defined __STDC__ && __STDC__ -static void exchange(char **); -#endif - -static void exchange(argv) char **argv; -{ - int bottom = first_nonopt; - int middle = last_nonopt; - int top = optind; - char *tem; - -/* Exchange the shorter segment with the far end of the longer segment. - That puts the shorter segment into the right place. - It leaves the longer segment in the right place overall, - but it consists of two parts that need to be swapped next. */ - -#ifdef _LIBC - /* First make sure the handling of the `__getopt_nonoption_flags' - string can work normally. Our top argument must be in the range - of the string. */ - if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) { - /* We must extend the array. The user plays games with us and - presents new arguments. */ - char *new_str = malloc(top + 1); - if (new_str == NULL) - nonoption_flags_len = nonoption_flags_max_len = 0; - else { - memset(__mempcpy(new_str, __getopt_nonoption_flags, - nonoption_flags_max_len), - '\0', top + 1 - nonoption_flags_max_len); - nonoption_flags_max_len = top + 1; - __getopt_nonoption_flags = new_str; - } - } -#endif - - while (top > middle && middle > bottom) { - if (top - middle > middle - bottom) { - /* Bottom segment is the short one. */ - int len = middle - bottom; - register int i; - - /* Swap it with the top part of the top segment. */ - for (i = 0; i < len; i++) { - tem = argv[bottom + i]; - argv[bottom + i] = - argv[top - (middle - bottom) + i]; - argv[top - (middle - bottom) + i] = tem; - SWAP_FLAGS(bottom + i, - top - (middle - bottom) + i); - } - /* Exclude the moved bottom segment from further - * swapping. */ - top -= len; - } else { - /* Top segment is the short one. */ - int len = top - middle; - register int i; - - /* Swap it with the bottom part of the bottom segment. - */ - for (i = 0; i < len; i++) { - tem = argv[bottom + i]; - argv[bottom + i] = argv[middle + i]; - argv[middle + i] = tem; - SWAP_FLAGS(bottom + i, middle + i); - } - /* Exclude the moved top segment from further swapping. - */ - bottom += len; - } - } - - /* Update records for the slots the non-options now occupy. */ - - first_nonopt += (optind - last_nonopt); - last_nonopt = optind; -} - -/* Initialize the internal data when the first call is made. */ - -#if defined __STDC__ && __STDC__ -static const char *_getopt_initialize(int, char *const *, const char *); -#endif -static const char *_getopt_initialize(argc, argv, optstring) int argc; -char *const *argv; -const char *optstring; -{ - /* Start processing options with ARGV-element 1 (since ARGV-element 0 - is the program name); the sequence of previously skipped - non-option ARGV-elements is empty. */ - - first_nonopt = last_nonopt = optind; - - nextchar = NULL; - - posixly_correct = getenv("POSIXLY_CORRECT"); - - /* Determine how to handle the ordering of options and nonoptions. */ - - if (optstring[0] == '-') { - ordering = RETURN_IN_ORDER; - ++optstring; - } else if (optstring[0] == '+') { - ordering = REQUIRE_ORDER; - ++optstring; - } else if (posixly_correct != NULL) - ordering = REQUIRE_ORDER; - else - ordering = PERMUTE; - -#ifdef _LIBC - if (posixly_correct == NULL && argc == original_argc - && argv == original_argv) { - if (nonoption_flags_max_len == 0) { - if (__getopt_nonoption_flags == NULL - || __getopt_nonoption_flags[0] == '\0') - nonoption_flags_max_len = -1; - else { - const char *orig_str = __getopt_nonoption_flags; - int len = nonoption_flags_max_len = - strlen(orig_str); - if (nonoption_flags_max_len < argc) - nonoption_flags_max_len = argc; - __getopt_nonoption_flags = - (char *)malloc(nonoption_flags_max_len); - if (__getopt_nonoption_flags == NULL) - nonoption_flags_max_len = -1; - else - memset(__mempcpy( - __getopt_nonoption_flags, - orig_str, len), - '\0', - nonoption_flags_max_len - len); - } - } - nonoption_flags_len = nonoption_flags_max_len; - } else - nonoption_flags_len = 0; -#endif - - return optstring; -} - -/* Scan elements of ARGV (whose length is ARGC) for option characters - given in OPTSTRING. - - If an element of ARGV starts with '-', and is not exactly "-" or "--", - then it is an option element. The characters of this element - (aside from the initial '-') are option characters. If `getopt' - is called repeatedly, it returns successively each of the option characters - from each of the option elements. - - If `getopt' finds another option character, it returns that character, - updating `optind' and `nextchar' so that the next call to `getopt' can - resume the scan with the following option character or ARGV-element. - - If there are no more option characters, `getopt' returns -1. - Then `optind' is the index in ARGV of the first ARGV-element - that is not an option. (The ARGV-elements have been permuted - so that those that are not options now come last.) - - OPTSTRING is a string containing the legitimate option characters. - If an option character is seen that is not listed in OPTSTRING, - return '?' after printing an error message. If you set `opterr' to - zero, the error message is suppressed but we still return '?'. - - If a char in OPTSTRING is followed by a colon, that means it wants an arg, - so the following text in the same ARGV-element, or the text of the following - ARGV-element, is returned in `optarg'. Two colons mean an option that - wants an optional arg; if there is text in the current ARGV-element, - it is returned in `optarg', otherwise `optarg' is set to zero. - - If OPTSTRING starts with `-' or `+', it requests different methods of - handling the non-option ARGV-elements. - See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. - - Long-named options begin with `--' instead of `-'. - Their names may be abbreviated as long as the abbreviation is unique - or is an exact match for some defined option. If they have an - argument, it follows the option name in the same ARGV-element, separated - from the option name by a `=', or else the in next ARGV-element. - When `getopt' finds a long-named option, it returns 0 if that option's - `flag' field is nonzero, the value of the option's `val' field - if the `flag' field is zero. - - The elements of ARGV aren't really const, because we permute them. - But we pretend they're const in the prototype to be compatible - with other systems. - - LONGOPTS is a vector of `struct option' terminated by an - element containing a name which is zero. - - LONGIND returns the index in LONGOPT of the long-named option found. - It is only valid when a long-named option has been found by the most - recent call. - - If LONG_ONLY is nonzero, '-' as well as '--' can introduce - long-named options. */ - -int _getopt_internal(argc, argv, optstring, longopts, longind, - long_only) int argc; -char *const *argv; -const char *optstring; -const struct option *longopts; -int *longind; -int long_only; -{ - optarg = NULL; - - if (optind == 0 || !__getopt_initialized) { - if (optind == 0) - optind = 1; /* Don't scan ARGV[0], the program name. */ - optstring = _getopt_initialize(argc, argv, optstring); - __getopt_initialized = 1; - } - -/* Test whether ARGV[optind] points to a non-option argument. - Either it does not have option syntax, or there is an environment flag - from the shell indicating it is not an option. The later information - is only used when the used in the GNU libc. */ -#ifdef _LIBC -#define NONOPTION_P \ - (argv[optind][0] != '-' || argv[optind][1] == '\0' \ - || (optind < nonoption_flags_len \ - && __getopt_nonoption_flags[optind] == '1')) -#else -# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') -#endif - - if (nextchar == NULL || *nextchar == '\0') { - /* Advance to the next ARGV-element. */ - - /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has - been - moved back by the user (who may also have changed the - arguments). */ - if (last_nonopt > optind) - last_nonopt = optind; - if (first_nonopt > optind) - first_nonopt = optind; - - if (ordering == PERMUTE) { - /* If we have just processed some options following some - non-options, - exchange them so that the options come first. */ - - if (first_nonopt != last_nonopt - && last_nonopt != optind) - exchange((char **)argv); - else if (last_nonopt != optind) - first_nonopt = optind; - - /* Skip any additional non-options - and extend the range of non-options previously - skipped. */ - - while (optind < argc && NONOPTION_P) - optind++; - last_nonopt = optind; - } - - /* The special ARGV-element `--' means premature end of options. - Skip it like a null option, - then exchange with previous non-options as if it were an - option, - then skip everything else like a non-option. */ - - if (optind != argc && !strcmp(argv[optind], "--")) { - optind++; - - if (first_nonopt != last_nonopt - && last_nonopt != optind) - exchange((char **)argv); - else if (first_nonopt == last_nonopt) - first_nonopt = optind; - last_nonopt = argc; - - optind = argc; - } - - /* If we have done all the ARGV-elements, stop the scan - and back over any non-options that we skipped and permuted. - */ - - if (optind == argc) { - /* Set the next-arg-index to point at the non-options - that we previously skipped, so the caller will digest - them. */ - if (first_nonopt != last_nonopt) - optind = first_nonopt; - return -1; - } - - /* If we have come to a non-option and did not permute it, - either stop the scan or describe it to the caller and pass it - by. */ - - if (NONOPTION_P) { - if (ordering == REQUIRE_ORDER) - return -1; - optarg = argv[optind++]; - return 1; - } - - /* We have found another option-ARGV-element. - Skip the initial punctuation. */ - - nextchar = (argv[optind] + 1 - + (longopts != NULL && argv[optind][1] == '-')); - } - - /* Decode the current option-ARGV-element. */ - - /* Check whether the ARGV-element is a long option. - - If long_only and the ARGV-element has the form "-f", where f is - a valid short option, don't consider it an abbreviated form of - a long option that starts with f. Otherwise there would be no - way to give the -f short option. - - On the other hand, if there's a long option "fubar" and - the ARGV-element is "-fu", do consider that an abbreviation of - the long option, just like "--fu", and not "-f" with arg "u". - - This distinction seems to be the most useful approach. */ - - if (longopts != NULL - && (argv[optind][1] == '-' - || (long_only && (argv[optind][2] - || !my_index(optstring, argv[optind][1]))))) { - char *nameend; - const struct option *p; - const struct option *pfound = NULL; - int exact = 0; - int ambig = 0; - int indfound = -1; - int option_index; - - for (nameend = nextchar; *nameend && *nameend != '='; nameend++) - /* Do nothing. */; - - /* Test all long options for either exact match - or abbreviated matches. */ - for (p = longopts, option_index = 0; p->name; - p++, option_index++) - if (!strncmp(p->name, nextchar, nameend - nextchar)) { - if ((unsigned int)(nameend - nextchar) - == (unsigned int)strlen(p->name)) { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } else if (pfound == NULL) { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } else - /* Second or later nonexact match found. - */ - ambig = 1; - } - - if (ambig && !exact) { - if (opterr) - fprintf(stderr, - _("%s: option `%s' is ambiguous\n"), - argv[0], argv[optind]); - nextchar += strlen(nextchar); - optind++; - optopt = 0; - return '?'; - } - - if (pfound != NULL) { - option_index = indfound; - optind++; - if (*nameend) { - /* Don't test has_arg with >, because some C - compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - optarg = nameend + 1; - else { - if (opterr) { - if (argv[optind - 1][1] == '-') - /* --option */ - fprintf(stderr, - _("%s: option `--%s' doesn't allow an argument\n"), - argv[0], - pfound->name); - else - /* +option or -option */ - fprintf(stderr, - _("%s: option `%c%s' doesn't allow an argument\n"), - argv[0], - argv[optind - 1] - [0], - pfound->name); - } - - nextchar += strlen(nextchar); - - optopt = pfound->val; - return '?'; - } - } else if (pfound->has_arg == 1) { - if (optind < argc) - optarg = argv[optind++]; - else { - if (opterr) - fprintf(stderr, - _("%s: option `%s' requires an argument\n"), - argv[0], - argv[optind - 1]); - nextchar += strlen(nextchar); - optopt = pfound->val; - return optstring[0] == ':' ? ':' : '?'; - } - } - nextchar += strlen(nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - - /* Can't find it as a long option. If this is not - getopt_long_only, - or the option starts with '--' or is not a valid short - option, then it's an error. - Otherwise interpret it as a short option. */ - if (!long_only || argv[optind][1] == '-' - || my_index(optstring, *nextchar) == NULL) { - if (opterr) { - if (argv[optind][1] == '-') - /* --option */ - fprintf(stderr, - _("%s: unrecognized option `--%s'\n"), - argv[0], nextchar); - else - /* +option or -option */ - fprintf(stderr, - _("%s: unrecognized option `%c%s'\n"), - argv[0], argv[optind][0], - nextchar); - } - nextchar = (char *)""; - optind++; - optopt = 0; - return '?'; - } - } - - /* Look at and handle the next short option-character. */ - - { - char c = *nextchar++; - char *temp = my_index(optstring, c); - - /* Increment `optind' when we start to process its last - * character. */ - if (*nextchar == '\0') - ++optind; - - if (temp == NULL || c == ':') { - if (opterr) { - if (posixly_correct) - /* 1003.2 specifies the format of this - * message. */ - fprintf(stderr, - _("%s: illegal option -- %c\n"), - argv[0], c); - else - fprintf(stderr, - _("%s: invalid option -- %c\n"), - argv[0], c); - } - optopt = c; - return '?'; - } - /* Convenience. Treat POSIX -W foo same as long option --foo */ - if (temp[0] == 'W' && temp[1] == ';') { - char *nameend; - const struct option *p; - const struct option *pfound = NULL; - int exact = 0; - int ambig = 0; - int indfound = 0; - int option_index; - - /* This is an option that requires an argument. */ - if (*nextchar != '\0') { - optarg = nextchar; - /* If we end this ARGV-element by taking the - rest as an arg, - we must advance to the next element now. */ - optind++; - } else if (optind == argc) { - if (opterr) { - /* 1003.2 specifies the format of this - * message. */ - fprintf(stderr, - _("%s: option requires an argument -- %c\n"), - argv[0], c); - } - optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - return c; - } else - /* We already incremented `optind' once; - increment it again when taking next ARGV-elt - as argument. */ - optarg = argv[optind++]; - - /* optarg is now the argument, see if it's in the - table of longopts. */ - - for (nextchar = nameend = optarg; - *nameend && *nameend != '='; nameend++) - /* Do nothing. */; - - /* Test all long options for either exact match - or abbreviated matches. */ - for (p = longopts, option_index = 0; p->name; - p++, option_index++) - if (!strncmp(p->name, nextchar, - nameend - nextchar)) { - if ((unsigned int)(nameend - nextchar) - == strlen(p->name)) { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } else if (pfound == NULL) { - /* First nonexact match found. - */ - pfound = p; - indfound = option_index; - } else - /* Second or later nonexact - * match found. */ - ambig = 1; - } - if (ambig && !exact) { - if (opterr) - fprintf(stderr, - _("%s: option `-W %s' is ambiguous\n"), - argv[0], argv[optind]); - nextchar += strlen(nextchar); - optind++; - return '?'; - } - if (pfound != NULL) { - option_index = indfound; - if (*nameend) { - /* Don't test has_arg with >, because - some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - optarg = nameend + 1; - else { - if (opterr) - fprintf(stderr, _("\ -%s: option `-W %s' doesn't allow an argument\n"), - argv[0], - pfound->name); - - nextchar += strlen(nextchar); - return '?'; - } - } else if (pfound->has_arg == 1) { - if (optind < argc) - optarg = argv[optind++]; - else { - if (opterr) - fprintf(stderr, - _("%s: option `%s' requires an argument\n"), - argv[0], - argv[optind - - 1]); - nextchar += strlen(nextchar); - return optstring[0] == ':' - ? ':' - : '?'; - } - } - nextchar += strlen(nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - nextchar = NULL; - return 'W'; /* Let the application handle it. */ - } - if (temp[1] == ':') { - if (temp[2] == ':') { - /* This is an option that accepts an argument - * optionally. */ - if (*nextchar != '\0') { - optarg = nextchar; - optind++; - } else - optarg = NULL; - nextchar = NULL; - } else { - /* This is an option that requires an argument. - */ - if (*nextchar != '\0') { - optarg = nextchar; - /* If we end this ARGV-element by taking - the rest as an arg, - we must advance to the next element - now. */ - optind++; - } else if (optind == argc) { - if (opterr) { - /* 1003.2 specifies the format - * of this message. */ - fprintf(stderr, - _("%s: option requires an argument -- %c\n"), - argv[0], c); - } - optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - } else - /* We already incremented `optind' once; - increment it again when taking next - ARGV-elt as argument. */ - optarg = argv[optind++]; - nextchar = NULL; - } - } - return c; - } -} - -#ifdef REALLY_NEED_PLAIN_GETOPT - -int getopt(argc, argv, optstring) int argc; -char *const *argv; -const char *optstring; -{ - return _getopt_internal(argc, argv, optstring, (const struct option *)0, - (int *)0, 0); -} - -#endif /* REALLY_NEED_PLAIN_GETOPT */ - -#endif /* Not ELIDE_CODE. */ - -#ifdef TEST - -/* Compile with -DTEST to make an executable for use in testing - the above definition of `getopt'. */ - -int main(argc, argv) int argc; -char **argv; -{ - int c; - int digit_optind = 0; - - while (1) { - int this_option_optind = optind ? optind : 1; - - c = getopt(argc, argv, "abc:d:0123456789"); - if (c == -1) - break; - - switch (c) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 - && digit_optind != this_option_optind) - printf("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf("option %c\n", c); - break; - - case 'a': - printf("option a\n"); - break; - - case 'b': - printf("option b\n"); - break; - - case 'c': - printf("option c with value `%s'\n", optarg); - break; - - case '?': - break; - - default: - printf("?? getopt returned character code 0%o ??\n", c); - } - } - - if (optind < argc) { - printf("non-option ARGV-elements: "); - while (optind < argc) - printf("%s ", argv[optind++]); - printf("\n"); - } - - exit(0); -} - -#endif /* TEST */ diff --git a/lib/getopt.h b/lib/getopt.h deleted file mode 100644 index 7863bdb66a..0000000000 --- a/lib/getopt.h +++ /dev/null @@ -1,143 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* Declarations for getopt. - * Copyright (C) 1989,90,91,92,93,94,96,97 Free Software Foundation, Inc. - * - * NOTE: The canonical source of this file is maintained with the GNU C Library. - * Bugs can be reported to bug-glibc@gnu.org. - */ - -#ifndef _GETOPT_H -#define _GETOPT_H 1 - -/* - * The operating system may or may not provide getopt_long(), and if - * so it may or may not be a version we are willing to use. Our - * strategy is to declare getopt here, and then provide code unless - * the supplied version is adequate. The difficult case is when a - * declaration for getopt is provided, as our declaration must match. - * - * XXX Arguably this version should be named differently, and the - * local names defined to refer to the system version when we choose - * to use the system version. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* For communication from `getopt' to the caller. - When `getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when `ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ - -extern char *optarg; - -/* Index in ARGV of the next element to be scanned. - This is used for communication to and from the caller - and for communication between successive calls to `getopt'. - - On entry to `getopt', zero means this is the first call; initialize. - - When `getopt' returns -1, this is the index of the first of the - non-option elements that the caller should itself scan. - - Otherwise, `optind' communicates from one call to the next - how much of ARGV has been scanned so far. */ - -extern int optind; - -/* Callers store zero here to inhibit the error message `getopt' prints - for unrecognized options. */ - -extern int opterr; - -/* Set to an option character which was unrecognized. */ - -extern int optopt; - -/* Describe the long-named options requested by the application. - The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector - of `struct option' terminated by an element containing a name which is - zero. - - The field `has_arg' is: - no_argument (or 0) if the option does not take an argument, - required_argument (or 1) if the option requires an argument, - optional_argument (or 2) if the option takes an optional argument. - - If the field `flag' is not NULL, it points to a variable that is set - to the value given in the field `val' when the option is found, but - left unchanged if the option is not found. - - To have a long-named option do something other than set an `int' to - a compiled-in constant, such as set a value from `optarg', set the - option's `flag' field to zero and its `val' field to a nonzero - value (the equivalent single-letter option character, if there is - one). For long options that have a zero `flag' field, `getopt' - returns the contents of the `val' field. */ - -struct option { -#if defined(__STDC__) && __STDC__ - const char *name; -#else - char *name; -#endif - /* has_arg can't be an enum because some compilers complain about - type mismatches in all the code that assumes it is an int. */ - int has_arg; - int *flag; - int val; -}; - -/* Names for the values of the `has_arg' field of `struct option'. */ - -#define no_argument 0 -#define required_argument 1 -#define optional_argument 2 - -#if defined(__STDC__) && __STDC__ - -#ifdef REALLY_NEED_PLAIN_GETOPT - -/* - * getopt is defined in POSIX.2. Assume that if the system defines - * getopt that it complies with POSIX.2. If not, an autoconf test - * should be written to define NONPOSIX_GETOPT_DEFINITION. - */ -#ifndef NONPOSIX_GETOPT_DEFINITION -extern int getopt(int argc, char *const *argv, const char *shortopts); -#else /* NONPOSIX_GETOPT_DEFINITION */ -extern int getopt(void); -#endif /* NONPOSIX_GETOPT_DEFINITION */ - -#endif - - -extern int getopt_long(int argc, char *const *argv, const char *shortopts, - const struct option *longopts, int *longind); -extern int getopt_long_only(int argc, char *const *argv, const char *shortopts, - const struct option *longopts, int *longind); - -/* Internal only. Users should not call this directly. */ -extern int _getopt_internal(int argc, char *const *argv, const char *shortopts, - const struct option *longopts, int *longind, - int long_only); -#else /* not __STDC__ */ - -#ifdef REALLY_NEED_PLAIN_GETOPT -extern int getopt(); -#endif /* REALLY_NEED_PLAIN_GETOPT */ - -extern int getopt_long(); -extern int getopt_long_only(); - -extern int _getopt_internal(); - -#endif /* __STDC__ */ - -#ifdef __cplusplus -} -#endif - -#endif /* getopt.h */ diff --git a/lib/getopt1.c b/lib/getopt1.c deleted file mode 100644 index cf21c3aab4..0000000000 --- a/lib/getopt1.c +++ /dev/null @@ -1,163 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* getopt_long and getopt_long_only entry points for GNU getopt. - * Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98 - * Free Software Foundation, Inc. - * - * NOTE: The canonical source of this file is maintained with the GNU C Library. - * Bugs can be reported to bug-glibc@gnu.org. - */ - -#include <zebra.h> -#include "getopt.h" - -#if !defined __STDC__ || !__STDC__ -/* This is a separate conditional since some stdc systems - reject `defined (const)'. */ -#ifndef const -#define const -#endif -#endif - -#include <stdio.h> - -/* Comment out all this code if we are using the GNU C Library, and are not - actually compiling the library itself. This code is part of the GNU C - Library, but also included in many other GNU distributions. Compiling - and linking in this code is a waste when using the GNU C library - (especially if it is a shared library). Rather than having every GNU - program understand `configure --with-gnu-libc' and omit the object files, - it is simpler to just do this in the source for each such file. */ - -#define GETOPT_INTERFACE_VERSION 2 -#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 -#include <gnu-versions.h> -#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION -#define ELIDE_CODE -#endif -#endif - -#ifndef ELIDE_CODE - - -/* This needs to come after some library #include - to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ -#include <stdlib.h> -#endif - -#ifndef NULL -#define NULL 0 -#endif - -int getopt_long(argc, argv, options, long_options, opt_index) int argc; -char *const *argv; -const char *options; -const struct option *long_options; -int *opt_index; -{ - return _getopt_internal(argc, argv, options, long_options, opt_index, - 0); -} - -/* Like getopt_long, but '-' as well as '--' can indicate a long option. - If an option that starts with '-' (not '--') doesn't match a long option, - but does match a short option, it is parsed as a short option - instead. */ - -int getopt_long_only(argc, argv, options, long_options, opt_index) int argc; -char *const *argv; -const char *options; -const struct option *long_options; -int *opt_index; -{ - return _getopt_internal(argc, argv, options, long_options, opt_index, - 1); -} - - -#endif /* Not ELIDE_CODE. */ - -#ifdef TEST - -#include <stdio.h> - -int main(argc, argv) int argc; -char **argv; -{ - int c; - int digit_optind = 0; - - while (1) { - int this_option_optind = optind ? optind : 1; - int option_index = 0; - static struct option long_options[] = { - {"add", 1, 0, 0}, {"append", 0, 0, 0}, - {"delete", 1, 0, 0}, {"verbose", 0, 0, 0}, - {"create", 0, 0, 0}, {"file", 1, 0, 0}, - {0, 0, 0, 0}}; - - c = getopt_long(argc, argv, "abc:d:0123456789", long_options, - &option_index); - if (c == -1) - break; - - switch (c) { - case 0: - printf("option %s", long_options[option_index].name); - if (optarg) - printf(" with arg %s", optarg); - printf("\n"); - break; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 - && digit_optind != this_option_optind) - printf("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf("option %c\n", c); - break; - - case 'a': - printf("option a\n"); - break; - - case 'b': - printf("option b\n"); - break; - - case 'c': - printf("option c with value `%s'\n", optarg); - break; - - case 'd': - printf("option d with value `%s'\n", optarg); - break; - - case '?': - break; - - default: - printf("?? getopt returned character code 0%o ??\n", c); - } - } - - if (optind < argc) { - printf("non-option ARGV-elements: "); - while (optind < argc) - printf("%s ", argv[optind++]); - printf("\n"); - } - - exit(0); -} - -#endif /* TEST */ diff --git a/lib/prefix.c b/lib/prefix.c index a6aae08a6a..b8cad910f4 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -1399,7 +1399,7 @@ bool ipv4_unicast_valid(const struct in_addr *addr) if (IPV4_CLASS_D(ip)) return false; - if (IPV4_CLASS_E(ip)) { + if (IPV4_NET0(ip) || IPV4_NET127(ip) || IPV4_CLASS_E(ip)) { if (cmd_allow_reserved_ranges_get()) return true; else diff --git a/lib/prefix.h b/lib/prefix.h index 9c57283706..88a228b55c 100644 --- a/lib/prefix.h +++ b/lib/prefix.h @@ -499,11 +499,8 @@ extern int macstr2prefix_evpn(const char *str, struct prefix_evpn *p); /* NOTE: This routine expects the address argument in network byte order. */ static inline bool ipv4_martian(const struct in_addr *addr) { - in_addr_t ip = ntohl(addr->s_addr); - - if (IPV4_NET0(ip) || IPV4_NET127(ip) || !ipv4_unicast_valid(addr)) { + if (!ipv4_unicast_valid(addr)) return true; - } return false; } diff --git a/lib/subdir.am b/lib/subdir.am index 469fac2446..0f5bbef0b2 100644 --- a/lib/subdir.am +++ b/lib/subdir.am @@ -38,8 +38,6 @@ lib_libfrr_la_SOURCES = \ lib/frrscript.c \ lib/frr_pthread.c \ lib/frrstr.c \ - lib/getopt.c \ - lib/getopt1.c \ lib/grammar_sandbox.c \ lib/graph.c \ lib/hash.c \ @@ -217,7 +215,6 @@ pkginclude_HEADERS += \ lib/frratomic.h \ lib/frrcu.h \ lib/frrstr.h \ - lib/getopt.h \ lib/graph.h \ lib/hash.h \ lib/hook.h \ diff --git a/mgmtd/mgmt_vty.c.safe b/mgmtd/mgmt_vty.c.safe deleted file mode 100644 index c43485c92b..0000000000 --- a/mgmtd/mgmt_vty.c.safe +++ /dev/null @@ -1,506 +0,0 @@ -/* - * MGMTD VTY Interface - * Copyright (C) 2021 Vmware, Inc. - * Pushpasis Sarkar <spushpasis@vmware.com> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; see the file COPYING; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <zebra.h> - -#include "command.h" -#include "json.h" -#include "mgmtd/mgmt.h" -#include "mgmtd/mgmt_be_server.h" -#include "mgmtd/mgmt_be_adapter.h" -#include "mgmtd/mgmt_fe_server.h" -#include "mgmtd/mgmt_fe_adapter.h" -#include "mgmtd/mgmt_ds.h" -#include "mgmtd/mgmt_history.h" - -#include "mgmtd/mgmt_vty_clippy.c" - -DEFPY(show_mgmt_be_adapter, - show_mgmt_be_adapter_cmd, - "show mgmt backend-adapter all", - SHOW_STR - MGMTD_STR - MGMTD_BE_ADAPTER_STR - "Display all Backend Adapters\n") -{ - mgmt_be_adapter_status_write(vty); - - return CMD_SUCCESS; -} - -DEFPY(show_mgmt_be_xpath_reg, - show_mgmt_be_xpath_reg_cmd, - "show mgmt backend-yang-xpath-registry", - SHOW_STR - MGMTD_STR - "Backend Adapter YANG Xpath Registry\n") -{ - mgmt_be_xpath_register_write(vty); - - return CMD_SUCCESS; -} - -DEFPY(show_mgmt_fe_adapter, - show_mgmt_fe_adapter_cmd, - "show mgmt frontend-adapter all", - SHOW_STR MGMTD_STR MGMTD_FE_ADAPTER_STR "Display all Frontend Adapters\n") -{ - mgmt_fe_adapter_status_write(vty, false); - - return CMD_SUCCESS; -} - -DEFPY(show_mgmt_fe_adapter_detail, show_mgmt_fe_adapter_detail_cmd, - "show mgmt frontend-adapter all detail", - SHOW_STR MGMTD_STR MGMTD_FE_ADAPTER_STR - "Display all Frontend Adapters\n" - "Details of commit stats\n") -{ - mgmt_fe_adapter_status_write(vty, true); - - return CMD_SUCCESS; -} - -DEFPY_HIDDEN(mgmt_performance_measurement, - mgmt_performance_measurement_cmd, - "[no] mgmt performance-measurement", - NO_STR - MGMTD_STR - "Enable performance measurement\n") -{ - if (no) - mgmt_fe_adapter_perf_measurement(vty, false); - else - mgmt_fe_adapter_perf_measurement(vty, true); - - return CMD_SUCCESS; -} - -DEFPY(mgmt_reset_performance_stats, - mgmt_reset_performance_stats_cmd, - "mgmt reset-statistics", - MGMTD_STR - "Reset the Performance measurement statistics\n") -{ - mgmt_fe_adapter_reset_perf_stats(vty); - - return CMD_SUCCESS; -} - -DEFPY(show_mgmt_txn, - show_mgmt_txn_cmd, - "show mgmt transaction all", - SHOW_STR - MGMTD_STR - MGMTD_TXN_STR - "Display all Transactions\n") -{ - mgmt_txn_status_write(vty); - - return CMD_SUCCESS; -} - -DEFPY(show_mgmt_ds, - show_mgmt_ds_cmd, - "show mgmt datastore [all|candidate|operational|running]$dsname", - SHOW_STR - MGMTD_STR - MGMTD_DS_STR - "All datastores (default)\n" - "Candidate datastore\n" - "Operational datastore\n" - "Running datastore\n") -{ - struct mgmt_ds_ctx *ds_ctx; - - if (!dsname || dsname[0] == 'a') { - mgmt_ds_status_write(vty); - return CMD_SUCCESS; - } - ds_ctx = mgmt_ds_get_ctx_by_id(mm, mgmt_ds_name2id(dsname)); - if (!ds_ctx) { - vty_out(vty, "ERROR: Could not access %s datastore!\n", dsname); - return CMD_ERR_NO_MATCH; - } - mgmt_ds_status_write_one(vty, ds_ctx); - - return CMD_SUCCESS; -} - -DEFPY(mgmt_commit, - mgmt_commit_cmd, - "mgmt commit <check|apply|abort>$type", - MGMTD_STR - "Commit action\n" - "Validate the set of config commands\n" - "Validate and apply the set of config commands\n" - "Abort and drop the set of config commands recently added\n") -{ - bool validate_only = type[0] == 'c'; - bool abort = type[1] == 'b'; - - if (vty_mgmt_send_commit_config(vty, validate_only, abort) != 0) - return CMD_WARNING_CONFIG_FAILED; - return CMD_SUCCESS; -} - -DEFPY(mgmt_set_config_data, mgmt_set_config_data_cmd, - "mgmt set-config WORD$path VALUE", - MGMTD_STR - "Set configuration data\n" - "XPath expression specifying the YANG data path\n" - "Value of the data to set\n") -{ - strlcpy(vty->cfg_changes[0].xpath, path, - sizeof(vty->cfg_changes[0].xpath)); - vty->cfg_changes[0].value = value; - vty->cfg_changes[0].operation = NB_OP_CREATE; - vty->num_cfg_changes = 1; - - vty->no_implicit_commit = true; - vty_mgmt_send_config_data(vty); - vty->no_implicit_commit = false; - return CMD_SUCCESS; -} - -DEFPY(mgmt_delete_config_data, mgmt_delete_config_data_cmd, - "mgmt delete-config WORD$path", - MGMTD_STR - "Delete configuration data\n" - "XPath expression specifying the YANG data path\n") -{ - - strlcpy(vty->cfg_changes[0].xpath, path, - sizeof(vty->cfg_changes[0].xpath)); - vty->cfg_changes[0].value = NULL; - vty->cfg_changes[0].operation = NB_OP_DESTROY; - vty->num_cfg_changes = 1; - - vty->no_implicit_commit = true; - vty_mgmt_send_config_data(vty); - vty->no_implicit_commit = false; - return CMD_SUCCESS; -} - -DEFPY(show_mgmt_get_config, show_mgmt_get_config_cmd, - "show mgmt get-config [candidate|operational|running]$dsname WORD$path", - SHOW_STR MGMTD_STR - "Get configuration data from a specific configuration datastore\n" - "Candidate datastore (default)\n" - "Operational datastore\n" - "Running datastore\n" - "XPath expression specifying the YANG data path\n") -{ - const char *xpath_list[VTY_MAXCFGCHANGES] = {0}; - Mgmtd__DatastoreId datastore = MGMTD_DS_CANDIDATE; - - if (dsname) - datastore = mgmt_ds_name2id(dsname); - - xpath_list[0] = path; - vty_mgmt_send_get_config(vty, datastore, xpath_list, 1); - return CMD_SUCCESS; -} - -DEFPY(show_mgmt_get_data, show_mgmt_get_data_cmd, - "show mgmt get-data [candidate|operational|running]$dsname WORD$path", - SHOW_STR MGMTD_STR - "Get data from a specific datastore\n" - "Candidate datastore\n" - "Operational datastore (default)\n" - "Running datastore\n" - "XPath expression specifying the YANG data path\n") -{ - const char *xpath_list[VTY_MAXCFGCHANGES] = {0}; - Mgmtd__DatastoreId datastore = MGMTD_DS_OPERATIONAL; - - if (dsname) - datastore = mgmt_ds_name2id(dsname); - - xpath_list[0] = path; - vty_mgmt_send_get_data(vty, datastore, xpath_list, 1); - return CMD_SUCCESS; -} - -DEFPY(show_mgmt_dump_data, - show_mgmt_dump_data_cmd, - "show mgmt datastore-contents [candidate|operational|running]$dsname [xpath WORD$path] [file WORD$filepath] <json|xml>$fmt", - SHOW_STR - MGMTD_STR - "Get Datastore contents from a specific datastore\n" - "Candidate datastore (default)\n" - "Operational datastore\n" - "Running datastore\n" - "XPath expression specifying the YANG data path\n" - "XPath string\n" - "Dump the contents to a file\n" - "Full path of the file\n" - "json output\n" - "xml output\n") -{ - struct mgmt_ds_ctx *ds_ctx; - Mgmtd__DatastoreId datastore = MGMTD_DS_CANDIDATE; - LYD_FORMAT format = fmt[0] == 'j' ? LYD_JSON : LYD_XML; - FILE *f = NULL; - - if (datastore) - datastore = mgmt_ds_name2id(dsname); - - ds_ctx = mgmt_ds_get_ctx_by_id(mm, datastore); - if (!ds_ctx) { - vty_out(vty, "ERROR: Could not access datastore!\n"); - return CMD_ERR_NO_MATCH; - } - - if (filepath) { - f = fopen(filepath, "w"); - if (!f) { - vty_out(vty, - "Could not open file pointed by filepath %s\n", - filepath); - return CMD_SUCCESS; - } - } - - mgmt_ds_dump_tree(vty, ds_ctx, path, f, format); - - if (f) - fclose(f); - return CMD_SUCCESS; -} - -DEFPY(show_mgmt_map_xpath, - show_mgmt_map_xpath_cmd, - "show mgmt yang-xpath-subscription WORD$path", - SHOW_STR - MGMTD_STR - "Get YANG Backend Subscription\n" - "XPath expression specifying the YANG data path\n") -{ - mgmt_be_xpath_subscr_info_write(vty, path); - return CMD_SUCCESS; -} - -DEFPY(mgmt_load_config, - mgmt_load_config_cmd, - "mgmt load-config WORD$filepath <merge|replace>$type", - MGMTD_STR - "Load configuration onto Candidate Datastore\n" - "Full path of the file\n" - "Merge configuration with contents of Candidate Datastore\n" - "Replace the existing contents of Candidate datastore\n") -{ - bool merge = type[0] == 'm' ? true : false; - struct mgmt_ds_ctx *ds_ctx; - int ret; - - if (access(filepath, F_OK) == -1) { - vty_out(vty, "ERROR: File %s : %s\n", filepath, - strerror(errno)); - return CMD_ERR_NO_FILE; - } - - ds_ctx = mgmt_ds_get_ctx_by_id(mm, MGMTD_DS_CANDIDATE); - if (!ds_ctx) { - vty_out(vty, "ERROR: Could not access Candidate datastore!\n"); - return CMD_ERR_NO_MATCH; - } - - ret = mgmt_ds_load_config_from_file(ds_ctx, filepath, merge); - if (ret != 0) - vty_out(vty, "Error with parsing the file with error code %d\n", - ret); - return CMD_SUCCESS; -} - -DEFPY(mgmt_save_config, - mgmt_save_config_cmd, - "mgmt save-config <candidate|running>$dsname WORD$filepath", - MGMTD_STR - "Save configuration from datastore\n" - "Candidate datastore\n" - "Running datastore\n" - "Full path of the file\n") -{ - Mgmtd__DatastoreId datastore = mgmt_ds_name2id(dsname); - struct mgmt_ds_ctx *ds_ctx; - FILE *f; - - ds_ctx = mgmt_ds_get_ctx_by_id(mm, datastore); - if (!ds_ctx) { - vty_out(vty, "ERROR: Could not access the '%s' datastore!\n", - dsname); - return CMD_ERR_NO_MATCH; - } - - if (!filepath) { - vty_out(vty, "ERROR: No file path mentioned!\n"); - return CMD_ERR_NO_MATCH; - } - - f = fopen(filepath, "w"); - if (!f) { - vty_out(vty, "Could not open file pointed by filepath %s\n", - filepath); - return CMD_SUCCESS; - } - - mgmt_ds_dump_tree(vty, ds_ctx, "/", f, LYD_JSON); - - fclose(f); - - return CMD_SUCCESS; -} - -DEFPY(show_mgmt_cmt_hist, - show_mgmt_cmt_hist_cmd, - "show mgmt commit-history", - SHOW_STR - MGMTD_STR - "Show commit history\n") -{ - show_mgmt_cmt_history(vty); - return CMD_SUCCESS; -} - -DEFPY(mgmt_rollback, - mgmt_rollback_cmd, - "mgmt rollback <commit-id WORD$commit | last [(1-10)]$last>", - MGMTD_STR - "Rollback commits\n" - "Rollback to commit ID\n" - "Commit-ID\n" - "Rollbak n commits\n" - "Number of commits\n") -{ - if (commit) - mgmt_history_rollback_by_id(vty, commit); - else - mgmt_history_rollback_n(vty, last); - - return CMD_SUCCESS; -} - -static int config_write_mgmt_debug(struct vty *vty); -static struct cmd_node debug_node = { - .name = "debug", - .node = DEBUG_NODE, - .prompt = "", - .config_write = config_write_mgmt_debug, -}; - -static int config_write_mgmt_debug(struct vty *vty) -{ - int n = mgmt_debug_be + mgmt_debug_fe + mgmt_debug_ds + mgmt_debug_txn; - if (!n) - return 0; - if (n == 4) { - vty_out(vty, "debug mgmt all\n"); - return 0; - } - - vty_out(vty, "debug mgmt"); - if (mgmt_debug_be) - vty_out(vty, " backend"); - if (mgmt_debug_ds) - vty_out(vty, " datastore"); - if (mgmt_debug_fe) - vty_out(vty, " frontend"); - if (mgmt_debug_txn) - vty_out(vty, " transaction"); - - vty_out(vty, "\n"); - - return 0; -} - -DEFPY(debug_mgmt, - debug_mgmt_cmd, - "[no$no] debug mgmt <all$all|{backend$be|datastore$ds|frontend$fe|transaction$txn}>", - NO_STR - DEBUG_STR - MGMTD_STR - "All debug\n" - "Back-end debug\n" - "Datastore debug\n" - "Front-end debug\n" - "Transaction debug\n") -{ - bool set = !no; - if (all) - be = fe = ds = txn = set ? all : NULL; - - if (be) - mgmt_debug_be = set; - if (ds) - mgmt_debug_ds = set; - if (fe) - mgmt_debug_fe = set; - if (txn) - mgmt_debug_txn = set; - - return CMD_SUCCESS; -} - -void mgmt_vty_init(void) -{ - /* - * Initialize command handling from VTYSH connection. - * Call command initialization routines defined by - * backend components that are moved to new MGMTD infra - * here one by one. - */ -#if HAVE_STATICD - extern void static_vty_init(void); - static_vty_init(); -#endif - - install_node(&debug_node); - - install_element(VIEW_NODE, &show_mgmt_be_adapter_cmd); - install_element(VIEW_NODE, &show_mgmt_be_xpath_reg_cmd); - install_element(VIEW_NODE, &show_mgmt_fe_adapter_cmd); - install_element(VIEW_NODE, &show_mgmt_fe_adapter_detail_cmd); - install_element(VIEW_NODE, &show_mgmt_txn_cmd); - install_element(VIEW_NODE, &show_mgmt_ds_cmd); - install_element(VIEW_NODE, &show_mgmt_get_config_cmd); - install_element(VIEW_NODE, &show_mgmt_get_data_cmd); - install_element(VIEW_NODE, &show_mgmt_dump_data_cmd); - install_element(VIEW_NODE, &show_mgmt_map_xpath_cmd); - install_element(VIEW_NODE, &show_mgmt_cmt_hist_cmd); - - install_element(CONFIG_NODE, &mgmt_commit_cmd); - install_element(CONFIG_NODE, &mgmt_set_config_data_cmd); - install_element(CONFIG_NODE, &mgmt_delete_config_data_cmd); - install_element(CONFIG_NODE, &mgmt_load_config_cmd); - install_element(CONFIG_NODE, &mgmt_save_config_cmd); - install_element(CONFIG_NODE, &mgmt_rollback_cmd); - - install_element(VIEW_NODE, &debug_mgmt_cmd); - install_element(CONFIG_NODE, &debug_mgmt_cmd); - - /* Enable view */ - install_element(ENABLE_NODE, &mgmt_performance_measurement_cmd); - install_element(ENABLE_NODE, &mgmt_reset_performance_stats_cmd); - - /* - * TODO: Register and handlers for auto-completion here. - */ -} diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c index d284912d1d..ead02d8bd7 100644 --- a/pimd/pim_iface.c +++ b/pimd/pim_iface.c @@ -982,6 +982,12 @@ int pim_if_add_vif(struct interface *ifp, bool ispimreg, bool is_vxlan_term) zlog_warn("%s: ifindex=%d < 1 on interface %s", __func__, ifp->ifindex, ifp->name); return -2; + } else if ((ifp->ifindex == 0) && + ((strncmp(ifp->name, "pimreg", 6)) && + (strncmp(ifp->name, "pim6reg", 7)))) { + zlog_warn("%s: ifindex=%d == 0 on interface %s", __func__, + ifp->ifindex, ifp->name); + return -2; } ifaddr = pim_ifp->primary_address; diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c index 17ad705969..91fb7f03b1 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -790,7 +790,7 @@ static int sharp_opaque_handler(ZAPI_CALLBACK_ARGS) zclient->session_id, info.type); if (info.type == LINK_STATE_UPDATE) { - lse = ls_stream2ted(sg.ted, s, false); + lse = ls_stream2ted(sg.ted, s, true); if (lse) { zlog_debug(" |- Got %s %s from Link State Database", status2txt[lse->status], diff --git a/tests/lib/cxxcompat.c b/tests/lib/cxxcompat.c index 8f54856186..4ad41fca42 100644 --- a/tests/lib/cxxcompat.c +++ b/tests/lib/cxxcompat.c @@ -25,7 +25,6 @@ #include "lib/frr_pthread.h" #include "lib/frratomic.h" #include "lib/frrstr.h" -#include "lib/getopt.h" #include "lib/graph.h" #include "lib/hash.h" #include "lib/hook.h" diff --git a/tests/topotests/all_protocol_startup/r1/ospf6d.conf-pre-v4 b/tests/topotests/all_protocol_startup/r1/ospf6d.conf-pre-v4 index 6d870f355f..9ce2f2e825 100644 --- a/tests/topotests/all_protocol_startup/r1/ospf6d.conf-pre-v4 +++ b/tests/topotests/all_protocol_startup/r1/ospf6d.conf-pre-v4 @@ -1,9 +1,9 @@ log file ospf6d.log ! -debug ospf6 lsa unknown -debug ospf6 zebra -debug ospf6 interface -debug ospf6 neighbor +!debug ospf6 lsa unknown +!debug ospf6 zebra +!debug ospf6 interface +!debug ospf6 neighbor ! interface r1-eth4 ! diff --git a/tests/topotests/bfd_topo3/r5/bfdd.conf b/tests/topotests/bfd_topo3/r5/bfdd.conf index 6d4483acc4..ec62d8d275 100644 --- a/tests/topotests/bfd_topo3/r5/bfdd.conf +++ b/tests/topotests/bfd_topo3/r5/bfdd.conf @@ -1,6 +1,6 @@ -debug bfd network -debug bfd peer -debug bfd zebra +!debug bfd network +!debug bfd peer +!debug bfd zebra ! bfd profile slow-tx diff --git a/tests/topotests/bfd_topo3/r6/bfdd.conf b/tests/topotests/bfd_topo3/r6/bfdd.conf index 6d4483acc4..ec62d8d275 100644 --- a/tests/topotests/bfd_topo3/r6/bfdd.conf +++ b/tests/topotests/bfd_topo3/r6/bfdd.conf @@ -1,6 +1,6 @@ -debug bfd network -debug bfd peer -debug bfd zebra +!debug bfd network +!debug bfd peer +!debug bfd zebra ! bfd profile slow-tx diff --git a/tests/topotests/bgp_accept_own/ce1/bgpd.conf b/tests/topotests/bgp_accept_own/ce1/bgpd.conf index fa53a42919..44f95b9bb3 100644 --- a/tests/topotests/bgp_accept_own/ce1/bgpd.conf +++ b/tests/topotests/bgp_accept_own/ce1/bgpd.conf @@ -1,5 +1,5 @@ ! -debug bgp updates +!debug bgp updates ! router bgp 65010 no bgp ebgp-requires-policy diff --git a/tests/topotests/bgp_accept_own/ce2/bgpd.conf b/tests/topotests/bgp_accept_own/ce2/bgpd.conf index cdf8898c90..d60fdcf7cb 100644 --- a/tests/topotests/bgp_accept_own/ce2/bgpd.conf +++ b/tests/topotests/bgp_accept_own/ce2/bgpd.conf @@ -1,5 +1,5 @@ ! -debug bgp updates +!debug bgp updates ! router bgp 65020 no bgp ebgp-requires-policy diff --git a/tests/topotests/bgp_accept_own/pe1/bgpd.conf b/tests/topotests/bgp_accept_own/pe1/bgpd.conf index 109e0eadbb..15466b4259 100644 --- a/tests/topotests/bgp_accept_own/pe1/bgpd.conf +++ b/tests/topotests/bgp_accept_own/pe1/bgpd.conf @@ -1,8 +1,8 @@ ! -debug bgp updates -debug bgp vpn leak-from-vrf -debug bgp vpn leak-to-vrf -debug bgp nht +!debug bgp updates +!debug bgp vpn leak-from-vrf +!debug bgp vpn leak-to-vrf +!debug bgp nht ! router bgp 65001 bgp router-id 10.10.10.10 diff --git a/tests/topotests/bgp_accept_own/rr1/bgpd.conf b/tests/topotests/bgp_accept_own/rr1/bgpd.conf index 4f0a6ab0f1..ad0ee3e471 100644 --- a/tests/topotests/bgp_accept_own/rr1/bgpd.conf +++ b/tests/topotests/bgp_accept_own/rr1/bgpd.conf @@ -1,5 +1,5 @@ ! -debug bgp updates +!debug bgp updates ! router bgp 65001 bgp router-id 10.10.10.101 diff --git a/tests/topotests/bgp_comm_list_match/r2/bgpd.conf b/tests/topotests/bgp_comm_list_match/r2/bgpd.conf index 35ad2d32e6..98a9780688 100644 --- a/tests/topotests/bgp_comm_list_match/r2/bgpd.conf +++ b/tests/topotests/bgp_comm_list_match/r2/bgpd.conf @@ -1,5 +1,5 @@ ! -debug bgp updates +!debug bgp updates ! router bgp 65002 no bgp ebgp-requires-policy diff --git a/tests/topotests/bgp_confed1/r1/bgpd.conf b/tests/topotests/bgp_confed1/r1/bgpd.conf index 8413ef7fc3..107d2ad8d2 100644 --- a/tests/topotests/bgp_confed1/r1/bgpd.conf +++ b/tests/topotests/bgp_confed1/r1/bgpd.conf @@ -1,7 +1,7 @@ -debug bgp neighbor-events -debug bgp nht -debug bgp updates in -debug bgp updates out +!debug bgp neighbor-events +!debug bgp nht +!debug bgp updates in +!debug bgp updates out ! router bgp 100 no bgp ebgp-requires-policy diff --git a/tests/topotests/bgp_confed1/r2/bgpd.conf b/tests/topotests/bgp_confed1/r2/bgpd.conf index 9f6a9852de..fe13dfe729 100644 --- a/tests/topotests/bgp_confed1/r2/bgpd.conf +++ b/tests/topotests/bgp_confed1/r2/bgpd.conf @@ -1,7 +1,7 @@ -debug bgp neighbor-events -debug bgp nht -debug bgp updates in -debug bgp updates out +!debug bgp neighbor-events +!debug bgp nht +!debug bgp updates in +!debug bgp updates out ! router bgp 200 no bgp ebgp-requires-policy diff --git a/tests/topotests/bgp_confed1/r3/bgpd.conf b/tests/topotests/bgp_confed1/r3/bgpd.conf index 3a018a42b3..74d5fd6e29 100644 --- a/tests/topotests/bgp_confed1/r3/bgpd.conf +++ b/tests/topotests/bgp_confed1/r3/bgpd.conf @@ -1,7 +1,7 @@ -debug bgp neighbor-events -debug bgp nht -debug bgp updates in -debug bgp updates out +!debug bgp neighbor-events +!debug bgp nht +!debug bgp updates in +!debug bgp updates out ! router bgp 300 no bgp ebgp-requires-policy diff --git a/tests/topotests/bgp_confed1/r4/bgpd.conf b/tests/topotests/bgp_confed1/r4/bgpd.conf index 134f221543..89a85e5a34 100644 --- a/tests/topotests/bgp_confed1/r4/bgpd.conf +++ b/tests/topotests/bgp_confed1/r4/bgpd.conf @@ -1,7 +1,7 @@ -debug bgp neighbor-events -debug bgp nht -debug bgp updates in -debug bgp updates out +!debug bgp neighbor-events +!debug bgp nht +!debug bgp updates in +!debug bgp updates out ! router bgp 400 no bgp ebgp-requires-policy diff --git a/tests/topotests/bgp_dont_capability_negotiate/r1/bgpd.conf b/tests/topotests/bgp_dont_capability_negotiate/r1/bgpd.conf index e2ff1df965..2f76d59d4a 100644 --- a/tests/topotests/bgp_dont_capability_negotiate/r1/bgpd.conf +++ b/tests/topotests/bgp_dont_capability_negotiate/r1/bgpd.conf @@ -1,5 +1,5 @@ ! -debug bgp neighbor +!debug bgp neighbor ! router bgp 65001 no bgp ebgp-requires-policy diff --git a/tests/topotests/bgp_evpn_vxlan_svd_topo1/test_bgp_evpn_vxlan_svd.py b/tests/topotests/bgp_evpn_vxlan_svd_topo1/test_bgp_evpn_vxlan_svd.py index f8af210ed7..8b9631175a 100755 --- a/tests/topotests/bgp_evpn_vxlan_svd_topo1/test_bgp_evpn_vxlan_svd.py +++ b/tests/topotests/bgp_evpn_vxlan_svd_topo1/test_bgp_evpn_vxlan_svd.py @@ -463,8 +463,8 @@ def test_ip_pe1_learn(): host1 = tgen.gears["host1"] pe1 = tgen.gears["PE1"] pe2 = tgen.gears["PE2"] - pe2.vtysh_cmd("debug zebra vxlan") - pe2.vtysh_cmd("debug zebra kernel") + #pe2.vtysh_cmd("debug zebra vxlan") + #pe2.vtysh_cmd("debug zebra kernel") # lets populate that arp cache host1.run("ping -c1 10.10.1.1") ip_learn_test(tgen, host1, pe1, pe2, "10.10.1.55") @@ -482,8 +482,8 @@ def test_ip_pe2_learn(): host2 = tgen.gears["host2"] pe1 = tgen.gears["PE1"] pe2 = tgen.gears["PE2"] - pe1.vtysh_cmd("debug zebra vxlan") - pe1.vtysh_cmd("debug zebra kernel") + #pe1.vtysh_cmd("debug zebra vxlan") + #pe1.vtysh_cmd("debug zebra kernel") # lets populate that arp cache host2.run("ping -c1 10.10.1.3") ip_learn_test(tgen, host2, pe2, pe1, "10.10.1.56") diff --git a/tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan.py b/tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan.py index 48b79ab5ee..6561833d6e 100755 --- a/tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan.py +++ b/tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan.py @@ -385,8 +385,8 @@ def test_ip_pe1_learn(): host1 = tgen.gears["host1"] pe1 = tgen.gears["PE1"] pe2 = tgen.gears["PE2"] - pe2.vtysh_cmd("debug zebra vxlan") - pe2.vtysh_cmd("debug zebra kernel") + #pe2.vtysh_cmd("debug zebra vxlan") + #pe2.vtysh_cmd("debug zebra kernel") # lets populate that arp cache host1.run("ping -c1 10.10.1.1") ip_learn_test(tgen, host1, pe1, pe2, "10.10.1.55") @@ -404,8 +404,8 @@ def test_ip_pe2_learn(): host2 = tgen.gears["host2"] pe1 = tgen.gears["PE1"] pe2 = tgen.gears["PE2"] - pe1.vtysh_cmd("debug zebra vxlan") - pe1.vtysh_cmd("debug zebra kernel") + #pe1.vtysh_cmd("debug zebra vxlan") + #pe1.vtysh_cmd("debug zebra kernel") # lets populate that arp cache host2.run("ping -c1 10.10.1.3") ip_learn_test(tgen, host2, pe2, pe1, "10.10.1.56") diff --git a/tests/topotests/bgp_labeled_unicast_addpath/test_bgp_labeled_unicast_addpath.py b/tests/topotests/bgp_labeled_unicast_addpath/test_bgp_labeled_unicast_addpath.py index 3af779c427..f4bb487e40 100644 --- a/tests/topotests/bgp_labeled_unicast_addpath/test_bgp_labeled_unicast_addpath.py +++ b/tests/topotests/bgp_labeled_unicast_addpath/test_bgp_labeled_unicast_addpath.py @@ -82,53 +82,23 @@ def test_bgp_addpath_labeled_unicast(): r3 = tgen.gears["r3"] r4 = tgen.gears["r4"] - def _bgp_check_advertised_routes(prefix_num): - output = json.loads( - r3.vtysh_cmd( - "show bgp ipv4 labeled-unicast neighbors 192.168.34.4 advertised-routes json" - ) - ) + def _bgp_check_received_routes(pfxcount): + output = json.loads(r4.vtysh_cmd("show bgp ipv4 labeled-unicast summary json")) expected = { - "advertisedRoutes": { - "10.0.0.1/32": { - "appliedStatusSymbols": { - "*": True, - ">": True, - "=": True, - } + "peers": { + "192.168.34.3": { + "pfxRcd": pfxcount, + "state": "Established", } - }, - "totalPrefixCounter": prefix_num, + } } return topotest.json_cmp(output, expected) - test_func = functools.partial(_bgp_check_advertised_routes, 2) + test_func = functools.partial(_bgp_check_received_routes, 2) _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5) assert ( result is None - ), "Failed to advertise labeled-unicast with addpath (multipath)" - - def _bgp_check_received_routes(): - output = json.loads(r4.vtysh_cmd("show bgp ipv4 labeled-unicast json")) - expected = { - "routes": { - "10.0.0.1/32": [ - { - "valid": True, - "path": "65003 65001", - }, - { - "valid": True, - "path": "65003 65002", - }, - ] - } - } - return topotest.json_cmp(output, expected) - - test_func = functools.partial(_bgp_check_received_routes) - _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5) - assert result is None, "Failed to receive labeled-unicast with addpath (multipath)" + ), "Failed to receive labeled-unicast with addpath (multipath=2)" step("Enable BGP session for R5") r3.vtysh_cmd( @@ -139,11 +109,11 @@ def test_bgp_addpath_labeled_unicast(): """ ) - test_func = functools.partial(_bgp_check_advertised_routes, 3) + test_func = functools.partial(_bgp_check_received_routes, 3) _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5) assert ( result is None - ), "Failed to advertise labeled-unicast with addpath (multipath)" + ), "Failed to receive labeled-unicast with addpath (multipath=3)" step("Disable BGP session for R5") r3.vtysh_cmd( @@ -154,11 +124,11 @@ def test_bgp_addpath_labeled_unicast(): """ ) - test_func = functools.partial(_bgp_check_advertised_routes, 2) + test_func = functools.partial(_bgp_check_received_routes, 2) _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5) assert ( result is None - ), "Failed to advertise labeled-unicast with addpath (multipath)" + ), "Failed to receive labeled-unicast with addpath (multipath=2)" if __name__ == "__main__": diff --git a/tests/topotests/bgp_prefix_list_any/r2/bgpd.conf b/tests/topotests/bgp_prefix_list_any/r2/bgpd.conf index 77f7c5581b..733205928f 100644 --- a/tests/topotests/bgp_prefix_list_any/r2/bgpd.conf +++ b/tests/topotests/bgp_prefix_list_any/r2/bgpd.conf @@ -1,5 +1,5 @@ ! -debug bgp updates +!debug bgp updates ! router bgp 65002 no bgp ebgp-requires-policy diff --git a/tests/topotests/bgp_route_map_delay_timer/r1/bgpd.conf b/tests/topotests/bgp_route_map_delay_timer/r1/bgpd.conf index 04dc73a06d..e5325c91bc 100644 --- a/tests/topotests/bgp_route_map_delay_timer/r1/bgpd.conf +++ b/tests/topotests/bgp_route_map_delay_timer/r1/bgpd.conf @@ -1,6 +1,6 @@ ! -debug bgp updates -debug bgp neighbor +!debug bgp updates +!debug bgp neighbor ! bgp route-map delay-timer 5 ! diff --git a/tests/topotests/bgp_route_map_vpn_import/r1/bgpd.conf b/tests/topotests/bgp_route_map_vpn_import/r1/bgpd.conf index c9ad0b1a5b..4aa11ec9d0 100644 --- a/tests/topotests/bgp_route_map_vpn_import/r1/bgpd.conf +++ b/tests/topotests/bgp_route_map_vpn_import/r1/bgpd.conf @@ -1,9 +1,9 @@ ! -debug bgp updates -debug bgp vpn leak-from-vrf -debug bgp vpn leak-to-vrf -debug bgp nht -debug route-map +!debug bgp updates +!debug bgp vpn leak-from-vrf +!debug bgp vpn leak-to-vrf +!debug bgp nht +!debug route-map ! router bgp 65001 bgp router-id 10.10.10.10 diff --git a/tests/topotests/bgp_snmp_bgp4v2mib/r2/bgpd.conf b/tests/topotests/bgp_snmp_bgp4v2mib/r2/bgpd.conf index 3512e66cec..cf0013e1b7 100644 --- a/tests/topotests/bgp_snmp_bgp4v2mib/r2/bgpd.conf +++ b/tests/topotests/bgp_snmp_bgp4v2mib/r2/bgpd.conf @@ -1,5 +1,5 @@ ! -debug bgp updates +!debug bgp updates ! router bgp 65002 no bgp ebgp-requires-policy diff --git a/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf2/r1/zebra.conf b/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf2/r1/zebra.conf index a9319a6aed..cbc5ce1f09 100644 --- a/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf2/r1/zebra.conf +++ b/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf2/r1/zebra.conf @@ -7,9 +7,9 @@ log stdout notifications log monitor notifications log commands ! -debug zebra packet -debug zebra dplane -debug zebra kernel +!debug zebra packet +!debug zebra dplane +!debug zebra kernel ! interface eth0 ipv6 address 2001::1/64 diff --git a/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf2/r2/zebra.conf b/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf2/r2/zebra.conf index 9e5fa0ac07..449ca74d5e 100644 --- a/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf2/r2/zebra.conf +++ b/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf2/r2/zebra.conf @@ -7,9 +7,9 @@ log stdout notifications log monitor notifications log commands ! -debug zebra packet -debug zebra dplane -debug zebra kernel +!debug zebra packet +!debug zebra dplane +!debug zebra kernel ! interface eth0 ipv6 address 2001::2/64 diff --git a/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf3/r1/zebra.conf b/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf3/r1/zebra.conf index 2c560dfc06..f913b9f002 100644 --- a/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf3/r1/zebra.conf +++ b/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf3/r1/zebra.conf @@ -7,9 +7,9 @@ log stdout notifications log monitor notifications log commands ! -debug zebra packet -debug zebra dplane -debug zebra kernel +!debug zebra packet +!debug zebra dplane +!debug zebra kernel ! interface eth0 ipv6 address 2001::1/64 diff --git a/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf3/r2/bgpd.conf b/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf3/r2/bgpd.conf index 8700f12d63..4ab5b98c12 100644 --- a/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf3/r2/bgpd.conf +++ b/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf3/r2/bgpd.conf @@ -1,6 +1,6 @@ frr defaults traditional ! -bgp send-extra-data zebra +!bgp send-extra-data zebra ! hostname r2 password zebra diff --git a/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf3/r2/zebra.conf b/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf3/r2/zebra.conf index b9277a9a8c..201d0cce23 100644 --- a/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf3/r2/zebra.conf +++ b/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf3/r2/zebra.conf @@ -7,9 +7,9 @@ log stdout notifications log monitor notifications log commands ! -debug zebra packet -debug zebra dplane -debug zebra kernel +!debug zebra packet +!debug zebra dplane +!debug zebra kernel ! interface eth0 ipv6 address 2001::2/64 diff --git a/tests/topotests/bgp_suppress_fib/r2/bgpd.allowas_in.conf b/tests/topotests/bgp_suppress_fib/r2/bgpd.allowas_in.conf index caebb0e922..fb6980a139 100644 --- a/tests/topotests/bgp_suppress_fib/r2/bgpd.allowas_in.conf +++ b/tests/topotests/bgp_suppress_fib/r2/bgpd.allowas_in.conf @@ -2,12 +2,12 @@ access-list access seq 10 permit 192.168.1.1/32 ! ip route 192.168.1.1/32 10.0.0.10 ! -debug bgp bestpath -debug bgp nht -debug bgp updates -debug bgp update-groups -debug bgp zebra -debug zebra rib detail +!debug bgp bestpath +!debug bgp nht +!debug bgp updates +!debug bgp update-groups +!debug bgp zebra +!debug zebra rib detail ! router bgp 2 address-family ipv4 uni diff --git a/tests/topotests/bgp_suppress_fib/r2/bgpd.conf b/tests/topotests/bgp_suppress_fib/r2/bgpd.conf index 010e86aad7..129b812036 100644 --- a/tests/topotests/bgp_suppress_fib/r2/bgpd.conf +++ b/tests/topotests/bgp_suppress_fib/r2/bgpd.conf @@ -1,6 +1,6 @@ -debug bgp updates -debug bgp bestpath 40.0.0.0/8 -debug bgp zebra +!debug bgp updates +!debug bgp bestpath 40.0.0.0/8 +!debug bgp zebra ! router bgp 2 no bgp ebgp-requires-policy @@ -8,4 +8,4 @@ router bgp 2 neighbor 10.0.0.1 remote-as 1 neighbor 10.0.0.10 remote-as 3 address-family ipv4 uni - network 60.0.0.0/24
\ No newline at end of file + network 60.0.0.0/24 diff --git a/tests/topotests/bgp_vrf_md5_peering/r1/bgpd.conf b/tests/topotests/bgp_vrf_md5_peering/r1/bgpd.conf index 8d8f64158f..9f2ee19357 100644 --- a/tests/topotests/bgp_vrf_md5_peering/r1/bgpd.conf +++ b/tests/topotests/bgp_vrf_md5_peering/r1/bgpd.conf @@ -1,5 +1,5 @@ ! -debug bgp neighbor +!debug bgp neighbor ! router bgp 65534 vrf public bgp router-id 10.0.0.1 diff --git a/tests/topotests/isis_snmp/r5/ldpdconf b/tests/topotests/isis_snmp/r5/ldpdconf index fc700608b5..b3d10b07ec 100644 --- a/tests/topotests/isis_snmp/r5/ldpdconf +++ b/tests/topotests/isis_snmp/r5/ldpdconf @@ -1,10 +1,10 @@ hostname r5 log file ldpd.log ! -debug mpls ldp zebra -debug mpls ldp event -debug mpls ldp errors -debug mpls ldp sync +!debug mpls ldp zebra +!debug mpls ldp event +!debug mpls ldp errors +!debug mpls ldp sync ! mpls ldp router-id 3.3.3.3 diff --git a/tests/topotests/ospf6_ecmp_inter_area/r1/ospf6d.conf b/tests/topotests/ospf6_ecmp_inter_area/r1/ospf6d.conf index 6c7cb96240..e6e5733010 100644 --- a/tests/topotests/ospf6_ecmp_inter_area/r1/ospf6d.conf +++ b/tests/topotests/ospf6_ecmp_inter_area/r1/ospf6d.conf @@ -1,35 +1,35 @@ -debug ospf6 lsa all -debug ospf6 message all -debug ospf6 route all -debug ospf6 spf time -debug ospf6 spf database -debug ospf6 zebra send -debug ospf6 zebra recv - -debug ospf6 lsa router -debug ospf6 lsa router originate -debug ospf6 lsa router examine -debug ospf6 lsa router flooding -debug ospf6 lsa as-external -debug ospf6 lsa as-external originate -debug ospf6 lsa as-external examine -debug ospf6 lsa as-external flooding -debug ospf6 lsa intra-prefix -debug ospf6 lsa intra-prefix originate -debug ospf6 lsa intra-prefix examine -debug ospf6 lsa intra-prefix flooding -debug ospf6 border-routers -debug ospf6 zebra -debug ospf6 interface -debug ospf6 neighbor -debug ospf6 flooding -debug ospf6 gr helper -debug ospf6 spf process -debug ospf6 route intra-area -debug ospf6 route inter-area -debug ospf6 abr -debug ospf6 asbr -debug ospf6 nssa +!debug ospf6 lsa all +!debug ospf6 message all +!debug ospf6 route all +!debug ospf6 spf time +!debug ospf6 spf database +!debug ospf6 zebra send +!debug ospf6 zebra recv +! +!debug ospf6 lsa router +!debug ospf6 lsa router originate +!debug ospf6 lsa router examine +!debug ospf6 lsa router flooding +!debug ospf6 lsa as-external +!debug ospf6 lsa as-external originate +!debug ospf6 lsa as-external examine +!debug ospf6 lsa as-external flooding +!debug ospf6 lsa intra-prefix +!debug ospf6 lsa intra-prefix originate +!debug ospf6 lsa intra-prefix examine +!debug ospf6 lsa intra-prefix flooding +!debug ospf6 border-routers +!debug ospf6 zebra +!debug ospf6 interface +!debug ospf6 neighbor +!debug ospf6 flooding +!debug ospf6 gr helper +!debug ospf6 spf process +!debug ospf6 route intra-area +!debug ospf6 route inter-area +!debug ospf6 abr +!debug ospf6 asbr +!debug ospf6 nssa ! interface r1-eth0 ipv6 ospf6 area 0 diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_topo1.py b/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_topo1.py index 3d15e94a51..9d7a15833c 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_topo1.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_topo1.py @@ -140,7 +140,7 @@ def setup_module(mod): pytest.skip(tgen.errors) # Api call verify whether OSPF is converged ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "setup_module :Failed \n Error {}".format( ospf_covergence ) @@ -260,11 +260,9 @@ def test_ospf_type5_summary_tc43_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_static_rtes, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) - step( - "Configure External Route summary in R0 to summarise 5" " routes to one route." - ) + step("Configure External Route summary in R0 to summarise 5 routes to one route.") ospf_summ_r1 = { "r0": { "ospf": { @@ -290,7 +288,7 @@ def test_ospf_type5_summary_tc43_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show the summaries.") input_dict = { @@ -306,7 +304,7 @@ def test_ospf_type5_summary_tc43_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) step("Change the summary address mask to lower match (ex - 16 to 8)") ospf_summ_r1 = { @@ -334,7 +332,7 @@ def test_ospf_type5_summary_tc43_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) step( "Verify that external routes(static / connected) are summarised" @@ -350,7 +348,7 @@ def test_ospf_type5_summary_tc43_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step("Change the summary address mask to higher match (ex - 8 to 24)") ospf_summ_r1 = { @@ -378,7 +376,7 @@ def test_ospf_type5_summary_tc43_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) step( "Verify that external routes(static / connected) are summarised" @@ -399,7 +397,7 @@ def test_ospf_type5_summary_tc43_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step(" Un configure one of the summary address.") ospf_summ_r1 = { @@ -432,7 +430,7 @@ def test_ospf_type5_summary_tc43_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) ospf_summ_r1 = { "r0": { @@ -459,7 +457,7 @@ def test_ospf_type5_summary_tc43_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) write_test_footer(tc_name) @@ -506,11 +504,9 @@ def test_ospf_type5_summary_tc48_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_static_rtes, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) - step( - "Configure External Route summary in R0 to summarise 5" " routes to one route." - ) + step("Configure External Route summary in R0 to summarise 5 routes to one route.") ospf_summ_r1 = { "r0": { @@ -538,7 +534,7 @@ def test_ospf_type5_summary_tc48_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show the summaries.") input_dict = { @@ -554,26 +550,26 @@ def test_ospf_type5_summary_tc48_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) - step("Verify that originally advertised routes are withdraw from there" " peer.") + step("Verify that originally advertised routes are withdraw from there peer.") input_dict = { "r0": {"static_routes": [{"network": NETWORK["ipv4"], "next_hop": "blackhole"}]} } dut = "r1" result = verify_ospf_rib(tgen, dut, input_dict, expected=False) - assert ( - result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( - tc_name, result + assert result is not True, ( + "Testcase {} : Failed\n Expected: Routes should not be present in OSPF RIB \n Error: " + "Routes still present in OSPF RIB {}".format(tc_name, result) ) result = verify_rib( tgen, "ipv4", dut, input_dict, protocol=protocol, expected=False ) - assert ( - result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in RIB\n" + "Error: Routes still present in RIB".format(tc_name) + ) step( "Configure route map and & rule to permit configured summary address," @@ -635,7 +631,7 @@ def test_ospf_type5_summary_tc48_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) input_dict = { SUMMARY["ipv4"][0]: { @@ -650,7 +646,7 @@ def test_ospf_type5_summary_tc48_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) write_test_footer(tc_name) @@ -697,7 +693,7 @@ def test_ospf_type5_summary_tc42_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_static_rtes, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step( "Configure External Route summary in R0 to summarise 5" @@ -731,7 +727,7 @@ def test_ospf_type5_summary_tc42_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show the summaries.") input_dict = { @@ -747,26 +743,26 @@ def test_ospf_type5_summary_tc42_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) - step("Verify that originally advertised routes are withdraw from there" " peer.") + step("Verify that originally advertised routes are withdraw from there peer.") input_dict = { "r0": {"static_routes": [{"network": NETWORK["ipv4"], "next_hop": "blackhole"}]} } dut = "r1" result = verify_ospf_rib(tgen, dut, input_dict, expected=False) - assert ( - result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( - tc_name, result + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in OSPF RIB \n Error: " + "Routes still present in OSPF RIB {}".format(tc_name, result) ) result = verify_rib( tgen, "ipv4", dut, input_dict, protocol=protocol, expected=False ) - assert ( - result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in RIB" + "Error: Routes still present in RIB".format(tc_name) + ) step("Delete the configured summary") ospf_summ_r1 = { @@ -789,19 +785,17 @@ def test_ospf_type5_summary_tc42_p0(request): step("Verify that summary lsa is withdrawn from R1 and deleted from R0.") dut = "r1" result = verify_ospf_rib(tgen, dut, input_dict, expected=False) - assert ( - result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( - tc_name, result + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in OSPF RIB \n Error: " + "Routes still present in OSPF RIB {}".format(tc_name, result) ) result = verify_rib( tgen, "ipv4", dut, input_dict_summary, protocol=protocol, expected=False ) - assert ( - result is not True - ), "Testcase {} : Failed" "Error: Summary Route still present in RIB".format( - tc_name + assert result is not True, ( + "Testcase {} : Failed \n Expected: Summary Route should not present in RIB" + "Error: Summary Route still present in RIB".format(tc_name) ) step("show ip ospf summary should not have any summary address.") @@ -816,9 +810,10 @@ def test_ospf_type5_summary_tc42_p0(request): } dut = "r0" result = verify_ospf_summary(tgen, topo, dut, input_dict, expected=False) - assert ( - result is not True - ), "Testcase {} : Failed" "Error: Summary still present in DB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \n Expected: Summary Route should not present in OSPF DB" + "Error: Summary still present in DB".format(tc_name) + ) dut = "r1" step("All 5 routes are advertised after deletion of configured summary.") @@ -829,7 +824,7 @@ def test_ospf_type5_summary_tc42_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_static_rtes, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step("configure the summary again and delete static routes .") ospf_summ_r1 = { @@ -857,7 +852,7 @@ def test_ospf_type5_summary_tc42_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) input_dict = { "r0": { @@ -874,18 +869,18 @@ def test_ospf_type5_summary_tc42_p0(request): dut = "r1" result = verify_ospf_rib(tgen, dut, input_dict_summary, expected=False) - assert ( - result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( - tc_name, result + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in OSPF RIB \n Error: " + "Routes still present in OSPF RIB {}".format(tc_name, result) ) result = verify_rib( tgen, "ipv4", dut, input_dict_summary, protocol=protocol, expected=False ) - assert ( - result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in RIB\n" + "Error: Routes still present in RIB".format(tc_name) + ) step("Add back static routes.") input_dict_static_rtes = { @@ -901,18 +896,18 @@ def test_ospf_type5_summary_tc42_p0(request): dut = "r1" result = verify_ospf_rib(tgen, dut, input_dict_static_rtes, expected=False) - assert ( - result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( - tc_name, result + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in OSPF RIB \n Error: " + "Routes still present in OSPF RIB {}".format(tc_name, result) ) result = verify_rib( tgen, "ipv4", dut, input_dict_static_rtes, protocol=protocol, expected=False ) - assert ( - result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in RIB" + "Error: Routes still present in RIB".format(tc_name) + ) input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv4"][0]}]}} dut = "r1" @@ -923,7 +918,7 @@ def test_ospf_type5_summary_tc42_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show configure summaries.") @@ -940,7 +935,7 @@ def test_ospf_type5_summary_tc42_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) step("Configure new static route which is matching configured summary.") input_dict_static_rtes = { @@ -1004,7 +999,7 @@ def test_ospf_type5_summary_tc42_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step("Shut one of the interface") intf = topo["routers"]["r0"]["links"]["r3-link0"]["interface"] @@ -1076,7 +1071,7 @@ def test_ospf_type5_summary_tc42_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv4"][0]}]}} @@ -1087,7 +1082,7 @@ def test_ospf_type5_summary_tc42_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) ospf_summ_r1 = { "r0": { @@ -1113,18 +1108,18 @@ def test_ospf_type5_summary_tc42_p0(request): dut = "r1" result = verify_ospf_rib(tgen, dut, input_dict_summary, expected=False) - assert ( - result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( - tc_name, result + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in OSPF RIB. \n Error: " + "Routes still present in OSPF RIB {}".format(tc_name, result) ) result = verify_rib( tgen, "ipv4", dut, input_dict_summary, protocol=protocol, expected=False ) - assert ( - result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in RIB" + "Error: Routes still present in RIB".format(tc_name) + ) ospf_summ_r1 = { "r0": { @@ -1188,11 +1183,9 @@ def test_ospf_type5_summary_tc45_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_static_rtes, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) - step( - "Configure External Route summary in R0 to summarise 5" " routes to one route." - ) + step("Configure External Route summary in R0 to summarise 5 routes to one route.") ospf_summ_r1 = { "r0": { "ospf": { @@ -1224,7 +1217,7 @@ def test_ospf_type5_summary_tc45_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show the summaries with tag.") input_dict = { @@ -1240,7 +1233,7 @@ def test_ospf_type5_summary_tc45_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) step("Delete the configured summary") ospf_summ_r1 = { @@ -1263,19 +1256,17 @@ def test_ospf_type5_summary_tc45_p0(request): step("Verify that summary lsa is withdrawn from R1 and deleted from R0.") dut = "r1" result = verify_ospf_rib(tgen, dut, input_dict_summary, expected=False) - assert ( - result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( - tc_name, result + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in OSPF RIB \n Error: " + "Routes still present in OSPF RIB {}".format(tc_name, result) ) result = verify_rib( tgen, "ipv4", dut, input_dict_summary, protocol=protocol, expected=False ) - assert ( - result is not True - ), "Testcase {} : Failed" "Error: Summary Route still present in RIB".format( - tc_name + assert result is not True, ( + "Testcase {} : Failed \n Expected: Summary Routes should not be present in RIB. \n" + "Error: Summary Route still present in RIB".format(tc_name) ) step("show ip ospf summary should not have any summary address.") @@ -1292,7 +1283,7 @@ def test_ospf_type5_summary_tc45_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, expected=False) assert ( result is not True - ), "Testcase {} : Failed" "Error: Summary still present in DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary still present in DB".format(tc_name) step("Configure Min tag value") ospf_summ_r1 = { @@ -1317,7 +1308,7 @@ def test_ospf_type5_summary_tc45_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show the summaries with tag.") input_dict = { @@ -1333,7 +1324,7 @@ def test_ospf_type5_summary_tc45_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) step("Configure Max Tag Value") ospf_summ_r1 = { @@ -1363,7 +1354,7 @@ def test_ospf_type5_summary_tc45_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step( "Verify that boundary values tags are used for summary route" @@ -1382,7 +1373,7 @@ def test_ospf_type5_summary_tc45_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) step("configure new static route with different tag.") input_dict_static_rtes_11 = { @@ -1403,10 +1394,9 @@ def test_ospf_type5_summary_tc45_p0(request): dut = "r1" result = verify_ospf_rib(tgen, dut, input_dict_summary, tag="88888", expected=False) - assert ( - result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( - tc_name, result + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in OSPF RIB \n Error: " + "Routes still present in OSPF RIB {}".format(tc_name, result) ) result = verify_rib( @@ -1418,9 +1408,10 @@ def test_ospf_type5_summary_tc45_p0(request): tag="88888", expected=False, ) - assert ( - result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in RIB\n" + "Error: Routes still present in RIB".format(tc_name) + ) step( "Verify that boundary values tags are used for summary route" @@ -1439,7 +1430,7 @@ def test_ospf_type5_summary_tc45_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, expected=False) assert ( result is not True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) step("Delete the configured summary address") ospf_summ_r1 = { @@ -1470,24 +1461,24 @@ def test_ospf_type5_summary_tc45_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_static_rtes, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step("Verify that summary address is flushed from neighbor.") dut = "r1" result = verify_ospf_rib(tgen, dut, input_dict_summary, expected=False) - assert ( - result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( - tc_name, result + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in OSPF RIB \n Error: " + "Routes still present in OSPF RIB {}".format(tc_name, result) ) result = verify_rib( tgen, "ipv4", dut, input_dict_summary, protocol=protocol, expected=False ) - assert ( - result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in RIB\n" + "Error: Routes still present in RIB".format(tc_name) + ) step("Configure summary first & then configure matching static route.") @@ -1589,7 +1580,7 @@ def test_ospf_type5_summary_tc45_p0(request): assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "setup_module :Failed \n Error {}".format( ospf_covergence ) @@ -1619,11 +1610,9 @@ def test_ospf_type5_summary_tc45_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_static_rtes, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) - step( - "Configure External Route summary in R0 to summarise 5" " routes to one route." - ) + step("Configure External Route summary in R0 to summarise 5 routes to one route.") ospf_summ_r1 = { "r0": { "ospf": { @@ -1655,7 +1644,7 @@ def test_ospf_type5_summary_tc45_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show the summaries with tag.") input_dict = { @@ -1691,19 +1680,17 @@ def test_ospf_type5_summary_tc45_p0(request): step("Verify that summary lsa is withdrawn from R1 and deleted from R0.") dut = "r1" result = verify_ospf_rib(tgen, dut, input_dict, expected=False) - assert ( - result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( - tc_name, result + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in OSPF RIB \n Error: " + "Routes still present in OSPF RIB {}".format(tc_name, result) ) result = verify_rib( tgen, "ipv4", dut, input_dict_summary, protocol=protocol, expected=False ) - assert ( - result is not True - ), "Testcase {} : Failed" "Error: Summary Route still present in RIB".format( - tc_name + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in RIB " + "Error: Summary Route still present in RIB".format(tc_name) ) step("show ip ospf summary should not have any summary address.") @@ -1720,7 +1707,7 @@ def test_ospf_type5_summary_tc45_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, expected=False) assert ( result is not True - ), "Testcase {} : Failed" "Error: Summary still present in DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary still present in DB".format(tc_name) step("Configure Min tag value") ospf_summ_r1 = { @@ -1745,7 +1732,7 @@ def test_ospf_type5_summary_tc45_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show the summaries with tag.") input_dict = { @@ -1761,7 +1748,7 @@ def test_ospf_type5_summary_tc45_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) step("Configure Max Tag Value") ospf_summ_r1 = { @@ -1791,7 +1778,7 @@ def test_ospf_type5_summary_tc45_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step( "Verify that boundary values tags are used for summary route" @@ -1810,7 +1797,7 @@ def test_ospf_type5_summary_tc45_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) step("configure new static route with different tag.") input_dict_static_rtes_11 = { @@ -1831,10 +1818,9 @@ def test_ospf_type5_summary_tc45_p0(request): dut = "r1" result = verify_ospf_rib(tgen, dut, input_dict_summary, tag="88888", expected=False) - assert ( - result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( - tc_name, result + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in OSPF RIB \n Error: " + "Routes still present in OSPF RIB {}".format(tc_name, result) ) result = verify_rib( @@ -1846,9 +1832,10 @@ def test_ospf_type5_summary_tc45_p0(request): tag="88888", expected=False, ) - assert ( - result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed\n Expected: Routes should not be present in RIB.\n" + "Error: Routes still present in RIB".format(tc_name) + ) step( "Verify that boundary values tags are used for summary route" @@ -1867,7 +1854,7 @@ def test_ospf_type5_summary_tc45_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, expected=False) assert ( result is not True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) step("Delete the configured summary address") ospf_summ_r1 = { @@ -1898,24 +1885,24 @@ def test_ospf_type5_summary_tc45_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_static_rtes, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step("Verify that summary address is flushed from neighbor.") dut = "r1" result = verify_ospf_rib(tgen, dut, input_dict_summary, expected=False) - assert ( - result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( - tc_name, result + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in OSPF RIB \n Error: " + "Routes still present in OSPF RIB {}".format(tc_name, result) ) result = verify_rib( tgen, "ipv4", dut, input_dict_summary, protocol=protocol, expected=False ) - assert ( - result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in RIB \n" + "Error: Routes still present in RIB".format(tc_name) + ) step("Configure summary first & then configure matching static route.") @@ -1999,7 +1986,7 @@ def test_ospf_type5_summary_tc46_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_static_rtes, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step( "Configure External Route summary in R0 to summarise 5" @@ -2031,20 +2018,20 @@ def test_ospf_type5_summary_tc46_p0(request): dut = "r1" result = verify_ospf_rib(tgen, dut, input_dict_summary, expected=False) - assert ( - result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( - tc_name, result + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in OSPF RIB.\n Error: " + "Routes still present in OSPF RIB {}".format(tc_name, result) ) result = verify_rib( tgen, "ipv4", dut, input_dict_summary, protocol=protocol, expected=False ) - assert ( - result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed\n Expected: Routes should not be present in RIB." + "Error: Routes still present in RIB".format(tc_name) + ) - step("Verify that show ip ospf summary should show the " "configured summaries.") + step("Verify that show ip ospf summary should show the configured summaries.") input_dict = { SUMMARY["ipv4"][0]: { "summaryAddress": SUMMARY["ipv4"][0], @@ -2055,7 +2042,7 @@ def test_ospf_type5_summary_tc46_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) step("Delete the configured summary") ospf_summ_r1 = { @@ -2080,10 +2067,9 @@ def test_ospf_type5_summary_tc46_p0(request): step("Verify that summary lsa is withdrawn from R1 and deleted from R0.") dut = "r1" result = verify_ospf_rib(tgen, dut, input_dict, expected=False) - assert ( - result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( - tc_name, result + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in OSPF RIB. \n Error: " + "Routes still present in OSPF RIB {}".format(tc_name, result) ) result = verify_rib( @@ -2091,9 +2077,7 @@ def test_ospf_type5_summary_tc46_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Summary Route still present in RIB".format( - tc_name - ) + ), "Testcase {} : Failed. Error: Summary Route still present in RIB".format(tc_name) step("show ip ospf summary should not have any summary address.") input_dict = { @@ -2109,7 +2093,7 @@ def test_ospf_type5_summary_tc46_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, expected=False) assert ( result is not True - ), "Testcase {} : Failed" "Error: Summary still present in DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary still present in DB".format(tc_name) step("Reconfigure summary with no advertise.") ospf_summ_r1 = { @@ -2138,20 +2122,20 @@ def test_ospf_type5_summary_tc46_p0(request): dut = "r1" result = verify_ospf_rib(tgen, dut, input_dict_summary, expected=False) - assert ( - result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( - tc_name, result + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in OSPF RIB. \n Error: " + "Routes still present in OSPF RIB {}".format(tc_name, result) ) result = verify_rib( tgen, "ipv4", dut, input_dict_summary, protocol=protocol, expected=False ) - assert ( - result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in RIB \n" + "Error: Routes still present in RIB".format(tc_name) + ) - step("Verify that show ip ospf summary should show the " "configured summaries.") + step("Verify that show ip ospf summary should show the configured summaries.") input_dict = { SUMMARY["ipv4"][0]: { "summaryAddress": SUMMARY["ipv4"][0], @@ -2162,7 +2146,7 @@ def test_ospf_type5_summary_tc46_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) step( "Change summary address from no advertise to advertise " @@ -2211,7 +2195,7 @@ def test_ospf_type5_summary_tc46_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show the summaries.") input_dict = { @@ -2227,26 +2211,26 @@ def test_ospf_type5_summary_tc46_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) - step("Verify that originally advertised routes are withdraw from there" " peer.") + step("Verify that originally advertised routes are withdraw from there peer.") input_dict = { "r0": {"static_routes": [{"network": NETWORK["ipv4"], "next_hop": "blackhole"}]} } dut = "r1" result = verify_ospf_rib(tgen, dut, input_dict, expected=False) - assert ( - result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( - tc_name, result + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in OSPF RIB \n Error: " + "Routes still present in OSPF RIB {}".format(tc_name, result) ) result = verify_rib( tgen, "ipv4", dut, input_dict, protocol=protocol, expected=False ) - assert ( - result is not True - ), "Testcase {} : Failed" "Error: Routes is present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed\n Expected: Routes should not be present in RIB" + "Error: Routes is present in RIB".format(tc_name) + ) write_test_footer(tc_name) @@ -2293,11 +2277,9 @@ def test_ospf_type5_summary_tc47_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_static_rtes, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) - step( - "Configure External Route summary in R0 to summarise 5" " routes to one route." - ) + step("Configure External Route summary in R0 to summarise 5 routes to one route.") ospf_summ_r1 = { "r0": { @@ -2325,7 +2307,7 @@ def test_ospf_type5_summary_tc47_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show the summaries.") input_dict = { @@ -2341,26 +2323,26 @@ def test_ospf_type5_summary_tc47_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) - step("Verify that originally advertised routes are withdraw from there" " peer.") + step("Verify that originally advertised routes are withdraw from there peer.") input_dict = { "r0": {"static_routes": [{"network": NETWORK["ipv4"], "next_hop": "blackhole"}]} } dut = "r1" result = verify_ospf_rib(tgen, dut, input_dict, expected=False) - assert ( - result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( - tc_name, result + assert result is not True, ( + "Testcase {} : Failed \n \n Expected: Routes should not be present in OSPF RIB.\n Error: " + "Routes still present in OSPF RIB {}".format(tc_name, result) ) result = verify_rib( tgen, "ipv4", dut, input_dict, protocol=protocol, expected=False ) - assert ( - result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed\n Expected: Routes should not be present in RIB.\n" + "Error: Routes still present in RIB".format(tc_name) + ) step( "configure route map and add rule to permit configured static " @@ -2423,7 +2405,7 @@ def test_ospf_type5_summary_tc47_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) input_dict = { SUMMARY["ipv4"][0]: { @@ -2461,18 +2443,18 @@ def test_ospf_type5_summary_tc47_p0(request): step("Verify that advertised summary route is flushed from neighbor.") dut = "r1" result = verify_ospf_rib(tgen, dut, input_dict_summary, expected=False) - assert ( - result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( - tc_name, result + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in OSPF RIB\n Error: " + "Routes still present in OSPF RIB {}".format(tc_name, result) ) result = verify_rib( tgen, "ipv4", dut, input_dict_summary, protocol=protocol, expected=False ) - assert ( - result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in RIB.\n" + "Error: Routes still present in RIB".format(tc_name) + ) step("Delete the configured route map.") @@ -2511,7 +2493,7 @@ def test_ospf_type5_summary_tc47_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) input_dict = { SUMMARY["ipv4"][0]: { @@ -2526,7 +2508,7 @@ def test_ospf_type5_summary_tc47_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) step("Reconfigure the route map with denying configure summary address.") @@ -2570,7 +2552,7 @@ def test_ospf_type5_summary_tc47_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step("Redistribute static/connected routes without route map.") @@ -2606,7 +2588,7 @@ def test_ospf_type5_summary_tc47_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) input_dict = { SUMMARY["ipv4"][0]: { @@ -2621,7 +2603,7 @@ def test_ospf_type5_summary_tc47_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) step( "Configure rule to deny all the routes in route map and configure" @@ -2672,18 +2654,18 @@ def test_ospf_type5_summary_tc47_p0(request): step("Verify that no summary route is originated.") dut = "r1" result = verify_ospf_rib(tgen, dut, input_dict_summary, expected=False) - assert ( - result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( - tc_name, result + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in OSPF RIB.\n Error: " + "Routes still present in OSPF RIB {}".format(tc_name, result) ) result = verify_rib( tgen, "ipv4", dut, input_dict_summary, protocol=protocol, expected=False ) - assert ( - result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed\n Expected: Routes should not be present in RIB" + "Error: Routes still present in RIB".format(tc_name) + ) routemaps = { "r0": { @@ -2773,7 +2755,7 @@ def test_ospf_type5_summary_tc47_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show the summaries.") input_dict = { @@ -2789,7 +2771,7 @@ def test_ospf_type5_summary_tc47_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) step("Change route map rule for 1 of the routes to deny.") # Create ip prefix list @@ -2822,7 +2804,7 @@ def test_ospf_type5_summary_tc47_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step("add rule in route map to deny configured summary address.") # Create ip prefix list @@ -2855,7 +2837,7 @@ def test_ospf_type5_summary_tc47_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) write_test_footer(tc_name) @@ -2995,7 +2977,7 @@ def test_ospf_type5_summary_tc51_p2(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) write_test_footer(tc_name) @@ -3042,11 +3024,9 @@ def test_ospf_type5_summary_tc49_p2(request): result = verify_rib(tgen, "ipv4", dut, input_dict_static_rtes, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) - step( - "Configure External Route summary in R0 to summarise 5" " routes to one route." - ) + step("Configure External Route summary in R0 to summarise 5 routes to one route.") ospf_summ_r1 = { "r0": { @@ -3074,7 +3054,7 @@ def test_ospf_type5_summary_tc49_p2(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show the summaries.") input_dict = { @@ -3090,26 +3070,26 @@ def test_ospf_type5_summary_tc49_p2(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) - step("Verify that originally advertised routes are withdraw from there" " peer.") + step("Verify that originally advertised routes are withdraw from there peer.") input_dict = { "r0": {"static_routes": [{"network": NETWORK["ipv4"], "next_hop": "blackhole"}]} } dut = "r1" result = verify_ospf_rib(tgen, dut, input_dict, expected=False) - assert ( - result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( - tc_name, result + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in OSPF RIB.\n Error: " + "Routes still present in OSPF RIB {}".format(tc_name, result) ) result = verify_rib( tgen, "ipv4", dut, input_dict, protocol=protocol, expected=False ) - assert ( - result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed\n Expected: Routes should not be present in RIB.\n" + "Error: Routes still present in RIB".format(tc_name) + ) step("Reload the FRR router") # stop/start -> restart FRR router and verify @@ -3130,7 +3110,7 @@ def test_ospf_type5_summary_tc49_p2(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show the summaries.") input_dict = { @@ -3146,26 +3126,26 @@ def test_ospf_type5_summary_tc49_p2(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) - step("Verify that originally advertised routes are withdraw from there" " peer.") + step("Verify that originally advertised routes are withdraw from there peer.") input_dict = { "r0": {"static_routes": [{"network": NETWORK["ipv4"], "next_hop": "blackhole"}]} } dut = "r1" result = verify_ospf_rib(tgen, dut, input_dict, expected=False) - assert ( - result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( - tc_name, result + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in OSPF RIB. \n Error: " + "Routes still present in OSPF RIB {}".format(tc_name, result) ) result = verify_rib( tgen, "ipv4", dut, input_dict, protocol=protocol, expected=False ) - assert ( - result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed\n Expected: Routes should not be present in RIB\n" + "Error: Routes still present in RIB".format(tc_name) + ) step("Kill OSPFd daemon on R0.") kill_router_daemons(tgen, "r0", ["ospfd"]) @@ -3176,7 +3156,7 @@ def test_ospf_type5_summary_tc49_p2(request): step("Verify OSPF neighbors are up after bringing back ospfd in R0") # Api call verify whether OSPF is converged ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "setup_module :Failed \n Error {}".format( ospf_covergence ) @@ -3194,7 +3174,7 @@ def test_ospf_type5_summary_tc49_p2(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show the summaries.") input_dict = { @@ -3210,26 +3190,26 @@ def test_ospf_type5_summary_tc49_p2(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) - step("Verify that originally advertised routes are withdraw from there" " peer.") + step("Verify that originally advertised routes are withdraw from there peer.") input_dict = { "r0": {"static_routes": [{"network": NETWORK["ipv4"], "next_hop": "blackhole"}]} } dut = "r1" result = verify_ospf_rib(tgen, dut, input_dict, expected=False) - assert ( - result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( - tc_name, result + assert result is not True, ( + "Testcase {} : Failed \n Expected: Routes should not be present in OSPF RIB. \n Error: " + "Routes still present in OSPF RIB {}".format(tc_name, result) ) result = verify_rib( tgen, "ipv4", dut, input_dict, protocol=protocol, expected=False ) - assert ( - result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed\n Expected: Routes should not be present in RIB\n" + "Error: Routes still present in RIB".format(tc_name) + ) step("restart zebrad") kill_router_daemons(tgen, "r0", ["zebra"]) @@ -3251,7 +3231,7 @@ def test_ospf_type5_summary_tc49_p2(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show the summaries.") input_dict = { @@ -3267,26 +3247,26 @@ def test_ospf_type5_summary_tc49_p2(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) - step("Verify that originally advertised routes are withdraw from there" " peer.") + step("Verify that originally advertised routes are withdraw from there peer.") input_dict = { "r0": {"static_routes": [{"network": NETWORK["ipv4"], "next_hop": "blackhole"}]} } dut = "r1" result = verify_ospf_rib(tgen, dut, input_dict, expected=False) - assert ( - result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( - tc_name, result + assert result is not True, ( + "Testcase {} : Failed\n Expected: Routes should not be present in OSPF RIB. \n Error: " + "Routes still present in OSPF RIB {}".format(tc_name, result) ) result = verify_rib( tgen, "ipv4", dut, input_dict, protocol=protocol, expected=False ) - assert ( - result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + assert result is not True, ( + "Testcase {} : Failed\n Expected: Routes should not be present in RIB.\n" + "Error: Routes still present in RIB".format(tc_name) + ) write_test_footer(tc_name) diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_type7_lsa.py b/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_type7_lsa.py index cff59c3a40..603aeadb85 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_type7_lsa.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_type7_lsa.py @@ -132,7 +132,7 @@ def setup_module(mod): pytest.skip(tgen.errors) # Api call verify whether OSPF is converged ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "setup_module :Failed \n Error {}".format( ospf_covergence ) @@ -235,11 +235,9 @@ def test_ospf_type5_summary_tc44_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_static_rtes, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) - step( - "Configure External Route summary in R0 to summarise 5" " routes to one route." - ) + step("Configure External Route summary in R0 to summarise 5 routes to one route.") ospf_summ_r0 = { "r0": { @@ -259,9 +257,7 @@ def test_ospf_type5_summary_tc44_p0(request): "route is sent to R1." ) - step( - "Configure summary & redistribute static/connected route with " "metric type 2" - ) + step("Configure summary & redistribute static/connected route with metric type 2") input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv4"][3]}]}} dut = "r1" @@ -272,7 +268,7 @@ def test_ospf_type5_summary_tc44_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show the summaries.") input_dict = { @@ -288,7 +284,7 @@ def test_ospf_type5_summary_tc44_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) step("Learn type 7 lsa from neighbours") @@ -312,7 +308,7 @@ def test_ospf_type5_summary_tc44_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict_static_rtes, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed. Error: Routes is missing in RIB".format(tc_name) ospf_summ_r0 = { "r0": { @@ -340,7 +336,7 @@ def test_ospf_type5_summary_tc44_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) step("Verify that already originated summary is intact.") input_dict = { @@ -356,7 +352,7 @@ def test_ospf_type5_summary_tc44_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict) assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed. Error: Summary missing in OSPF DB".format(tc_name) dut = "r1" aggr_timer = {"r1": {"ospf": {"aggr_timer": 6}}} diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_authentication.py b/tests/topotests/ospf_basic_functionality/test_ospf_authentication.py index 40df0b2308..88219b8400 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_authentication.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_authentication.py @@ -100,7 +100,7 @@ def setup_module(mod): pytest.skip(tgen.errors) ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "setup_module :Failed \n Error {}".format( ospf_covergence ) @@ -166,7 +166,7 @@ def test_ospf_authentication_simple_pass_tc28_p1(request): step("Verify that the neighbour is not FULL between R1 and R2.") dut = "r1" ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut, expected=False) - assert ospf_covergence is not True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is not True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -192,7 +192,7 @@ def test_ospf_authentication_simple_pass_tc28_p1(request): dut = "r2" ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -223,7 +223,7 @@ def test_ospf_authentication_simple_pass_tc28_p1(request): ospf_covergence = verify_ospf_neighbor( tgen, topo, dut=dut, expected=False, retry_timeout=10 ) - assert ospf_covergence is not True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is not True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -245,7 +245,7 @@ def test_ospf_authentication_simple_pass_tc28_p1(request): dut = "r2" ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -260,7 +260,7 @@ def test_ospf_authentication_simple_pass_tc28_p1(request): "show ip ospf neighbor cmd." ) ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut, expected=False) - assert ospf_covergence is not True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is not True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -274,7 +274,7 @@ def test_ospf_authentication_simple_pass_tc28_p1(request): dut = "r2" ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -314,7 +314,7 @@ def test_ospf_authentication_simple_pass_tc28_p1(request): dut = "r1" ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -361,7 +361,7 @@ def test_ospf_authentication_md5_tc29_p1(request): ospf_covergence = verify_ospf_neighbor( tgen, topo, dut=dut, expected=False, retry_timeout=6 ) - assert ospf_covergence is not True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is not True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -393,7 +393,7 @@ def test_ospf_authentication_md5_tc29_p1(request): dut = "r2" ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -426,7 +426,7 @@ def test_ospf_authentication_md5_tc29_p1(request): ospf_covergence = verify_ospf_neighbor( tgen, topo, dut=dut, expected=False, retry_timeout=10 ) - assert ospf_covergence is not True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is not True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -454,7 +454,7 @@ def test_ospf_authentication_md5_tc29_p1(request): dut = "r2" ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -469,7 +469,7 @@ def test_ospf_authentication_md5_tc29_p1(request): "show ip ospf neighbor cmd." ) ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut, expected=False) - assert ospf_covergence is not True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is not True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -483,7 +483,7 @@ def test_ospf_authentication_md5_tc29_p1(request): dut = "r2" ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -528,7 +528,7 @@ def test_ospf_authentication_md5_tc29_p1(request): dut = "r1" ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -576,7 +576,7 @@ def test_ospf_authentication_different_auths_tc30_p1(request): ospf_covergence = verify_ospf_neighbor( tgen, topo, dut=dut, expected=False, retry_timeout=10 ) - assert ospf_covergence is not True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is not True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -608,7 +608,7 @@ def test_ospf_authentication_different_auths_tc30_p1(request): dut = "r2" ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -655,7 +655,7 @@ def test_ospf_authentication_different_auths_tc30_p1(request): dut = "r2" ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -687,7 +687,7 @@ def test_ospf_authentication_different_auths_tc30_p1(request): dut = "r2" ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -720,7 +720,7 @@ def test_ospf_authentication_different_auths_tc30_p1(request): dut = "r2" ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -765,7 +765,7 @@ def test_ospf_authentication_different_auths_tc30_p1(request): dut = "r2" ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -810,7 +810,7 @@ def test_ospf_authentication_different_auths_tc30_p1(request): dut = "r2" ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_chaos.py b/tests/topotests/ospf_basic_functionality/test_ospf_chaos.py index 124b36a5fa..e58f081f96 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_chaos.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_chaos.py @@ -111,7 +111,7 @@ def setup_module(mod): pytest.skip(tgen.errors) ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "setup_module :Failed \n Error {}".format( ospf_covergence ) @@ -177,7 +177,7 @@ def test_ospf_chaos_tc31_p1(request): step("Verify OSPF neighbors after base config is done.") # Api call verify whether OSPF is converged ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -198,7 +198,7 @@ def test_ospf_chaos_tc31_p1(request): dut = "r0" # Api call verify whether OSPF is converged ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut, expected=False) - assert ospf_covergence is not True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is not True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -208,7 +208,7 @@ def test_ospf_chaos_tc31_p1(request): result = verify_ospf_rib(tgen, dut, input_dict, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: OSPF routes are present \n Error: {}".format( + ), "Testcase {} : Failed \n r1: OSPF routes are present \n Error: {}".format( tc_name, result ) @@ -217,7 +217,7 @@ def test_ospf_chaos_tc31_p1(request): ) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: routes are still present \n Error: {}".format( + ), "Testcase {} : Failed \n r1: routes are still present \n Error: {}".format( tc_name, result ) @@ -227,7 +227,7 @@ def test_ospf_chaos_tc31_p1(request): step("Verify OSPF neighbors are up after bringing back ospfd in R0") # Api call verify whether OSPF is converged ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -250,7 +250,7 @@ def test_ospf_chaos_tc31_p1(request): dut = "r1" # Api call verify whether OSPF is converged ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut, expected=False) - assert ospf_covergence is not True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is not True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -260,7 +260,7 @@ def test_ospf_chaos_tc31_p1(request): step("Verify OSPF neighbors are up after bringing back ospfd in R1") # Api call verify whether OSPF is converged ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -316,7 +316,7 @@ def test_ospf_chaos_tc32_p1(request): step("Verify OSPF neighbors after base config is done.") # Api call verify whether OSPF is converged ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -338,7 +338,7 @@ def test_ospf_chaos_tc32_p1(request): step("Verify OSPF neighbors are up after restarting R0") # Api call verify whether OSPF is converged ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -361,7 +361,7 @@ def test_ospf_chaos_tc32_p1(request): step("Verify OSPF neighbors are up after restarting R1") # Api call verify whether OSPF is converged ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -421,7 +421,7 @@ def test_ospf_chaos_tc34_p1(request): step("Verify OSPF neighbors after base config is done.") # Api call verify whether OSPF is converged ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -444,7 +444,7 @@ def test_ospf_chaos_tc34_p1(request): result = verify_ospf_rib(tgen, dut, input_dict, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: OSPF routes are present \n Error: {}".format( + ), "Testcase {} : Failed \n r1: OSPF routes are present \n Error: {}".format( tc_name, result ) @@ -453,7 +453,7 @@ def test_ospf_chaos_tc34_p1(request): ) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: routes are still present \n Error: {}".format( + ), "Testcase {} : Failed \n r1: routes are still present \n Error: {}".format( tc_name, result ) @@ -463,7 +463,7 @@ def test_ospf_chaos_tc34_p1(request): step("Verify OSPF neighbors are up after bringing back ospfd in R0") # Api call verify whether OSPF is converged ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -488,7 +488,7 @@ def test_ospf_chaos_tc34_p1(request): step("Verify OSPF neighbors are up after bringing back ospfd in R1") # Api call verify whether OSPF is converged ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_ecmp.py b/tests/topotests/ospf_basic_functionality/test_ospf_ecmp.py index d58e2503ed..aba313db9f 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_ecmp.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_ecmp.py @@ -114,7 +114,7 @@ def setup_module(mod): pytest.skip(tgen.errors) # Api call verify whether OSPF is converged ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "setup_module :Failed \n Error {}".format( ospf_covergence ) @@ -168,7 +168,7 @@ def test_ospf_ecmp_tc16_p0(request): step("Verify that OSPF is up with 8 neighborship sessions.") dut = "r1" ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -217,7 +217,7 @@ def test_ospf_ecmp_tc16_p0(request): result = verify_ospf_rib(tgen, dut, input_dict, next_hop=nh, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: OSPF routes are present \n Error: {}".format( + ), "Testcase {} : Failed \n r1: OSPF routes are present \n Error: {}".format( tc_name, result ) @@ -227,7 +227,7 @@ def test_ospf_ecmp_tc16_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: routes are still present \n Error: {}".format( + ), "Testcase {} : Failed \n r1: routes are still present \n Error: {}".format( tc_name, result ) @@ -259,7 +259,7 @@ def test_ospf_ecmp_tc16_p0(request): step("Verify that OSPF is up with 8 neighborship sessions.") dut = "r1" ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -286,7 +286,7 @@ def test_ospf_ecmp_tc16_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: OSPF routes are present \n Error: {}".format( + ), "Testcase {} : Failed \n r1: OSPF routes are present \n Error: {}".format( tc_name, result ) @@ -303,7 +303,7 @@ def test_ospf_ecmp_tc16_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: routes are still present \n Error: {}".format( + ), "Testcase {} : Failed \n r1: routes are still present \n Error: {}".format( tc_name, result ) @@ -343,7 +343,7 @@ def test_ospf_ecmp_tc17_p0(request): step("Verify that OSPF is up with 2 neighborship sessions.") dut = "r1" ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -394,7 +394,7 @@ def test_ospf_ecmp_tc17_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: OSPF routes are present \n Error: {}".format( + ), "Testcase {} : Failed \n r1: OSPF routes are present \n Error: {}".format( tc_name, result ) @@ -411,7 +411,7 @@ def test_ospf_ecmp_tc17_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: routes are still present \n Error: {}".format( + ), "Testcase {} : Failed \n r1: routes are still present \n Error: {}".format( tc_name, result ) diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_ecmp_lan.py b/tests/topotests/ospf_basic_functionality/test_ospf_ecmp_lan.py index 6a565571be..1eeb23e9f7 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_ecmp_lan.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_ecmp_lan.py @@ -115,7 +115,7 @@ def setup_module(mod): pytest.skip(tgen.errors) # Api call verify whether OSPF is converged ospf_covergence = verify_ospf_neighbor(tgen, topo, lan=True) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "setup_module :Failed \n Error {}".format( ospf_covergence ) @@ -169,7 +169,7 @@ def test_ospf_lan_ecmp_tc18_p0(request): step("Verify that OSPF is up with 8 neighborship sessions.") ospf_covergence = verify_ospf_neighbor(tgen, topo, lan=True) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -222,7 +222,7 @@ def test_ospf_lan_ecmp_tc18_p0(request): dut = "r0" ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut, lan=True) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -231,7 +231,7 @@ def test_ospf_lan_ecmp_tc18_p0(request): dut = "r2" ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut, lan=True) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -261,7 +261,7 @@ def test_ospf_lan_ecmp_tc18_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: OSPF routes are present \n Error: {}".format( + ), "Testcase {} : Failed \n r1: OSPF routes are present \n Error: {}".format( tc_name, result ) @@ -278,7 +278,7 @@ def test_ospf_lan_ecmp_tc18_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: routes are still present \n Error: {}".format( + ), "Testcase {} : Failed \n r1: routes are still present \n Error: {}".format( tc_name, result ) diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_lan.py b/tests/topotests/ospf_basic_functionality/test_ospf_lan.py index 53b1be6d71..c166702958 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_lan.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_lan.py @@ -114,7 +114,7 @@ def setup_module(mod): pytest.skip(tgen.errors) # Api call verify whether OSPF is converged ospf_covergence = verify_ospf_neighbor(tgen, topo, lan=True) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "setup_module :Failed \n Error {}".format( ospf_covergence ) @@ -196,9 +196,7 @@ def test_ospf_lan_tc1_p0(request): result = verify_ospf_neighbor(tgen, topo, dut, input_dict, lan=True) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) - step( - "Configure DR pririty 100 on R0 and clear ospf neighbors " "on all the routers." - ) + step("Configure DR pririty 100 on R0 and clear ospf neighbors on all the routers.") input_dict = { "r0": { @@ -234,9 +232,7 @@ def test_ospf_lan_tc1_p0(request): result = verify_ospf_neighbor(tgen, topo, dut, input_dict, lan=True) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) - step( - "Configure DR pririty 150 on R0 and clear ospf neighbors " "on all the routers." - ) + step("Configure DR pririty 150 on R0 and clear ospf neighbors on all the routers.") input_dict = { "r0": { @@ -355,7 +351,7 @@ def test_ospf_lan_tc1_p0(request): result = verify_ospf_neighbor(tgen, topo, dut, lan=True, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n " "r0: OSPF neighbors-hip is up \n Error: {}".format( + ), "Testcase {} : Failed \n r0: OSPF neighbors-hip is up \n Error: {}".format( tc_name, result ) diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_nssa.py b/tests/topotests/ospf_basic_functionality/test_ospf_nssa.py index 0c4697cc21..d669e21d4d 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_nssa.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_nssa.py @@ -112,7 +112,7 @@ def setup_module(mod): pytest.skip(tgen.errors) # Api call verify whether OSPF is converged ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "setup_module :Failed \n Error {}".format( ospf_covergence ) @@ -220,11 +220,11 @@ def test_ospf_learning_tc15_p0(request): assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) - step("Change area 1 as non nssa area (on the fly changing area" " type on DUT).") + step("Change area 1 as non nssa area (on the fly changing area type on DUT).") for rtr in ["r1", "r2", "r3"]: input_dict = { diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_routemaps.py b/tests/topotests/ospf_basic_functionality/test_ospf_routemaps.py index dad6d915e8..c9f43cdfe4 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_routemaps.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_routemaps.py @@ -127,7 +127,7 @@ def setup_module(mod): pytest.skip(tgen.errors) # Api call verify whether OSPF is converged ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "setup_module :Failed \n Error {}".format( ospf_covergence ) @@ -201,9 +201,7 @@ def test_ospf_routemaps_functionality_tc19_p0(request): redistribute_ospf(tgen, topo, "r0", "static", delete=True) - step( - "Create prefix-list in R0 to permit 10.0.20.1/32 prefix &" " deny 10.0.20.2/32" - ) + step("Create prefix-list in R0 to permit 10.0.20.1/32 prefix & deny 10.0.20.2/32") # Create ip prefix list pfx_list = { @@ -294,7 +292,7 @@ def test_ospf_routemaps_functionality_tc19_p0(request): result = verify_ospf_rib(tgen, dut, input_dict, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: OSPF routes are present \n Error: {}".format( + ), "Testcase {} : Failed \n r1: OSPF routes are present \n Error: {}".format( tc_name, result ) @@ -303,7 +301,7 @@ def test_ospf_routemaps_functionality_tc19_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: routes are present in fib \n Error: {}".format( + ), "Testcase {} : Failed \n r1: routes are present in fib \n Error: {}".format( tc_name, result ) @@ -347,7 +345,7 @@ def test_ospf_routemaps_functionality_tc19_p0(request): result = verify_ospf_rib(tgen, dut, input_dict, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: OSPF routes are present \n Error: {}".format( + ), "Testcase {} : Failed \n r1: OSPF routes are present \n Error: {}".format( tc_name, result ) @@ -356,7 +354,7 @@ def test_ospf_routemaps_functionality_tc19_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: OSPF routes are present \n Error: {}".format( + ), "Testcase {} : Failed \n r1: OSPF routes are present \n Error: {}".format( tc_name, result ) @@ -404,7 +402,7 @@ def test_ospf_routemaps_functionality_tc19_p0(request): result = verify_ospf_rib(tgen, dut, input_dict, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: OSPF routes are present \n Error: {}".format( + ), "Testcase {} : Failed \n r1: OSPF routes are present \n Error: {}".format( tc_name, result ) @@ -413,7 +411,7 @@ def test_ospf_routemaps_functionality_tc19_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: routes are still present \n Error: {}".format( + ), "Testcase {} : Failed \n r1: routes are still present \n Error: {}".format( tc_name, result ) @@ -464,7 +462,7 @@ def test_ospf_routemaps_functionality_tc20_p0(request): result = verify_ospf_rib(tgen, dut, input_dict, retry_timeout=4, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: OSPF routes are present \n Error: {}".format( + ), "Testcase {} : Failed \n r1: OSPF routes are present \n Error: {}".format( tc_name, result ) @@ -479,7 +477,7 @@ def test_ospf_routemaps_functionality_tc20_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: routes are still present \n Error: {}".format( + ), "Testcase {} : Failed \n r1: routes are still present \n Error: {}".format( tc_name, result ) @@ -499,7 +497,7 @@ def test_ospf_routemaps_functionality_tc20_p0(request): result = verify_ospf_rib(tgen, dut, input_dict, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: OSPF routes are present \n Error: {}".format( + ), "Testcase {} : Failed \n r1: OSPF routes are present \n Error: {}".format( tc_name, result ) @@ -508,7 +506,7 @@ def test_ospf_routemaps_functionality_tc20_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: routes are still present \n Error: {}".format( + ), "Testcase {} : Failed \n r1: routes are still present \n Error: {}".format( tc_name, result ) @@ -523,7 +521,7 @@ def test_ospf_routemaps_functionality_tc20_p0(request): result = verify_ospf_rib(tgen, dut, input_dict, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: OSPF routes are present \n Error: {}".format( + ), "Testcase {} : Failed \n r1: OSPF routes are present \n Error: {}".format( tc_name, result ) @@ -532,7 +530,7 @@ def test_ospf_routemaps_functionality_tc20_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: routes are still present \n Error: {}".format( + ), "Testcase {} : Failed \n r1: routes are still present \n Error: {}".format( tc_name, result ) @@ -553,7 +551,7 @@ def test_ospf_routemaps_functionality_tc20_p0(request): result = verify_ospf_rib(tgen, dut, input_dict, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: OSPF routes are present \n Error: {}".format( + ), "Testcase {} : Failed \n r1: OSPF routes are present \n Error: {}".format( tc_name, result ) @@ -562,7 +560,7 @@ def test_ospf_routemaps_functionality_tc20_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed \n " "r1: routes are still present \n Error: {}".format( + ), "Testcase {} : Failed \n r1: routes are still present \n Error: {}".format( tc_name, result ) @@ -861,7 +859,7 @@ def test_ospf_routemaps_functionality_tc24_p0(request): result = verify_prefix_lists(tgen, pfx_list) assert ( result is not True - ), "Testcase {} : Failed \n Prefix list not " "present. Error: {}".format( + ), "Testcase {} : Failed \n Prefix list not present. Error: {}".format( tc_name, result ) @@ -930,7 +928,7 @@ def test_ospf_routemaps_functionality_tc24_p0(request): result = verify_prefix_lists(tgen, pfx_list) assert ( result is not True - ), "Testcase {} : Failed \n Prefix list not " "present. Error: {}".format( + ), "Testcase {} : Failed \n Prefix list not present. Error: {}".format( tc_name, result ) @@ -1078,7 +1076,7 @@ def test_ospf_routemaps_functionality_tc25_p0(request): # Api call verify whether OSPF is converged ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_rte_calc.py b/tests/topotests/ospf_basic_functionality/test_ospf_rte_calc.py index 63c421ec84..f0950a2db3 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_rte_calc.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_rte_calc.py @@ -123,7 +123,7 @@ def setup_module(mod): pytest.skip(tgen.errors) # Api call verify whether OSPF is converged ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "setup_module :Failed \n Error {}".format( ospf_covergence ) @@ -171,7 +171,7 @@ def test_ospf_redistribution_tc5_p0(request): step("Verify that OSPF neighbors are FULL.") ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -295,7 +295,7 @@ def test_ospf_redistribution_tc6_p0(request): step("Verify that OSPF neighbors are FULL.") ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -524,7 +524,7 @@ def test_ospf_redistribution_tc8_p1(request): step("Verify that OSPF neighbours are reset and forms new adjacencies.") # Api call verify whether OSPF is converged ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -558,7 +558,7 @@ def test_ospf_rfc2328_appendinxE_p0(request): step("Verify that OSPF neighbours are Full.") # Api call verify whether OSPF is converged ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_single_area.py b/tests/topotests/ospf_basic_functionality/test_ospf_single_area.py index 39bbab42e7..757d6fb1d5 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_single_area.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_single_area.py @@ -108,7 +108,7 @@ def setup_module(mod): pytest.skip(tgen.errors) ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "setup_module :Failed \n Error {}".format( ospf_covergence ) @@ -358,7 +358,7 @@ def test_ospf_p2p_tc3_p0(request): # Api call verify whether BGP is converged ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -440,7 +440,7 @@ def test_ospf_hello_tc10_p0(request): step("verify that ospf neighbours are full") ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -486,7 +486,7 @@ def test_ospf_hello_tc10_p0(request): step("verify that ospf neighbours are full") ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -532,7 +532,7 @@ def test_ospf_hello_tc10_p0(request): step("verify that ospf neighbours are full") ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -575,7 +575,7 @@ def test_ospf_hello_tc10_p0(request): step("verify that ospf neighbours are full") ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -597,7 +597,7 @@ def test_ospf_show_p1(request): reset_config_on_routers(tgen) ospf_covergence = verify_ospf_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) dut = "r1" @@ -690,7 +690,7 @@ def test_ospf_dead_tc11_p0(request): result = verify_ospf_interface(tgen, topo, dut=dut, input_dict=input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) - step("modify dead interval from default value to r1" "dead interval timer on r2") + step("modify dead interval from default value to r1 dead interval timer on r2") topo1 = { "r0": { @@ -714,11 +714,11 @@ def test_ospf_dead_tc11_p0(request): step("verify that ospf neighbours are full") ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) - step("reconfigure the default dead interval timer value to " "default on r1 and r2") + step("reconfigure the default dead interval timer value to default on r1 and r2") topo1 = { "r0": { "links": { @@ -755,7 +755,7 @@ def test_ospf_dead_tc11_p0(request): step("verify that ospf neighbours are full") ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -797,7 +797,7 @@ def test_ospf_dead_tc11_p0(request): step("verify that ospf neighbours are full") ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error {}".format( ospf_covergence ) @@ -835,9 +835,7 @@ def test_ospf_dead_tc11_p0(request): result = create_interfaces_cfg(tgen, topo1) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) - step( - "Verify that timer value is deleted from intf & " "set to default value 40 sec." - ) + step("Verify that timer value is deleted from intf & set to default value 40 sec.") input_dict = {"r1": {"links": {"r0": {"ospf": {"timerDeadSecs": 40}}}}} dut = "r1" result = verify_ospf_interface(tgen, topo, dut=dut, input_dict=input_dict) @@ -883,18 +881,14 @@ def test_ospf_tc4_mtu_ignore_p0(request): clear_ospf(tgen, "r0") - step( - "Verify that OSPF neighborship between R0 and R1 is stuck in Exstart" " State." - ) + step("Verify that OSPF neighborship between R0 and R1 is stuck in Exstart State.") result = verify_ospf_neighbor(tgen, topo, expected=False) assert result is not True, ( "Testcase {} : Failed \n OSPF nbrs are Full " "instead of Exstart. Error: {}".format(tc_name, result) ) - step( - "Verify that configured MTU value is updated in the show ip " "ospf interface." - ) + step("Verify that configured MTU value is updated in the show ip ospf interface.") dut = "r0" input_dict = {"r0": {"links": {"r1": {"ospf": {"mtuBytes": 1200}}}}} @@ -951,9 +945,7 @@ def test_ospf_tc4_mtu_ignore_p0(request): clear_ospf(tgen, "r0") - step( - "Verify that OSPF neighborship between R0 and R1 is stuck in Exstart" " State." - ) + step("Verify that OSPF neighborship between R0 and R1 is stuck in Exstart State.") result = verify_ospf_neighbor(tgen, topo, expected=False) assert result is not True, ( "Testcase {} : Failed \n OSPF nbrs are Full " @@ -970,9 +962,7 @@ def test_ospf_tc4_mtu_ignore_p0(request): result = verify_ospf_neighbor(tgen, topo) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) - step( - "Configure ospf interface with jumbo MTU (9216)." "Reset ospf neighbors on R0." - ) + step("Configure ospf interface with jumbo MTU (9216). Reset ospf neighbors on R0.") rtr0.run("ip link set {} mtu 9216".format(r0_r1_intf)) rtr1.run("ip link set {} mtu 9216".format(r1_r0_intf)) diff --git a/tests/topotests/ospf_gr_helper/test_ospf_gr_helper1.py b/tests/topotests/ospf_gr_helper/test_ospf_gr_helper1.py index 1c26596230..9dce5a976d 100644 --- a/tests/topotests/ospf_gr_helper/test_ospf_gr_helper1.py +++ b/tests/topotests/ospf_gr_helper/test_ospf_gr_helper1.py @@ -119,7 +119,7 @@ def setup_module(mod): pytest.skip(tgen.errors) ospf_covergence = verify_ospf_neighbor(tgen, topo, lan=True) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "setup_module :Failed \n Error: {}".format( ospf_covergence ) @@ -182,9 +182,9 @@ def test_ospf_gr_helper_tc1_p0(request): ospf_covergence = verify_ospf_neighbor(tgen, topo, lan=True) assert ( ospf_covergence is True - ), "OSPF is not after reset config \n Error:" " {}".format(ospf_covergence) + ), "OSPF is not after reset config \n Error: {}".format(ospf_covergence) - step("Verify that GR helper route is disabled by default to the in" "the DUT.") + step("Verify that GR helper route is disabled by default to the in the DUT.") input_dict = { "helperSupport": "Disabled", "strictLsaCheck": "Enabled", @@ -195,7 +195,7 @@ def test_ospf_gr_helper_tc1_p0(request): result = verify_ospf_gr_helper(tgen, topo, dut, input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) - step("Verify that DUT does not enter helper mode upon receiving the " "grace lsa.") + step("Verify that DUT does not enter helper mode upon receiving the grace lsa.") # send grace lsa scapy_send_raw_packet(tgen, topo, "r1", intf1, pkt) @@ -205,7 +205,7 @@ def test_ospf_gr_helper_tc1_p0(request): result = verify_ospf_gr_helper(tgen, topo, dut, input_dict, expected=False) assert ( result is not True - ), "Testcase {} : Failed. DUT entered helper role " " \n Error: {}".format( + ), "Testcase {} : Failed. DUT entered helper role \n Error: {}".format( tc_name, result ) @@ -234,7 +234,7 @@ def test_ospf_gr_helper_tc1_p0(request): assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) step("Perform GR in RR.") - step("Verify that DUT does enter helper mode upon receiving" " the grace lsa.") + step("Verify that DUT does enter helper mode upon receiving the grace lsa.") input_dict = {"activeRestarterCnt": 1} gracelsa_sent = False repeat = 0 @@ -277,7 +277,7 @@ def test_ospf_gr_helper_tc1_p0(request): result = create_router_ospf(tgen, topo, ospf_gr_r0) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) - step("Verify that DUT does enter helper mode upon receiving" " the grace lsa.") + step("Verify that DUT does enter helper mode upon receiving the grace lsa.") input_dict = {"activeRestarterCnt": 1} gracelsa_sent = False repeat = 0 @@ -306,7 +306,7 @@ def test_ospf_gr_helper_tc1_p0(request): result = create_router_ospf(tgen, topo, ospf_gr_r0) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) - step("Verify that GR helper router is disabled in the DUT for" " router id x.x.x.x") + step("Verify that GR helper router is disabled in the DUT for router id x.x.x.x") input_dict = {"enabledRouterIds": [{"routerId": "1.1.1.1"}]} dut = "r0" result = verify_ospf_gr_helper(tgen, topo, dut, input_dict, expected=False) @@ -343,7 +343,7 @@ def test_ospf_gr_helper_tc2_p0(request): ospf_covergence = verify_ospf_neighbor(tgen, topo, lan=True) assert ( ospf_covergence is True - ), "OSPF is not after reset config \n Error:" " {}".format(ospf_covergence) + ), "OSPF is not after reset config \n Error: {}".format(ospf_covergence) ospf_gr_r0 = { "r0": {"ospf": {"graceful-restart": {"helper enable": [], "opaque": True}}} } diff --git a/tests/topotests/ospf_gr_helper/test_ospf_gr_helper2.py b/tests/topotests/ospf_gr_helper/test_ospf_gr_helper2.py index a3ccb58d38..202afe5485 100644 --- a/tests/topotests/ospf_gr_helper/test_ospf_gr_helper2.py +++ b/tests/topotests/ospf_gr_helper/test_ospf_gr_helper2.py @@ -119,7 +119,7 @@ def setup_module(mod): pytest.skip(tgen.errors) ospf_covergence = verify_ospf_neighbor(tgen, topo, lan=True) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "setup_module :Failed \n Error: {}".format( ospf_covergence ) @@ -188,10 +188,8 @@ def test_ospf_gr_helper_tc3_p1(request): ospf_covergence = verify_ospf_neighbor(tgen, topo, lan=True) assert ( ospf_covergence is True - ), "OSPF is not after reset config \n Error:" " {}".format(ospf_covergence) - step( - "Configure DR pririty 100 on R0 and clear ospf neighbors " "on all the routers." - ) + ), "OSPF is not after reset config \n Error: {}".format(ospf_covergence) + step("Configure DR pririty 100 on R0 and clear ospf neighbors on all the routers.") input_dict = { "r0": { @@ -282,10 +280,8 @@ def test_ospf_gr_helper_tc4_p1(request): ospf_covergence = verify_ospf_neighbor(tgen, topo, lan=True) assert ( ospf_covergence is True - ), "OSPF is not after reset config \n Error:" " {}".format(ospf_covergence) - step( - "Configure DR pririty 100 on R0 and clear ospf neighbors " "on all the routers." - ) + ), "OSPF is not after reset config \n Error: {}".format(ospf_covergence) + step("Configure DR pririty 100 on R0 and clear ospf neighbors on all the routers.") input_dict = { "r0": { diff --git a/tests/topotests/ospf_gr_helper/test_ospf_gr_helper3.py b/tests/topotests/ospf_gr_helper/test_ospf_gr_helper3.py index 64aac2fba8..3be28196d8 100644 --- a/tests/topotests/ospf_gr_helper/test_ospf_gr_helper3.py +++ b/tests/topotests/ospf_gr_helper/test_ospf_gr_helper3.py @@ -119,7 +119,7 @@ def setup_module(mod): pytest.skip(tgen.errors) ospf_covergence = verify_ospf_neighbor(tgen, topo, lan=True) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "setup_module :Failed \n Error: {}".format( ospf_covergence ) @@ -193,7 +193,7 @@ def test_ospf_gr_helper_tc7_p1(request): ospf_covergence = verify_ospf_neighbor(tgen, topo, lan=True) assert ( ospf_covergence is True - ), "OSPF is not after reset config \n Error:" " {}".format(ospf_covergence) + ), "OSPF is not after reset config \n Error: {}".format(ospf_covergence) ospf_gr_r0 = { "r0": {"ospf": {"graceful-restart": {"helper enable": [], "opaque": True}}} } @@ -221,7 +221,7 @@ def test_ospf_gr_helper_tc7_p1(request): result = verify_ospf_gr_helper(tgen, topo, dut, input_dict, expected=False) assert ( result is not True - ), "Testcase {} : Failed. DUT entered helper role " " \n Error: {}".format( + ), "Testcase {} : Failed. DUT entered helper role \n Error: {}".format( tc_name, result ) @@ -253,7 +253,7 @@ def test_ospf_gr_helper_tc8_p1(request): ospf_covergence = verify_ospf_neighbor(tgen, topo, lan=True) assert ( ospf_covergence is True - ), "OSPF is not after reset config \n Error:" " {}".format(ospf_covergence) + ), "OSPF is not after reset config \n Error: {}".format(ospf_covergence) ospf_gr_r0 = { "r0": {"ospf": {"graceful-restart": {"helper enable": [], "opaque": True}}} } diff --git a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_asbr_summary_topo1.py b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_asbr_summary_topo1.py index 55166367c1..b0e56e619a 100644 --- a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_asbr_summary_topo1.py +++ b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_asbr_summary_topo1.py @@ -156,7 +156,7 @@ def setup_module(mod): pytest.skip(tgen.errors) # Api call verify whether OSPF is converged ospf_covergence = verify_ospf6_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "setup_module :Failed \n Error: {}".format( ospf_covergence ) @@ -280,7 +280,7 @@ def test_ospfv3_type5_summary_tc42_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) step( "Configure External Route summary in R0 to summarise 5" @@ -314,7 +314,7 @@ def test_ospfv3_type5_summary_tc42_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show the summaries.") input_dict = { @@ -330,9 +330,9 @@ def test_ospfv3_type5_summary_tc42_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6") assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name) - step("Verify that originally advertised routes are withdraw from there" " peer.") + step("Verify that originally advertised routes are withdraw from there peer.") input_dict = { "r0": {"static_routes": [{"network": NETWORK["ipv6"], "next_hop": "blackhole"}]} } @@ -340,7 +340,7 @@ def test_ospfv3_type5_summary_tc42_p0(request): result = verify_ospf6_rib(tgen, dut, input_dict, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( + ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format( tc_name, result ) @@ -349,7 +349,7 @@ def test_ospfv3_type5_summary_tc42_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name) step("Delete the configured summary") ospf_summ_r1 = { @@ -374,7 +374,7 @@ def test_ospfv3_type5_summary_tc42_p0(request): result = verify_ospf6_rib(tgen, dut, input_dict, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( + ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format( tc_name, result ) @@ -383,9 +383,7 @@ def test_ospfv3_type5_summary_tc42_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Summary Route still present in RIB".format( - tc_name - ) + ), "Testcase {} : Failed Error: Summary Route still present in RIB".format(tc_name) step("show ip ospf summary should not have any summary address.") input_dict = { @@ -403,7 +401,7 @@ def test_ospfv3_type5_summary_tc42_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Summary still present in DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary still present in DB".format(tc_name) dut = "r1" step("All 5 routes are advertised after deletion of configured summary.") @@ -414,7 +412,7 @@ def test_ospfv3_type5_summary_tc42_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) step("configure the summary again and delete static routes .") ospf_summ_r1 = { @@ -442,7 +440,7 @@ def test_ospfv3_type5_summary_tc42_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6") assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name) input_dict = { "r0": { @@ -461,7 +459,7 @@ def test_ospfv3_type5_summary_tc42_p0(request): result = verify_ospf6_rib(tgen, dut, input_dict_summary, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( + ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format( tc_name, result ) @@ -470,7 +468,7 @@ def test_ospfv3_type5_summary_tc42_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name) step("Add back static routes.") input_dict_static_rtes = { @@ -488,7 +486,7 @@ def test_ospfv3_type5_summary_tc42_p0(request): result = verify_ospf6_rib(tgen, dut, input_dict_static_rtes, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( + ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format( tc_name, result ) @@ -497,7 +495,7 @@ def test_ospfv3_type5_summary_tc42_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name) input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}} dut = "r1" @@ -508,7 +506,7 @@ def test_ospfv3_type5_summary_tc42_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show configure summaries.") @@ -525,7 +523,7 @@ def test_ospfv3_type5_summary_tc42_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6") assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name) step("Configure new static route which is matching configured summary.") input_dict_static_rtes = { @@ -591,7 +589,7 @@ def test_ospfv3_type5_summary_tc42_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) step("Shut one of the interface") intf = topo["routers"]["r0"]["links"]["r3-link0"]["interface"] @@ -663,7 +661,7 @@ def test_ospfv3_type5_summary_tc42_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6") assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name) input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}} @@ -674,7 +672,7 @@ def test_ospfv3_type5_summary_tc42_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) ospf_summ_r1 = { "r0": { @@ -702,7 +700,7 @@ def test_ospfv3_type5_summary_tc42_p0(request): result = verify_ospf6_rib(tgen, dut, input_dict_summary, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( + ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format( tc_name, result ) @@ -711,7 +709,7 @@ def test_ospfv3_type5_summary_tc42_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name) ospf_summ_r1 = { "r0": { @@ -774,11 +772,9 @@ def test_ospfv3_type5_summary_tc43_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) - step( - "Configure External Route summary in R0 to summarise 5" " routes to one route." - ) + step("Configure External Route summary in R0 to summarise 5 routes to one route.") ospf_summ_r1 = { "r0": { "ospf6": { @@ -804,7 +800,7 @@ def test_ospfv3_type5_summary_tc43_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show the summaries.") input_dict = { @@ -820,7 +816,7 @@ def test_ospfv3_type5_summary_tc43_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6") assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name) step("Change the summary address mask to lower match (ex - 16 to 8)") ospf_summ_r1 = { @@ -855,7 +851,7 @@ def test_ospfv3_type5_summary_tc43_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6") assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name) step( "Verify that external routes(static / connected) are summarised" @@ -871,7 +867,7 @@ def test_ospfv3_type5_summary_tc43_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) step("Change the summary address mask to higher match (ex - 8 to 24)") ospf_summ_r1 = { @@ -899,7 +895,7 @@ def test_ospfv3_type5_summary_tc43_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6") assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name) step( "Verify that external routes(static / connected) are summarised" @@ -920,7 +916,7 @@ def test_ospfv3_type5_summary_tc43_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) step(" Un configure one of the summary address.") ospf_summ_r1 = { @@ -955,7 +951,7 @@ def test_ospfv3_type5_summary_tc43_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) ospf_summ_r1 = { "r0": { @@ -982,7 +978,7 @@ def test_ospfv3_type5_summary_tc43_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) write_test_footer(tc_name) @@ -1030,11 +1026,9 @@ def ospfv3_type5_summary_tc45_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) - step( - "Configure External Route summary in R0 to summarise 5" " routes to one route." - ) + step("Configure External Route summary in R0 to summarise 5 routes to one route.") ospf_summ_r1 = { "r0": { "ospf6": { @@ -1066,7 +1060,7 @@ def ospfv3_type5_summary_tc45_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show the summaries with tag.") input_dict = { @@ -1082,7 +1076,7 @@ def ospfv3_type5_summary_tc45_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6") assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name) step("Delete the configured summary") ospf_summ_r1 = { @@ -1107,7 +1101,7 @@ def ospfv3_type5_summary_tc45_p0(request): result = verify_ospf6_rib(tgen, dut, input_dict, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( + ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format( tc_name, result ) @@ -1116,9 +1110,7 @@ def ospfv3_type5_summary_tc45_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Summary Route still present in RIB".format( - tc_name - ) + ), "Testcase {} : Failed Error: Summary Route still present in RIB".format(tc_name) step("show ip ospf summary should not have any summary address.") input_dict = { @@ -1136,7 +1128,7 @@ def ospfv3_type5_summary_tc45_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Summary still present in DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary still present in DB".format(tc_name) step("Configure Min tag value") ospf_summ_r1 = { @@ -1161,7 +1153,7 @@ def ospfv3_type5_summary_tc45_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show the summaries with tag.") input_dict = { @@ -1177,7 +1169,7 @@ def ospfv3_type5_summary_tc45_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6") assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name) step("Configure Max Tag Value") ospf_summ_r1 = { @@ -1207,7 +1199,7 @@ def ospfv3_type5_summary_tc45_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) step( "Verify that boundary values tags are used for summary route" @@ -1226,7 +1218,7 @@ def ospfv3_type5_summary_tc45_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6") assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name) step("configure new static route with different tag.") input_dict_static_rtes_11 = { @@ -1251,7 +1243,7 @@ def ospfv3_type5_summary_tc45_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( + ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format( tc_name, result ) @@ -1266,7 +1258,7 @@ def ospfv3_type5_summary_tc45_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name) step( "Verify that boundary values tags are used for summary route" @@ -1287,7 +1279,7 @@ def ospfv3_type5_summary_tc45_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name) step("Delete the configured summary address") ospf_summ_r1 = { @@ -1318,7 +1310,7 @@ def ospfv3_type5_summary_tc45_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) step("Verify that summary address is flushed from neighbor.") @@ -1326,7 +1318,7 @@ def ospfv3_type5_summary_tc45_p0(request): result = verify_ospf6_rib(tgen, dut, input_dict_summary, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( + ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format( tc_name, result ) @@ -1335,7 +1327,7 @@ def ospfv3_type5_summary_tc45_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name) step("Configure summary first & then configure matching static route.") @@ -1467,11 +1459,9 @@ def ospfv3_type5_summary_tc45_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) - step( - "Configure External Route summary in R0 to summarise 5" " routes to one route." - ) + step("Configure External Route summary in R0 to summarise 5 routes to one route.") ospf_summ_r1 = { "r0": { "ospf6": { @@ -1503,7 +1493,7 @@ def ospfv3_type5_summary_tc45_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show the summaries with tag.") input_dict = { @@ -1541,7 +1531,7 @@ def ospfv3_type5_summary_tc45_p0(request): result = verify_ospf6_rib(tgen, dut, input_dict, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( + ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format( tc_name, result ) @@ -1550,9 +1540,7 @@ def ospfv3_type5_summary_tc45_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Summary Route still present in RIB".format( - tc_name - ) + ), "Testcase {} : Failed Error: Summary Route still present in RIB".format(tc_name) step("show ip ospf summary should not have any summary address.") input_dict = { @@ -1570,7 +1558,7 @@ def ospfv3_type5_summary_tc45_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Summary still present in DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary still present in DB".format(tc_name) step("Configure Min tag value") ospf_summ_r1 = { @@ -1595,7 +1583,7 @@ def ospfv3_type5_summary_tc45_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show the summaries with tag.") input_dict = { @@ -1611,7 +1599,7 @@ def ospfv3_type5_summary_tc45_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6") assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name) step("Configure Max Tag Value") ospf_summ_r1 = { @@ -1641,7 +1629,7 @@ def ospfv3_type5_summary_tc45_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) step( "Verify that boundary values tags are used for summary route" @@ -1660,7 +1648,7 @@ def ospfv3_type5_summary_tc45_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6") assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name) step("configure new static route with different tag.") input_dict_static_rtes_11 = { @@ -1685,7 +1673,7 @@ def ospfv3_type5_summary_tc45_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( + ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format( tc_name, result ) @@ -1700,7 +1688,7 @@ def ospfv3_type5_summary_tc45_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name) step( "Verify that boundary values tags are used for summary route" @@ -1721,7 +1709,7 @@ def ospfv3_type5_summary_tc45_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name) step("Delete the configured summary address") ospf_summ_r1 = { @@ -1752,7 +1740,7 @@ def ospfv3_type5_summary_tc45_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) step("Verify that summary address is flushed from neighbor.") @@ -1760,7 +1748,7 @@ def ospfv3_type5_summary_tc45_p0(request): result = verify_ospf6_rib(tgen, dut, input_dict_summary, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( + ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format( tc_name, result ) @@ -1769,7 +1757,7 @@ def ospfv3_type5_summary_tc45_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name) step("Configure summary first & then configure matching static route.") @@ -1853,7 +1841,7 @@ def test_ospfv3_type5_summary_tc46_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) step( "Configure External Route summary in R0 to summarise 5" @@ -1887,7 +1875,7 @@ def test_ospfv3_type5_summary_tc46_p0(request): result = verify_ospf6_rib(tgen, dut, input_dict_summary, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( + ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format( tc_name, result ) @@ -1896,9 +1884,9 @@ def test_ospfv3_type5_summary_tc46_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name) - step("Verify that show ip ospf summary should show the " "configured summaries.") + step("Verify that show ip ospf summary should show the configured summaries.") input_dict = { SUMMARY["ipv6"][0]: { "summaryAddress": SUMMARY["ipv6"][0], @@ -1909,7 +1897,7 @@ def test_ospfv3_type5_summary_tc46_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6") assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name) step("Delete the configured summary") ospf_summ_r1 = { @@ -1936,7 +1924,7 @@ def test_ospfv3_type5_summary_tc46_p0(request): result = verify_ospf6_rib(tgen, dut, input_dict, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( + ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format( tc_name, result ) @@ -1945,9 +1933,7 @@ def test_ospfv3_type5_summary_tc46_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Summary Route still present in RIB".format( - tc_name - ) + ), "Testcase {} : Failed Error: Summary Route still present in RIB".format(tc_name) step("show ip ospf summary should not have any summary address.") input_dict = { @@ -1965,7 +1951,7 @@ def test_ospfv3_type5_summary_tc46_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Summary still present in DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary still present in DB".format(tc_name) step("Reconfigure summary with no advertise.") ospf_summ_r1 = { @@ -1996,7 +1982,7 @@ def test_ospfv3_type5_summary_tc46_p0(request): result = verify_ospf6_rib(tgen, dut, input_dict_summary, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( + ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format( tc_name, result ) @@ -2005,9 +1991,9 @@ def test_ospfv3_type5_summary_tc46_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name) - step("Verify that show ip ospf summary should show the " "configured summaries.") + step("Verify that show ip ospf summary should show the configured summaries.") input_dict = { SUMMARY["ipv6"][0]: { "summaryAddress": SUMMARY["ipv6"][0], @@ -2018,7 +2004,7 @@ def test_ospfv3_type5_summary_tc46_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6") assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name) step( "Change summary address from no advertise to advertise " @@ -2067,7 +2053,7 @@ def test_ospfv3_type5_summary_tc46_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show the summaries.") input_dict = { @@ -2083,9 +2069,9 @@ def test_ospfv3_type5_summary_tc46_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6") assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name) - step("Verify that originally advertised routes are withdraw from there" " peer.") + step("Verify that originally advertised routes are withdraw from there peer.") output = tgen.gears["r0"].vtysh_cmd( "show ipv6 ospf6 database as-external json", isjson=True ) @@ -2101,7 +2087,7 @@ def test_ospfv3_type5_summary_tc46_p0(request): result = verify_ospf6_rib(tgen, dut, input_dict, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( + ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format( tc_name, result ) @@ -2110,7 +2096,7 @@ def test_ospfv3_type5_summary_tc46_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Routes is present in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is present in RIB".format(tc_name) write_test_footer(tc_name) @@ -2157,11 +2143,9 @@ def test_ospfv3_type5_summary_tc48_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) - step( - "Configure External Route summary in R0 to summarise 5" " routes to one route." - ) + step("Configure External Route summary in R0 to summarise 5 routes to one route.") ospf_summ_r1 = { "r0": { @@ -2189,7 +2173,7 @@ def test_ospfv3_type5_summary_tc48_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show the summaries.") input_dict = { @@ -2205,9 +2189,9 @@ def test_ospfv3_type5_summary_tc48_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6") assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name) - step("Verify that originally advertised routes are withdraw from there" " peer.") + step("Verify that originally advertised routes are withdraw from there peer.") input_dict = { "r0": {"static_routes": [{"network": NETWORK["ipv6"], "next_hop": "blackhole"}]} } @@ -2215,7 +2199,7 @@ def test_ospfv3_type5_summary_tc48_p0(request): result = verify_ospf6_rib(tgen, dut, input_dict, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( + ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format( tc_name, result ) @@ -2224,7 +2208,7 @@ def test_ospfv3_type5_summary_tc48_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name) step( "Configure route map and & rule to permit configured summary address," @@ -2287,7 +2271,7 @@ def test_ospfv3_type5_summary_tc48_p0(request): result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) input_dict = { SUMMARY["ipv6"][0]: { @@ -2302,7 +2286,7 @@ def test_ospfv3_type5_summary_tc48_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6") assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name) step("Configure metric type as 1 in route map.") @@ -2339,7 +2323,7 @@ def test_ospfv3_type5_summary_tc48_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6") assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name) step("Un configure metric type from route map.") @@ -2376,7 +2360,7 @@ def test_ospfv3_type5_summary_tc48_p0(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6") assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name) step("Change rule from permit to deny in prefix list.") pfx_list = { @@ -2407,7 +2391,7 @@ def test_ospfv3_type5_summary_tc48_p0(request): result = verify_ospf6_rib(tgen, dut, input_dict_summary, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( + ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format( tc_name, result ) @@ -2416,7 +2400,7 @@ def test_ospfv3_type5_summary_tc48_p0(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name) write_test_footer(tc_name) @@ -2556,7 +2540,7 @@ def test_ospfv3_type5_summary_tc51_p2(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6") assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name) write_test_footer(tc_name) @@ -2603,11 +2587,9 @@ def test_ospfv3_type5_summary_tc49_p2(request): result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) - step( - "Configure External Route summary in R0 to summarise 5" " routes to one route." - ) + step("Configure External Route summary in R0 to summarise 5 routes to one route.") ospf_summ_r1 = { "r0": { @@ -2635,7 +2617,7 @@ def test_ospfv3_type5_summary_tc49_p2(request): result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show the summaries.") input_dict = { @@ -2651,9 +2633,9 @@ def test_ospfv3_type5_summary_tc49_p2(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6") assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name) - step("Verify that originally advertised routes are withdraw from there" " peer.") + step("Verify that originally advertised routes are withdraw from there peer.") input_dict = { "r0": {"static_routes": [{"network": NETWORK["ipv6"], "next_hop": "blackhole"}]} } @@ -2661,7 +2643,7 @@ def test_ospfv3_type5_summary_tc49_p2(request): result = verify_ospf6_rib(tgen, dut, input_dict, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( + ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format( tc_name, result ) @@ -2670,7 +2652,7 @@ def test_ospfv3_type5_summary_tc49_p2(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name) step("Reload the FRR router") # stop/start -> restart FRR router and verify @@ -2691,7 +2673,7 @@ def test_ospfv3_type5_summary_tc49_p2(request): result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol) assert ( result is True - ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name) step("Verify that show ip ospf summary should show the summaries.") input_dict = { @@ -2707,9 +2689,9 @@ def test_ospfv3_type5_summary_tc49_p2(request): result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6") assert ( result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) + ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name) - step("Verify that originally advertised routes are withdraw from there" " peer.") + step("Verify that originally advertised routes are withdraw from there peer.") input_dict = { "r0": {"static_routes": [{"network": NETWORK["ipv6"], "next_hop": "blackhole"}]} } @@ -2717,7 +2699,7 @@ def test_ospfv3_type5_summary_tc49_p2(request): result = verify_ospf6_rib(tgen, dut, input_dict, expected=False) assert ( result is not True - ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format( + ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format( tc_name, result ) @@ -2726,7 +2708,7 @@ def test_ospfv3_type5_summary_tc49_p2(request): ) assert ( result is not True - ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name) + ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name) write_test_footer(tc_name) diff --git a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_authentication.py b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_authentication.py index 2f90c98785..58608e249b 100644 --- a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_authentication.py +++ b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_authentication.py @@ -111,7 +111,7 @@ def setup_module(mod): pytest.skip(tgen.errors) ospf6_covergence = verify_ospf6_neighbor(tgen, topo) - assert ospf6_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf6_covergence is True, "setup_module :Failed \n Error: {}".format( ospf6_covergence ) @@ -182,7 +182,7 @@ def test_ospf6_auth_trailer_tc1_md5(request): ospf6_covergence = verify_ospf6_neighbor( tgen, topo, dut=dut, expected=False, retry_timeout=3 ) - assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -214,7 +214,7 @@ def test_ospf6_auth_trailer_tc1_md5(request): dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) - assert ospf6_covergence is True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -244,7 +244,7 @@ def test_ospf6_auth_trailer_tc1_md5(request): ospf6_covergence = verify_ospf6_neighbor( tgen, topo, dut=dut, expected=False, retry_timeout=5 ) - assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -272,7 +272,7 @@ def test_ospf6_auth_trailer_tc1_md5(request): dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) - assert ospf6_covergence is True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -287,7 +287,7 @@ def test_ospf6_auth_trailer_tc1_md5(request): "show ip ospf6 neighbor cmd." ) ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut, expected=False) - assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -301,7 +301,7 @@ def test_ospf6_auth_trailer_tc1_md5(request): dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) - assert ospf6_covergence is True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -348,7 +348,7 @@ def test_ospf6_auth_trailer_tc2_sha256(request): ospf6_covergence = verify_ospf6_neighbor( tgen, topo, dut=dut, expected=False, retry_timeout=3 ) - assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -380,7 +380,7 @@ def test_ospf6_auth_trailer_tc2_sha256(request): dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) - assert ospf6_covergence is True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -410,7 +410,7 @@ def test_ospf6_auth_trailer_tc2_sha256(request): ospf6_covergence = verify_ospf6_neighbor( tgen, topo, dut=dut, expected=False, retry_timeout=5 ) - assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -438,7 +438,7 @@ def test_ospf6_auth_trailer_tc2_sha256(request): dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) - assert ospf6_covergence is True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -453,7 +453,7 @@ def test_ospf6_auth_trailer_tc2_sha256(request): "show ip ospf6 neighbor cmd." ) ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut, expected=False) - assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -467,7 +467,7 @@ def test_ospf6_auth_trailer_tc2_sha256(request): dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) - assert ospf6_covergence is True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -531,7 +531,7 @@ def test_ospf6_auth_trailer_tc3_keychain_md5(request): ospf6_covergence = verify_ospf6_neighbor( tgen, topo, dut=dut, expected=False, retry_timeout=3 ) - assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -561,7 +561,7 @@ def test_ospf6_auth_trailer_tc3_keychain_md5(request): dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) - assert ospf6_covergence is True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -580,7 +580,7 @@ def test_ospf6_auth_trailer_tc3_keychain_md5(request): ospf6_covergence = verify_ospf6_neighbor( tgen, topo, dut=dut, expected=False, retry_timeout=5 ) - assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -606,7 +606,7 @@ def test_ospf6_auth_trailer_tc3_keychain_md5(request): dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) - assert ospf6_covergence is True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -621,7 +621,7 @@ def test_ospf6_auth_trailer_tc3_keychain_md5(request): "show ip ospf6 neighbor cmd." ) ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut, expected=False) - assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -635,7 +635,7 @@ def test_ospf6_auth_trailer_tc3_keychain_md5(request): dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) - assert ospf6_covergence is True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -699,7 +699,7 @@ def test_ospf6_auth_trailer_tc4_keychain_sha256(request): ospf6_covergence = verify_ospf6_neighbor( tgen, topo, dut=dut, expected=False, retry_timeout=3 ) - assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -729,7 +729,7 @@ def test_ospf6_auth_trailer_tc4_keychain_sha256(request): dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) - assert ospf6_covergence is True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -748,7 +748,7 @@ def test_ospf6_auth_trailer_tc4_keychain_sha256(request): ospf6_covergence = verify_ospf6_neighbor( tgen, topo, dut=dut, expected=False, retry_timeout=5 ) - assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -774,7 +774,7 @@ def test_ospf6_auth_trailer_tc4_keychain_sha256(request): dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) - assert ospf6_covergence is True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -789,7 +789,7 @@ def test_ospf6_auth_trailer_tc4_keychain_sha256(request): "show ip ospf6 neighbor cmd." ) ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut, expected=False) - assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -803,7 +803,7 @@ def test_ospf6_auth_trailer_tc4_keychain_sha256(request): dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) - assert ospf6_covergence is True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -850,7 +850,7 @@ def test_ospf6_auth_trailer_tc5_md5_keymissmatch(request): ospf6_covergence = verify_ospf6_neighbor( tgen, topo, dut=dut, expected=False, retry_timeout=3 ) - assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -887,7 +887,7 @@ def test_ospf6_auth_trailer_tc5_md5_keymissmatch(request): ospf6_covergence = verify_ospf6_neighbor( tgen, topo, dut=dut, expected=False, retry_timeout=3 ) - assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -919,7 +919,7 @@ def test_ospf6_auth_trailer_tc5_md5_keymissmatch(request): dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) - assert ospf6_covergence is True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -966,7 +966,7 @@ def test_ospf6_auth_trailer_tc6_sha256_mismatch(request): ospf6_covergence = verify_ospf6_neighbor( tgen, topo, dut=dut, expected=False, retry_timeout=3 ) - assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -998,7 +998,7 @@ def test_ospf6_auth_trailer_tc6_sha256_mismatch(request): ospf6_covergence = verify_ospf6_neighbor( tgen, topo, dut=dut, expected=False, retry_timeout=3 ) - assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -1030,7 +1030,7 @@ def test_ospf6_auth_trailer_tc6_sha256_mismatch(request): dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) - assert ospf6_covergence is True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -1102,7 +1102,7 @@ def test_ospf6_auth_trailer_tc7_keychain_md5_missmatch(request): ospf6_covergence = verify_ospf6_neighbor( tgen, topo, dut=dut, expected=False, retry_timeout=3 ) - assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -1132,7 +1132,7 @@ def test_ospf6_auth_trailer_tc7_keychain_md5_missmatch(request): ospf6_covergence = verify_ospf6_neighbor( tgen, topo, dut=dut, expected=False, retry_timeout=3 ) - assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -1162,7 +1162,7 @@ def test_ospf6_auth_trailer_tc7_keychain_md5_missmatch(request): dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) - assert ospf6_covergence is True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -1234,7 +1234,7 @@ def test_ospf6_auth_trailer_tc8_keychain_sha256_missmatch(request): ospf6_covergence = verify_ospf6_neighbor( tgen, topo, dut=dut, expected=False, retry_timeout=3 ) - assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -1264,7 +1264,7 @@ def test_ospf6_auth_trailer_tc8_keychain_sha256_missmatch(request): ospf6_covergence = verify_ospf6_neighbor( tgen, topo, dut=dut, expected=False, retry_timeout=3 ) - assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -1294,7 +1294,7 @@ def test_ospf6_auth_trailer_tc8_keychain_sha256_missmatch(request): dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) - assert ospf6_covergence is True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -1342,7 +1342,7 @@ def test_ospf6_auth_trailer_tc9_keychain_not_configured(request): ospf6_covergence = verify_ospf6_neighbor( tgen, topo, dut=dut, expected=False, retry_timeout=3 ) - assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -1372,7 +1372,7 @@ def test_ospf6_auth_trailer_tc9_keychain_not_configured(request): ospf6_covergence = verify_ospf6_neighbor( tgen, topo, dut=dut, expected=False, retry_timeout=3 ) - assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is not True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) @@ -1402,7 +1402,7 @@ def test_ospf6_auth_trailer_tc10_no_auth_trailer(request): dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) - assert ospf6_covergence is True, "Testcase {} :Failed \n Error:" " {}".format( + assert ospf6_covergence is True, "Testcase {} :Failed \n Error: {}".format( tc_name, ospf6_covergence ) diff --git a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_ecmp.py b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_ecmp.py index 472364e84f..0c1e3fa43e 100644 --- a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_ecmp.py +++ b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_ecmp.py @@ -115,7 +115,7 @@ def setup_module(mod): pytest.skip(tgen.errors) ospf_covergence = verify_ospf6_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "setup_module :Failed \n Error: {}".format( ospf_covergence ) @@ -257,7 +257,7 @@ def test_ospfv3_ecmp_tc16_p0(request): step("Verify that OSPF is up with 8 neighborship sessions.") dut = "r1" ospf_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error: {}".format( ospf_covergence ) @@ -352,7 +352,7 @@ def test_ospfv3_ecmp_tc16_p0(request): step("Verify that OSPF is up with 8 neighborship sessions.") dut = "r1" ospf_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error: {}".format( ospf_covergence ) @@ -390,7 +390,7 @@ def test_ospfv3_ecmp_tc17_p0(request): step("Verify that OSPF is up with 2 neighborship sessions.") dut = "r1" ospf_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error: {}".format( ospf_covergence ) diff --git a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_ecmp_lan.py b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_ecmp_lan.py index 6b3e16965c..7c6773260e 100644 --- a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_ecmp_lan.py +++ b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_ecmp_lan.py @@ -128,7 +128,7 @@ def setup_module(mod): pytest.skip(tgen.errors) # Api call verify whether OSPF is converged ospf_covergence = verify_ospf6_neighbor(tgen, topo, lan=True) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "setup_module :Failed \n Error: {}".format( ospf_covergence ) @@ -282,7 +282,7 @@ def test_ospfv3_lan_ecmp_tc18_p0(request): step("Verify that OSPF is up with 8 neighborship sessions.") ospf_covergence = verify_ospf6_neighbor(tgen, topo, lan=True) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error: {}".format( ospf_covergence ) @@ -343,7 +343,7 @@ def test_ospfv3_lan_ecmp_tc18_p0(request): dut = "r0" ospf_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut, lan=True) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error: {}".format( ospf_covergence ) @@ -352,7 +352,7 @@ def test_ospfv3_lan_ecmp_tc18_p0(request): dut = "r2" ospf_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut, lan=True) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error: {}".format( ospf_covergence ) diff --git a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_nssa.py b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_nssa.py index c0d8d718cc..dc4ce88830 100644 --- a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_nssa.py +++ b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_nssa.py @@ -73,7 +73,7 @@ def setup_module(mod): pytest.skip(tgen.errors) result = verify_ospf6_neighbor(tgen, topo) - assert result is True, "setup_module: Failed \n Error:" " {}".format(result) + assert result is True, "setup_module: Failed \n Error: {}".format(result) logger.info("Running setup_module() done") diff --git a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_nssa2.py b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_nssa2.py index 138112775f..90548fb5ce 100644 --- a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_nssa2.py +++ b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_nssa2.py @@ -138,7 +138,7 @@ def setup_module(mod): # Api call verify whether OSPF is converged ospf_covergence = verify_ospf6_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "setup_module :Failed \n Error: {}".format( ospf_covergence ) @@ -277,7 +277,7 @@ def test_ospfv3_nssa_tc26_p0(request): result = verify_ospf6_neighbor(tgen, topo, dut="r2", expected=False) assert ( result is not True - ), "Testcase {} : Failed \n Nbrs are not down" "Error: {}".format(tc_name, result) + ), "Testcase {} : Failed \n Nbrs are not down Error: {}".format(tc_name, result) step("Now configure area 0 on interface of r1 connecting to r2.") @@ -349,7 +349,7 @@ def test_ospfv3_nssa_tc26_p0(request): result = verify_ospf6_neighbor(tgen, topo, dut="r2", expected=False) assert ( result is not True - ), "Testcase {} : Failed \n Nbrs are not down" "Error: {}".format(tc_name, result) + ), "Testcase {} : Failed \n Nbrs are not down Error: {}".format(tc_name, result) step("Now configure area 2 on interface of r1 connecting to r2.") @@ -471,7 +471,7 @@ def test_ospfv3_learning_tc15_p0(request): result = verify_ospf6_neighbor(tgen, topo) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) - step("Change area 1 as non nssa area (on the fly changing area" " type on DUT).") + step("Change area 1 as non nssa area (on the fly changing area type on DUT).") for rtr in ["r1", "r2", "r3"]: input_dict = { diff --git a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_routemaps.py b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_routemaps.py index b2cd0da24e..069806a3ef 100644 --- a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_routemaps.py +++ b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_routemaps.py @@ -129,7 +129,7 @@ def setup_module(mod): pytest.skip(tgen.errors) ospf_covergence = verify_ospf6_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "setup_module :Failed \n Error: {}".format( ospf_covergence ) @@ -212,9 +212,7 @@ def test_ospfv3_routemaps_functionality_tc19_p0(request): result = create_router_ospf(tgen, topo, ospf_red_r1) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) - step( - "Create prefix-list in R0 to permit 10.0.20.1/32 prefix &" " deny 10.0.20.2/32" - ) + step("Create prefix-list in R0 to permit 10.0.20.1/32 prefix & deny 10.0.20.2/32") # Create ip prefix list pfx_list = { @@ -686,7 +684,7 @@ def test_ospfv3_routemaps_functionality_tc25_p0(request): # Api call verify whether OSPF is converged ospf_covergence = verify_ospf6_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error: {}".format( ospf_covergence ) @@ -1078,7 +1076,7 @@ def test_ospfv3_routemaps_functionality_tc24_p0(request): result = verify_prefix_lists(tgen, pfx_list) assert ( result is not True - ), "Testcase {} : Failed \n Prefix list not " "present. Error: {}".format( + ), "Testcase {} : Failed \n Prefix list not present. Error: {}".format( tc_name, result ) @@ -1147,7 +1145,7 @@ def test_ospfv3_routemaps_functionality_tc24_p0(request): result = verify_prefix_lists(tgen, pfx_list) assert ( result is not True - ), "Testcase {} : Failed \n Prefix list not " "present. Error: {}".format( + ), "Testcase {} : Failed \n Prefix list not present. Error: {}".format( tc_name, result ) diff --git a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_rte_calc.py b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_rte_calc.py index 9e7f112efb..645dea8dec 100644 --- a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_rte_calc.py +++ b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_rte_calc.py @@ -120,7 +120,7 @@ def setup_module(mod): pytest.skip(tgen.errors) ospf_covergence = verify_ospf6_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "setup_module :Failed \n Error: {}".format( ospf_covergence ) @@ -256,7 +256,7 @@ def test_ospfv3_redistribution_tc5_p0(request): step("Verify that OSPF neighbors are FULL.") ospf_covergence = verify_ospf6_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error: {}".format( ospf_covergence ) @@ -616,7 +616,7 @@ def test_ospfv3_redistribution_tc8_p1(request): step("Verify that OSPF neighbours are reset and forms new adjacencies.") # Api call verify whether OSPF is converged ospf_covergence = verify_ospf6_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error: {}".format( ospf_covergence ) diff --git a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_single_area.py b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_single_area.py index 5d5ba1480f..7199f160fe 100644 --- a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_single_area.py +++ b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_single_area.py @@ -114,7 +114,7 @@ def setup_module(mod): pytest.skip(tgen.errors) ospf_covergence = verify_ospf6_neighbor(tgen, topo) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "setup_module :Failed \n Error: {}".format( ospf_covergence ) @@ -460,7 +460,7 @@ def test_ospfv3_hello_tc10_p0(request): step("verify that ospf neighbours are full") ospf_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error: {}".format( ospf_covergence ) @@ -513,7 +513,7 @@ def test_ospfv3_hello_tc10_p0(request): step("verify that ospf neighbours are full") ospf_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error: {}".format( ospf_covergence ) @@ -566,7 +566,7 @@ def test_ospfv3_hello_tc10_p0(request): step("verify that ospf neighbours are full") ospf_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error: {}".format( ospf_covergence ) @@ -618,7 +618,7 @@ def test_ospfv3_hello_tc10_p0(request): step("verify that ospf neighbours are full") ospf_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) - assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( + assert ospf_covergence is True, "Testcase Failed \n Error: {}".format( ospf_covergence ) @@ -709,9 +709,7 @@ def test_ospfv3_hello_tc10_p0(request): result = create_interfaces_cfg(tgen, topo1) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) - step( - "Verify that timer value is deleted from intf & " "set to default value 40 sec." - ) + step("Verify that timer value is deleted from intf & set to default value 40 sec.") input_dict = {"r1": {"links": {"r0": {"ospf6": {"timerIntervalsConfigHello": 10}}}}} dut = "r1" result = verify_ospf6_interface(tgen, topo, dut=dut, input_dict=input_dict) @@ -763,7 +761,7 @@ def test_ospfv3_dead_tc11_p0(request): result = verify_ospf6_interface(tgen, topo, dut=dut, input_dict=input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) - step("modify dead interval from default value to r1" "dead interval timer on r2") + step("modify dead interval from default value to r1 dead interval timer on r2") topo1 = { "r0": { @@ -799,7 +797,7 @@ def test_ospfv3_dead_tc11_p0(request): # reconfiguring deleted ospf process by resetting the configs. reset_config_on_routers(tgen) - step("reconfigure the default dead interval timer value to " "default on r1 and r2") + step("reconfigure the default dead interval timer value to default on r1 and r2") topo1 = { "r0": { "links": { @@ -920,9 +918,7 @@ def test_ospfv3_dead_tc11_p0(request): result = create_interfaces_cfg(tgen, topo1) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) - step( - "Verify that timer value is deleted from intf & " "set to default value 40 sec." - ) + step("Verify that timer value is deleted from intf & set to default value 40 sec.") input_dict = {"r1": {"links": {"r0": {"ospf6": {"timerIntervalsConfigDead": 40}}}}} dut = "r1" result = verify_ospf6_interface(tgen, topo, dut=dut, input_dict=input_dict) @@ -967,18 +963,14 @@ def test_ospfv3_tc4_mtu_ignore_p0(request): clear_ospf(tgen, "r0", ospf="ospf6") clear_ospf(tgen, "r1", ospf="ospf6") - step( - "Verify that OSPF neighborship between R0 and R1 is stuck in Exstart" " State." - ) + step("Verify that OSPF neighborship between R0 and R1 is stuck in Exstart State.") result = verify_ospf6_neighbor(tgen, topo, expected=False) assert result is not True, ( "Testcase {} : Failed \n OSPF nbrs are Full " "instead of Exstart. Error: {}".format(tc_name, result) ) - step( - "Verify that configured MTU value is updated in the show ip " "ospf interface." - ) + step("Verify that configured MTU value is updated in the show ip ospf interface.") dut = "r0" input_dict = {"r0": {"links": {"r1": {"ospf6": {"interfaceMtu": 1400}}}}} @@ -1035,9 +1027,7 @@ def test_ospfv3_tc4_mtu_ignore_p0(request): clear_ospf(tgen, "r0", ospf="ospf6") - step( - "Verify that OSPF neighborship between R0 and R1 is stuck in Exstart" " State." - ) + step("Verify that OSPF neighborship between R0 and R1 is stuck in Exstart State.") result = verify_ospf6_neighbor(tgen, topo, expected=False) assert result is not True, ( "Testcase {} : Failed \n OSPF nbrs are Full " @@ -1054,9 +1044,7 @@ def test_ospfv3_tc4_mtu_ignore_p0(request): result = verify_ospf6_neighbor(tgen, topo) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) - step( - "Configure ospf interface with jumbo MTU (9216)." "Reset ospf neighbors on R0." - ) + step("Configure ospf interface with jumbo MTU (9216). Reset ospf neighbors on R0.") rtr0.run("ifconfig {} mtu 9216".format(r0_r1_intf)) rtr1.run("ifconfig {} mtu 9216".format(r1_r0_intf)) @@ -1091,53 +1079,6 @@ def test_ospfv3_show_p1(request): result = create_debug_log_config(tgen, input_dict) - # Code coverage steps #Do Not upstream - input_dict_config = { - "r1": { - "raw_config": [ - "end", - "debug ospf6 event", - "debug ospf6 gr helper", - "debug ospf6 ism events", - "debug ospf6 ism status", - "debug ospf6 ism timers", - "debug ospf6 nsm events", - "debug ospf6 nsm status", - "debug ospf6 nsm timers ", - "debug ospf6 nssa", - "debug ospf6 lsa aggregate", - "debug ospf6 lsa flooding ", - "debug ospf6 lsa generate", - "debug ospf6 lsa install ", - "debug ospf6 lsa refresh", - "debug ospf6 packet all detail", - "debug ospf6 packet all recv", - "debug ospf6 packet all send", - "debug ospf6 packet dd detail", - "debug ospf6 packet dd recv", - "debug ospf6 packet dd send ", - "debug ospf6 packet hello detail", - "debug ospf6 packet hello recv", - "debug ospf6 packet hello send", - "debug ospf6 packet ls-ack detail", - "debug ospf6 packet ls-ack recv", - "debug ospf6 packet ls-ack send", - "debug ospf6 packet ls-request detail", - "debug ospf6 packet ls-request recv", - "debug ospf6 packet ls-request send", - "debug ospf6 packet ls-update detail", - "debug ospf6 packet ls-update recv", - "debug ospf6 packet ls-update send", - "debug ospf6 sr", - "debug ospf6 te ", - "debug ospf6 zebra interface", - "debug ospf6 zebra redistribute", - ] - } - } - - apply_raw_config(tgen, input_dict_config) - for rtr in topo["routers"]: clear_ospf(tgen, rtr, ospf="ospf6") @@ -1234,7 +1175,7 @@ def ospfv3_router_id_tc14_p2(request): clear_ospf(tgen, rtr, ospf="ospf6") ospf_covergence = verify_ospf6_neighbor(tgen, topo1) - assert ospf_covergence is True, "OSPF NBRs not up.Failed \n Error:" " {}".format( + assert ospf_covergence is True, "OSPF NBRs not up.Failed \n Error: {}".format( ospf_covergence ) @@ -1260,9 +1201,9 @@ def ospfv3_router_id_tc14_p2(request): assert result is True, "Testcase : Failed \n Error: {}".format(result) ospf_covergence = verify_ospf6_neighbor(tgen, topo, expected=False) - assert ( - ospf_covergence is not True - ), "OSPF NBRs are up.Failed \n Error:" " {}".format(ospf_covergence) + assert ospf_covergence is not True, "OSPF NBRs are up.Failed \n Error: {}".format( + ospf_covergence + ) topo1 = {} topo1 = deepcopy(topo) @@ -1305,7 +1246,7 @@ def ospfv3_router_id_tc14_p2(request): topo1["routers"]["r3"]["ospf6"]["router_id"] = "1.1.1.4" ospf_covergence = verify_ospf6_neighbor(tgen, topo1) - assert ospf_covergence is True, "OSPF NBRs not up.Failed \n Error:" " {}".format( + assert ospf_covergence is True, "OSPF NBRs not up.Failed \n Error: {}".format( ospf_covergence ) @@ -1313,7 +1254,7 @@ def ospfv3_router_id_tc14_p2(request): reset_config_on_routers(tgen) ospf_covergence = verify_ospf6_neighbor(tgen, topo) - assert ospf_covergence is True, "OSPF NBRs not up.Failed \n Error:" " {}".format( + assert ospf_covergence is True, "OSPF NBRs not up.Failed \n Error: {}".format( ospf_covergence ) diff --git a/vrrpd/vrrp_main.c b/vrrpd/vrrp_main.c index 32ee4bb136..5245c74689 100644 --- a/vrrpd/vrrp_main.c +++ b/vrrpd/vrrp_main.c @@ -6,11 +6,12 @@ */ #include <zebra.h> +#include <getopt.h> + #include <lib/version.h> #include "lib/command.h" #include "lib/filter.h" -#include "lib/getopt.h" #include "lib/if.h" #include "lib/libfrr.h" #include "lib/log.h" diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 0a164ec16d..4d52bd036d 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -49,19 +49,6 @@ char *vtysh_pager_name = NULL; /* VTY should add timestamp */ bool vtysh_add_timestamp; -/* VTY shell client structure */ -struct vtysh_client { - int fd; - const char *name; - int flag; - char path[MAXPATHLEN]; - struct vtysh_client *next; - - struct event *log_reader; - int log_fd; - uint32_t lost_msgs; -}; - static bool stderr_tty; static bool stderr_stdout_same; @@ -119,6 +106,10 @@ static void vtysh_pager_envdef(bool fallback) /* --- */ +/* + * When updating this array, remember to change the array size here and in + * vtysh.h + */ struct vtysh_client vtysh_client[] = { {.name = "mgmtd", .flag = VTYSH_MGMTD}, {.name = "zebra", .flag = VTYSH_ZEBRA}, @@ -3545,7 +3536,7 @@ DEFUN (vtysh_copy_to_running, int ret; const char *fname = argv[1]->arg; - ret = vtysh_read_config(fname, true); + ret = vtysh_apply_config(fname, true, false); /* Return to enable mode - the 'read_config' api leaves us up a level */ vtysh_execute_no_pager("enable"); diff --git a/vtysh/vtysh.h b/vtysh/vtysh.h index cb6357f5e6..1c2cca9d90 100644 --- a/vtysh/vtysh.h +++ b/vtysh/vtysh.h @@ -98,7 +98,7 @@ void config_add_line(struct list *, const char *); int vtysh_mark_file(const char *filename); -int vtysh_read_config(const char *filename, bool dry_run); +int vtysh_apply_config(const char *config_file_path, bool dry_run, bool fork); int vtysh_write_config_integrated(void); void vtysh_config_parse_line(void *, const char *); @@ -119,4 +119,18 @@ extern int user_mode; extern bool vtysh_add_timestamp; +struct vtysh_client { + int fd; + const char *name; + int flag; + char path[MAXPATHLEN]; + struct vtysh_client *next; + + struct event *log_reader; + int log_fd; + uint32_t lost_msgs; +}; + +extern struct vtysh_client vtysh_client[22]; + #endif /* VTYSH_H */ diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c index 905761a011..2949faa427 100644 --- a/vtysh/vtysh_config.c +++ b/vtysh/vtysh_config.c @@ -4,6 +4,7 @@ */ #include <zebra.h> +#include <sys/wait.h> #include "command.h" #include "linklist.h" @@ -625,18 +626,20 @@ static int vtysh_read_file(FILE *confp, bool dry_run) return (ret); } -/* Read up configuration file from config_default_dir. */ -int vtysh_read_config(const char *config_default_dir, bool dry_run) +/* + * Read configuration file and send it to all connected daemons + */ +static int vtysh_read_config(const char *config_file_path, bool dry_run) { FILE *confp = NULL; bool save; int ret; - confp = fopen(config_default_dir, "r"); + confp = fopen(config_file_path, "r"); if (confp == NULL) { fprintf(stderr, "%% Can't open configuration file %s due to '%s'.\n", - config_default_dir, safe_strerror(errno)); + config_file_path, safe_strerror(errno)); return CMD_ERR_NO_FILE; } @@ -648,7 +651,103 @@ int vtysh_read_config(const char *config_default_dir, bool dry_run) vtysh_add_timestamp = save; - return (ret); + return ret; +} + +int vtysh_apply_config(const char *config_file_path, bool dry_run, bool do_fork) +{ + /* + * We need to apply the whole config file to all daemons. Instead of + * having one client talk to N daemons, we fork N times and let each + * child handle one daemon. + */ + pid_t fork_pid = getpid(); + int status = 0; + int ret; + int my_client_type; + char my_client[64]; + + if (do_fork) { + for (unsigned int i = 0; i < array_size(vtysh_client); i++) { + /* Store name of client this fork will handle */ + strlcpy(my_client, vtysh_client[i].name, + sizeof(my_client)); + my_client_type = vtysh_client[i].flag; + fork_pid = fork(); + + /* If child, break */ + if (fork_pid == 0) + break; + } + + /* parent, wait for children */ + if (fork_pid != 0) { + int keep_status = 0; + + fprintf(stdout, + "Waiting for children to finish applying config...\n"); + while (wait(&status) > 0) { + if (!keep_status && WEXITSTATUS(status)) + keep_status = WEXITSTATUS(status); + } + + /* + * This will return the first status received + * that failed( if that happens ). This is + * good enough for the moment + */ + return keep_status; + } + + /* + * children, grow up to be cowboys + */ + for (unsigned int i = 0; i < array_size(vtysh_client); i++) { + if (my_client_type != vtysh_client[i].flag) { + struct vtysh_client *cl; + + /* + * If this is a client we aren't responsible + * for, disconnect + */ + for (cl = &vtysh_client[i]; cl; cl = cl->next) { + if (cl->fd >= 0) + close(cl->fd); + cl->fd = -1; + } + } else if (vtysh_client[i].fd == -1 && + vtysh_client[i].next == NULL) { + /* + * If this is the client we are responsible + * for, but we aren't already connected to that + * client, that means the client isn't up in + * the first place and we can exit early + */ + exit(0); + } + } + + fprintf(stdout, "[%d|%s] sending configuration\n", getpid(), + my_client); + } + + ret = vtysh_read_config(config_file_path, dry_run); + + if (ret) { + if (do_fork) + fprintf(stderr, + "[%d|%s] Configuration file[%s] processing failure: %d\n", + getpid(), my_client, frr_config, ret); + else + fprintf(stderr, + "Configuration file[%s] processing failure: %d\n", + frr_config, ret); + } else if (do_fork) { + fprintf(stderr, "[%d|%s] done\n", getpid(), my_client); + exit(0); + } + + return ret; } /* We don't write vtysh specific into file from vtysh. vtysh.conf should diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c index c22889a4f6..860d79d5f9 100644 --- a/vtysh/vtysh_main.c +++ b/vtysh/vtysh_main.c @@ -7,7 +7,6 @@ #include <sys/un.h> #include <setjmp.h> -#include <sys/wait.h> #include <pwd.h> #include <sys/file.h> #include <unistd.h> @@ -178,6 +177,8 @@ static void usage(int status) "-u --user Run as an unprivileged user\n" "-w, --writeconfig Write integrated config (frr.conf) and exit\n" "-H, --histfile Override history file\n" + "-t, --timestamp Print a timestamp before going to shell or reading the configuration\n" + " --no-fork Don't fork clients to handle daemons (slower for large configs)\n" "-h, --help Display this help and exit\n\n" "Note that multiple commands may be executed from the command\n" "line by passing multiple -c args, or by embedding linefeed\n" @@ -191,6 +192,7 @@ static void usage(int status) /* VTY shell options, we use GNU getopt library. */ #define OPTION_VTYSOCK 1000 #define OPTION_CONFDIR 1001 +#define OPTION_NOFORK 1002 struct option longopts[] = { {"boot", no_argument, NULL, 'b'}, /* For compatibility with older zebra/quagga versions */ @@ -210,6 +212,7 @@ struct option longopts[] = { {"pathspace", required_argument, NULL, 'N'}, {"user", no_argument, NULL, 'u'}, {"timestamp", no_argument, NULL, 't'}, + {"no-fork", no_argument, NULL, OPTION_NOFORK}, {0}}; bool vtysh_loop_exited; @@ -321,6 +324,7 @@ int main(int argc, char **argv, char **env) int dryrun = 0; int boot_flag = 0; bool ts_flag = false; + bool no_fork = false; const char *daemon_name = NULL; const char *inputfile = NULL; struct cmd_rec { @@ -392,6 +396,9 @@ int main(int argc, char **argv, char **env) ditch_suid = 1; /* option disables SUID */ snprintf(sysconfdir, sizeof(sysconfdir), "%s/", optarg); break; + case OPTION_NOFORK: + no_fork = true; + break; case 'N': if (strchr(optarg, '/') || strchr(optarg, '.')) { fprintf(stderr, @@ -440,6 +447,10 @@ int main(int argc, char **argv, char **env) } } + /* No need for forks if we're talking to 1 daemon */ + if (daemon_name) + no_fork = true; + if (ditch_suid) { elevuid = realuid; elevgid = realgid; @@ -483,7 +494,7 @@ int main(int argc, char **argv, char **env) /* Read vtysh configuration file before connecting to daemons. * (file may not be readable to calling user in SUID mode) */ suid_on(); - vtysh_read_config(vtysh_config, dryrun); + vtysh_apply_config(vtysh_config, dryrun, false); suid_off(); } /* Error code library system */ @@ -502,9 +513,9 @@ int main(int argc, char **argv, char **env) /* Start execution only if not in dry-run mode */ if (dryrun && !cmd) { if (inputfile) { - ret = vtysh_read_config(inputfile, dryrun); + ret = vtysh_apply_config(inputfile, dryrun, false); } else { - ret = vtysh_read_config(frr_config, dryrun); + ret = vtysh_apply_config(frr_config, dryrun, false); } exit(ret); @@ -583,10 +594,17 @@ int main(int argc, char **argv, char **env) return vtysh_write_config_integrated(); } - if (inputfile) { + if (boot_flag) + inputfile = frr_config; + + if (inputfile || boot_flag) { vtysh_flock_config(inputfile); - ret = vtysh_read_config(inputfile, dryrun); + ret = vtysh_apply_config(inputfile, dryrun, !no_fork); vtysh_unflock_config(); + + if (no_error) + ret = 0; + exit(ret); } @@ -703,23 +721,6 @@ int main(int argc, char **argv, char **env) exit(0); } - /* Boot startup configuration file. */ - if (boot_flag) { - vtysh_flock_config(frr_config); - ret = vtysh_read_config(frr_config, dryrun); - vtysh_unflock_config(); - if (ret) { - fprintf(stderr, - "Configuration file[%s] processing failure: %d\n", - frr_config, ret); - if (no_error) - exit(0); - else - exit(ret); - } else - exit(0); - } - vtysh_readline_init(); vty_hello(vty); diff --git a/zebra/main.c b/zebra/main.c index ba43ae910b..78932bfced 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -175,11 +175,6 @@ static void sigint(void) if (zrouter.lsp_process_q) work_queue_free_and_null(&zrouter.lsp_process_q); - vrf_terminate(); - - ns_walk_func(zebra_ns_early_shutdown, NULL, NULL); - zebra_ns_notify_close(); - access_list_reset(); prefix_list_reset(); /* @@ -207,6 +202,11 @@ void zebra_finalize(struct event *dummy) { zlog_info("Zebra final shutdown"); + vrf_terminate(); + + ns_walk_func(zebra_ns_early_shutdown, NULL, NULL); + zebra_ns_notify_close(); + /* Stop dplane thread and finish any cleanup */ zebra_dplane_shutdown(); |
