URL: https://github.com/freeipa/freeipa/pull/4254 Author: kaleemsiddiqu Title: #4254: [Backport][ipa-4-8]Tests for backup-restore when pkg required missing #3962 Action: opened
PR body: """ Signed-off-by: Kaleemullah Siddiqui <ksidd...@redhat.com> """ To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/4254/head:pr4254 git checkout pr4254
From efb18afdaa2f0e203208ac6e124e1b6336655125 Mon Sep 17 00:00:00 2001 From: Kaleemullah Siddiqui <ksidd...@redhat.com> Date: Fri, 29 Nov 2019 16:56:34 +0530 Subject: [PATCH] Manual backport of #3962 Signed-off-by: Kaleemullah Siddiqui <ksidd...@redhat.com> --- .../prci_definitions/nightly_ipa-4-8.yaml | 12 +++++ ipatests/pytest_ipa/integration/tasks.py | 4 ++ .../test_backup_and_restore.py | 50 ++++++++++++++++++- 3 files changed, 64 insertions(+), 2 deletions(-) diff --git a/ipatests/prci_definitions/nightly_ipa-4-8.yaml b/ipatests/prci_definitions/nightly_ipa-4-8.yaml index e190bdaade..76d38e8933 100644 --- a/ipatests/prci_definitions/nightly_ipa-4-8.yaml +++ b/ipatests/prci_definitions/nightly_ipa-4-8.yaml @@ -1472,3 +1472,15 @@ jobs: template: *ci-master-f30 timeout: 7200 topology: *adroot_adchild_adtree_master_1client + + fedora-latest/test_backup_and_restore_TestBackupAndRestoreTrust: + requires: [fedora-latest/build] + priority: 50 + job: + class: RunPytest + args: + build_url: '{fedora-latest/build_url}' + test_suite: test_integration/test_backup_and_restore.py::TestBackupAndRestoreTrust + template: *ci-master-latest + timeout: 7200 + topology: *master_1repl diff --git a/ipatests/pytest_ipa/integration/tasks.py b/ipatests/pytest_ipa/integration/tasks.py index 0c75f4e452..73adc68d42 100755 --- a/ipatests/pytest_ipa/integration/tasks.py +++ b/ipatests/pytest_ipa/integration/tasks.py @@ -2017,6 +2017,8 @@ def install_packages(host, pkgs): # Only supports RHEL 8+ and Fedora for now if platform in ('rhel', 'fedora'): install_cmd = ['/usr/bin/dnf', 'install', '-y'] + elif platform in ('ubuntu'): + install_cmd = ['apt-get', 'install', '-y'] else: raise ValueError('install_packages: unknown platform %s' % platform) host.run_command(install_cmd + pkgs) @@ -2031,6 +2033,8 @@ def uninstall_packages(host, pkgs): # Only supports RHEL 8+ and Fedora for now if platform in ('rhel', 'fedora'): install_cmd = ['/usr/bin/dnf', 'remove', '-y'] + elif platform in ('ubuntu'): + install_cmd = ['apt-get', 'remove', '-y'] else: raise ValueError('install_packages: unknown platform %s' % platform) host.run_command(install_cmd + pkgs) diff --git a/ipatests/test_integration/test_backup_and_restore.py b/ipatests/test_integration/test_backup_and_restore.py index dbe44ff22c..1d5d3ae222 100644 --- a/ipatests/test_integration/test_backup_and_restore.py +++ b/ipatests/test_integration/test_backup_and_restore.py @@ -297,7 +297,10 @@ def install(cls, mh): tasks.install_master(cls.master, setup_dns=True) def _full_backup_restore_with_DNS_zone(self, reinstall=False): - """backup, uninstall, restore""" + """backup, uninstall, restore. + + Test for bug https://pagure.io/freeipa/issue/7630. + """ with restore_checker(self.master): self.master.run_command([ 'ipa', 'dnszone-add', @@ -312,13 +315,20 @@ def _full_backup_restore_with_DNS_zone(self, reinstall=False): '--uninstall', '-U']) + tasks.uninstall_packages(self.master, ['*ipa-server-dns']) if reinstall: tasks.install_master(self.master, setup_dns=True) dirman_password = self.master.config.dirman_password + result = self.master.run_command( + ['ipa-restore', backup_path], + stdin_text=dirman_password + '\nyes', + raiseonerr=False) + assert 'Please install the package' in result.stderr_text + + tasks.install_packages(self.master, ['*ipa-server-dns']) self.master.run_command(['ipa-restore', backup_path], stdin_text=dirman_password + '\nyes') - tasks.resolve_record(self.master.ip, self.example_test_zone) tasks.kinit_admin(self.master) @@ -861,3 +871,39 @@ def test_replica_install_after_restore(self): # install second replica after restore tasks.install_replica(master, replica2) check_replication(master, replica2, "testuser2") + + +class TestBackupAndRestoreTrust(IntegrationTest): + """Test for Backup and Restore for Trust scenario""" + topology = 'star' + + def test_restore_trust_pkg_before_restore(self): + """Test restore with adtrust when trust-ad pkg is missing. + + Test for bug https://pagure.io/freeipa/issue/7630. + """ + tasks.install_packages(self.master, ['*ipa-server-trust-ad']) + self.master.run_command(['ipa-adtrust-install', '-U', + '--enable-compat', '--netbios-name', 'IPA', + '-a', self.master.config.admin_password, + '--add-sids']) + + with restore_checker(self.master): + backup_path = backup(self.master) + + self.master.run_command(['ipa-server-install', + '--uninstall', + '-U']) + + tasks.uninstall_packages(self.master, ['*ipa-server-trust-ad']) + + dirman_password = self.master.config.dirman_password + result = self.master.run_command( + ['ipa-restore', backup_path], + stdin_text=dirman_password + '\nyes', + raiseonerr=False) + assert 'Please install the package' in result.stderr_text + + tasks.install_packages(self.master, ['*ipa-server-trust-ad']) + self.master.run_command(['ipa-restore', backup_path], + stdin_text=dirman_password + '\nyes')
_______________________________________________ FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedorahosted.org/archives/list/freeipa-devel@lists.fedorahosted.org