コード例 #1
0
ファイル: wait_for_tests.py プロジェクト: helenhe40/cime
def create_cdash_upload_xml(results, cdash_build_name, cdash_build_group, utc_time, hostname):
###############################################################################

    data_rel_path = os.path.join("Testing", utc_time)

    try:
        log_dir = "%s_logs" % cdash_build_name

        need_to_upload = False

        for test_name, test_data in results.iteritems():
            test_path, test_status = test_data

            if (test_status not in [TEST_PASS_STATUS, NAMELIST_FAIL_STATUS]):
                full_results = parse_test_status_file(test_path)[0]

                if ("BUILD" in full_results): # If did not even make it to build phase, no useful logs
                    if ( full_results["BUILD"] != TEST_PASS_STATUS or
                         ("RUN" in full_results and full_results["RUN"] != TEST_PASS_STATUS) ):

                        param = "EXEROOT" if full_results["BUILD"] != TEST_PASS_STATUS else "RUNDIR"
                        src_dir = acme_util.run_cmd("./xmlquery %s -value" % param, from_dir=os.path.dirname(test_path))
                        log_dst_dir = os.path.join(log_dir, "%s_%s_logs" % (test_name, param))
                        os.makedirs(log_dst_dir)
                        for log_file in glob.glob(os.path.join(src_dir, "*log*")):
                            shutil.copy(log_file, log_dst_dir)

                        need_to_upload = True

        if (need_to_upload):

            tarball = "%s.tar.gz" % log_dir
            if (os.path.exists(tarball)):
                os.remove(tarball)

            acme_util.run_cmd("tar -cf - %s | gzip -c > %s" % (log_dir, tarball))
            base64 = acme_util.run_cmd("base64 %s" % tarball)

            xml_text = \
r"""<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="Dart/Source/Server/XSL/Build.xsl <file:///Dart/Source/Server/XSL/Build.xsl> "?>
<Site BuildName="%s" BuildStamp="%s-%s" Name="%s" Generator="ctest3.0.0">
<Upload>
<File filename="%s">
<Content encoding="base64">
%s
</Content>
</File>
</Upload>
</Site>
""" % (cdash_build_name, utc_time, cdash_build_group, hostname, os.path.abspath(tarball), base64)

            with open(os.path.join(data_rel_path, "Upload.xml"), "w") as fd:
                fd.write(xml_text)

    finally:
        if (os.path.isdir(log_dir)):
            shutil.rmtree(log_dir)
