#8620 ipatests: add ability to resolve systemd unit names on the target system
Opened 3 years ago by abbra. Modified 3 years ago

Many tests do direct manipulation of systemd services like systemctl restart <name> in multiple tests. Recently, support for DNS service did change to use a different name for named service on Fedora than on RHEL8. As a result, use of named literal in the test suite does not work anymore with FreeIPA 4.9.0 release candidates:

Fedora:
In [1]: from ipaplatform.services import knownservices                                                                                                                                        
In [2]: print(knownservices.named.systemd_name)                                                                                                                                              
named.service

--------------------------------------------------------------

RHEL8.4
Red Hat Enterprise Linux release 8.4 Beta (Ootpa)

>>> from ipaplatform.services import knownservices
>>> print(knownservices.named.systemd_name)
named-pkcs11.service


[root@server1 ~]# systemctl restart named
Failed to restart named.service: Unit named.service is masked.
[root@server1 ~]# echo $?
1
[root@server1 ~]# systemctl status named
● named.service
   Loaded: masked (Reason: Unit named.service is masked.)
   Active: inactive (dead)

-----------------------------------------------------------
...
 2020-12-14T07:36:44 [ipatests.pytest_ipa.integration.host.Host.master.IPAOpenSSHTransport] INFO RUN ['ipa-adtrust-install', '-U', '--enable-compat', '--netbios-name', 'TESTRELM', '-a', 'Secret.123', '--add-sids']
2020-12-14T07:36:58 [ipatests.pytest_ipa.integration.host.Host.master.IPAOpenSSHTransport] INFO RUN ['python3', '-c', 'from ipaplatform.osinfo import OSInfo; print(OSInfo().platform)']
2020-12-14T07:36:58 [ipatests.pytest_ipa.integration.host.Host.master.IPAOpenSSHTransport] INFO RUN ['systemctl', 'unmask', 'firewalld']
2020-12-14T07:36:58 [ipatests.pytest_ipa.integration.host.Host.master.IPAOpenSSHTransport] INFO RUN ['systemctl', 'enable', 'firewalld']
2020-12-14T07:36:58 [ipatests.pytest_ipa.integration.host.Host.master.IPAOpenSSHTransport] INFO RUN ['systemctl', 'start', 'firewalld']
2020-12-14T07:36:58 [ipatests.pytest_ipa.integration.host.Host.master.IPAOpenSSHTransport] INFO RUN ['firewall-cmd', '--add-service', 'freeipa-trust']
2020-12-14T07:36:59 [ipatests.pytest_ipa.integration.host.Host.master.IPAOpenSSHTransport] INFO RUN ['firewall-cmd', '--add-service', 'freeipa-trust', '--permanent']
2020-12-14T07:36:59 [ipatests.pytest_ipa.integration.host.Host.master.IPAOpenSSHTransport] INFO RUN ['systemctl', 'restart', 'named.service']
2020-12-14T07:36:59 [ipatests.pytest_ipa.integration.host.Host.master.cmd59] ERROR stderr: Failed to restart named.service: Unit named.service is masked.
2020-12-14T07:36:59
2020-12-14T07:36:59 [ipatests.pytest_ipa.integration] INFO Collecting logs from: master.testrelm.test



integration/tasks.py
from ipaplatform.services import knownservices
def install_adtrust(host)
    host.run_command(['systemctl', 'restart',
                      knownservices.named.systemd_name])

The command being run is resolved on the controller rather than on the target host.


If I understand correctly, this is the case where tests controller OS differs from tests target?

Yes, exactly. If you have a controller Fedora and targets on RHEL, for example. Or Fedora and Debian, etc.

It seems the first time mixing.
Usually, test writers don't even assume this case.

Yes, we need to assume they are different. It is expected case when your target platform lacks some packages that are used by the controller but otherwise aren't needed for IPA deployment.

Can we assume that IPA versions are the same in this case and guaranteed by the environment? For example, the controller's ipa-tests package corresponds to the target's ones(client, server, etc.).

I think that is something we can require, yes. If we can discover the target system's platform, then we can reuse it locally.

Metadata Update from @slev:
- Issue assigned to slev

3 years ago

Login to comment on this ticket.

Metadata