Esempio n. 1
0
def test_compiler_bootstrap_from_binary_mirror(install_mockery_mutable_config,
                                               mock_packages, mock_fetch,
                                               mock_archive, mutable_config,
                                               monkeypatch, tmpdir):
    """Make sure installing compiler from buildcache registers compiler"""

    # Create a temp mirror directory for buildcache usage
    mirror_dir = tmpdir.join('mirror_dir')
    mirror_url = 'file://{0}'.format(mirror_dir.strpath)

    # Install a compiler, because we want to put it in a buildcache
    install('[email protected]')

    # Put installed compiler in the buildcache
    buildcache('create', '-u', '-a', '-f', '-d', mirror_dir.strpath,
               '[email protected]')

    # Now uninstall the compiler
    uninstall('-y', '[email protected]')

    monkeypatch.setattr(spack.concretize.Concretizer,
                        'check_for_compiler_existence', False)
    spack.config.set('config:install_missing_compilers', True)
    assert CompilerSpec('[email protected]') not in compilers.all_compiler_specs()

    # Configure the mirror where we put that buildcache w/ the compiler
    mirror('add', 'test-mirror', mirror_url)

    # Now make sure that when the compiler is installed from binary mirror,
    # it also gets configured as a compiler.  Test succeeds if it does not
    # raise an error
    install('--no-check-signature', '--cache-only', '--only', 'dependencies',
            'b%[email protected]')
    install('--no-cache', '--only', 'package', 'b%[email protected]')
Esempio n. 2
0
def test_compiler_bootstrap(install_mockery_mutable_config, mock_packages,
                            mock_fetch, mock_archive, mutable_config,
                            monkeypatch):
    monkeypatch.setattr(spack.concretize.Concretizer,
                        'check_for_compiler_existence', False)
    spack.config.set('config:install_missing_compilers', True)
    assert CompilerSpec('[email protected]') not in compilers.all_compiler_specs()

    # Test succeeds if it does not raise an error
    install('a%[email protected]')
Esempio n. 3
0
def test_ci_generate_bootstrap_prune_dag(install_mockery_mutable_config,
                                         mock_packages, mock_fetch,
                                         mock_archive, mutable_config,
                                         monkeypatch, tmpdir,
                                         mutable_mock_env_path,
                                         env_deactivate):
    """Test compiler bootstrapping with DAG pruning.  Specifically, make
       sure that if we detect the bootstrapped compiler needs to be rebuilt,
       we ensure the spec we want to build with that compiler is scheduled
       for rebuild as well."""

    # Create a temp mirror directory for buildcache usage
    mirror_dir = tmpdir.join('mirror_dir')
    mirror_url = 'file://{0}'.format(mirror_dir.strpath)

    # Install a compiler, because we want to put it in a buildcache
    install_cmd('[email protected]%[email protected]')

    # Put installed compiler in the buildcache
    buildcache_cmd('create', '-u', '-a', '-f', '-d', mirror_dir.strpath,
                   '[email protected]%[email protected]')

    # Now uninstall the compiler
    uninstall_cmd('-y', '[email protected]%[email protected]')

    monkeypatch.setattr(spack.concretize.Concretizer,
                        'check_for_compiler_existence', False)
    spack.config.set('config:install_missing_compilers', True)
    assert CompilerSpec('[email protected]') not in compilers.all_compiler_specs()

    # Configure the mirror where we put that buildcache w/ the compiler
    mirror_cmd('add', 'test-mirror', mirror_url)

    install_cmd('--no-check-signature', 'a%[email protected]')

    # Put spec built with installed compiler in the buildcache
    buildcache_cmd('create', '-u', '-a', '-f', '-d', mirror_dir.strpath,
                   'a%[email protected]')

    # Now uninstall the spec
    uninstall_cmd('-y', 'a%[email protected]')

    filename = str(tmpdir.join('spack.yaml'))
    with open(filename, 'w') as f:
        f.write("""\
spack:
  definitions:
    - bootstrap:
      - [email protected]%[email protected]
  specs:
    - a%[email protected]
  mirrors:
    atestm: {0}
  gitlab-ci:
    bootstrap:
      - name: bootstrap
        compiler-agnostic: true
    mappings:
      - match:
          - arch=test-debian6-x86_64
        runner-attributes:
          tags:
            - donotcare
      - match:
          - arch=test-debian6-core2
        runner-attributes:
          tags:
            - meh
""".format(mirror_url))

    # Without this monkeypatch, pipeline generation process would think that
    # nothing in the environment needs rebuilding.  With the monkeypatch, the
    # process sees the compiler as needing a rebuild, which should then result
    # in the specs built with that compiler needing a rebuild too.
    def fake_get_mirrors_for_spec(spec=None,
                                  full_hash_match=False,
                                  mirrors_to_check=None,
                                  index_only=False):
        if spec.name == 'gcc':
            return []
        else:
            return [{
                'spec': spec,
                'mirror_url': mirror_url,
            }]

    with tmpdir.as_cwd():
        env_cmd('create', 'test', './spack.yaml')
        outputfile = str(tmpdir.join('.gitlab-ci.yml'))

        with ev.read('test'):
            monkeypatch.setattr(ci, 'SPACK_PR_MIRRORS_ROOT_URL',
                                r"file:///fake/mirror")

            ci_cmd('generate', '--output-file', outputfile)

            with open(outputfile) as of:
                yaml_contents = of.read()
                original_yaml_contents = syaml.load(yaml_contents)

            # without the monkeypatch, everything appears up to date and no
            # rebuild jobs are generated.
            assert (original_yaml_contents)
            assert ('no-specs-to-rebuild' in original_yaml_contents)

            monkeypatch.setattr(spack.binary_distribution,
                                'get_mirrors_for_spec',
                                fake_get_mirrors_for_spec)

            ci_cmd('generate', '--output-file', outputfile)

            with open(outputfile) as of:
                yaml_contents = of.read()
                new_yaml_contents = syaml.load(yaml_contents)

            assert (new_yaml_contents)

            # This 'needs' graph reflects that even though specs 'a' and 'b' do
            # not otherwise need to be rebuilt (thanks to DAG pruning), they
            # both end up in the generated pipeline because the compiler they
            # depend on is bootstrapped, and *does* need to be rebuilt.
            needs_graph = {
                '(bootstrap) gcc': [],
                '(specs) b': [
                    '(bootstrap) gcc',
                ],
                '(specs) a': [
                    '(bootstrap) gcc',
                    '(specs) b',
                ],
            }

            _validate_needs_graph(new_yaml_contents, needs_graph, False)