tests/power_telemetry: update telemetry client file to specify socket file

Message ID 20230602154142.92670-1-karen.kelly@intel.com (mailing list archive)
State Accepted
Headers
Series tests/power_telemetry: update telemetry client file to specify socket file |

Checks

Context Check Description
ci/Intel-dts-format-test success Testing OK
ci/Intel-dts-pylama-test success Testing OK
ci/Intel-dts-suite-test warning SKIPPED

Commit Message

Kelly, Karen June 2, 2023, 3:41 p.m. UTC
  From: Tadhg Kearney <tadhg.kearney@intel.com>

Telemetry test creates a client file to support creating json data, using
this you can specify a socket file instead of default. Currently bug in
dpdk-telemetry-client.py which doesn't allow this to work.

Signed-off-by: Tadhg Kearney <tadhg.kearney@intel.com>
---
 tests/TestSuite_power_telemetry.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
  

Comments

Pattan, Reshma June 6, 2023, 7:06 a.m. UTC | #1
> -----Original Message-----
> From: Kelly, Karen <karen.kelly@intel.com>
> Sent: Friday, June 2, 2023 4:42 PM
> To: dts@dpdk.org
> Cc: Kelly, Karen <karen.kelly@intel.com>; Pattan, Reshma
> <reshma.pattan@intel.com>; Kearney, Tadhg <tadhg.kearney@intel.com>
> Subject: [dts] tests/power_telemetry: update telemetry client file to specify
> socket file
> 
> From: Tadhg Kearney <tadhg.kearney@intel.com>
> 
> Telemetry test creates a client file to support creating json data, using this you
> can specify a socket file instead of default. Currently bug in dpdk-telemetry-
> client.py which doesn't allow this to work.
> 
> Signed-off-by: Tadhg Kearney <tadhg.kearney@intel.com>


Acked-by: Reshma Pattan <reshma.pattan@intel.com>
  

Patch

diff --git a/tests/TestSuite_power_telemetry.py b/tests/TestSuite_power_telemetry.py
index c2f65273..9ddf7992 100644
--- a/tests/TestSuite_power_telemetry.py
+++ b/tests/TestSuite_power_telemetry.py
@@ -148,26 +148,26 @@  class TestPowerTelemetry(TestCase):
         """
         script_content = textwrap.dedent(
             """
-            #! /usr/bin/env python
+            #! /usr/bin/env python3
             import argparse
             import time
             import json
             from dpdk_telemetry_client import Client, GLOBAL_METRICS_REQ, BUFFER_SIZE
-            
+
             class ClientExd(Client):
                 def __init__(self, json_file):
                     super(ClientExd, self).__init__()
                     self.json_file = json_file
                 def save_date(self, data):
-                    with open(self.json_file, 'w') as fp:
+                    with open(self.json_file, 'wb') as fp:
                         fp.write(data)
                 def requestGlobalMetrics(self):
-                    self.socket.client_fd.send(GLOBAL_METRICS_REQ)
+                    self.socket.client_fd.send(GLOBAL_METRICS_REQ.encode())
                     data = self.socket.client_fd.recv(BUFFER_SIZE)
                     self.save_date(data)
             parser = argparse.ArgumentParser(description='telemetry')
             parser.add_argument('-f',
-                                '--file',
+                                '--file-prefix',
                                 nargs='*',
                                 default=1,
                                 help='message channel')
@@ -177,9 +177,10 @@  class TestPowerTelemetry(TestCase):
                                 default=None,
                                 help='json_file option')
             args = parser.parse_args()
-            file_path = args.file[0]
+            file_path = args.file_prefix[0]
             client = ClientExd(args.json_file[0])
             client.getFilepath(file_path)
+            client.setRunpath(file_path)
             client.register()
             client.requestGlobalMetrics()
             time.sleep(2)