コード例 #2
0
ファイル: create_test_impl.py プロジェクト: E3SM-Project/cime
    def _nlcomp_phase(self, test_name):
    ###########################################################################
        test_dir          = self._get_test_dir(test_name)
        casedoc_dir       = os.path.join(test_dir, "CaseDocs")
        baseline_dir      = os.path.join(self._baseline_root, self._baseline_name, test_name)
        baseline_casedocs = os.path.join(baseline_dir, "CaseDocs")
        compare_nl        = os.path.join(test_dir, "Tools/compare_namelists")
        simple_compare    = os.path.join(test_dir, "Tools/simple_compare")

        if (self._compare):
            has_fails = False

            # Start off by comparing everything in CaseDocs except a few arbitrary files (ugh!)
            # TODO: Namelist files should have consistent suffix
            all_items_to_compare = \
                [ item for item in glob.glob("%s/*" % casedoc_dir) if "README" not in os.path.basename(item) and not item.endswith("doc") and not item.endswith("prescribed") and not os.path.basename(item).startswith(".")] + \
                glob.glob("%s/*user_nl*" % test_dir)
            for item in all_items_to_compare:
                baseline_counterpart = os.path.join(baseline_casedocs if os.path.dirname(item).endswith("CaseDocs") else baseline_dir,
                                                    os.path.basename(item))
                if (not os.path.exists(baseline_counterpart)):
                    self._log_output(test_name, "Missing baseline namelist '%s'" % baseline_counterpart)
                    has_fails = True
                else:
                    if (compare_namelists.is_namelist_file(item)):
                        rc, output, _  = run_cmd("%s %s %s -c %s 2>&1" % (compare_nl, baseline_counterpart, item, test_name), ok_to_fail=True)
                    else:
                        rc, output, _  = run_cmd("%s %s %s -c %s 2>&1" % (simple_compare, baseline_counterpart, item, test_name), ok_to_fail=True)

                    if (rc != 0):
                        has_fails = True
                        self._log_output(test_name, output)

            if (has_fails):
                idx = self._test_names.index(test_name)
                self._tests_with_nl_problems[idx] = test_name

        elif (self._generate):
            if (not os.path.isdir(baseline_dir)):
                os.makedirs(baseline_dir, stat.S_IRWXU | stat.S_IRWXG | stat.S_IXOTH | stat.S_IROTH)

            if (os.path.isdir(baseline_casedocs)):
                shutil.rmtree(baseline_casedocs)
            shutil.copytree(casedoc_dir, baseline_casedocs)
            os.chmod(baseline_casedocs, stat.S_IRWXU | stat.S_IRWXG | stat.S_IXOTH | stat.S_IROTH)
            for item in glob.glob("%s/*" % baseline_casedocs):
                os.chmod(item, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IWGRP)

            for item in glob.glob(os.path.join(test_dir, "user_nl*")):
                preexisting_baseline = os.path.join(baseline_dir, os.path.basename(item))
                if (os.path.exists(preexisting_baseline)):
                    os.remove(preexisting_baseline)
                shutil.copy2(item, baseline_dir)
                os.chmod(preexisting_baseline, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IWGRP)

        # Always mark as passed unless we hit exception
        return True
コード例 #3
0
    def _run_phase_command(self, test_name, cmd, phase, from_dir=None):
        ###########################################################################
        while (True):
            rc, output, errput = run_cmd(cmd,
                                         ok_to_fail=True,
                                         from_dir=from_dir)
            if (rc != 0):
                self._log_output(
                    test_name,
                    "%s FAILED for test '%s'.\nCommand: %s\nOutput: %s\n\nErrput: %s"
                    % (phase, test_name, cmd, output, errput))
                # Temporary hack to get around odd file descriptor use by
                # buildnml scripts.
                if ("bad interpreter" in errput):
                    time.sleep(1)
                    continue
                else:
                    break
            else:
                self._log_output(
                    test_name,
                    "%s PASSED for test '%s'.\nCommand: %s\nOutput: %s\n\nErrput: %s"
                    % (phase, test_name, cmd, output, errput))
                break

        return rc == 0
コード例 #4
0
ファイル: create_test_impl.py プロジェクト: rljacob/cime
 def _get_procs_needed(self, test_name, phase):
 ###########################################################################
     if (phase == RUN_PHASE and self._no_batch):
         test_dir = self._get_test_dir(test_name)
         out = run_cmd("./xmlquery TOTALPES -value", from_dir=test_dir)
         return int(out)
     else:
         return 1
コード例 #5
0
 def _get_procs_needed(self, test_name, phase):
     ###########################################################################
     if (phase == RUN_PHASE and self._no_batch):
         test_dir = self._get_test_dir(test_name)
         out = run_cmd("./xmlquery TOTALPES -value", from_dir=test_dir)
         return int(out)
     else:
         return 1
コード例 #6
0
ファイル: wait_for_tests.py プロジェクト: helenhe40/cime
def get_test_time(test_path):
###############################################################################
    cmd = "grep TIME %s" % os.path.join(test_path, TEST_STATUS_FILENAME)
    stat, output, _ = acme_util.run_cmd(cmd, ok_to_fail=True)
    if (stat == 0):
        return int(output.split()[-1])
    else:
        warning("No timing data found in %s" % test_path)
        return 0
