Skip to content
Draft
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
12 changes: 12 additions & 0 deletions sssd_test_framework/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .config import SSSDTopologyMark
from .topology_controllers import (
ADTopologyController,
BigLDAPTopologyController,
ClientTopologyController,
GDMTopologyController,
IPATopologyController,
Expand Down Expand Up @@ -215,6 +216,17 @@ def test_ldap(client: Client, ldap: LDAP):
.. topology-mark:: KnownTopology.Keycloak
"""

BigLDAP = SSSDTopologyMark(
name="big-ldap",
topology=Topology(TopologyDomain("sssd", client=1, ldap=1)),
controller=BigLDAPTopologyController(),
domains=dict(test="sssd.ldap[0]"),
fixtures=dict(client="sssd.client[0]", ldap="sssd.ldap[0]", provider="sssd.ldap[0]"),
)
"""
.. topology-mark:: KnownTopology.BigLDAP
"""


class KnownTopologyGroup(KnownTopologyGroupBase):
"""
Expand Down
16 changes: 16 additions & 0 deletions sssd_test_framework/topology_controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"IPATrustADTopologyController",
"IPATrustSambaTopologyController",
"KeycloakTopologyController",
"BigLDAPTopologyController",
]


Expand Down Expand Up @@ -417,3 +418,18 @@ def topology_teardown(self, client: ClientHost, ipa: IPAHost, keycloak: Keycloak
ipa.conn.run("ipa idp-del keycloak")

super().topology_teardown()


class BigLDAPTopologyController(ProvisionedBackupTopologyController):
"""
LDAP Topology Controller with large amount of users and large groups.
"""

@BackupTopologyController.restore_vanilla_on_error
def topology_setup(self, client: ClientHost, ldap: LDAPHost) -> None:
ldap.conn.run(
"systemctl stop dirsrv@localhost.service && "
"dsctl slapd-localhost bak2db largedata && "
"systemctl start dirsrv@localhost.service"
)
super().topology_setup()
Comment on lines +429 to +435

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

There are several issues with the current implementation of topology_setup in BigLDAPTopologyController:

  1. Bypassing self.provisioned: The setup commands are executed even if self.provisioned is True. This defeats the purpose of pre-provisioned topologies (which are meant to skip setup/provisioning steps to save time).
  2. Hardcoded Service Management: Hardcoding systemctl stop dirsrv@localhost.service and systemctl start dirsrv@localhost.service bypasses the LDAPHost service management abstraction (ldap.stop() and ldap.start()), which respects the configured ldap_service_name.
  3. Hardcoded Instance Name: Hardcoding slapd-localhost assumes the instance name is always localhost. We can dynamically extract the instance name from ldap._ldap_service_name.
  4. Missing Error Handling Decorator: Other topology controllers use @BackupTopologyController.restore_vanilla_on_error to ensure the environment is restored to a clean state if setup fails.

We can address all of these by refactoring the method.

Suggested change
def topology_setup(self, client: ClientHost, ldap: LDAPHost) -> None:
ldap.conn.run(
"systemctl stop dirsrv@localhost.service && "
"dsctl slapd-localhost bak2db largedata && "
"systemctl start dirsrv@localhost.service"
)
super().topology_setup()
@BackupTopologyController.restore_vanilla_on_error
def topology_setup(self, client: ClientHost, ldap: LDAPHost) -> None:
if not self.provisioned:
instance = ldap._ldap_service_name.split("@")[-1].split(".")[0]
ldap.stop()
ldap.conn.run(f"dsctl {instance} bak2db largedata")
ldap.start()
super().topology_setup()

Loading