示例#1
0
def process():
    # pylint: disable=no-else-return  - false positive
    # TODO: should we take care about stuff of kernel-rt and kernel in the same
    # time when both are present? or just one? currently, handle only one
    # of these during the upgrade. kernel-rt has higher prio when original sys
    # was realtime

    if is_rhel_realtime():
        version = _get_kernel_version('kernel-rt')
        if version:
            api.produce(InstalledTargetKernelVersion(version=version))
            return
        else:
            api.current_logger().warning(
                'The kernel-rt rpm from RHEL 8 has not been detected. Switching to non-preemptive kernel.'
            )
            # TODO: create report with instructions to install kernel-rt manually
            # - attach link to article if any
            # - this possibly happens just in case the repository with kernel-rt
            # # is not enabled during the upgrade.

    # standard (non-preemptive) kernel
    version = _get_kernel_version('kernel')
    if version:
        api.produce(InstalledTargetKernelVersion(version=version))
    else:
        # This is very unexpected situation. At least one kernel has to be
        # installed always. Some actors consuming the InstalledTargetKernelVersion
        # will crash without the created message. I am keeping kind of original
        # behaviour in this case, but at least the let me log the error msg
        #
        api.current_logger().error('Cannot detect any kernel RPM')
示例#2
0
def test_flawless(monkeypatch, msgs, files, modules):
    _msgs = msgs + [InstalledTargetKernelVersion(version=KERNEL_VERSION)]
    run_mocked = RunMocked()
    monkeypatch.setattr(api, 'current_actor', CurrentActorMocked(msgs=_msgs))
    monkeypatch.setattr(targetinitramfsgenerator, 'run', run_mocked)
    # FIXME
    monkeypatch.setattr(targetinitramfsgenerator, 'copy_dracut_modules',
                        lambda dummy: None)

    targetinitramfsgenerator.process()
    assert run_mocked.called

    # check files
    if files:
        assert '--install' in run_mocked.args
        arg = run_mocked.args[run_mocked.args.index('--install') + 1]
        for f in files:
            assert f in arg
    else:
        assert '--install' not in run_mocked.args

    # check modules
    if modules:
        assert '--add' in run_mocked.args
        arg = run_mocked.args[run_mocked.args.index('--add') + 1]
        for m in modules:
            assert m[0] in arg
    else:
        assert '--add' not in run_mocked.args
示例#3
0
def process():
    kernels = stdlib.run(["rpm", "-q", "kernel"], split=True)["stdout"]
    for kernel in kernels:
        version = kernel.split("-", 1)[1]
        if "el8" in version:
            api.produce(InstalledTargetKernelVersion(version=version))
            break
示例#4
0
def mocked_consume(*models):
    if InstalledTargetKernelVersion in models:
        return iter((InstalledTargetKernelVersion(version=KERNEL_VERSION),))
    return iter((
        KernelCmdlineArg(key='some_key1', value='some_value1'),
        KernelCmdlineArg(key='some_key2', value='some_value2')
    ))
def test_flawless(monkeypatch):
    run_mocked = RunMocked()
    monkeypatch.setattr(
        api, 'current_actor',
        CurrentActorMocked(msgs=[
            InitrdIncludes(files=INCLUDES1),
            InitrdIncludes(files=INCLUDES2),
            InstalledTargetKernelVersion(version=KERNEL_VERSION)
        ]))
    monkeypatch.setattr(initrdinclude, 'run', run_mocked)

    initrdinclude.process()
    assert run_mocked.called
    for f in INCLUDES1 + INCLUDES2:
        assert (f in arg for arg in run_mocked.args)
def test_dracut_fail(monkeypatch):
    run_mocked = RunMocked(raise_err=True)
    monkeypatch.setattr(
        api, 'current_actor',
        CurrentActorMocked(msgs=[
            InitrdIncludes(files=INCLUDES1),
            InitrdIncludes(files=INCLUDES2),
            InstalledTargetKernelVersion(version=KERNEL_VERSION)
        ]))
    monkeypatch.setattr(initrdinclude, 'run', run_mocked)

    with pytest.raises(StopActorExecutionError) as e:
        initrdinclude.process()
    assert 'Cannot regenerate dracut image' in str(e)
    assert run_mocked.called
示例#7
0
def test_dracut_fail(monkeypatch, msgs):
    run_mocked = RunMocked(raise_err=True)
    monkeypatch.setattr(api, 'current_actor', CurrentActorMocked(msgs=msgs))
    monkeypatch.setattr(
        api, 'current_actor',
        CurrentActorMocked(
            msgs=msgs +
            [InstalledTargetKernelVersion(version=KERNEL_VERSION)]))
    monkeypatch.setattr(targetinitramfsgenerator, 'run', run_mocked)
    # FIXME
    monkeypatch.setattr(targetinitramfsgenerator, 'copy_dracut_modules',
                        lambda dummy: None)

    with pytest.raises(StopActorExecutionError) as e:
        targetinitramfsgenerator.process()
    assert 'Cannot regenerate dracut image' in str(e)
    assert run_mocked.called
 def impl(*args):
     if case.message_available:
         return iter((InstalledTargetKernelVersion(
             version=TARGET_KERNEL_VERSION), ))
     return iter(())
def mocked_consume_no_args(*models):
    if InstalledTargetKernelVersion in models:
        return iter((InstalledTargetKernelVersion(version=KERNEL_VERSION), ))
    return iter(())