Example #1
0
def test_get_threads(project_dir):
    threads = get_threads(str(project_dir), 'check-patch')
    assert list(threads) == [
        JobThread(
            'check-patch', 'default', 'el7', 'x86_64', {
                'yumrepos':
                None,
                'script':
                'automation/check-patch.sh',
                'upstreamsources': {},
                'repos': [
                    RepoConfig('repo-734392d7a1ac9e3cfe63184b3e48eb0c',
                               'repo1'),
                    RepoConfig('repo-1f02dddd81d2931b7c82f0a857dc2431',
                               'repo2'),
                    RepoConfig('repo-1fb4cda750e4eac7714ee79c6bb4db28',
                               'repo3')
                ],
                'environment': [{
                    'name': 'test',
                    'valuefrom': {
                        'runtimeenv': 'PWD'
                    }
                }],
                'runtimerequirements':
                'dummy_req',
                'mounts': [],
                'releasebranches': {},
                'packages': ['pkg1', 'pkg2', 'pkg3'],
                'ignore_if_missing_script':
                True,
                DepthLevel:
                1
            })
    ]
Example #2
0
def test_resolve_changed_files(modified, conditions, expected, monkeypatch):
    monkeypatch.setattr(
        'scripts.stdci_dsl.options.normalize.MODIFIED_FILES',
        {'project': modified},
    )
    thread = JobThread('a', 'b', 'c', 'd', {})
    out = _resolve_changed_files('project', thread, conditions)
    assert out == expected
Example #3
0
def test_get_threads_with_globals(project_dir):
    threads, gopts = get_threads_with_globals(str(project_dir), 'check-patch')
    assert list(threads) == [
        JobThread(
            'check-patch',
            'default',
            'el7',
            'x86_64',
            {
                'yumrepos':
                None,
                'script':
                'automation/check-patch.sh',
                'upstreamsources': {},
                'repos': [
                    RepoConfig('repo-734392d7a1ac9e3cfe63184b3e48eb0c',
                               'repo1'),  # noqa
                    RepoConfig('repo-1f02dddd81d2931b7c82f0a857dc2431',
                               'repo2'),  # noqa
                    RepoConfig('repo-1fb4cda750e4eac7714ee79c6bb4db28',
                               'repo3'),  # noqa
                ],
                'environment': [{
                    'name': 'test',
                    'valuefrom': {
                        'runtimeenv': 'PWD'
                    }
                }],
                'runtimerequirements': {
                    'supportnestinglevel': 0,
                    'hostdistro': 'any',
                    'isolationlevel': 'virtual',
                },
                'mounts': [],
                'releasebranches': {},
                'packages': ['pkg1', 'pkg2', 'pkg3'],
                'ignore_if_missing_script':
                True,
                'reporting': {
                    'style': 'default',
                },
                'timeout':
                '3h',
                DepthLevel:
                1
            })
    ]
    assert gopts == {'releasebranches': {}, 'upstreamsources': {}}
Example #4
0
def apply_default_categories(threads, current_stage=None):
    """Apply default values for categories in a given list of JobThread objects

    :param Iterable threads: Iterable of threads to set default values for.
    :param str current_stage:    Current stage we process threads for.

    :rtype: Iterator
    :returns: Iterator over a new list of threads whith default categories set.
    """
    return (
        JobThread(
            stage=thread.stage if thread.stage is not None else current_stage,
            substage=thread.substage if thread.substage is not None else 'default',
            distro=thread.distro if thread.distro is not None else 'el7',
            arch=thread.arch if thread.arch is not None else 'x86_64',
            options=thread.options
        ) for thread in threads
    )
Example #5
0
def test_normalize_timeout_exception(timeout_input, exception):
    jt = JobThread('st', 'sbst', 'dst', 'ar', {'timeout': timeout_input})
    with pytest.raises(exception):
        _normalize_timeout(jt)
Example #6
0
def test_normalize_timeout(timeout_input, expected_output):
    jt = JobThread('st', 'sbst', 'dst', 'ar', {'timeout': timeout_input})
    output = _normalize_timeout(jt)
    print(type(output))
    assert output == expected_output
Example #7
0
def test_resolve_changed_files_exceptions(conditions, monkeypatch):
    monkeypatch.setattr('scripts.stdci_dsl.options.normalize.MODIFIED_FILES',
                        {'project': []})
    thread = JobThread('a', 'b', 'c', 'd', {})
    with pytest.raises(ConfigurationSyntaxError):
        _resolve_changed_files('project', thread, conditions)
Example #8
0
def stdci_project_dir(tmpdir):
    project_dir = tmpdir.mkdir('stdci-project')
    automation = project_dir.mkdir('automation')
    (automation / 'check-patch.environment.yaml').write('test: yaml cfg\n')
    (automation / 'check-patch.sh').write('script')
    (automation / 'check-patch.packages').write('p1\np2')
    (automation / 'check-patch.yumrepos').write('yumreposfile')
    (automation / 'check-merged.sh').mksymlinkto('check-patch.sh')
    return project_dir


