PAPI stats: Use list as argument to ls 26/31826/2
authorVratko Polak <vrpolak@cisco.com>
Tue, 30 Mar 2021 14:31:26 +0000 (16:31 +0200)
committerVratko Polak <vrpolak@cisco.com>
Tue, 30 Mar 2021 14:31:26 +0000 (16:31 +0200)
In the VPP PAPI stats code, the "ls" argument has always [0]
been named "patterns", suggesting it expects a list of strings.
In the CSIT utility we have always [1] been using it wrong
(passing a single string), but it happened to work
as VPP code had a workaround [2] for that.
This workaround that got removed by accident in [3],
and will be reintroduced in [4].

This change fixes occasional failures in CSIT
(if merged sooner than [4]), mainly useful
in aviding such failures during bisection.

[0] https://gerrit.fd.io/r/c/vpp/+/14584/4/src/vpp-api/python/vpp_papi/vpp_stats.py#122
[1] https://gerrit.fd.io/r/c/csit/+/18419/13/resources/tools/papi/vpp_papi_provider.py#181
[2] https://gerrit.fd.io/r/c/vpp/+/14584/4/src/vpp-api/python/vpp_papi/vpp_stats.py#64
[3] https://gerrit.fd.io/r/c/vpp/+/31678
[4] https://gerrit.fd.io/r/c/vpp/+/31817

Change-Id: Ic0f9d906be064b386b67154ba738646c4362aa2b
Signed-off-by: Vratko Polak <vrpolak@cisco.com>
resources/tools/papi/vpp_papi_provider.py

index bd333b1..c9a4344 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
-# Copyright (c) 2020 Cisco and/or its affiliates.
+# Copyright (c) 2021 Cisco and/or its affiliates.
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at:
@@ -226,7 +226,12 @@ def process_stats(args):
     reply = list()
 
     for path in json_data:
-        directory = stats.ls(path)
+        # The ls method can match multiple patterns,
+        # but we feed it one path at a time anyway, because the caller
+        # expect results in a list, one item per path.
+        # Most VPP versions understand a string is a single pattern,
+        # but some blindly iterate (as if it was a list of chars).
+        directory = stats.ls([path])
         data = stats.dump(directory)
         reply.append(data)