def run_phase(self): ########################################################################### # Clean up any da.log files in case this is a re-run. self._activate_case2() case_root = self._get_caseroot2() rundir2 = self._case.get_value("RUNDIR") da_files = glob.glob(os.path.join(rundir2, 'da.log.*')) for file_ in da_files: os.remove(file_) # End for # CONTINUE_RUN ends up TRUE, set it back in case this is a re-run. self._case.set_value("CONTINUE_RUN", False) # Start normal run here self._activate_case1() SystemTestsCompareTwo.run_phase(self) # Do some checks on the data assimilation 'output' from case2 self._activate_case2() da_files = glob.glob(os.path.join(rundir2, 'da.log.*')) if da_files is None: logger = logging.getLogger(__name__) logger.warning("No DA files in %s", os.path.join(case_root, 'da.log.*')) da_cycles = self._case.get_value("DATA_ASSIMILATION_CYCLES") expect( (da_files is not None) and (len(da_files) == da_cycles), "ERROR: There were %d DA cycles in run but %d DA files were found" % (da_cycles, len(da_files) if da_files is not None else 0)) da_files.sort() cycle_num = 0 for fname in da_files: found_caseroot = False found_cycle = False with open(fname) as dfile: for line in dfile: expect(line[0:5] != 'ERROR', "ERROR, error line found in %s" % fname) if line[0:8] == 'caseroot': found_caseroot = True elif line[0:5] == 'cycle': found_cycle = True expect( int(line[7:]) == cycle_num, "ERROR: Wrong cycle (%d) found in %s (expected %d)" % (int(line[7:]), fname, cycle_num)) else: expect( False, "ERROR: Unrecognized line ('%s') found in %s" % (line, fname)) # End of for loop expect(found_caseroot, "ERROR: No caseroot found in %s" % fname) expect(found_cycle, "ERROR: No cycle found in %s" % fname) # End of with cycle_num = cycle_num + 1
def run_phase(self): # pylint: disable=arguments-differ ########################################################################### self._activate_case2() should_match = (self._case.get_value("DESP_MODE") == "NOCHANGE") SystemTestsCompareTwo.run_phase(self, success_change=not should_match) # Look for expected coupler restart files logger = logging.getLogger(__name__) self._activate_case1() rundir1 = self._case.get_value("RUNDIR") self._activate_case2() rundir2 = self._case.get_value("RUNDIR") compare_ok = True pause_comps = self._case.get_value("PAUSE_COMPONENT_LIST") expect((pause_comps != 'none'), "Pause/Resume (PRE) test has no pause components") if pause_comps == 'all': pause_comps = self._case.get_values("COMP_CLASSES") else: pause_comps = pause_comps.split(':') multi_driver = self._case.get_value("MULTI_DRIVER") for comp in pause_comps: if comp == "cpl": if multi_driver: ninst = self._case.get_value("NINST_MAX") else: ninst = 1 else: ninst = self._case.get_value("NINST_{}".format(comp.upper())) comp_name = self._case.get_value('COMP_{}'.format(comp.upper())) for index in range(1,ninst+1): if ninst == 1: rname = '*.{}.r.*'.format(comp_name) else: rname = '*.{}_{:04d}.r.*'.format(comp_name, index) restart_files_1 = glob.glob(os.path.join(rundir1, rname)) expect((len(restart_files_1) > 0), "No case1 restart files for {}".format(comp)) restart_files_2 = glob.glob(os.path.join(rundir2, rname)) expect((len(restart_files_2) > len(restart_files_1)), "No pause (restart) files found in case2 for {}".format(comp)) # Do cprnc of restart files. rfile1 = restart_files_1[len(restart_files_1) - 1] # rfile2 has to match rfile1 (same time string) parts = os.path.basename(rfile1).split(".") glob_str = "*.{}".format(".".join(parts[len(parts)-4:])) restart_files_2 = glob.glob(os.path.join(rundir2, glob_str)) expect((len(restart_files_2) == 1), "Missing case2 restart file, {}", glob_str) rfile2 = restart_files_2[0] ok = cprnc(comp, rfile1, rfile2, self._case, rundir2)[0] logger.warning("CPRNC result for {}: {}".format(os.path.basename(rfile1), "PASS" if (ok == should_match) else "FAIL")) compare_ok = compare_ok and (should_match == ok) expect(compare_ok, "Not all restart files {}".format("matched" if should_match else "failed to match"))
def run_phase(self): # pylint: disable=arguments-differ ########################################################################### self._activate_case2() should_match = (self._case.get_value("DESP_MODE") == "NOCHANGE") SystemTestsCompareTwo.run_phase(self, success_change=not should_match) # Look for expected coupler restart files logger = logging.getLogger(__name__) self._activate_case1() rundir1 = self._case.get_value("RUNDIR") self._activate_case2() rundir2 = self._case.get_value("RUNDIR") compare_ok = True multi_driver = self._case.get_value("MULTI_DRIVER") comps = self._case.get_values("COMP_CLASSES") for comp in comps: if not self._case.get_value("PAUSE_ACTIVE_{}".format(comp)): continue if comp == "CPL": if multi_driver: ninst = self._case.get_value("NINST_MAX") else: ninst = 1 else: ninst = self._case.get_value("NINST_{}".format(comp)) comp_name = self._case.get_value('COMP_{}'.format(comp)) for index in range(1, ninst + 1): if ninst == 1: rname = '*.{}.r.*'.format(comp_name) else: rname = '*.{}_{:04d}.r.*'.format(comp_name, index) restart_files_1 = glob.glob(os.path.join(rundir1, rname)) expect((len(restart_files_1) > 0), "No case1 restart files for {}".format(comp)) restart_files_2 = glob.glob(os.path.join(rundir2, rname)) expect((len(restart_files_2) > len(restart_files_1)), "No pause (restart) files found in case2 for {}".format( comp)) # Do cprnc of restart files. rfile1 = restart_files_1[len(restart_files_1) - 1] # rfile2 has to match rfile1 (same time string) parts = os.path.basename(rfile1).split(".") glob_str = "*.{}".format(".".join(parts[len(parts) - 4:])) restart_files_2 = glob.glob(os.path.join(rundir2, glob_str)) expect((len(restart_files_2) == 1), "Missing case2 restart file, {}", glob_str) rfile2 = restart_files_2[0] ok = cprnc(comp, rfile1, rfile2, self._case, rundir2)[0] logger.warning("CPRNC result for {}: {}".format( os.path.basename(rfile1), "PASS" if (ok == should_match) else "FAIL")) compare_ok = compare_ok and (should_match == ok) expect( compare_ok, "Not all restart files {}".format( "matched" if should_match else "failed to match"))
def run_phase(self): # pylint: disable=arguments-differ ########################################################################### # Clean up any da.log files in case this is a re-run. self._activate_case2() case_root = self._get_caseroot2() rundir2 = self._case.get_value("RUNDIR") da_files = glob.glob(os.path.join(rundir2, 'da.log.*')) for file_ in da_files: os.remove(file_) # End for # CONTINUE_RUN ends up TRUE, set it back in case this is a re-run. self._case.set_value("CONTINUE_RUN", False) # Start normal run here self._activate_case1() SystemTestsCompareTwo.run_phase(self) # Do some checks on the data assimilation 'output' from case2 self._activate_case2() da_files = glob.glob(os.path.join(rundir2, 'da.log.*')) if da_files is None: logger = logging.getLogger(__name__) path = os.path.join(case_root, 'da.log.*') logger.warning("No DA files in {}".format(path)) da_cycles = self._case.get_value("DATA_ASSIMILATION_CYCLES") expect((da_files is not None) and (len(da_files) == da_cycles), "ERROR: There were {:d} DA cycles in run but {:d} DA files were found".format(da_cycles, len(da_files) if da_files is not None else 0)) da_files.sort() cycle_num = 0 for fname in da_files: found_caseroot = False found_cycle = False with open(fname) as dfile: for line in dfile: expect(line[0:5] != 'ERROR', "ERROR, error line found in {}".format(fname)) if line[0:8] == 'caseroot': found_caseroot = True elif line[0:5] == 'cycle': found_cycle = True expect(int(line[7:]) == cycle_num, "ERROR: Wrong cycle ({:d}) found in {} (expected {:d})".format(int(line[7:]), fname, cycle_num)) else: expect(False, "ERROR: Unrecognized line ('{}') found in {}".format(line, fname)) # End of for loop expect(found_caseroot, "ERROR: No caseroot found in {}".format(fname)) expect(found_cycle, "ERROR: No cycle found in {}".format(fname)) # End of with cycle_num = cycle_num + 1
def run_phase(self): ########################################################################### SystemTestsCompareTwo.run_phase(self) # Look for expected coupler restart files logger = logging.getLogger(__name__) self._activate_case1() rundir1 = self._case.get_value("RUNDIR") self._activate_case2() rundir2 = self._case.get_value("RUNDIR") should_match = (self._case.get_value("DESP_MODE") == "NOCHANGE") compare_ok = True pause_comps = self._case.get_value("PAUSE_COMPONENT_LIST") expect((pause_comps != 'none'), "Pause/Resume (PRE) test has no pause components") if pause_comps == 'all': pause_comps = self._case.get_values("COMP_CLASSES") else: pause_comps = pause_comps.split(':') for comp in pause_comps: comp_name = self._case.get_value('COMP_%s' % comp.upper()) rname = '*.%s.r.*' % comp_name restart_files_1 = glob.glob(os.path.join(rundir1, rname)) expect((len(restart_files_1) > 0), "No case1 restart files for %s" % comp) restart_files_2 = glob.glob(os.path.join(rundir2, rname)) expect((len(restart_files_2) > len(restart_files_1)), "No pause (restart) files found in case2 for %s" % comp) # Do cprnc of restart files. rfile1 = restart_files_1[len(restart_files_1) - 1] # rfile2 has to match rfile1 (same time string) parts = os.path.basename(rfile1).split(".") glob_str = "*.%s" % ".".join(parts[len(parts) - 4:]) restart_files_2 = glob.glob(os.path.join(rundir2, glob_str)) expect((len(restart_files_2) == 1), "Missing case2 restart file, %s", glob_str) rfile2 = restart_files_2[0] ok, out = cprnc(comp, rfile1, rfile2, self._case, rundir2) # pylint: disable=unused-variable logger.warning("CPRNC result for %s: %s" % (os.path.basename(rfile1), "PASS" if (ok == should_match) else "FAIL")) compare_ok = compare_ok and (should_match == ok) expect( compare_ok, "Not all restart files %s" % ("matched" if should_match else "failed to match"))
def run_phase(self): ########################################################################### SystemTestsCompareTwo.run_phase(self) # Do some checks on the data assimilation 'output' from case2 self._activate_case2() case_root = self._get_caseroot2() da_files = glob.glob(os.path.join(case_root, 'da.log.*')) if da_files is None: logger = logging.getLogger(__name__) logger.warning("No DA files in %s", os.path.join(case_root, 'da.log.*')) da_cycles = self._case.get_value("DATA_ASSIMILATION_CYCLES") expect((da_files is not None) and (len(da_files) == da_cycles), "ERROR: There were %d DA cycles in run but %d DA files were found"% (da_cycles, len(da_files) if da_files is not None else 0)) da_files.sort() cycle_num = 0 for fname in da_files: found_caseroot = False found_cycle = False found_total = False with open(fname) as dfile: for line in dfile: expect(line[0:5] != 'ERROR', "ERROR, error line found in %s"%fname) if line[0:8] == 'caseroot': found_caseroot = True elif line[0:5] == 'cycle': found_cycle = True expect(int(line[7:]) == cycle_num, "ERROR: Wrong cycle (%d) found in %s (expected %d)"% (int(line[7:]), fname, cycle_num)) elif line[0:12] == 'total_cycles': found_total = True expect(int(line[14:]) == da_cycles, "ERROR: Wrong total cycle count (%d) found in %s (expected %d)"% (int(line[14:]), fname, da_cycles)) else: expect(False, "ERROR: Unrecognized line ('%s') found in %s"%(line, fname)) # End of for loop expect(found_caseroot, "ERROR: No caseroot found in %s"%fname) expect(found_cycle, "ERROR: No cycle found in %s"%fname) expect(found_total, "ERROR: No total_cycles found in %s"%fname) # End of with cycle_num = cycle_num + 1
def run_phase(self): # pylint: disable=arguments-differ ########################################################################### # Clean up any da.log files in case this is a re-run. self._activate_case2() case_root = self._get_caseroot2() rundir2 = self._case.get_value("RUNDIR") da_files = glob.glob(os.path.join(rundir2, 'da.log.*')) for file_ in da_files: os.remove(file_) # End for # CONTINUE_RUN ends up TRUE, set it back in case this is a re-run. self._case.set_value("CONTINUE_RUN", False) # Start normal run here self._activate_case1() SystemTestsCompareTwo.run_phase(self) # Do some checks on the data assimilation 'output' from case2 self._activate_case2() da_files = glob.glob(os.path.join(rundir2, 'da.log.*')) if da_files is None: logger = logging.getLogger(__name__) path = os.path.join(case_root, 'da.log.*') logger.warning("No DA files in {}".format(path)) da_cycles = self._case.get_value("DATA_ASSIMILATION_CYCLES") expect((da_files is not None) and ( len(da_files) == da_cycles ), "ERROR: There were {:d} DA cycles in run but {:d} DA files were found" .format(da_cycles, len(da_files) if da_files is not None else 0)) da_files.sort() cycle_num = 0 for fname in da_files: found_caseroot = False found_cycle = False with gzip.open(fname, "r") as dfile: for bline in dfile: line = bline.decode("utf-8") expect( not 'ERROR' in line, "ERROR, error line {} found in {}".format(line, fname)) if 'caseroot' in line[0:8]: found_caseroot = True elif 'cycle' in line[0:5]: found_cycle = True expect( int(line[7:]) == cycle_num, "ERROR: Wrong cycle ({:d}) found in {} (expected {:d})" .format(int(line[7:]), fname, cycle_num)) else: expect( False, "ERROR: Unrecognized line ('{}') found in {}". format(line, fname)) # End of for loop expect(found_caseroot, "ERROR: No caseroot found in {}".format(fname)) expect(found_cycle, "ERROR: No cycle found in {}".format(fname)) # End of with cycle_num = cycle_num + 1
def run_phase(self): # pylint: disable=arguments-differ ########################################################################### # Clean up any da.log files in case this is a re-run. self._activate_case2() case_root = self._get_caseroot2() rundir2 = self._case.get_value("RUNDIR") da_files = glob.glob(os.path.join(rundir2, 'da.log.*')) for file_ in da_files: os.remove(file_) # End for # CONTINUE_RUN ends up TRUE, set it back in case this is a re-run. self._case.set_value("CONTINUE_RUN", False) # Start normal run here self._activate_case1() SystemTestsCompareTwo.run_phase(self) # Do some checks on the data assimilation 'output' from case2 self._activate_case2() da_files = glob.glob(os.path.join(rundir2, 'da.log.*')) if da_files is None: logger = logging.getLogger(__name__) path = os.path.join(case_root, 'da.log.*') logger.warning("No DA files in {}".format(path)) da_cycles = self._case.get_value("DATA_ASSIMILATION_CYCLES") expect((da_files is not None) and (len(da_files) == da_cycles), "ERROR: There were {:d} DA cycles in run but {:d} DA files were found".format(da_cycles, len(da_files) if da_files is not None else 0)) da_files.sort() cycle_num = 0 compset = self._case.get_value("COMPSET") is_dwav = '_DWAV' in compset for fname in da_files: found_caseroot = False found_cycle = False found_signal = 0 if is_dwav and (cycle_num > 0): expected_signal = self._case.get_value("NINST_WAV") else: expected_signal = 0 with gzip.open(fname, "r") as dfile: for bline in dfile: line = bline.decode("utf-8") expect(not 'ERROR' in line, "ERROR, error line {} found in {}".format(line, fname)) if 'caseroot' in line[0:8]: found_caseroot = True elif 'cycle' in line[0:5]: found_cycle = True expect(int(line[7:]) == cycle_num, "ERROR: Wrong cycle ({:d}) found in {} (expected {:d})".format(int(line[7:]), fname, cycle_num)) elif 'resume signal' in line: found_signal = found_signal + 1 expect('Post-DA resume signal found' in line[0:27], "ERROR: bad post-DA message found in {}".format(fname)) else: expect(False, "ERROR: Unrecognized line ('{}') found in {}".format(line, fname)) # End of for loop expect(found_caseroot, "ERROR: No caseroot found in {}".format(fname)) expect(found_cycle, "ERROR: No cycle found in {}".format(fname)) expect(found_signal == expected_signal, "ERROR: Expected {} post-DA resume signal message(s), {} found in {}".format(expected_signal, found_signal, fname)) # End of with cycle_num = cycle_num + 1
def run_phase(self): # pylint: disable=arguments-differ ########################################################################### # Clean up any da.log files in case this is a re-run. self._activate_case2() case_root = self._get_caseroot2() rundir2 = self._case.get_value("RUNDIR") da_files = glob.glob(os.path.join(rundir2, "da.log.*")) for file_ in da_files: os.remove(file_) # End for # CONTINUE_RUN ends up TRUE, set it back in case this is a re-run. with self._case: self._case.set_value("CONTINUE_RUN", False) # Turn off post DA in case this is a re-run for comp in self._case.get_values("COMP_CLASSES"): if comp == "ESP": continue else: self._case.set_value("DATA_ASSIMILATION_{}".format(comp), False) # Start normal run here self._activate_case1() SystemTestsCompareTwo.run_phase(self) # Do some checks on the data assimilation 'output' from case2 self._activate_case2() da_files = glob.glob(os.path.join(rundir2, "da.log.*")) if da_files is None: logger = logging.getLogger(__name__) path = os.path.join(case_root, "da.log.*") logger.warning("No DA files in {}".format(path)) da_cycles = self._case.get_value("DATA_ASSIMILATION_CYCLES") expect( (da_files is not None) and (len(da_files) == da_cycles), "ERROR: There were {:d} DA cycles in run but {:d} DA files were found" .format(da_cycles, len(da_files) if da_files is not None else 0), ) da_files.sort() cycle_num = 0 compset = self._case.get_value("COMPSET") # Special case for DWAV so we can make sure other variables are set is_dwav = "_DWAV" in compset for fname in da_files: found_caseroot = False found_cycle = False found_signal = 0 found_init = 0 if is_dwav: expected_init = self._case.get_value("NINST_WAV") else: # Expect a signal from every instance of every DA component expected_init = 0 for comp in self._case.get_values("COMP_CLASSES"): if comp == "ESP": continue elif self._case.get_value( "DATA_ASSIMILATION_{}".format(comp)): expected_init = expected_init + self._case.get_value( "NINST_{}".format(comp)) # Adjust expected initial run and post-DA numbers if cycle_num == 0: expected_signal = 0 else: expected_signal = expected_init expected_init = 0 with gzip.open(fname, "r") as dfile: for bline in dfile: line = bline.decode("utf-8") expect( not "ERROR" in line, "ERROR, error line {} found in {}".format(line, fname), ) if "caseroot" in line[0:8]: found_caseroot = True elif "cycle" in line[0:5]: found_cycle = True expect( int(line[7:]) == cycle_num, "ERROR: Wrong cycle ({:d}) found in {} (expected {:d})" .format(int(line[7:]), fname, cycle_num), ) elif "resume signal" in line: found_signal = found_signal + 1 expect( "Post-DA resume signal found" in line[0:27], "ERROR: bad post-DA message found in {}".format( fname), ) elif "Initial run" in line: found_init = found_init + 1 expect( "Initial run signal found" in line[0:24], "ERROR: bad Initial run message found in {}". format(fname), ) else: expect( False, "ERROR: Unrecognized line ('{}') found in {}". format(line, fname), ) # End for expect(found_caseroot, "ERROR: No caseroot found in {}".format(fname)) expect(found_cycle, "ERROR: No cycle found in {}".format(fname)) expect( found_signal == expected_signal, "ERROR: Expected {} post-DA resume signal message(s), {} found in {}" .format(expected_signal, found_signal, fname), ) expect( found_init == expected_init, "ERROR: Expected {} Initial run message(s), {} found in {}" .format(expected_init, found_init, fname), ) # End with cycle_num = cycle_num + 1
def run_phase(self): # pylint: disable=arguments-differ ########################################################################### # Clean up any da.log files in case this is a re-run. self._activate_case2() case_root = self._get_caseroot2() rundir2 = self._case.get_value("RUNDIR") da_files = glob.glob(os.path.join(rundir2, 'da.log.*')) for file_ in da_files: os.remove(file_) # End for # CONTINUE_RUN ends up TRUE, set it back in case this is a re-run. with self._case: self._case.set_value("CONTINUE_RUN", False) # Turn off post DA in case this is a re-run for comp in self._case.get_values("COMP_CLASSES"): if comp == "ESP": continue else: self._case.set_value("DATA_ASSIMILATION_{}".format(comp), False) # Start normal run here self._activate_case1() SystemTestsCompareTwo.run_phase(self) # Do some checks on the data assimilation 'output' from case2 self._activate_case2() da_files = glob.glob(os.path.join(rundir2, 'da.log.*')) if da_files is None: logger = logging.getLogger(__name__) path = os.path.join(case_root, 'da.log.*') logger.warning("No DA files in {}".format(path)) da_cycles = self._case.get_value("DATA_ASSIMILATION_CYCLES") expect((da_files is not None) and (len(da_files) == da_cycles), "ERROR: There were {:d} DA cycles in run but {:d} DA files were found".format(da_cycles, len(da_files) if da_files is not None else 0)) da_files.sort() cycle_num = 0 compset = self._case.get_value("COMPSET") # Special case for DWAV so we can make sure other variables are set is_dwav = '_DWAV' in compset for fname in da_files: found_caseroot = False found_cycle = False found_signal = 0 found_init = 0 if is_dwav: expected_init = self._case.get_value("NINST_WAV") else: # Expect a signal from every instance of every DA component expected_init = 0 for comp in self._case.get_values("COMP_CLASSES"): if comp == "ESP": continue elif self._case.get_value("DATA_ASSIMILATION_{}".format(comp)): expected_init = expected_init + self._case.get_value("NINST_{}".format(comp)) # Adjust expected initial run and post-DA numbers if cycle_num == 0: expected_signal = 0 else: expected_signal = expected_init expected_init = 0 with gzip.open(fname, "r") as dfile: for bline in dfile: line = bline.decode("utf-8") expect(not 'ERROR' in line, "ERROR, error line {} found in {}".format(line, fname)) if 'caseroot' in line[0:8]: found_caseroot = True elif 'cycle' in line[0:5]: found_cycle = True expect(int(line[7:]) == cycle_num, "ERROR: Wrong cycle ({:d}) found in {} (expected {:d})".format(int(line[7:]), fname, cycle_num)) elif 'resume signal' in line: found_signal = found_signal + 1 expect('Post-DA resume signal found' in line[0:27], "ERROR: bad post-DA message found in {}".format(fname)) elif 'Initial run' in line: found_init = found_init + 1 expect('Initial run signal found' in line[0:24], "ERROR: bad Initial run message found in {}".format(fname)) else: expect(False, "ERROR: Unrecognized line ('{}') found in {}".format(line, fname)) # End for expect(found_caseroot, "ERROR: No caseroot found in {}".format(fname)) expect(found_cycle, "ERROR: No cycle found in {}".format(fname)) expect(found_signal == expected_signal, "ERROR: Expected {} post-DA resume signal message(s), {} found in {}".format(expected_signal, found_signal, fname)) expect(found_init == expected_init, "ERROR: Expected {} Initial run message(s), {} found in {}".format(expected_init, found_init, fname)) # End with cycle_num = cycle_num + 1