diff --git a/junit_reporter.py b/junit_reporter.py index a9c2a90..8302786 100644 --- a/junit_reporter.py +++ b/junit_reporter.py @@ -21,8 +21,8 @@ class UIPerformanceJUnitReporter: } @staticmethod - def create_junit_report(all_thresholds, failed_thresholds, total_thresholds, failed_count, quality_gate_status, - degradation_rate=None, missed_thresholds_percent=None): + def create_junit_report(all_thresholds, failed_thresholds, total_thresholds, failed_count, quality_gate_status, + deviation=None, baseline_deviation=None, missed_thresholds_percent=None): """Create JUnit XML report for UI performance test results.""" test_name = environ.get("JOB_NAME", "UI_Performance_Test") report_id = environ.get("REPORT_ID", "unknown") @@ -46,9 +46,9 @@ def create_junit_report(all_thresholds, failed_thresholds, total_thresholds, fai unit_suffix = f" {unit}" if unit else "" system_out = f"Value: {display_value:.2f}{unit_suffix}. Threshold value: {threshold_value:.2f}{unit_suffix}" - - if degradation_rate and degradation_rate > 0 and adjusted_threshold != threshold_value: - system_out += f". Degradation rate: {degradation_rate}% (adj. threshold: {adjusted_threshold:.2f}{unit_suffix})" + + if deviation and deviation > 0 and adjusted_threshold != threshold_value: + system_out += f". Deviation: {deviation}% (adj. threshold: {adjusted_threshold:.2f}{unit_suffix})" if scope == page: testcase_name = f"Threshold for {scope}, target - {target}" diff --git a/post_processing.py b/post_processing.py index a1148c1..8a54f48 100644 --- a/post_processing.py +++ b/post_processing.py @@ -34,7 +34,8 @@ try: # Fetch test configuration for quality gate settings - degradation_rate = None + deviation = None + baseline_deviation = None missed_thresholds_percent = None try: test_config_url = f"{URL}/api/v1/ui_performance/tests/{PROJECT_ID}" @@ -53,11 +54,12 @@ integrations_config = test.get('integrations', {}) processing_config = integrations_config.get('processing', {}) quality_gate_config = processing_config.get('quality_gate', {}) - - degradation_rate = quality_gate_config.get('degradation_rate') + + deviation = quality_gate_config.get('deviation') + baseline_deviation = quality_gate_config.get('baseline_deviation') missed_thresholds_percent = quality_gate_config.get('missed_thresholds') - logger.info(f"Quality gate configuration - degradation_rate: {degradation_rate}, missed_thresholds: {missed_thresholds_percent}") + logger.info(f"Quality gate configuration - deviation: {deviation}, baseline_deviation: {baseline_deviation}, missed_thresholds: {missed_thresholds_percent}") break else: logger.warning(f"Test '{TEST_NAME}' not found in configuration response") @@ -216,10 +218,10 @@ def get_result_type(identifier): threshold_value = threshold.get('value', 0) comparison = threshold.get('comparison', 'lte') - # Apply degradation rate tolerance if configured + # Apply deviation tolerance if configured adjusted_threshold = threshold_value - if degradation_rate is not None and degradation_rate > 0: - tolerance = threshold_value * (degradation_rate / 100.0) + if deviation is not None and deviation > 0: + tolerance = threshold_value * (deviation / 100.0) if comparison in ['gte', 'gt']: adjusted_threshold = threshold_value + tolerance elif comparison in ['lte', 'lt']: @@ -241,13 +243,13 @@ def get_result_type(identifier): threshold_record['status'] = 'failed' failed_thresholds.append(threshold_record) all_evaluated_thresholds.append(threshold_record) - degradation_info = f" (tolerance: {adjusted_threshold:.3f})" if degradation_rate else "" + degradation_info = f" (tolerance: {adjusted_threshold:.3f})" if deviation else "" logger.warning(f"{threshold['scope']} {threshold['target']} = {comparison_value:.3f} " f"violates {comparison} {threshold_value}{degradation_info} [FAILED]") else: threshold_record['status'] = 'passed' all_evaluated_thresholds.append(threshold_record) - degradation_info = f" (tolerance: {adjusted_threshold:.3f})" if degradation_rate else "" + degradation_info = f" (tolerance: {adjusted_threshold:.3f})" if deviation else "" logger.debug(f"{threshold['scope']} {threshold['target']} = {comparison_value:.3f} " f"complies {comparison} {threshold_value}{degradation_info} [PASSED]") @@ -308,7 +310,8 @@ def get_result_type(identifier): total_thresholds=total, failed_count=failed, quality_gate_status=status, - degradation_rate=degradation_rate, + deviation=deviation, + baseline_deviation=baseline_deviation, missed_thresholds_percent=missed_thresholds_percent ) @@ -361,7 +364,8 @@ def get_result_type(identifier): quality_gate_config = integrations['processing']['quality_gate'] else: quality_gate_config = {} - event["performance_degradation_rate"] = quality_gate_config.get('degradation_rate') + event["deviation"] = quality_gate_config.get('deviation') + event["baseline_deviation"] = quality_gate_config.get('baseline_deviation') event["missed_thresholds"] = quality_gate_config.get('missed_thresholds') res = requests.post(task_url, json=event, headers={'Authorization': f'bearer {TOKEN}',