diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/lib/cli/test_commands.c | 3 | ||||
| -rw-r--r-- | tests/lib/cxxcompat.c | 2 | ||||
| -rw-r--r-- | tests/lib/test_timer_correctness.c | 1 | ||||
| -rw-r--r-- | tests/lib/test_timer_performance.c | 1 | ||||
| -rw-r--r-- | tests/lib/test_typelist.h | 16 | ||||
| -rw-r--r-- | tests/topotests/bgp_comm-list_delete/__init__.py | 0 | ||||
| -rw-r--r-- | tests/topotests/bgp_comm-list_delete/r1/bgpd.conf | 9 | ||||
| -rw-r--r-- | tests/topotests/bgp_comm-list_delete/r1/zebra.conf | 9 | ||||
| -rw-r--r-- | tests/topotests/bgp_comm-list_delete/r2/bgpd.conf | 11 | ||||
| -rw-r--r-- | tests/topotests/bgp_comm-list_delete/r2/zebra.conf | 6 | ||||
| -rw-r--r-- | tests/topotests/bgp_comm-list_delete/test_bgp_comm-list_delete.py | 105 | ||||
| -rw-r--r-- | tests/topotests/lib/bgp.py | 12 |
12 files changed, 157 insertions, 18 deletions
diff --git a/tests/lib/cli/test_commands.c b/tests/lib/cli/test_commands.c index ba46bdcea9..bbdc8b238d 100644 --- a/tests/lib/cli/test_commands.c +++ b/tests/lib/cli/test_commands.c @@ -243,7 +243,8 @@ static void test_run(struct prng *prng, struct vty *vty, const char *cmd, (test_buf[0] != '\0') ? ", " : "", test_buf); - if (isspace((int)test_str[strlen(test_str) - 1])) { + if (isspace((unsigned char)test_str[ + strlen(test_str) - 1])) { vector_set(vline, NULL); appended_null = 1; } diff --git a/tests/lib/cxxcompat.c b/tests/lib/cxxcompat.c index 6624de7386..88126e84bc 100644 --- a/tests/lib/cxxcompat.c +++ b/tests/lib/cxxcompat.c @@ -55,7 +55,6 @@ #include "lib/libospf.h" #include "lib/linklist.h" #include "lib/log.h" -#include "lib/logicalrouter.h" #include "lib/md5.h" #include "lib/memory.h" #include "lib/memory_vty.h" @@ -73,7 +72,6 @@ #include "lib/openbsd-tree.h" #include "lib/pbr.h" #include "lib/plist.h" -#include "lib/pqueue.h" #include "lib/prefix.h" #include "lib/privs.h" #include "lib/ptm_lib.h" diff --git a/tests/lib/test_timer_correctness.c b/tests/lib/test_timer_correctness.c index 43e79ba9d0..cbf9b05546 100644 --- a/tests/lib/test_timer_correctness.c +++ b/tests/lib/test_timer_correctness.c @@ -28,7 +28,6 @@ #include <unistd.h> #include "memory.h" -#include "pqueue.h" #include "prng.h" #include "thread.h" diff --git a/tests/lib/test_timer_performance.c b/tests/lib/test_timer_performance.c index d5f4badc85..2960e0d81e 100644 --- a/tests/lib/test_timer_performance.c +++ b/tests/lib/test_timer_performance.c @@ -28,7 +28,6 @@ #include <unistd.h> #include "thread.h" -#include "pqueue.h" #include "prng.h" #define SCHEDULE_TIMERS 1000000 diff --git a/tests/lib/test_typelist.h b/tests/lib/test_typelist.h index b288f0bd8e..7ff210cae3 100644 --- a/tests/lib/test_typelist.h +++ b/tests/lib/test_typelist.h @@ -209,7 +209,7 @@ static void concat(test_, TYPE)(void) assert(list_add(&head, &dummy) == &itm[j]); else { assert(list_add(&head, &dummy) == NULL); - list_del(&head, &dummy); + assert(list_del(&head, &dummy) != NULL); } } ts_hashx("add-dup", "a538546a6e6ab0484e925940aa8dd02fd934408bbaed8cb66a0721841584d838"); @@ -255,7 +255,7 @@ static void concat(test_, TYPE)(void) list_first(&head) == &dummy); } else if (list_next(&head, &dummy)) assert(list_next(&head, &dummy)->val > j); - list_del(&head, &dummy); + assert(list_del(&head, &dummy) != NULL); } ts_hash("add-dup+find_{lt,gteq}", "a538546a6e6ab0484e925940aa8dd02fd934408bbaed8cb66a0721841584d838"); #endif @@ -295,7 +295,7 @@ static void concat(test_, TYPE)(void) (void)prng_rand(prng); j = prng_rand(prng) % NITEM; if (itm[j].scratchpad == 1) { - list_del(&head, &itm[j]); + assert(list_del(&head, &itm[j]) != NULL); itm[j].scratchpad = 0; l++; } @@ -307,7 +307,7 @@ static void concat(test_, TYPE)(void) assert(item->scratchpad != 0); if (item->val & 1) { - list_del(&head, item); + assert(list_del(&head, item) != NULL); item->scratchpad = 0; l++; } @@ -333,7 +333,7 @@ static void concat(test_, TYPE)(void) for (i = 0; i < NITEM / 2; i++) { j = prng_rand(prng) % NITEM; if (itm[j].scratchpad == 1) { - list_del(&head, &itm[j]); + assert(list_del(&head, &itm[j]) != NULL); itm[j].scratchpad = 0; k--; } @@ -371,7 +371,7 @@ static void concat(test_, TYPE)(void) for (i = 0; i < NITEM / 2; i++) { j = prng_rand(prng) % NITEM; if (itm[j].scratchpad == 1) { - list_del(&head, &itm[j]); + assert(list_del(&head, &itm[j]) != NULL); itm[j].scratchpad = 0; k--; } @@ -424,7 +424,7 @@ static void concat(test_, TYPE)(void) item = &itm[j]; if (item->scratchpad == 0) continue; - list_del(&head, item); + assert(list_del(&head, item) != NULL); } item->scratchpad = 0; k--; @@ -469,7 +469,7 @@ static void concat(test_, TYPE)(void) item = &itm[j]; if (item->scratchpad == 0) continue; - list_del(&head, item); + assert(list_del(&head, item) != NULL); } item->scratchpad = 0; k--; diff --git a/tests/topotests/bgp_comm-list_delete/__init__.py b/tests/topotests/bgp_comm-list_delete/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/topotests/bgp_comm-list_delete/__init__.py diff --git a/tests/topotests/bgp_comm-list_delete/r1/bgpd.conf b/tests/topotests/bgp_comm-list_delete/r1/bgpd.conf new file mode 100644 index 0000000000..6e1273f464 --- /dev/null +++ b/tests/topotests/bgp_comm-list_delete/r1/bgpd.conf @@ -0,0 +1,9 @@ +router bgp 65000 + neighbor 192.168.255.2 remote-as 65001 + address-family ipv4 unicast + redistribute connected route-map r2-out + exit-address-family +! +route-map r2-out permit 10 + set community 111:111 222:222 333:333 444:444 +! diff --git a/tests/topotests/bgp_comm-list_delete/r1/zebra.conf b/tests/topotests/bgp_comm-list_delete/r1/zebra.conf new file mode 100644 index 0000000000..0a283c06d5 --- /dev/null +++ b/tests/topotests/bgp_comm-list_delete/r1/zebra.conf @@ -0,0 +1,9 @@ +! +interface lo + ip address 172.16.255.254/32 +! +interface r1-eth0 + ip address 192.168.255.1/24 +! +ip forwarding +! diff --git a/tests/topotests/bgp_comm-list_delete/r2/bgpd.conf b/tests/topotests/bgp_comm-list_delete/r2/bgpd.conf new file mode 100644 index 0000000000..3d354d56b1 --- /dev/null +++ b/tests/topotests/bgp_comm-list_delete/r2/bgpd.conf @@ -0,0 +1,11 @@ +router bgp 65001 + neighbor 192.168.255.1 remote-as 65000 + address-family ipv4 + neighbor 192.168.255.1 route-map r1-in in + exit-address-family +! +bgp community-list standard r1 permit 333:333 +! +route-map r1-in permit 10 + set comm-list r1 delete +! diff --git a/tests/topotests/bgp_comm-list_delete/r2/zebra.conf b/tests/topotests/bgp_comm-list_delete/r2/zebra.conf new file mode 100644 index 0000000000..606c17bec9 --- /dev/null +++ b/tests/topotests/bgp_comm-list_delete/r2/zebra.conf @@ -0,0 +1,6 @@ +! +interface r2-eth0 + ip address 192.168.255.2/24 +! +ip forwarding +! diff --git a/tests/topotests/bgp_comm-list_delete/test_bgp_comm-list_delete.py b/tests/topotests/bgp_comm-list_delete/test_bgp_comm-list_delete.py new file mode 100644 index 0000000000..de6c35ba8f --- /dev/null +++ b/tests/topotests/bgp_comm-list_delete/test_bgp_comm-list_delete.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python + +# +# bgp_comm-list_delete.py +# Part of NetDEF Topology Tests +# +# Copyright (c) 2019 by +# Network Device Education Foundation, Inc. ("NetDEF") +# +# Permission to use, copy, modify, and/or distribute this software +# for any purpose with or without fee is hereby granted, provided +# that the above copyright notice and this permission notice appear +# in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY +# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS +# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. +# + +""" +bgp_comm-list_delete.py: + +Test if works the following commands: +route-map test permit 10 + set comm-list <arg> delete +""" + +import os +import sys +import json +import time +import pytest + +CWD = os.path.dirname(os.path.realpath(__file__)) +sys.path.append(os.path.join(CWD, '../')) + +# pylint: disable=C0413 +from lib import topotest +from lib.topogen import Topogen, TopoRouter, get_topogen +from lib.topolog import logger +from mininet.topo import Topo + +class TemplateTopo(Topo): + def build(self, *_args, **_opts): + tgen = get_topogen(self) + + for routern in range(1, 3): + tgen.add_router('r{}'.format(routern)) + + switch = tgen.add_switch('s1') + switch.add_link(tgen.gears['r1']) + switch.add_link(tgen.gears['r2']) + +def setup_module(mod): + tgen = Topogen(TemplateTopo, mod.__name__) + tgen.start_topology() + + router_list = tgen.routers() + + for i, (rname, router) in enumerate(router_list.iteritems(), 1): + router.load_config( + TopoRouter.RD_ZEBRA, + os.path.join(CWD, '{}/zebra.conf'.format(rname)) + ) + router.load_config( + TopoRouter.RD_BGP, + os.path.join(CWD, '{}/bgpd.conf'.format(rname)) + ) + + tgen.start_router() + +def teardown_module(mod): + tgen = get_topogen() + tgen.stop_topology() + +def test_bgp_maximum_prefix_invalid(): + tgen = get_topogen() + + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + def _bgp_converge(router): + while True: + output = json.loads(tgen.gears[router].vtysh_cmd("show ip bgp neighbor 192.168.255.1 json")) + if output['192.168.255.1']['bgpState'] == 'Established': + if output['192.168.255.1']['addressFamilyInfo']['IPv4 Unicast']['acceptedPrefixCounter'] == 2: + return True + + def _bgp_comm_list_delete(router): + output = json.loads(tgen.gears[router].vtysh_cmd("show ip bgp 172.16.255.254/32 json")) + if '333:333' in output['paths'][0]['community']['list']: + return False + return True + + if _bgp_converge('r2'): + assert _bgp_comm_list_delete('r2') == True + +if __name__ == '__main__': + args = ["-s"] + sys.argv[1:] + sys.exit(pytest.main(args)) diff --git a/tests/topotests/lib/bgp.py b/tests/topotests/lib/bgp.py index 13f8824976..2613f45f1c 100644 --- a/tests/topotests/lib/bgp.py +++ b/tests/topotests/lib/bgp.py @@ -932,7 +932,7 @@ def clear_bgp_and_verify(tgen, topo, router): # Peer up time dictionary peer_uptime_before_clear_bgp[bgp_neighbor] = \ - ipv4_data[neighbor_ip]["peerUptime"] + ipv4_data[neighbor_ip]["peerUptimeEstablishedEpoch"] else: ipv6_data = show_bgp_json["ipv6Unicast"][ "peers"] @@ -940,7 +940,7 @@ def clear_bgp_and_verify(tgen, topo, router): # Peer up time dictionary peer_uptime_before_clear_bgp[bgp_neighbor] = \ - ipv6_data[neighbor_ip]["peerUptime"] + ipv6_data[neighbor_ip]["peerUptimeEstablishedEpoch"] if nh_state == "Established": no_of_peer += 1 @@ -953,6 +953,7 @@ def clear_bgp_and_verify(tgen, topo, router): logger.warning("BGP is not yet Converged for router %s " "before bgp clear", router) + logger.info(peer_uptime_before_clear_bgp) # Clearing BGP logger.info("Clearing BGP neighborship for router %s..", router) for addr_type in bgp_addr_type.keys(): @@ -1010,14 +1011,14 @@ def clear_bgp_and_verify(tgen, topo, router): "peers"] nh_state = ipv4_data[neighbor_ip]["state"] peer_uptime_after_clear_bgp[bgp_neighbor] = \ - ipv4_data[neighbor_ip]["peerUptime"] + ipv4_data[neighbor_ip]["peerUptimeEstablishedEpoch"] else: ipv6_data = show_bgp_json["ipv6Unicast"][ "peers"] nh_state = ipv6_data[neighbor_ip]["state"] # Peer up time dictionary peer_uptime_after_clear_bgp[bgp_neighbor] = \ - ipv6_data[neighbor_ip]["peerUptime"] + ipv6_data[neighbor_ip]["peerUptimeEstablishedEpoch"] if nh_state == "Established": no_of_peer += 1 @@ -1030,7 +1031,8 @@ def clear_bgp_and_verify(tgen, topo, router): logger.warning("BGP is not yet Converged for router %s after" " bgp clear", router) - # Compariung peerUptime dictionaries + logger.info(peer_uptime_after_clear_bgp) + # Comparing peerUptimeEstablishedEpoch dictionaries if peer_uptime_before_clear_bgp != peer_uptime_after_clear_bgp: logger.info("BGP neighborship is reset after clear BGP on router %s", router) |