コード例 #7
0
ファイル: wait_for_tests.py プロジェクト: helenhe40/cime
def get_test_time(test_path):
    ###############################################################################
    cmd = "grep TIME %s" % os.path.join(test_path, TEST_STATUS_FILENAME)
    stat, output, _ = acme_util.run_cmd(cmd, ok_to_fail=True)
    if (stat == 0):
        return int(output.split()[-1])
    else:
        warning("No timing data found in %s" % test_path)
        return 0
コード例 #8
0
ファイル: create_test_impl.py プロジェクト: rljacob/cime
    def _run_phase_command(self, test_name, cmd, phase, from_dir=None):
    ###########################################################################
        while (True):
            rc, output, errput = run_cmd(cmd, ok_to_fail=True, from_dir=from_dir)
            if (rc != 0):
                self._log_output(test_name,
                                 "%s FAILED for test '%s'.\nCommand: %s\nOutput: %s\n\nErrput: %s" %
                                 (phase, test_name, cmd, output, errput))
                # Temporary hack to get around odd file descriptor use by
                # buildnml scripts.
                if ("bad interpreter" in errput):
                    time.sleep(1)
                    continue
                else:
                    break
            else:
                self._log_output(test_name,
                                 "%s PASSED for test '%s'.\nCommand: %s\nOutput: %s\n\nErrput: %s" %
                                 (phase, test_name, cmd, output, errput))
                break

        return rc == 0
コード例 #9
0
ファイル: update_acme_tests.py プロジェクト: rljacob/cime
def update_acme_tests(xml_file, categories, platform=None):
###############################################################################
    # Retrieve all supported ACME platforms, killing the third entry (MPI lib)
    # for the moment.
    supported_platforms = [p[:2] for p in find_all_supported_platforms()]

    # Fish all of the existing machine/compiler combos out of the XML file.
    if (platform is not None):
        platforms = [tuple(platform.split(","))]
    else:
        platforms = find_all_platforms(xml_file)
        # Prune the non-supported platforms from our list.
        for p in platforms:
            if p not in supported_platforms:
                acme_util.verbose_print("pruning unsupported platform %s"%repr(p))
        platforms = [p for p in platforms if p in supported_platforms]

    manage_xml_entries = os.path.join(acme_util.get_cime_root(), "scripts", "manage_testlists")

    expect(os.path.isfile(manage_xml_entries),
           "Couldn't find manage_testlists, expected it to be here: '%s'" % manage_xml_entries)

    for category in categories:
        # Remove any existing acme test category from the file.
        if (platform is None):
            acme_util.run_cmd("%s -component allactive -removetests -category %s" % (manage_xml_entries, category))
        else:
            acme_util.run_cmd("%s -component allactive -removetests -category %s -machine %s -compiler %s"
                              % (manage_xml_entries, category, platforms[0][0], platforms[0][1]))

        # Generate a list of test entries corresponding to our suite at the top
        # of the file.
        new_test_file = generate_acme_test_entries(category, platforms)
        acme_util.run_cmd("%s -component allactive -addlist -file %s -category %s" %
                          (manage_xml_entries, new_test_file, category))
        os.unlink(new_test_file)

    print "SUCCESS"
