]> git.puffer.fish Git - matthieu/frr.git/commitdiff
tests: fix test_static_timing route removal
authorIgor Ryzhov <iryzhov@nfware.com>
Wed, 13 Oct 2021 21:13:57 +0000 (00:13 +0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Wed, 20 Oct 2021 22:04:44 +0000 (01:04 +0300)
On the first step, the test creates 10000 static routes. It passes 10000
to `get_ip_networks` and it generates 10000 /22 routes.

On the fourth step, the test tries to remove 5000 previously created
routes. It passes 5000 to `get_ip_networks` and here starts the problem.
Instead of generating 5000 /22 routes, it generates 5000 /21 routes. And
the whole step is a no-op, we constantly see the following logs:
```
% Refusing to remove a non-existent route
```

To consistently generate same routes, `get_ip_networks` must always use
the same prefix length.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
tests/topotests/config_timing/test_config_timing.py

index c3eb8ed84051535e1af332f6967a56ac3a068042..cf225645059cca283ea582c55ea8847a3fe1e14f 100644 (file)
@@ -77,8 +77,8 @@ def teardown_module(mod):
     tgen.stop_topology()
 
 
-def get_ip_networks(super_prefix, count):
-    count_log2 = math.log(count, 2)
+def get_ip_networks(super_prefix, base_count, count):
+    count_log2 = math.log(base_count, 2)
     if count_log2 != int(count_log2):
         count_log2 = int(count_log2) + 1
     else:
@@ -94,6 +94,7 @@ def test_static_timing():
         pytest.skip(tgen.errors)
 
     def do_config(
+        base_count,
         count,
         bad_indices,
         base_delta,
@@ -121,7 +122,7 @@ def test_static_timing():
                 router.logdir, rname, "{}-routes-{}.conf".format(iptype.lower(), optype)
             )
             with open(config_file, "w") as f:
-                for i, net in enumerate(get_ip_networks(super_prefix, count)):
+                for i, net in enumerate(get_ip_networks(super_prefix, base_count, count)):
                     if i in bad_indices:
                         if add:
                             f.write("ip route {} {} bad_input\n".format(net, via))
@@ -170,21 +171,22 @@ def test_static_timing():
     bad_indices = []
     for ipv6 in [False, True]:
         base_delta = do_config(
-            prefix_count, bad_indices, 0, 0, True, ipv6, prefix_base[ipv6][0]
+            prefix_count, prefix_count, bad_indices, 0, 0, True, ipv6, prefix_base[ipv6][0]
         )
 
         # Another set of same number of prefixes
         do_config(
-            prefix_count, bad_indices, base_delta, 2, True, ipv6, prefix_base[ipv6][1]
+            prefix_count, prefix_count, bad_indices, base_delta, 2, True, ipv6, prefix_base[ipv6][1]
         )
 
         # Duplicate config
         do_config(
-            prefix_count, bad_indices, base_delta, 2, True, ipv6, prefix_base[ipv6][0]
+            prefix_count, prefix_count, bad_indices, base_delta, 2, True, ipv6, prefix_base[ipv6][0]
         )
 
         # Remove 1/2 of duplicate
         do_config(
+            prefix_count,
             prefix_count // 2,
             bad_indices,
             base_delta,
@@ -196,15 +198,15 @@ def test_static_timing():
 
         # Add all back in so 1/2 replicate 1/2 new
         do_config(
-            prefix_count, bad_indices, base_delta, 2, True, ipv6, prefix_base[ipv6][0]
+            prefix_count, prefix_count, bad_indices, base_delta, 2, True, ipv6, prefix_base[ipv6][0]
         )
 
         # remove all
         delta = do_config(
-            prefix_count, bad_indices, base_delta, 2, False, ipv6, prefix_base[ipv6][0]
+            prefix_count, prefix_count, bad_indices, base_delta, 2, False, ipv6, prefix_base[ipv6][0]
         )
         delta += do_config(
-            prefix_count, bad_indices, base_delta, 2, False, ipv6, prefix_base[ipv6][1]
+            prefix_count, prefix_count, bad_indices, base_delta, 2, False, ipv6, prefix_base[ipv6][1]
         )