Improvements for parse_baselines script
# SPDX-License-Identifier: Apache-2.0
"""Script used to calculate baselines from raw performance test output."""
+# We need to call sys.path.append(os.path.join(os.getcwd(), 'tests'))
+# before importing SUPPORTED_KERNELS. But this results in a pyling error.
+# pylint: disable=wrong-import-position
+
import argparse
import os
import tempfile
@@ -13,17 +17,19 @@ from providers.types import FileDataProvider
from providers.iperf3 import Iperf3DataParser
from providers.block import BlockDataParser
from providers.snapshot_restore import SnapshotRestoreDataParser
-from framework.defs import SUPPORTED_KERNELS
-from framework.utils import get_kernel_version
sys.path.append(os.path.join(os.getcwd(), 'tests'))
+from framework.defs import SUPPORTED_KERNELS # noqa: E402
OUTPUT_FILENAMES = {
- 'vsock_throughput': 'test_vsock_throughput',
- 'network_tcp_throughput': 'test_network_tcp_throughput',
- 'block_performance': 'test_block_performance',
- 'snapshot_restore_performance': 'test_snap_restore_performance'
+ 'vsock_throughput': ['test_vsock_throughput'],
+ 'network_tcp_throughput': ['test_network_tcp_throughput'],
+ 'block_performance': [
+ 'test_block_performance_sync',
+ 'test_block_performance_async'
+ ],
+ 'snapshot_restore_performance': ['test_snap_restore_performance']
}
DATA_PARSERS = {
@@ -39,12 +45,12 @@ def get_data_files(args) -> List[str]:
assert os.path.isdir(args.data_folder)
file_list = []
- host_version = get_kernel_version(level=1)
- res_file = f"{OUTPUT_FILENAMES[args.test]}_results_{host_version}.json"
+ res_files = [f"{filename}_results_{args.kernel}.json"
+ for filename in OUTPUT_FILENAMES[args.test]]
# Get all files in the dir tree that have the right name.
for root, _, files in os.walk(args.data_folder):
for file in files:
- if file == res_file:
+ if file in res_files:
file_list.append(os.path.join(root, file))
# We need at least one file.
@@ -93,6 +99,13 @@ def main():
action="store",
choices=SUPPORTED_KERNELS,
required=True)
+ parser.add_argument("-i", "--instance",
+ help="Instance type on which the baselines \
+ were obtained.",
+ action="store",
+ choices=['m5d.metal',
+ 'm6g.metal'],
+ required=True)
args = parser.parse_args()
# Create the concatenated data file.
@@ -104,8 +117,17 @@ def main():
# Instantiate the right data parser.
parser = DATA_PARSERS[args.test](data_provider)
- # Finally, parse and print the baselines.
- print(json.dumps(parser.parse(), indent=4))
+ # Finally, parse and update the baselines.
+ with open(f"./tests/integration_tests/performance/configs/"
+ f"test_{args.test}_config_{args.kernel}.json",
+ 'r+', encoding="utf8") as baselines_file:
+ json_baselines = json.load(baselines_file)
+ cpus = parser.parse()
+ json_baselines["hosts"]["instances"][args.instance] = {"cpus": cpus}
+
+ baselines_file.truncate(0)
+ baselines_file.seek(0, 0)
+ json.dump(json_baselines, baselines_file, indent=4)
if __name__ == "__main__":
