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 B3597A056C; Wed, 4 Mar 2020 09:23:36 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9D1181BE7D; Wed, 4 Mar 2020 09:23:36 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 0C11FFEB for ; Wed, 4 Mar 2020 09:23:33 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Mar 2020 00:23:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,513,1574150400"; d="scan'208";a="258683449" Received: from dpdk-moyufen06.sh.intel.com ([10.67.116.222]) by orsmga002.jf.intel.com with ESMTP; 04 Mar 2020 00:23:32 -0800 From: yufengmx To: dts@dpdk.org, lei.a.yao@intel.com Cc: yufengmx Date: Wed, 4 Mar 2020 16:27:38 +0800 Message-Id: <20200304082738.6184-2-yufengx.mo@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200304082738.6184-1-yufengx.mo@intel.com> References: <20200304082738.6184-1-yufengx.mo@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [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" #. 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. Signed-off-by: yufengmx --- tests/TestSuite_power_telemetry.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) 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 def d_con(self, cmd): - _cmd = [cmd, '# ', 10] if isinstance(cmd, (str, unicode)) else cmd + _cmd = [cmd, '# ', 10] if isinstance(cmd, str) else cmd return self.dut.send_expect(*_cmd) def d_a_con(self, cmd): - _cmd = [cmd, '# ', 10] if isinstance(cmd, (str, unicode)) else cmd + _cmd = [cmd, '# ', 10] if isinstance(cmd, str) else cmd return self.dut.alt_session.send_expect(*_cmd) def get_pkt_len(self, pkt_type, frame_size=64): - headers_size = sum(map(lambda x: HEADER_SIZE[x], - ['eth', 'ip', pkt_type])) + headers_size = sum([HEADER_SIZE[x] for x in ['eth', 'ip', pkt_type]]) pktlen = frame_size - headers_size return pktlen @@ -87,7 +86,7 @@ class TestPowerTelemetry(TestCase): pkt_type = values.get('type') pkt_layers = values.get('pkt_layers') pkt = Packet(pkt_type=pkt_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 @@ -154,6 +153,7 @@ class TestPowerTelemetry(TestCase): self.l3fwd_power = self.prepare_binary('l3fwd-power') def start_l3fwd_power(self, core_config='1S/2C/1T'): + core_mask, core = '0x6', 2 option = (' ' '-c {core_mask} ' '-n {mem_channel} ' @@ -162,9 +162,10 @@ class TestPowerTelemetry(TestCase): '--telemetry ' '-p 0x1 ' '-P ' - '--config="(0,0,2)" ' + '--config="(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 = 'L3FWD_POWER: entering main telemetry loop' cmd = [' '.join([self.l3fwd_power, option]), prompt, 60] @@ -174,8 +175,8 @@ class TestPowerTelemetry(TestCase): def close_l3fwd_power(self): if not self.is_l3fwd_on: return - cmd = 'killall ' + os.path.basename(self.l3fwd_power) - self.d_a_con(cmd) + cmd = "^C" + self.d_con(cmd) def create_query_script(self): ''' @@ -224,8 +225,8 @@ class TestPowerTelemetry(TestCase): """) fileName = 'query_tool.py' query_script = os.path.join(self.output_path, fileName) - with open(query_script, 'wb') as fp: - fp.write('#! /usr/bin/env python' + os.linesep + script_content) + 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 = os.path.join(self.target_dir, fileName) cmd = 'chmod 777 {}'.format(script_file) @@ -251,7 +252,7 @@ class TestPowerTelemetry(TestCase): pipe = '/var/run/some_client' cmd = "{0} -j {1} -f {2}".format(self.query_tool, json_file, pipe) output = self.d_a_con(cmd) - msg = 'faile to query metric data' + msg = 'failed to query metric data' self.verify("Get metrics done" in output, msg) dst_file = 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 = None try: self.start_l3fwd_power() + duration = 20 option = { '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