|
1 | 1 | import os |
2 | 2 | import json |
3 | 3 | import sys |
| 4 | +import glob |
4 | 5 |
|
5 | 6 | ERROR_DIR = "test_output" # Directory where error files are stored |
6 | 7 |
|
@@ -28,13 +29,87 @@ def load_aggregated_error_file(): |
28 | 29 |
|
29 | 30 | return {} |
30 | 31 |
|
| 32 | +def combine_error_files(): |
| 33 | + """Combine all error files from parallel Jenkins stages""" |
| 34 | + combined_errors = {} |
| 35 | + |
| 36 | + # Look for error files in the current directory and subdirectories |
| 37 | + error_patterns = [ |
| 38 | + "test_output/errors_*.json", |
| 39 | + "*/test_output/errors_*.json", # For archived workspaces |
| 40 | + "**/test_output/errors_*.json" # For nested archived workspaces |
| 41 | + ] |
| 42 | + |
| 43 | + for pattern in error_patterns: |
| 44 | + for error_file in glob.glob(pattern, recursive=True): |
| 45 | + try: |
| 46 | + with open(error_file, 'r') as f: |
| 47 | + node_errors = json.load(f) |
| 48 | + |
| 49 | + # Extract node name from filename |
| 50 | + filename = os.path.basename(error_file) |
| 51 | + node_name = filename.replace("errors_", "").replace(".json", "").replace("_", " ") |
| 52 | + |
| 53 | + if node_name not in combined_errors: |
| 54 | + combined_errors[node_name] = {} |
| 55 | + |
| 56 | + # Merge errors |
| 57 | + for error_key, count in node_errors.items(): |
| 58 | + if error_key in combined_errors[node_name]: |
| 59 | + combined_errors[node_name][error_key] += count |
| 60 | + else: |
| 61 | + combined_errors[node_name][error_key] = count |
| 62 | + |
| 63 | + except Exception as e: |
| 64 | + print(f"⚠️ Failed to read {error_file}: {str(e)}") |
| 65 | + |
| 66 | + return combined_errors |
| 67 | + |
31 | 68 | def print_error_summary(): |
32 | 69 | print("\n\n📊 Error Breakdown by Node:\n") |
33 | 70 |
|
34 | 71 | # Check if a specific node is being tested |
35 | 72 | node_to_test = os.getenv("NODE_TO_TEST") |
36 | 73 |
|
37 | | - # Try individual files first (preferred method) |
| 74 | + # First try to combine all error files from parallel execution |
| 75 | + combined_errors = combine_error_files() |
| 76 | + |
| 77 | + if combined_errors: |
| 78 | + print("📁 Using combined error files from parallel execution:") |
| 79 | + |
| 80 | + # If a specific node is being tested, only show that node's errors |
| 81 | + if node_to_test: |
| 82 | + if node_to_test in combined_errors: |
| 83 | + print(f"🔧 {node_to_test}") |
| 84 | + node_errors = combined_errors[node_to_test] |
| 85 | + |
| 86 | + if not node_errors: |
| 87 | + print(" ✅ No errors") |
| 88 | + else: |
| 89 | + for error_key, count in node_errors.items(): |
| 90 | + print(f" • {count}x {error_key}") |
| 91 | + print() |
| 92 | + else: |
| 93 | + print(f"🔧 {node_to_test}") |
| 94 | + print(" ✅ No errors") |
| 95 | + print() |
| 96 | + else: |
| 97 | + # Show all nodes |
| 98 | + for node_name in sorted(combined_errors.keys()): |
| 99 | + print(f"🔧 {node_name}") |
| 100 | + |
| 101 | + node_errors = combined_errors[node_name] |
| 102 | + |
| 103 | + if not node_errors: |
| 104 | + print(" ✅ No errors") |
| 105 | + else: |
| 106 | + for error_key, count in node_errors.items(): |
| 107 | + print(f" • {count}x {error_key}") |
| 108 | + |
| 109 | + print() |
| 110 | + return |
| 111 | + |
| 112 | + # Fallback to original logic |
38 | 113 | error_files = load_error_files() |
39 | 114 |
|
40 | 115 | if error_files: |
|
0 commit comments