111 def run(self, test: WorkflowTest) -> bool:
112 self.logger.info("---------------------------------------------------------------------------------------")
113 self.logger.info(f"Running {test.ID} Frozen Tier0 Policy Check on {self.format} for {self.max_events} events")
114
115 diff_rules_path: Path = self.setup.diff_rules_path
116 diff_rules_exclusion_filename: str = f"{test.ID}_{self.format}_diff-exclusion-list.txt"
117 diff_rules_interest_filename: str = f"{test.ID}_{self.format}_diff-interest-list.txt"
118 diff_rules_file = None
119
120 file_name = f"my{self.format}.pool.root"
121 if test.type == WorkflowType.Derivation:
122 file_name = f"{self.format}.myOutput.pool.root"
123 reference_file = self.reference_file(test, file_name)
124 if reference_file is None:
125 self.logger.
error(f
"Reference file {file_name} not found")
126 return False
127
128 if self.setup.validation_only:
129 cvmfs_path = Path(references_CVMFS_path)
130 diff_rules_path = cvmfs_path / self.setup.release_ID / test.ID
131
132 self.logger.info(f"Reading the reference file from location {reference_file}")
133
134
135 branches_of_interest = False
136 if self.setup.diff_rules_path is None:
137 diff_rules_exclusion_local_path = test.validation_path / diff_rules_exclusion_filename
138 diff_rules_interest_local_path = test.validation_path / diff_rules_interest_filename
139 subprocess.Popen(["/bin/bash", "-c", f"cd {test.validation_path}; get_files -remove -data {diff_rules_exclusion_filename}"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
140 subprocess.Popen(["/bin/bash", "-c", f"cd {test.validation_path}; get_files -remove -data {diff_rules_interest_filename}"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
141 if not diff_rules_exclusion_local_path.exists() and not diff_rules_interest_local_path.exists():
142 self.logger.info(f"Neither '{diff_rules_exclusion_local_path}' nor '{diff_rules_interest_local_path}' files exist in the release.")
143 elif diff_rules_exclusion_local_path.exists():
144 diff_rules_file = diff_rules_exclusion_local_path
145 elif diff_rules_interest_local_path.exists():
146 diff_rules_file = diff_rules_interest_local_path
147 branches_of_interest = True
148
149 if diff_rules_file is None and diff_rules_path is not None:
150 diff_rules_file = diff_rules_path / diff_rules_exclusion_filename
151 if not diff_rules_file.exists():
152 diff_rules_file = diff_rules_path / diff_rules_interest_filename
153 if diff_rules_file.exists():
154 branches_of_interest = True
155
156 if diff_rules_file is not None and diff_rules_file.exists():
157 self.logger.info(f"Reading the diff rules file from location {diff_rules_file}")
158 diff_root_list = []
159 with diff_rules_file.open() as f:
160 for line in f:
161 stripped_line = line.rstrip()
162 if stripped_line and stripped_line[0] != '#':
163 diff_root_list.append(rf"'{stripped_line}'")
164 else:
165 self.logger.info("No diff rules file exists, using the default list")
166 diff_root_list = [r"'index_ref'"]
167
168 if self.allow_tolerance and test.diff_tolerances is not None:
169 self.logger.info(f"Reading the tolerances from location {test.diff_tolerances}")
170 else:
171 self.logger.info("Default diff-root tolerances will be used")
172
173 validation_file = test.validation_path / file_name
174 log_file = test.validation_path / f"diff-root-{test.ID}.{self.format}.log"
175 diff_root_list = " ".join(diff_root_list)
176 diff_root_mode = "--branches-of-interest" if branches_of_interest else "--ignore-leaves"
177 tolerances_mode = f"--tolerances @{test.diff_tolerances}" if self.allow_tolerance and test.diff_tolerances is not None else ""
178
179 comparison_mode = "detailed" if self.detailed_comparison else "semi-detailed"
180 comparison_command = f"acmd.py diff-root {reference_file} {validation_file} --order-trees --nan-equal --exact-branches --mode {comparison_mode} --error-mode resilient {diff_root_mode} {diff_root_list} --entries {self.max_events} {tolerances_mode} > {log_file} 2>&1"
181 output, error = subprocess.Popen(["/bin/bash", "-c", comparison_command], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
182 output, error = output.decode("utf-8"), error.decode("utf-8")
183
184
185
186
187 passed_frozen_tier0_test = True
188 all_good = False
189 with log_file.open() as file:
190 for line in file:
191 if "WARNING" in line:
192 self.logger.
error(line.strip())
193 passed_frozen_tier0_test = False
194 if "leaves differ" in line:
195 self.logger.
error(line.strip())
196 passed_frozen_tier0_test = False
197 if "ERROR" in line:
198 self.logger.
error(line.strip())
199 passed_frozen_tier0_test = False
200 if "INFO all good." in line:
201 all_good = True
202
203 result = passed_frozen_tier0_test and all_good
204 if result:
205 self.logger.info("Passed!\n")
206 else:
207
208 if self.setup.disable_release_setup:
209 self.logger.
print(f
"ATLAS-CI-ADD-LABEL: {test.run.value}-{test.type.value}-output-changed")
210 self.logger.
print(
"")
211
212 if "DAOD" in self.format:
213 self.logger.
error(f
"Your change breaks the frozen derivation policy in test {test.ID}.")
214 self.logger.
error(
"Please make sure you explain the reason for the change and ask relevant experts for approval.")
215 else:
216 self.logger.
error(f
"Your change affects standard outputs in test {test.ID}.")
217 self.logger.
error(
"Please make sure you explain the reason for the change and ask relevant experts for approval.")
218
219
220 if self.setup.disable_release_setup:
221 comparison_command = f"CopyCIArtifact.sh {validation_file}"
222 output, error = subprocess.Popen(["/bin/bash", "-c", comparison_command], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
223 output, error = output.decode("utf-8"), error.decode("utf-8")
224
225 if error or not output:
226 self.logger.
error(f
"Tried copying '{validation_file}' to the CI artifacts area but it failed.")
227 self.logger.
error(f
" {error.strip()}")
228 else:
229 self.logger.
error(output)
230
231 with log_file.open() as file:
232 for line in file:
233 self.logger.info(f" {line.strip()}")
234 self.logger.info("-----------------------------------------------------\n")
235
236 return result
237
238
void print(char *figname, TCanvas *c1)
int run(int argc, char *argv[])