From 1c6efcd9fd9c0006b5a696b010e6f438a88a3ab3 Mon Sep 17 00:00:00 2001 From: Tibor Dudlák Date: Jul 31 2019 13:20:26 +0000 Subject: ipatests: Add tests for interactive chronyd config Add interactive configuration tests for ipa-server-install and ipa-client-install FreeIPA server as it is now is unable to configure NTP interactively for replica installations. Resolves: https://pagure.io/freeipa/issue/7908 Reviewed-By: Michal Polovka Reviewed-By: Rob Crittenden --- diff --git a/ipatests/pytest_ipa/integration/tasks.py b/ipatests/pytest_ipa/integration/tasks.py index 2060ffa..5963cd7 100644 --- a/ipatests/pytest_ipa/integration/tasks.py +++ b/ipatests/pytest_ipa/integration/tasks.py @@ -498,7 +498,7 @@ def install_replica(master, replica, setup_ca=True, setup_dns=False, return result -def install_client(master, client, extra_args=(), user=None, +def install_client(master, client, extra_args=[], user=None, password=None, unattended=True, stdin_text=None): client.collect_log(paths.IPACLIENT_INSTALL_LOG) @@ -528,7 +528,9 @@ def install_client(master, client, extra_args=(), user=None, if unattended: args.append('-U') - result = client.run_command(args + list(extra_args), stdin_text=stdin_text) + args.extend(extra_args) + + result = client.run_command(args, stdin_text=stdin_text) setup_sssd_debugging(client) kinit_admin(client) diff --git a/ipatests/test_integration/test_ntp_options.py b/ipatests/test_integration/test_ntp_options.py index fd13ea3..6cdc3cc 100644 --- a/ipatests/test_integration/test_ntp_options.py +++ b/ipatests/test_integration/test_ntp_options.py @@ -20,6 +20,12 @@ class TestNTPoptions(IntegrationTest): ntp_server1 = "1.pool.ntp.org" ntp_server2 = "2.pool.ntp.org" + print_chrony_conf = ['cat', paths.CHRONY_CONF] + + exp_records_msg = "No SRV records of NTP servers found and " \ + "no NTP server or pool address was provided." + exp_chrony_msg = "Using default chrony configuration." + @classmethod def install(cls, mh): cls.client = cls.clients[0] @@ -226,6 +232,157 @@ class TestNTPoptions(IntegrationTest): cmd = self.replica.run_command(['cat', paths.CHRONY_CONF]) assert self.ntp_pool in cmd.stdout_text + def test_interactive_ntp_set_opt(self): + """ + Test to verify that ipa installations with ntp options passed + interactively (without -U/--nattended) will be successful + - ipa-server-install + - ipa-client-install + Both NTP servers and pool passed interactively to options. + """ + server_input = ( + # Do you want to configure integrated DNS (BIND)? [no]: + "No\n" + # Server host name [hostname]: + "\n" + # Do you want to configure chrony with NTP server + # or pool address? [no]: + "Yes\n" + # Enter NTP source server addresses separated by comma, + # or press Enter to skip: + "{},{}\n".format(self.ntp_server2, self.ntp_server1) + + # Enter a NTP source pool address, or press Enter to skip: + "{}\n".format(self.ntp_pool) + + # Continue to configure the system with these values? [no]: + "Yes" + ) + + client_input = ( + # Proceed with fixed values and no DNS discovery? [no]: + "Yes\n" + # Do you want to configure chrony with NTP server + # or pool address? [no]: + "Yes\n" + # Enter NTP source server addresses separated by comma, + # or press Enter to skip: + "{},{}\n".format(self.ntp_server2, self.ntp_server1) + + # Enter a NTP source pool address, or press Enter to skip: + "{}\n".format(self.ntp_pool) + + # Continue to configure the system with these values? [no]: + "Yes" + ) + + server_install = tasks.install_master(self.master, + setup_dns=False, + unattended=False, + stdin_text=server_input) + + assert server_install.returncode == 0 + assert self.ntp_pool in server_install.stdout_text + assert self.ntp_server1 in server_install.stdout_text + assert self.ntp_server2 in server_install.stdout_text + + cmd = self.master.run_command(self.print_chrony_conf) + assert self.ntp_pool in cmd.stdout_text + assert self.ntp_server1 in cmd.stdout_text + assert self.ntp_server2 in cmd.stdout_text + + client_install = tasks.install_client(self.master, + self.client, + unattended=False, + stdin_text=client_input) + + assert client_install.returncode == 0 + + cmd = self.client.run_command(self.print_chrony_conf) + assert self.ntp_pool in cmd.stdout_text + assert self.ntp_server1 in cmd.stdout_text + assert self.ntp_server2 in cmd.stdout_text + + def test_interactive_ntp_no_opt(self): + """ + Test to verify that ipa installations without ntp options passed + interactively (without -U/--nattended) will be successful + - ipa-server-install + - ipa-client-install + Both NTP servers and pool configuration skipped interactively. + """ + + server_input = ( + "No\n" + "\n" + "Yes\n" + "\n" + "\n" + "Yes" + ) + + client_input = ( + "Yes\n" + "Yes\n" + "\n" + "\n" + "Yes" + ) + + server_install = tasks.install_master(self.master, + setup_dns=False, + unattended=False, + stdin_text=server_input) + + assert server_install.returncode == 0 + assert self.exp_records_msg in server_install.stderr_text + assert self.exp_chrony_msg in server_install.stdout_text + + client_install = tasks.install_client(self.master, + self.client, + unattended=False, + stdin_text=client_input) + + assert client_install.returncode == 0 + assert self.exp_records_msg in client_install.stderr_text + assert self.exp_chrony_msg in client_install.stdout_text + + def test_interactive_ntp_no_conf(self): + """ + Test to verify that ipa installations without selecting + to configure ntp options interactively (without -U/--nattended) + will be successful + - ipa-server-install + - ipa-client-install + """ + + server_input = ( + "\n" + + "\n" + "No\n" + "Yes" + ) + + client_input = ( + "Yes\n" + "No\n" + "Yes" + ) + + server_install = tasks.install_master(self.master, + setup_dns=False, + unattended=False, + stdin_text=server_input) + + assert server_install.returncode == 0 + assert self.exp_records_msg in server_install.stderr_text + assert self.exp_chrony_msg in server_install.stdout_text + + client_install = tasks.install_client(self.master, + self.client, + unattended=False, + stdin_text=client_input) + + assert client_install.returncode == 0 + assert self.exp_records_msg in client_install.stderr_text + assert self.exp_chrony_msg in client_install.stdout_text + def teardown_method(self, method): """ Uninstall ipa-server, ipa-replica and ipa-client