From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3C1B5A0567; Fri, 13 Mar 2020 07:29:38 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2F18D1C022; Fri, 13 Mar 2020 07:29:38 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 6608F1C01E for ; Fri, 13 Mar 2020 07:29:36 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Mar 2020 23:29:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,547,1574150400"; d="scan'208";a="416197595" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga005.jf.intel.com with ESMTP; 12 Mar 2020 23:29:35 -0700 Received: from fmsmsx124.amr.corp.intel.com (10.18.125.39) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 12 Mar 2020 23:29:34 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx124.amr.corp.intel.com (10.18.125.39) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 12 Mar 2020 23:29:34 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.43]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.201]) with mapi id 14.03.0439.000; Fri, 13 Mar 2020 14:29:31 +0800 From: "Tu, Lijuan" To: "Mo, YufengX" , "dts@dpdk.org" , "Yao, Lei A" CC: "Mo, YufengX" Thread-Topic: [dts] [PATCH V1 1/1] tests/power_telemetry: python3 support and script optimize Thread-Index: AQHV8f83nWFw/bxzUkOGTu/4zToB3ahGHYBw Date: Fri, 13 Mar 2020 06:29:31 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BBEC6D9@SHSMSX101.ccr.corp.intel.com> References: <20200304082738.6184-1-yufengx.mo@intel.com> <20200304082738.6184-2-yufengx.mo@intel.com> In-Reply-To: <20200304082738.6184-2-yufengx.mo@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH V1 1/1] tests/power_telemetry: python3 support and script optimize X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Applied, thanks > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of yufengmx > Sent: Wednesday, March 4, 2020 4:28 PM > To: dts@dpdk.org; Yao, Lei A > Cc: Mo, YufengX > Subject: [dts] [PATCH V1 1/1] tests/power_telemetry: python3 support and > script optimize >=20 >=20 > #. python3 support. > #. for dpdk use hard code, change core mask to hard code. > #. set longer traffic duration for stability. > #. use ^C to take the place of killall. >=20 > Signed-off-by: yufengmx > --- > tests/TestSuite_power_telemetry.py | 30 ++++++++++++++++-------------- > 1 file changed, 16 insertions(+), 14 deletions(-) >=20 > diff --git a/tests/TestSuite_power_telemetry.py > b/tests/TestSuite_power_telemetry.py > index 9c2bdbc..90404e3 100644 > --- a/tests/TestSuite_power_telemetry.py > +++ b/tests/TestSuite_power_telemetry.py > @@ -63,16 +63,15 @@ class TestPowerTelemetry(TestCase): > return target_dir >=20 > def d_con(self, cmd): > - _cmd =3D [cmd, '# ', 10] if isinstance(cmd, (str, unicode)) else= cmd > + _cmd =3D [cmd, '# ', 10] if isinstance(cmd, str) else cmd > return self.dut.send_expect(*_cmd) >=20 > def d_a_con(self, cmd): > - _cmd =3D [cmd, '# ', 10] if isinstance(cmd, (str, unicode)) else= cmd > + _cmd =3D [cmd, '# ', 10] if isinstance(cmd, str) else cmd > return self.dut.alt_session.send_expect(*_cmd) >=20 > def get_pkt_len(self, pkt_type, frame_size=3D64): > - headers_size =3D sum(map(lambda x: HEADER_SIZE[x], > - ['eth', 'ip', pkt_type])) > + headers_size =3D sum([HEADER_SIZE[x] for x in ['eth', 'ip', > + pkt_type]]) > pktlen =3D frame_size - headers_size > return pktlen >=20 > @@ -87,7 +86,7 @@ class TestPowerTelemetry(TestCase): > pkt_type =3D values.get('type') > pkt_layers =3D values.get('pkt_layers') > pkt =3D Packet(pkt_type=3Dpkt_type) > - for layer in pkt_layers.keys(): > + for layer in list(pkt_layers.keys()): > pkt.config_layer(layer, pkt_layers[layer]) > return pkt.pktgen.pkt >=20 > @@ -154,6 +153,7 @@ class TestPowerTelemetry(TestCase): > self.l3fwd_power =3D self.prepare_binary('l3fwd-power') >=20 > def start_l3fwd_power(self, core_config=3D'1S/2C/1T'): > + core_mask, core =3D '0x6', 2 > option =3D (' ' > '-c {core_mask} ' > '-n {mem_channel} ' > @@ -162,9 +162,10 @@ class TestPowerTelemetry(TestCase): > '--telemetry ' > '-p 0x1 ' > '-P ' > - '--config=3D"(0,0,2)" ' > + '--config=3D"(0,0,{core})" ' > ).format(**{ > - 'core_mask': self.get_cores_mask(core_config), > + 'core_mask': core_mask, > + 'core': core, > 'mem_channel': self.dut.get_memory_channels(), }) > prompt =3D 'L3FWD_POWER: entering main telemetry loop' > cmd =3D [' '.join([self.l3fwd_power, option]), prompt, 60] @@ -1= 74,8 > +175,8 @@ class TestPowerTelemetry(TestCase): > def close_l3fwd_power(self): > if not self.is_l3fwd_on: > return > - cmd =3D 'killall ' + os.path.basename(self.l3fwd_power) > - self.d_a_con(cmd) > + cmd =3D "^C" > + self.d_con(cmd) >=20 > def create_query_script(self): > ''' > @@ -224,8 +225,8 @@ class TestPowerTelemetry(TestCase): > """) > fileName =3D 'query_tool.py' > query_script =3D os.path.join(self.output_path, fileName) > - with open(query_script, 'wb') as fp: > - fp.write('#! /usr/bin/env python' + os.linesep + script_cont= ent) > + with open(query_script, 'w') as fp: > + fp.write('#! /usr/bin/env python' + os.linesep + > + str(script_content)) > self.dut.session.copy_file_to(query_script, self.target_dir) > script_file =3D os.path.join(self.target_dir, fileName) > cmd =3D 'chmod 777 {}'.format(script_file) @@ -251,7 +252,7 @@ c= lass > TestPowerTelemetry(TestCase): > pipe =3D '/var/run/some_client' > cmd =3D "{0} -j {1} -f {2}".format(self.query_tool, json_file, p= ipe) > output =3D self.d_a_con(cmd) > - msg =3D 'faile to query metric data' > + msg =3D 'failed to query metric data' > self.verify("Get metrics done" in output, msg) > dst_file =3D os.path.join(self.output_path, json_name) > self.dut.session.copy_file_from(json_file, dst_file) @@ -392,11 = +393,12 > @@ class TestPowerTelemetry(TestCase): > except_content =3D None > try: > self.start_l3fwd_power() > + duration =3D 20 > option =3D { > 'traffic_opt': { > 'method': 'throughput', > - 'duration': 15, > - 'interval': 10, > + 'duration': duration, > + 'interval': duration - 2, > 'callback': self.telemetry_query_on_traffic, }} > self.run_traffic(option) > time.sleep(5) > -- > 2.21.0