Add module to the table URL segment in ScaleClient.py 42/98642/4
authorSangwook Ha <sangwook.ha@verizon.com>
Tue, 23 Nov 2021 00:45:00 +0000 (16:45 -0800)
committerSangwook Ha <sangwook.ha@verizon.com>
Tue, 23 Nov 2021 19:57:44 +0000 (11:57 -0800)
In Phosphorus/Sulfur URL without the module name for
the augmented data node, i.e. the table list augmented to
opendaylight-inventory, returns 409 error. Add the module
name 'flow-node-inventory' to the path segment to address
the issue.

And add a step to break out of request loop in ScaleClient.py
if there are many request errors (more than 10) to prevent
the overall test from failing to complete (or taking too long).

Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
Change-Id: I9b7225c90160836fa1f2ad0ab2e492593cebc4b5

csit/libraries/ScaleClient.py

index bcaea6475820880b13e0124f83c1dbd0a13b6169..10406ba55d58fba39d71487ecbb0aa6948a19d46 100644 (file)
@@ -170,7 +170,7 @@ def _prepare_add(cntl, method, flows, template=None):
     sw, tab, fl, ip = fl1
     url = "http://" + cntl + ":" + "8181"
     url += "/rests/data/opendaylight-inventory:nodes/node=openflow%3A" + str(sw)
-    url += "/table=" + str(tab) + "/flow=" + str(fl)
+    url += "/flow-node-inventory:table=" + str(tab) + "/flow=" + str(fl)
     flow = copy.deepcopy(template["flow"][0])
     flow["cookie"] = fl
     flow["flow-name"] = "TestFlow-%d" % fl
@@ -211,7 +211,7 @@ def _prepare_table_add(cntl, method, flows, template=None):
     url += (
         "/rests/data/opendaylight-inventory:nodes/node=openflow%3A"
         + str(sw)
-        + "/table="
+        + "/flow-node-inventory:table="
         + str(tab)
     )
     fdets = []
@@ -255,7 +255,7 @@ def _prepare_delete(cntl, method, flows, template=None):
     sw, tab, fl, ip = fl1
     url = "http://" + cntl + ":" + "8181"
     url += "/rests/data/opendaylight-inventory:nodes/node=openflow%3A" + str(sw)
-    url += "/table=" + str(tab) + "/flow=" + str(fl)
+    url += "/flow-node-inventory:table=" + str(tab) + "/flow=" + str(fl)
     req = requests.Request(
         "DELETE",
         url,
@@ -391,8 +391,11 @@ def _wt_request_sender(
     cntl = controllers[0]
     counter = [0 for i in range(600)]
     loop = True
+    req_no = 0
+    num_errors = 0
 
     while loop:
+        req_no += 1
         try:
             flowlist = inqueue.get(timeout=1)
         except queue.Empty:
@@ -405,7 +408,7 @@ def _wt_request_sender(
         try:
             rsp = ses.send(prep, timeout=5)
         except requests.exceptions.Timeout:
-            print(f"*WARN* Timeout: {req.method} {req.url}")
+            print(f"*WARN* [{req_no}] Timeout: {req.method} {req.url}")
             counter[99] += 1
             if counter[99] > 10:
                 print("*ERROR* Too many timeouts.")
@@ -414,8 +417,13 @@ def _wt_request_sender(
         else:
             if rsp.status_code not in [200, 201, 204]:
                 print(
-                    f"*WARN* Status code {rsp.status_code}: {req.method} {req.url}\n{rsp.text}"
+                    f"*WARN* [{req_no}] Status code {rsp.status_code}:"
+                    f" {req.method} {req.url}\n{rsp.text}"
                 )
+                num_errors += 1
+                if num_errors > 10:
+                    print("*ERROR* Too many errors.")
+                    break
         counter[rsp.status_code] += 1
     res = {}
     for i, v in enumerate(counter):