#8414 Nightly test failure in test_integration/test_replica_promotion.py::TestReplicaPromotionLevel1::test_sssd_config_allows_ipaapi_access_to_ifp
Closed: fixed by frenaud. Opened by mpolovka.

Issue

The nightly test test_integration/test_replica_promotion.py::TestReplicaPromotionLevel1::test_sssd_config_allows_ipaapi_access_to_ifp is failing since mergin of PR #4914 replica: Add tests to ensure the ipaapi user is allowed access to ifp on replicas

Logs

host = <ipatests.pytest_ipa.integration.host.Host replica0.ipa.test (replica)>
    @contextmanager
    def remote_sssd_config(host):
        """Context manager for editing sssd config file on a remote host.
        It provides SimpleSSSDConfig object which is automatically serialized and
        uploaded to remote host upon exit from the context.
        If exception is raised inside the context then the ini file is NOT updated
        on remote host.
        SimpleSSSDConfig is a SSSDConfig descendant with added helper methods
        for modifying options: edit_domain and edit_service.
        Example:
            with remote_sssd_config(master) as sssd_conf:
                # use helper methods
                # add/replace option
                sssd_conf.edit_domain(master.domain, 'filter_users', 'root')
                # add/replace provider option
                sssd_conf.edit_domain(master.domain, 'sudo_provider', 'ipa')
                # delete option
                sssd_conf.edit_service('pam', 'pam_verbosity', None)
                # use original methods of SSSDConfig
                domain = sssd_conf.get_domain(master.domain.name)
                domain.set_name('example.test')
                self.save_domain(domain)
            """
        from SSSDConfig import SSSDConfig
        class SimpleSSSDConfig(SSSDConfig):
            def edit_domain(self, domain_or_name, option, value):
                """Add/replace/delete option in a domain section.
                :param domain_or_name: Domain object or domain name
                :param option: option name
                :param value: value to assign to option. If None, option will be
                    deleted
                """
                if hasattr(domain_or_name, 'name'):
                    domain_name = domain_or_name.name
                else:
                    domain_name = domain_or_name
                domain = self.get_domain(domain_name)
                if value is None:
                    domain.remove_option(option)
                else:
                    domain.set_option(option, value)
                self.save_domain(domain)
            def edit_service(self, service_name, option, value):
                """Add/replace/delete option in a service section.
                :param service_name: a string
                :param option: option name
                :param value: value to assign to option. If None, option will be
                    deleted
                """
                service = self.get_service(service_name)
                if value is None:
                    service.remove_option(option)
                else:
                    service.set_option(option, value)
                self.save_service(service)
        fd, temp_config_file = tempfile.mkstemp()
        os.close(fd)
        try:
>           current_config = host.transport.get_file_contents(paths.SSSD_CONF)
pytest_ipa/integration/tasks.py:809: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <ipatests.pytest_ipa.integration.transport.IPAOpenSSHTransport object at 0x7f82299f9950>
filename = '/etc/sssd/sssd.conf', encoding = None
    def get_file_contents(self, filename, encoding=None):
        self.log.info('GET %s', filename)
        cmd = self._run(['cat', filename], log_stdout=False)
        cmd.wait(raiseonerr=False)
        if cmd.returncode == 0:
            result = cmd.stdout_bytes
            if encoding:
                result = result.decode(encoding)
            return result
        else:
>           raise IOError('File %r could not be read' % filename)
E           OSError: File '/etc/sssd/sssd.conf' could not be read
../pytest_multihost/transport.py:445: OSError
During handling of the above exception, another exception occurred:
args = (<ipatests.test_integration.test_replica_promotion.TestReplicaPromotionLevel1 object at 0x7f82299b5910>,)
    def wrapped(*args):
>       func(*args)
pytest_ipa/integration/tasks.py:1562: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_integration/test_replica_promotion.py:126: in test_sssd_config_allows_ipaapi_access_to_ifp
    sssd_config_allows_ipaapi_access_to_ifp(replica)
test_integration/test_replica_promotion.py:57: in sssd_config_allows_ipaapi_access_to_ifp
    with tasks.remote_sssd_config(host) as sssd_conf:
/usr/lib64/python3.7/contextlib.py:112: in __enter__
    return next(self.gen)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