@pytest.mark.parametrize(
    "thread,expected",
    [(JobThread(
        'chk-patch', 'default', 'el7', 'x86_64', {
            'mounts':
            ['mymount1:mymountdst1', 'mymount2:mymountdst2', 'mymountdst3'],
        }), [
            MountConfig(src='mymount1', dst='mymountdst1'),
            MountConfig(src='mymount2', dst='mymountdst2'),
            MountConfig(src='mymountdst3', dst='mymountdst3')
        ]),
     (JobThread('chk-patch', 'default', 'el7', 'x86_64', {
         'mounts': ['mount1', 'mount2', 'mount3'],
     }), [
         MountConfig(src='mount1', dst='mount1'),
         MountConfig(src='mount2', dst='mount2'),
         MountConfig(src='mount3', dst='mount3')
     ]),
     (JobThread('chk-patch', 'default', 'el7', 'x86_64', {'mounts': []}), [])])
def test_normalize_mounts_config(thread, expected, stdci_project_dir):
Example #9
0
@pytest.fixture(scope='function')
def stdci_project_dir(tmpdir):
    project_dir = tmpdir.mkdir('stdci-project')
    automation = project_dir.mkdir('automation')
    (automation / 'check-patch.environment.yaml').write('test: yaml cfg\n')
    (automation / 'check-patch.sh').write('script')
    (automation / 'check-patch.packages').write('p1\np2')
    (automation / 'check-patch.yumrepos').write('yumreposfile')
    (automation / 'check-merged.sh').mksymlinkto('check-patch.sh')
    return project_dir


@pytest.mark.parametrize("thread,expected", [
    (JobThread(
        'check-patch', 'default', 'el7', 'x86_64', {
            'mounts':
            ['mymount1:mymountdst1', 'mymount2:mymountdst2', 'mymountdst3'],
        }), [
            MountConfig(src='mymount1', dst='mymountdst1'),
            MountConfig(src='mymount2', dst='mymountdst2'),
            MountConfig(src='mymountdst3', dst='mymountdst3')
        ]),
    (JobThread('check-patch', 'default', 'el7', 'x86_64', {
        'mounts': ['mount1', 'mount2', 'mount3'],
    }), [
        MountConfig(src='mount1', dst='mount1'),
        MountConfig(src='mount2', dst='mount2'),
        MountConfig(src='mount3', dst='mount3')
    ]),
    (JobThread('check-patch', 'default', 'el7', 'x86_64', {'mounts': []}), [])
])
Example #10
0
 }, ('global_config:\n'
     '  release_branches:\n'
     '    r: b\n'
     '  upstream_sources:\n'
     '    u: s\n'
     'jobs: []\n')),
 ([
     JobThread(
         'check-patch', 'default', 'fc25', 'x86_64', {
             'script': 's',
             'releasebranches': {
                 'r': 'b'
             },
             'upstreamsources': {
                 'u': 's'
             },
             'runtimerequirements': {
                 'r': 'r'
             },
             'reporting': {
                 'style': 'default'
             },
             'timeout': '3h',
         }),
     JobThread(
         'build-artifacts', 'default', 'fc26', 'x86_64', {
             'script': 's',
             'releasebranches': {
                 'r': 'b'
             },
             'upstreamsources': {
Example #11
0
#!/bin/env python

import pytest
from scripts.stdci_dsl.categories import apply_default_categories
from scripts.stdci_dsl.job_thread import JobThread


@pytest.mark.parametrize("vectors,expected", [
    ([], []),
    ([JobThread(None, None, None, None, {})
      ], [JobThread('check-patch', 'default', 'el7', 'x86_64', {})]),
    (
        [
            JobThread(None, 'substage', 'distro', 'arch', {}),
            JobThread('stage', None, 'distro', 'arch', {}),
            JobThread('stage', 'substage', None, 'arch', {}),
            JobThread('stage', 'substage', 'arch', None, {}),
        ],
        [
            JobThread('check-patch', 'substage', 'distro', 'arch', {}),
            JobThread('stage', 'default', 'distro', 'arch', {}),
            JobThread('stage', 'substage', 'el7', 'arch', {}),
            JobThread('stage', 'substage', 'arch', 'x86_64', {}),
        ],
    ),
    (
        [JobThread('stage', 'substage', 'distro', 'arch', {'opts': 'v'})],
        [JobThread('stage', 'substage', 'distro', 'arch', {'opts': 'v'})],
    ),
])
def test_apply_default_categories(vectors, expected):
Example #12
0
         'u': 's'
     },
 }, ('global_config:\n'
     '  release_branches:\n'
     '    r: b\n'
     '  upstream_sources:\n'
     '    u: s\n'
     'jobs: []\n')),
 ([
     JobThread(
         'check-patch', 'default', 'fc25', 'x86_64', {
             'script': 's',
             'releasebranches': {
                 'r': 'b'
             },
             'upstreamsources': {
                 'u': 's'
             },
             'runtimerequirements': {
                 'r': 'r'
             },
         }),
     JobThread(
         'build-artifacts', 'default', 'fc26', 'x86_64', {
             'script': 's',
             'releasebranches': {
                 'r': 'b'
             },
             'upstreamsources': {
                 'u': 's'
             },