コード例 #10
0
def update_acme_tests(xml_file, categories, platform=None):
###############################################################################
    # Retrieve all supported ACME platforms, killing the third entry (MPI lib)
    # for the moment.
    supported_platforms = [p[:2] for p in find_all_supported_platforms()]

    # Fish all of the existing machine/compiler combos out of the XML file.
    if (platform is not None):
        platforms = [tuple(platform.split(","))]
    else:
        platforms = find_all_platforms(xml_file)
        # Prune the non-supported platforms from our list.
        for p in platforms:
            if p not in supported_platforms:
                acme_util.verbose_print("pruning unsupported platform %s"%repr(p))
        platforms = [p for p in platforms if p in supported_platforms]

    manage_xml_entries = os.path.join(acme_util.get_cime_root(), "scripts", "manage_testlists")

    expect(os.path.isfile(manage_xml_entries),
           "Couldn't find manage_testlists, expected it to be here: '%s'" % manage_xml_entries)

    for category in categories:
        # Remove any existing acme test category from the file.
        if (platform is None):
            acme_util.run_cmd("%s -component allactive -removetests -category %s" % (manage_xml_entries, category))
        else:
            acme_util.run_cmd("%s -component allactive -removetests -category %s -machine %s -compiler %s"
                              % (manage_xml_entries, category, platforms[0][0], platforms[0][1]))

        # Generate a list of test entries corresponding to our suite at the top
        # of the file.
        new_test_file = generate_acme_test_entries(category, platforms)
        acme_util.run_cmd("%s -component allactive -addlist -file %s -category %s" %
                          (manage_xml_entries, new_test_file, category))
        os.unlink(new_test_file)

    print "SUCCESS"
コード例 #11
0
ファイル: wait_for_tests.py プロジェクト: helenhe40/cime
def create_cdash_xml(results, cdash_build_name, cdash_project, cdash_build_group, start_time):
###############################################################################

    #
    # Create dart config file
    #

    if (start_time is None):
        warning("No valid start_time provided, using current time instead")
        start_time = time.time()

    utc_time_tuple = time.gmtime(start_time)
    cdash_timestamp = time.strftime("%H:%M:%S", utc_time_tuple)

    hostname = acme_util.probe_machine_name()
    if (hostname is None):
        hostname = socket.gethostname().split(".")[0]
        warning("Could not convert hostname '%s' into an ACME machine name" % (hostname))

    dart_config = \
"""
SourceDirectory: %s
BuildDirectory: %s

# Site is something like machine.domain, i.e. pragmatic.crd
Site: %s

# Build name is osname-revision-compiler, i.e. Linux-2.4.2-2smp-c++
BuildName: %s

# Submission information
IsCDash: TRUE
CDashVersion:
QueryCDashVersion:
DropSite: my.cdash.org
DropLocation: /submit.php?project=%s
DropSiteUser:
DropSitePassword:
DropSiteMode:
DropMethod: http
TriggerSite:
ScpCommand: %s

# Dashboard start time
NightlyStartTime: %s UTC
""" % (os.getcwd(), os.getcwd(), hostname,
       cdash_build_name, cdash_project, distutils.spawn.find_executable("scp"), cdash_timestamp)

    with open("DartConfiguration.tcl", "w") as dart_fd:
        dart_fd.write(dart_config)

    utc_time = time.strftime('%Y%m%d-%H%M', utc_time_tuple)
    os.makedirs(os.path.join("Testing", utc_time))

    # Make tag file
    with open("Testing/TAG", "w") as tag_fd:
        tag_fd.write("%s\n%s\n" % (utc_time, cdash_build_group))

    create_cdash_test_xml(results, cdash_build_name, cdash_build_group, utc_time, start_time, hostname)

    create_cdash_upload_xml(results, cdash_build_name, cdash_build_group, utc_time, hostname)

    acme_util.run_cmd("ctest -VV -D NightlySubmit", verbose=True)
コード例 #12
0
ファイル: wait_for_tests.py プロジェクト: helenhe40/cime
def create_cdash_xml(results, cdash_build_name, cdash_project,
                     cdash_build_group, start_time):
    ###############################################################################

    #
    # Create dart config file
    #

    if (start_time is None):
        warning("No valid start_time provided, using current time instead")
        start_time = time.time()

    utc_time_tuple = time.gmtime(start_time)
    cdash_timestamp = time.strftime("%H:%M:%S", utc_time_tuple)

    hostname = acme_util.probe_machine_name()
    if (hostname is None):
        hostname = socket.gethostname().split(".")[0]
        warning("Could not convert hostname '%s' into an ACME machine name" %
                (hostname))

    dart_config = \
