예제 #1
0
 def test_baselineDir_overridden(self):
     """Tests get_possibly_overridden_mach_value when baseline_dir is provided"""
     defaults = self.create_defaults()
     machine = create_machine('cheyenne', defaults, account='a123')
     baseline_dir = get_possibly_overridden_mach_value(
         machine, varname='baseline_dir', value='mypath')
     self.assertEqual(baseline_dir, 'mypath')
예제 #2
0
 def test_baselineDir_default(self):
     """Tests get_possibly_overridden_mach_value when baseline_dir is not provided"""
     defaults = self.create_defaults()
     machine = create_machine('cheyenne', defaults, account='a123')
     baseline_dir = get_possibly_overridden_mach_value(
         machine, varname='baseline_dir', value=None)
     self.assertEqual(baseline_dir,
                      os.path.join(os.path.sep, 'my', 'baselines'))
예제 #3
0
 def test_baselineDir_noDefault(self):
     """Tests get_possibly_overridden_mach_value when baseline_dir is not provided
     and there is no default"""
     machine = create_machine('unknown_test_machine',
                              MACHINE_DEFAULTS,
                              account='a123')
     baseline_dir = get_possibly_overridden_mach_value(
         machine, varname='baseline_dir', value=None)
     self.assertIsNone(baseline_dir)
예제 #4
0
def run_sys_tests(machine,
                  cime_path,
                  skip_testroot_creation=False,
                  skip_git_status=False,
                  dry_run=False,
                  suite_name=None,
                  testfile=None,
                  testlist=None,
                  suite_compilers=None,
                  testid_base=None,
                  testroot_base=None,
                  rerun_existing_failures=False,
                  compare_name=None,
                  generate_name=None,
                  baseline_root=None,
                  walltime=None,
                  queue=None,
                  retry=None,
                  extra_create_test_args=''):
    """Implementation of run_sys_tests command

    Exactly one of suite_name, testfile or testlist should be provided

    Args:
    machine: Machine object, as defined in machine.py
    cime_path (str): path to root of cime
    skip_testroot_creation (bool): if True, assume the testroot directory has already been
        created, so don't try to recreate it or re-make the link to it
    skip_git_status (bool): if True, skip printing git and manage_externals status
    dry_run (bool): if True, print commands to be run but don't run them
    suite_name (str): name of test suite/category to run
    testfile (str): path to file containing list of tests to run
    testlist (list of strings): names of tests to run
    suite_compilers (list of strings): compilers to use in the test suite; only applicable
        with suite_name; if not specified, use all compilers that are defined for this
        test suite
    testid_base (str): test id, or start of the test id in the case of a test suite (if
        not provided, will be generated automatically)
    testroot_base (str): path to the directory that will contain the testroot (if not
        provided, will be determined based on machine defaults)
    rerun_existing_failures (bool): if True, add the '--use-existing' option to create_test
        If specified, then --testid-base should also be specified. This also implies
        skip_testroot_creation.
    compare_name (str): if not None, baseline name to compare against
    generate_name (str): if not None, baseline name to generate
    baseline_root (str): path in which baselines should be compared and generated (if not
        provided, this will be obtained from the default value in the machine object; if
        that is None, then the test suite will determine it automatically)
    walltime (str): walltime to use for each test (if not provided, the test suite will
        determine it automatically)
    queue (str): queue to use for each test (if not provided, will use the default for
        this machine based on the passed-in machine object; if that is unspecified, then
        the test suite will determine it automatically)
    retry (int): retry value to pass to create_test (if not provided, will use the default
        for this machine)
    extra_create_test_args (str): any extra arguments to create_test, as a single,
        space-delimited string
    testlist: list of strings giving test names to run

    """
    num_provided_options = ((suite_name is not None) + (testfile is not None) +
                            (testlist is not None and len(testlist) > 0))
    if num_provided_options != 1:
        raise RuntimeError(
            "Exactly one of suite_name, testfile or testlist must be provided")

    if testid_base is None:
        testid_base = _get_testid_base(machine.name)
    if testroot_base is None:
        testroot_base = _get_testroot_base(machine)
    testroot = _get_testroot(testroot_base, testid_base)
    if not (skip_testroot_creation or rerun_existing_failures):
        _make_testroot(testroot, testid_base, dry_run)
    else:
        if not os.path.exists(testroot):
            raise RuntimeError(
                "testroot directory does NOT exist as expected when a rerun" +
                " option is used: directory expected = " + testroot)
    print("Testroot: {}\n".format(testroot))
    retry_final = get_possibly_overridden_mach_value(
        machine, varname='create_test_retry', value=retry)
    # Note the distinction between a queue of None and a queue of
    # CREATE_TEST_QUEUE_UNSPECIFIED in the following: If queue is None (meaning that the
    # user hasn't specified a '--queue' argument to run_sys_tests), then we'll use the
    # queue specified in the machine object; if queue is CREATE_TEST_QUEUE_UNSPECIFIED,
    # then we'll force queue_final to be None, which means we won't add a '--queue'
    # argument to create_test, regardless of what is specified in the machine object.
    # (It's also possible for the machine object to specify a queue of
    # CREATE_TEST_QUEUE_UNSPECIFIED, which means that we won't use a '--queue' argument to
    # create_test unless the user specifies a '--queue' argument to run_sys_tests.)
    queue_final = get_possibly_overridden_mach_value(
        machine, varname='create_test_queue', value=queue)
    if queue_final == CREATE_TEST_QUEUE_UNSPECIFIED:
        queue_final = None
    if not skip_git_status:
        _record_git_status(testroot, retry_final, dry_run)

    baseline_root_final = get_possibly_overridden_mach_value(
        machine, varname='baseline_dir', value=baseline_root)
    create_test_args = _get_create_test_args(
        compare_name=compare_name,
        generate_name=generate_name,
        baseline_root=baseline_root_final,
        account=machine.account,
        walltime=walltime,
        queue=queue_final,
        retry=retry_final,
        rerun_existing_failures=rerun_existing_failures,
        extra_create_test_args=extra_create_test_args)
    if suite_name:
        if not dry_run:
            _make_cs_status_for_suite(testroot, testid_base)
        _run_test_suite(cime_path=cime_path,
                        suite_name=suite_name,
                        suite_compilers=suite_compilers,
                        machine=machine,
                        testid_base=testid_base,
                        testroot=testroot,
                        create_test_args=create_test_args,
                        dry_run=dry_run)
    else:
        if not dry_run:
            _make_cs_status_non_suite(testroot, testid_base)
        if testfile:
            test_args = ['--testfile', os.path.abspath(testfile)]
        elif testlist:
            test_args = testlist
        else:
            raise RuntimeError(
                "None of suite_name, testfile or testlist were provided")
        _run_create_test(cime_path=cime_path,
                         test_args=test_args,
                         machine=machine,
                         testid=testid_base,
                         testroot=testroot,
                         create_test_args=create_test_args,
                         dry_run=dry_run)