From 63abf4094780cd4ac52ae68b706305575022c65f Mon Sep 17 00:00:00 2001 From: Mariia Azbeleva Date: Thu, 9 Nov 2023 14:22:11 +0200 Subject: [PATCH] Separate reports for different build types Signed-off-by: Mariia Azbeleva --- .../lib/PerformanceDataProcessing.py | 43 ++++++++++++------- .../test-suites/performance/network.robot | 6 +-- .../test-suites/performance/performance.robot | 14 +++--- 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/Robot-Framework/lib/PerformanceDataProcessing.py b/Robot-Framework/lib/PerformanceDataProcessing.py index 9131403..ad80c47 100644 --- a/Robot-Framework/lib/PerformanceDataProcessing.py +++ b/Robot-Framework/lib/PerformanceDataProcessing.py @@ -3,6 +3,7 @@ import csv import os +import json import matplotlib.pyplot as plt import logging from robot.api.deco import keyword @@ -10,10 +11,22 @@ class PerformanceDataProcessing: - def __init__(self, device): - # Initialize the instance variable with the global variable value - self.data_dir = "../../../Performance_test_results/" + def __init__(self, device, build_number): self.device = device + self.build_number = build_number + self.data_dir = self._create_result_dir() + + def _get_job_name(self): + f = open(f"../config/{self.build_number}.json") + data = json.load(f) + job_name = data["Job"] + return job_name + + def _create_result_dir(self): + job = self._get_job_name() + data_dir = f"../../../Performance_test_results/{job}/" + os.makedirs(data_dir, exist_ok=True) + return data_dir def _write_to_csv(self, test_name, data): file_path = os.path.join(self.data_dir, f"{self.device}_{test_name}.csv") @@ -23,8 +36,8 @@ def _write_to_csv(self, test_name, data): csvwriter.writerow(data) @keyword - def write_cpu_to_csv(self, test_name, build_number, cpu_data): - data = [build_number, + def write_cpu_to_csv(self, test_name, cpu_data): + data = [self.build_number, cpu_data['cpu_events_per_second'], cpu_data['min_latency'], cpu_data['avg_latency'], @@ -35,8 +48,8 @@ def write_cpu_to_csv(self, test_name, build_number, cpu_data): self._write_to_csv(test_name, data) @keyword - def write_mem_to_csv(self, test_name, build_number, mem_data): - data = [build_number, + def write_mem_to_csv(self, test_name, mem_data): + data = [self.build_number, mem_data['operations_per_second'], mem_data['data_transfer_speed'], mem_data['min_latency'], @@ -48,8 +61,8 @@ def write_mem_to_csv(self, test_name, build_number, mem_data): self._write_to_csv(test_name, data) @keyword - def write_speed_to_csv(self, test_name, build_number, speed_data): - data = [build_number, + def write_speed_to_csv(self, test_name, speed_data): + data = [self.build_number, speed_data['tx'], speed_data['rx'], self.device] @@ -243,19 +256,19 @@ def read_speed_csv_and_plot(self, test_name): plt.savefig(f'../test-suites/{self.device}_{test_name}.png') # Save the plot as an image file @keyword - def save_cpu_data(self, test_name, build_number, cpu_data): + def save_cpu_data(self, test_name, cpu_data): - self.write_cpu_to_csv(test_name, build_number, cpu_data) + self.write_cpu_to_csv(test_name, cpu_data) self.read_cpu_csv_and_plot(test_name) @keyword - def save_memory_data(self, test_name, build_number, cpu_data): + def save_memory_data(self, test_name, cpu_data): - self.write_mem_to_csv(test_name, build_number, cpu_data) + self.write_mem_to_csv(test_name, cpu_data) self.read_mem_csv_and_plot(test_name) @keyword - def save_speed_data(self, test_name, build_number, cpu_data): + def save_speed_data(self, test_name, cpu_data): - self.write_speed_to_csv(test_name, build_number, cpu_data) + self.write_speed_to_csv(test_name, cpu_data) self.read_speed_csv_and_plot(test_name) diff --git a/Robot-Framework/test-suites/performance/network.robot b/Robot-Framework/test-suites/performance/network.robot index d4c55e4..ba4835f 100644 --- a/Robot-Framework/test-suites/performance/network.robot +++ b/Robot-Framework/test-suites/performance/network.robot @@ -9,7 +9,7 @@ Resource ../../resources/ssh_keywords.resource Resource ../../config/variables.robot Library ../../lib/output_parser.py Library Process -Library ../../lib/PerformanceDataProcessing.py ${DEVICE} +Library ../../lib/PerformanceDataProcessing.py ${DEVICE} ${BUILD_ID} Suite Setup Common Setup Suite Teardown Close All Connections @@ -21,7 +21,7 @@ TCP speed test [Tags] tcp SP-T91 Run iperf server on DUT &{tcp_speed} Run TCP test - Save Speed Data ${TEST NAME} ${BUILD_ID} ${tcp_speed} + Save Speed Data ${TEST NAME} ${tcp_speed} Log TCP Plot HTML [Teardown] Stop iperf server @@ -30,7 +30,7 @@ UDP speed test [Tags] udp SP-T92 Run iperf server on DUT &{udp_speed} Run UDP test - Save Speed Data ${TEST NAME} ${BUILD_ID} ${udp_speed} + Save Speed Data ${TEST NAME} ${udp_speed} Log UDP Plot HTML [Teardown] Stop iperf server diff --git a/Robot-Framework/test-suites/performance/performance.robot b/Robot-Framework/test-suites/performance/performance.robot index e2689ad..d2330e1 100644 --- a/Robot-Framework/test-suites/performance/performance.robot +++ b/Robot-Framework/test-suites/performance/performance.robot @@ -7,7 +7,7 @@ Force Tags performance Resource ../../resources/ssh_keywords.resource Resource ../../config/variables.robot Library ../../lib/output_parser.py -Library ../../lib/PerformanceDataProcessing.py ${DEVICE} +Library ../../lib/PerformanceDataProcessing.py ${DEVICE} ${BUILD_ID} Suite Setup Common Setup Suite Teardown Close All Connections @@ -22,7 +22,7 @@ CPU One thread test ${output} Execute Command sysbench cpu --time=10 --threads=1 --cpu-max-prime=20000 run Log ${output} &{cpu_data} Parse Cpu Results ${output} - Save Cpu Data ${TEST NAME} ${BUILD_ID} ${cpu_data} + Save Cpu Data ${TEST NAME} ${cpu_data} Log CPU Plot HTML CPU multimple threads test @@ -33,7 +33,7 @@ CPU multimple threads test ${output} Execute Command sysbench cpu --time=10 --threads=${threads_number} --cpu-max-prime=20000 run Log ${output} &{cpu_data} Parse Cpu Results ${output} - Save Cpu Data ${TEST NAME} ${BUILD_ID} ${cpu_data} + Save Cpu Data ${TEST NAME} ${cpu_data} Log CPU Plot HTML Memory Read One thread test @@ -45,7 +45,7 @@ Memory Read One thread test ${output} Execute Command sysbench memory --time=60 --memory-oper=read --threads=1 run Log ${output} &{cpu_data} Parse Memory Results ${output} - Save Memory Data ${TEST NAME} ${BUILD_ID} ${cpu_data} + Save Memory Data ${TEST NAME} ${cpu_data} Log Mem Plot HTML Memory Write One thread test @@ -57,7 +57,7 @@ Memory Write One thread test ${output} Execute Command sysbench memory --time=60 --memory-oper=write --threads=1 run Log ${output} &{cpu_data} Parse Memory Results ${output} - Save Memory Data ${TEST NAME} ${BUILD_ID} ${cpu_data} + Save Memory Data ${TEST NAME} ${cpu_data} Log Mem Plot HTML Memory Read multimple threads test @@ -69,7 +69,7 @@ Memory Read multimple threads test ${output} Execute Command sysbench memory --time=60 --memory-oper=read --threads=${threads_number} run Log ${output} &{cpu_data} Parse Memory Results ${output} - Save Memory Data ${TEST NAME} ${BUILD_ID} ${cpu_data} + Save Memory Data ${TEST NAME} ${cpu_data} Log Mem Plot HTML Memory Write multimple threads test @@ -81,7 +81,7 @@ Memory Write multimple threads test ${output} Execute Command sysbench memory --time=60 --memory-oper=write --threads=${threads_number} run Log ${output} &{cpu_data} Parse Memory Results ${output} - Save Memory Data ${TEST NAME} ${BUILD_ID} ${cpu_data} + Save Memory Data ${TEST NAME} ${cpu_data} Log Mem Plot HTML