"""
SourceDirectory: %s
BuildDirectory: %s

# Site is something like machine.domain, i.e. pragmatic.crd
Site: %s

# Build name is osname-revision-compiler, i.e. Linux-2.4.2-2smp-c++
BuildName: %s

# Submission information
IsCDash: TRUE
CDashVersion:
QueryCDashVersion:
DropSite: my.cdash.org
DropLocation: /submit.php?project=%s
DropSiteUser:
DropSitePassword:
DropSiteMode:
DropMethod: http
TriggerSite:
ScpCommand: %s

# Dashboard start time
NightlyStartTime: %s UTC
""" % (os.getcwd(), os.getcwd(), hostname,
       cdash_build_name, cdash_project, distutils.spawn.find_executable("scp"), cdash_timestamp)

    with open("DartConfiguration.tcl", "w") as dart_fd:
        dart_fd.write(dart_config)

    utc_time = time.strftime('%Y%m%d-%H%M', utc_time_tuple)
    os.makedirs(os.path.join("Testing", utc_time))

    # Make tag file
    with open("Testing/TAG", "w") as tag_fd:
        tag_fd.write("%s\n%s\n" % (utc_time, cdash_build_group))

    create_cdash_test_xml(results, cdash_build_name, cdash_build_group,
                          utc_time, start_time, hostname)

    create_cdash_upload_xml(results, cdash_build_name, cdash_build_group,
                            utc_time, hostname)

    acme_util.run_cmd("ctest -VV -D NightlySubmit", verbose=True)
コード例 #13
0
ファイル: wait_for_tests.py プロジェクト: helenhe40/cime
def create_cdash_upload_xml(results, cdash_build_name, cdash_build_group,
                            utc_time, hostname):
    ###############################################################################

    data_rel_path = os.path.join("Testing", utc_time)

    try:
        log_dir = "%s_logs" % cdash_build_name

        need_to_upload = False

        for test_name, test_data in results.iteritems():
            test_path, test_status = test_data

            if (test_status not in [TEST_PASS_STATUS, NAMELIST_FAIL_STATUS]):
                full_results = parse_test_status_file(test_path)[0]

                if (
                        "BUILD" in full_results
                ):  # If did not even make it to build phase, no useful logs
                    if (full_results["BUILD"] != TEST_PASS_STATUS
                            or ("RUN" in full_results
                                and full_results["RUN"] != TEST_PASS_STATUS)):

                        param = "EXEROOT" if full_results[
                            "BUILD"] != TEST_PASS_STATUS else "RUNDIR"
                        src_dir = acme_util.run_cmd(
                            "./xmlquery %s -value" % param,
                            from_dir=os.path.dirname(test_path))
                        log_dst_dir = os.path.join(
                            log_dir, "%s_%s_logs" % (test_name, param))
                        os.makedirs(log_dst_dir)
                        for log_file in glob.glob(
                                os.path.join(src_dir, "*log*")):
                            shutil.copy(log_file, log_dst_dir)

                        need_to_upload = True

        if (need_to_upload):

            tarball = "%s.tar.gz" % log_dir
            if (os.path.exists(tarball)):
                os.remove(tarball)

            acme_util.run_cmd("tar -cf - %s | gzip -c > %s" %
                              (log_dir, tarball))
            base64 = acme_util.run_cmd("base64 %s" % tarball)

            xml_text = \
r"""<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="Dart/Source/Server/XSL/Build.xsl <file:///Dart/Source/Server/XSL/Build.xsl> "?>
<Site BuildName="%s" BuildStamp="%s-%s" Name="%s" Generator="ctest3.0.0">
<Upload>
<File filename="%s">
<Content encoding="base64">
%s
</Content>
</File>
</Upload>
</Site>
""" % (cdash_build_name, utc_time, cdash_build_group, hostname, os.path.abspath(tarball), base64)

            with open(os.path.join(data_rel_path, "Upload.xml"), "w") as fd:
                fd.write(xml_text)

    finally:
        if (os.path.isdir(log_dir)):
            shutil.rmtree(log_dir)