diff --git a/performance/README.md b/performance/README.md index 147f370..5358292 100644 --- a/performance/README.md +++ b/performance/README.md @@ -15,7 +15,7 @@ Before using the script, ensure the following prerequisites are met: ## Usage ### 1. Configuration -A custom configuration file should be provided as a command-line argument. The script will use the parameters specified in that file for configuring the load test and fetching query data for the APIs under test. +A custom configuration file in JSON format should be provided as a command-line argument. The script will use the parameters specified in that file for configuring the load test and fetching query data for the APIs under test. The configuration file should include the following parameters: @@ -30,9 +30,11 @@ The configuration file should include the following parameters: If any of these parameters are missing in the configuration file, the script raises an exception to ensure that crucial configuration parameters are provided. +Additionally, a sample configuration file named 'sample_configs.json' is provided in the repository. + ### 2. Command Line Arguments The script accepts two optional command-line arguments: -- `--config-file`: Path to the custom configuration file (default: None). If provided, the script will use the parameters specified in this file. If not provided, the script will use hardcoded default values for configuration parameters. +- `--config-file`: Path to the json configuration file. The script will use the parameters specified in this file. If not provided, the script will raise an error. - `--metrics-xml`: Path to the XML file where performance metrics will be dumped (default: None). If provided, performance metrics will be saved to this file. @@ -53,7 +55,7 @@ export ENV_SDK_VAR_API_SECRET="" ### 4. Running the Script To run the script, execute the following command in your terminal: ``` -python load_test_performance_analysis.py --config-file --metrics-xml +python performance/load_test_performance_analysis.py --config-file --metrics-xml ``` Replace `` with the desired path where you want to save the performance metrics XML file. If you don't want to save the metrics, you can omit the `--metrics-xml` argument. diff --git a/performance/load_test_performance_analysis.py b/performance/load_test_performance_analysis.py index 962afc1..2c5f608 100644 --- a/performance/load_test_performance_analysis.py +++ b/performance/load_test_performance_analysis.py @@ -185,6 +185,13 @@ def perform_test( throughput = total_responses / elapsed_time if elapsed_time > 0 else 0 error_rate = (len(errors) / (len(response_times) + len(errors))) * 100 + # Limiting the values to 6 decimal places + elapsed_time = round(elapsed_time, 6) + avg_response_time = round(avg_response_time, 6) + min_response_time = round(min_response_time, 6) + max_response_time = round(max_response_time, 6) + throughput = round(throughput, 6) + logger.info("Performance Metrics:") logger.info(f"Run Time: {elapsed_time}") logger.info(f"Number of Response: {total_responses}") @@ -274,8 +281,6 @@ def perform_get_line_data_load_test( "limit": line_data_config.get("MAX_ROWS", 100), } - print(f"DebugInf:: query - {query}") - return perform_test(get_line_data, config, cli, **query) diff --git a/performance/sample_configs.json b/performance/sample_configs.json new file mode 100644 index 0000000..7aafaca --- /dev/null +++ b/performance/sample_configs.json @@ -0,0 +1,70 @@ +{ + "num_peak_users": 5, + "ramp_up_rate": 5, + "total_run_time": 10, + "min_wait_time": 1, + "max_wait_time": 5, + "get_cycles_query_config": { + "Machine": "Abidjan - Lasercut 1", + "End Time__gte": "2023-04-01T00:00:00", + "End Time__lte": "2023-04-02T00:00:00", + "_order_by": "-End Time", + "_limit": 100, + "_only": [ + "Machine", + "Cycle Start Time", + "Cycle End Time", + "Production Day", + "Cycle Time (Net)", + "Cycle Time (Gross)", + "Shift", + "Output" + ] + }, + "get_line_data_query_config": { + "TIME_TYPE": "absolute", + "START_DATETIME": "2023-04-01T08:00:00.000Z", + "END_DATETIME": "2023-04-02T23:00:00.000Z", + "TIME_ZONE": "America/Los_Angeles", + "ASSETS": [ + "JB_NG_PickAndPlace_1_Stage4" + ], + "FIELDS": [ + "stats__BLOCKED__val", + "stats__PneumaticPressure__val" + ], + "FILTERS": [ + { + "asset": "JB_NG_PickAndPlace_1_Stage4", + "field": "stats__PneumaticPressure__val", + "op": "gte", + "value": 75.25 + } + ], + "MAX_ROWS": 50 + }, + "get_kpi_data_viz_query_config": { + "TIME_TYPE": "relative", + "RELATIVE_START": 7, + "RELATIVE_UNIT": "day", + "TIME_ZONE": "America/Los_Angeles", + "ASSETS": [ + "JB_NG_PickAndPlace_1_Stage4" + ], + "KPIS": [ + "quality" + ], + "I_VARS": [ + { + "name": "endtime", + "time_resolution": "day", + "query_tz": "America/Los_Angeles", + "output_tz": "America/Los_Angeles", + "bin_strategy": "user_defined2", + "bin_count": 50 + } + ], + "WHERE": [], + "DB_MODE": "sql" + } + } \ No newline at end of file