Skip to content

Commit

Permalink
Separate reports for different build types
Browse files Browse the repository at this point in the history
Signed-off-by: Mariia Azbeleva <[email protected]>
  • Loading branch information
azbeleva committed Nov 9, 2023
1 parent 7b9700a commit 63abf40
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 25 deletions.
43 changes: 28 additions & 15 deletions Robot-Framework/lib/PerformanceDataProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,30 @@

import csv
import os
import json
import matplotlib.pyplot as plt
import logging
from robot.api.deco import keyword


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")
Expand All @@ -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'],
Expand All @@ -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'],
Expand All @@ -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]
Expand Down Expand Up @@ -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)
6 changes: 3 additions & 3 deletions Robot-Framework/test-suites/performance/network.robot
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 <img src="${DEVICE}_${TEST NAME}.png" alt="TCP Plot" width="1200"> HTML
[Teardown] Stop iperf server

Expand All @@ -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 <img src="${DEVICE}_${TEST NAME}.png" alt="UDP Plot" width="1200"> HTML
[Teardown] Stop iperf server

Expand Down
14 changes: 7 additions & 7 deletions Robot-Framework/test-suites/performance/performance.robot
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 <img src="${DEVICE}_${TEST NAME}.png" alt="CPU Plot" width="1200"> HTML

CPU multimple threads test
Expand All @@ -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 <img src="${DEVICE}_${TEST NAME}.png" alt="CPU Plot" width="1200"> HTML

Memory Read One thread test
Expand All @@ -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 <img src="${DEVICE}_${TEST NAME}.png" alt="Mem Plot" width="1200"> HTML

Memory Write One thread test
Expand All @@ -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 <img src="${DEVICE}_${TEST NAME}.png" alt="Mem Plot" width="1200"> HTML

Memory Read multimple threads test
Expand All @@ -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 <img src="${DEVICE}_${TEST NAME}.png" alt="Mem Plot" width="1200"> HTML

Memory Write multimple threads test
Expand All @@ -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 <img src="${DEVICE}_${TEST NAME}.png" alt="Mem Plot" width="1200"> HTML


Expand Down

0 comments on commit 63abf40

Please sign in to comment.