host = <ipatests.pytest_ipa.integration.host.Host replica0.ipa.test (replica)>
    @contextmanager
    def remote_sssd_config(host):
        """Context manager for editing sssd config file on a remote host.
        It provides SimpleSSSDConfig object which is automatically serialized and
        uploaded to remote host upon exit from the context.
        If exception is raised inside the context then the ini file is NOT updated
        on remote host.
        SimpleSSSDConfig is a SSSDConfig descendant with added helper methods
        for modifying options: edit_domain and edit_service.
        Example:
            with remote_sssd_config(master) as sssd_conf:
                # use helper methods
                # add/replace option
                sssd_conf.edit_domain(master.domain, 'filter_users', 'root')
                # add/replace provider option
                sssd_conf.edit_domain(master.domain, 'sudo_provider', 'ipa')
                # delete option
                sssd_conf.edit_service('pam', 'pam_verbosity', None)
                # use original methods of SSSDConfig
                domain = sssd_conf.get_domain(master.domain.name)
                domain.set_name('example.test')
                self.save_domain(domain)
            """
        from SSSDConfig import SSSDConfig
        class SimpleSSSDConfig(SSSDConfig):
            def edit_domain(self, domain_or_name, option, value):
                """Add/replace/delete option in a domain section.
                :param domain_or_name: Domain object or domain name
                :param option: option name
                :param value: value to assign to option. If None, option will be
                    deleted
                """
                if hasattr(domain_or_name, 'name'):
                    domain_name = domain_or_name.name
                else:
                    domain_name = domain_or_name
                domain = self.get_domain(domain_name)
                if value is None:
                    domain.remove_option(option)
                else:
                    domain.set_option(option, value)
                self.save_domain(domain)
            def edit_service(self, service_name, option, value):
                """Add/replace/delete option in a service section.
                :param service_name: a string
                :param option: option name
                :param value: value to assign to option. If None, option will be
                    deleted
                """
                service = self.get_service(service_name)
                if value is None:
                    service.remove_option(option)
                else:
                    service.set_option(option, value)
                self.save_service(service)
        fd, temp_config_file = tempfile.mkstemp()
        os.close(fd)
        try:
            current_config = host.transport.get_file_contents(paths.SSSD_CONF)
            with open(temp_config_file, 'wb') as f:
                f.write(current_config)
            # In order to use SSSDConfig() locally we need to import the schema
            # Create a tar file with /usr/share/sssd.api.conf and
            # /usr/share/sssd/sssd.api.d
            tmpname = create_temp_file(host)
            host.run_command(
                ['tar', 'cJvf', tmpname,
                 'sssd.api.conf',
                 'sssd.api.d'],
                log_stdout=False, cwd="/usr/share/sssd")
            # fetch tar file
            tar_dir = tempfile.mkdtemp()
            tarname = os.path.join(tar_dir, "sssd_schema.tar.xz")
            with open(tarname, 'wb') as f:
                f.write(host.get_file_contents(tmpname))
            # delete from remote
            host.run_command(['rm', '-f', tmpname])
            # Unpack on the local side
            ipautil.run([paths.TAR, 'xJvf', tarname], cwd=tar_dir)
            os.unlink(tarname)
            # Use the imported schema
            sssd_config = SimpleSSSDConfig(
                schemafile=os.path.join(tar_dir, "sssd.api.conf"),
                schemaplugindir=os.path.join(tar_dir, "sssd.api.d"))
            sssd_config.import_config(temp_config_file)
            yield sssd_config
            new_config = sssd_config.dump(sssd_config.opts).encode('utf-8')
            host.transport.put_file_contents(paths.SSSD_CONF, new_config)
        finally:
            try:
                os.remove(temp_config_file)
>               shutil.rmtree(tar_dir)
E               UnboundLocalError: local variable 'tar_dir' referenced before assignment
pytest_ipa/integration/tasks.py:847: UnboundLocalError
 -------------------------------Captured log call-------------------------------- 
INFO     ipatests.pytest_ipa.integration.host.Host.replica0.IPAOpenSSHTransport:transport.py:436 GET /etc/sssd/sssd.conf
DEBUG    ipatests.pytest_ipa.integration.host.Host.replica0.cmd89:transport.py:513 RUN ['cat', '/etc/sssd/sssd.conf']
DEBUG    ipatests.pytest_ipa.integration.host.Host.replica0.cmd89:transport.py:558 cat: /etc/sssd/sssd.conf: No such file or directory
DEBUG    ipatests.pytest_ipa.integration.host.Host.replica0.cmd89:transport.py:217 Exit code: 1

Metadata Update from @frenaud:
- Issue assigned to frenaud

Metadata Update from @frenaud:
- Custom field on_review adjusted to https://github.com/freeipa/freeipa/pull/4926

Another failure: PR304, logs

master:

  • 1fc1947c4875595edf48000ef3a01d0ae9ffd3c1 ipatests: fix TestUnprivilegedUserPermissions
  • 062e18c4f0c3febcac7db99e8a7e4c690684db60 ipatests: Fix TestReplicaPromotionLevel1

ipa-4-8:

  • 819bcacb81f942ac31691638beb64f77c0e74a40 ipatests: fix TestUnprivilegedUserPermissions
  • 3c53c7036a8a214eeb93c241d730d5c737950cd1 ipatests: Fix TestReplicaPromotionLevel1

Metadata Update from @frenaud:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

Metadata