Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solve KCM failure on system tests on F40 #69

Merged
merged 3 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
jc
pytest
python-ldap
pytest-mh >= 1.0.8
pytest-mh >= 1.0.9
61 changes: 0 additions & 61 deletions sssd_test_framework/hosts/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,67 +60,6 @@ def features(self) -> dict[str, bool]:

return self._features

def pytest_setup(self) -> None:
"""
Called once before execution of any tests.

- override systemd unit to disable burst limiting, otherwise we will be
unable to restart the service frequently
- reload systemd to apply change to the unit file
"""
super().pytest_setup()

self.logger.info("Creating SSSD systemd override")
self.ssh.run(
"""
set -ex

backuppath="/tmp/mh.client.systemd.backup"
overridedir="/etc/systemd/system/sssd.service.d"
if [ -d "$overridedir" ] || [ -f "$overridedir" ]; then
cp --force --archive "$overridedir" "$backuppath"
fi

# Disable burst limiting to allow often sssd restarts for tests
mkdir -p "$overridedir"
cat <<EOF > "$overridedir/override.conf"
[Unit]
StartLimitIntervalSec=0
StartLimitBurst=0
EOF

# Reload systemd to pickup changes
systemctl daemon-reload
""",
log_level=SSHLog.Error,
)

def pytest_teardown(self) -> None:
"""
Called once after all tests are finished.

- remove systemd changes
"""
self.logger.info("Removing SSSD systemd override")
self.ssh.run(
"""
set -ex

backuppath="/tmp/mh.client.systemd.backup"
overridedir="/etc/systemd/system/sssd.service.d"

rm -fr "$overridedir"
if [ -d "$overridedir" ] || [ -f "$overridedir" ]; then
mv --force "$backuppath" "$overridedir"
fi

# Reload systemd to pickup changes
systemctl daemon-reload
""",
log_level=SSHLog.Error,
)
super().pytest_teardown()

def backup(self) -> None:
"""
Backup all SSSD data.
Expand Down
34 changes: 27 additions & 7 deletions sssd_test_framework/utils/sssd.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def async_start(
debug_level: str | None = "0xfff0",
) -> SSHProcess:
"""
Start SSSD service. Non-blocking call.
Start the SSSD and KCM services. Non-blocking call.

:param service: Service to start, defaults to 'sssd'
:type service: str, optional
Expand All @@ -135,6 +135,10 @@ def async_start(
if apply_config:
self.config_apply(check_config=check_config, debug_level=debug_level)

# Also stop kcm so that it is started when first used.
if service == "sssd":
self.svc.async_stop("sssd-kcm.service")

return self.svc.async_start(service)

def start(
Expand All @@ -147,7 +151,7 @@ def start(
debug_level: str | None = "0xfff0",
) -> SSHProcessResult:
"""
Start SSSD service. The call will wait until the operation is finished.
Start the SSSD and KCM services. The call will wait until the operation is finished.

:param service: Service to start, defaults to 'sssd'
:type service: str, optional
Expand All @@ -165,26 +169,30 @@ def start(
if apply_config:
self.config_apply(check_config=check_config, debug_level=debug_level)

# Also stop kcm so it can pick up changes when started again by socket-activation
# Also stop kcm so that it is started when first used.
if service == "sssd":
self.svc.stop("sssd-kcm.service")

return self.svc.start(service, raise_on_error=raise_on_error)

def async_stop(self, service="sssd") -> SSHProcess:
"""
Stop SSSD service. Non-blocking call.
Stop the SSSD and KCM services. Non-blocking call.

:param service: Service to start, defaults to 'sssd'
:type service: str, optional
:return: Running SSH process.
:rtype: SSHProcess
"""
# Also stop kcm. Nevertheless, it will be started when first used.
if service == "sssd":
self.svc.async_stop("sssd-kcm.service")

return self.svc.async_stop(service)

def stop(self, service="sssd", *, raise_on_error: bool = True) -> SSHProcessResult:
"""
Stop SSSD service. The call will wait until the operation is finished.
Stop the SSSD and KCM services. The call will wait until the operation is finished.

:param service: Service to start, defaults to 'sssd'
:type service: str, optional
Expand All @@ -193,6 +201,10 @@ def stop(self, service="sssd", *, raise_on_error: bool = True) -> SSHProcessResu
:return: SSH process result.
:rtype: SSHProcess
"""
# Also stop kcm. Nevertheless, it will be started when first used.
if service == "sssd":
self.svc.stop("sssd-kcm.service")

return self.svc.stop(service, raise_on_error=raise_on_error)

def async_restart(
Expand All @@ -204,7 +216,7 @@ def async_restart(
debug_level: str | None = "0xfff0",
) -> SSHProcess:
"""
Restart SSSD service. Non-blocking call.
Restart the SSSD and KCM services. Non-blocking call.

:param service: Service to start, defaults to 'sssd'
:type service: str, optional
Expand All @@ -220,6 +232,10 @@ def async_restart(
if apply_config:
self.config_apply(check_config=check_config, debug_level=debug_level)

# Also stop kcm so that it is started when first used.
if service == "sssd":
self.svc.async_stop("sssd-kcm.service")

return self.svc.async_restart(service)

def restart(
Expand All @@ -232,7 +248,7 @@ def restart(
debug_level: str | None = "0xfff0",
) -> SSHProcessResult:
"""
Restart SSSD service. The call will wait until the operation is finished.
Restart the SSSD and KCM services. The call will wait until the operation is finished.

:param service: Service to start, defaults to 'sssd'
:type service: str, optional
Expand All @@ -250,6 +266,10 @@ def restart(
if apply_config:
self.config_apply(check_config=check_config, debug_level=debug_level)

# Also stop kcm so that it is started when first used.
if service == "sssd":
self.svc.stop("sssd-kcm.service")

return self.svc.restart(service, raise_on_error=raise_on_error)

def clear(self, *, db: bool = True, memcache: bool = True, config: bool = False, logs: bool = False):
Expand Down
Loading