stats: add a retry mechanism in a symlink test 13/32813/4
authorArthur de Kerhor <arthurdekerhor@gmail.com>
Mon, 21 Jun 2021 13:35:01 +0000 (15:35 +0200)
committerOle Tr�an <otroan@employees.org>
Tue, 22 Jun 2021 10:00:27 +0000 (10:00 +0000)
When creating a new node, a corresponding node symlink is created when
the nodes counters update. To be sure we are able to access this
symlink, a retry mechanism was added.

Type: fix

Signed-off-by: Arthur de Kerhor <arthurdekerhor@gmail.com>
Change-Id: Ieb08d8554b4fd13d01e79062b5f820b235be9a13

test/test_stats_client.py

index 7e17e2a..e5b6aa7 100644 (file)
@@ -2,6 +2,8 @@
 
 import unittest
 import psutil
+import sys
+import six
 from vpp_papi.vpp_stats import VPPStats
 
 from framework import tag_fixme_vpp_workers
@@ -108,7 +110,19 @@ class StatsClientTestCase(VppTestCase):
         # We wait for nodes symlinks to update (interfaces created/deleted).
         # ... and packets to be sent
         self.sleep(0.1)
-        vectors = self.statistics.get_counter('/nodes/pg1-tx/vectors')
+        for _ in range(5):
+            try:
+                vectors = self.statistics.get_counter('/nodes/pg1-tx/vectors')
+                if vectors[0] == 0:
+                    raise ValueError("Nodes counters are not up to date")
+                break
+            except:
+                t, v, tb = sys.exc_info()
+
+                self.sleep(0.1)
+                continue
+        else:
+            six.reraise(t, v, tb)
 
         self.assertEqual(tx[0]['bytes'] - tx_before_sending[0]['bytes'],
                          bytes_to_send)