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

Added automation for NTP options test scenarios #2404

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions ipatests/prci_definitions/nightly_master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -930,3 +930,15 @@ jobs:
template: *ci-master-f29
timeout: 3600
topology: *master_1repl

fedora-28/test_ntp_options:
requires: [fedora-29/build]
priority: 50
job:
class: RunPytest
args:
build_url: '{fedora-29/build_url}'
test_suite: test_integration/test_ntp_options.py::TestNTPoptions
template: *ci-master-f29
timeout: 7200
topology: *master_1repl_1client
12 changes: 12 additions & 0 deletions ipatests/prci_definitions/nightly_rawhide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -918,3 +918,15 @@ jobs:
template: *ci-master-frawhide
timeout: 3600
topology: *master_1repl

fedora-rawhide/test_ntp_options:
requires: [fedora-rawhide/build]
priority: 50
job:
class: RunPytest
args:
build_url: '{fedora-rawhide/build_url}'
test_suite: test_integration/test_ntp_options.py::TestNTPoptions
template: *ci-master-frawhide
timeout: 7200
topology: *master_1repl_1client
227 changes: 227 additions & 0 deletions ipatests/test_integration/test_ntp_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
#
# Copyright (C) 2018 FreeIPA Contributors see COPYING for license
#

from ipatests.test_integration.base import IntegrationTest
from ipatests.pytest_ipa.integration import tasks
from ipaplatform.paths import paths


class TestNTPoptions(IntegrationTest):
"""
Test NTP Options:
--no-ntp / -N
--ntp-server
--ntp-pool
"""
num_clients = 1
num_replicas = 1

@classmethod
def install(cls, mh):
cls.client = cls.clients[0]
cls.replica = cls.replicas[0]

def install_client(self, *args):
Copy link
Member

Choose a reason for hiding this comment

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

Is there any specific reason why you have not used

tasks.install_client(master, client, extra_args=(),
                     user=None, password=None)

was something failing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need to use "raiseonerr". I believe install_client does not have this parameter

cmd = ['ipa-client-install', '-U',
'--domain', self.client.domain.name,
'--realm', self.client.domain.realm,
'-p', self.client.config.admin_name,
'-w', self.client.config.admin_password,
'--server', self.master.hostname, *args]
return self.client.run_command(cmd, raiseonerr=False)

def install_replica(self, *args):
Copy link
Member

Choose a reason for hiding this comment

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

Same as above; was task for replica failing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need to use "raiseonerr". I believe install_replica does not have this parameter

cmd = ['ipa-replica-install', '-w', self.master.config.admin_password,
'-n', self.master.domain.name, '-r', self.master.domain.realm,
'--server', self.master.hostname, '-U', *args]
return self.replica.run_command(cmd, raiseonerr=False)

def test_server_client_install_without_options(self):
"""
test to verify that ipa-server and ipa-client install uses
default chrony configuration without any NTP options specified
"""
expected_msg1 = "No SRV records of NTP servers found and " \
"no NTP server or pool address was provided."
expected_msg2 = "Using default chrony configuration."

server_install = tasks.install_master(self.master, setup_dns=False)
assert expected_msg1 in server_install.stderr_text
assert expected_msg2 in server_install.stdout_text

client_install = self.install_client()
assert expected_msg1 in client_install.stderr_text
assert expected_msg2 in client_install.stdout_text

self.cleanup()

def test_server_client_install_no_ntp(self):
"""
test to verify that ipa-server and ipa-client install invoked with
option -N uses system defined NTP daemon configuration
"""
expected_msg1 = "Excluded by options:"
expected_msg2 = "Using default chrony configuration."

server_install = tasks.install_master(self.master, setup_dns=False,
extra_args=['-N'])
assert expected_msg1 in server_install.stdout_text
assert expected_msg2 not in server_install.stdout_text

client_install = self.install_client('--no-ntp')
assert expected_msg2 not in client_install.stdout_text

self.cleanup()

def test_server_client_install_with_multiple_ntp_srv(self):
"""
test to verify that ipa-server-install passes with multiple
--ntp-server option used
"""
ntp_server1 = "1.pool.ntp.org"
ntp_server2 = "2.pool.ntp.org"
expected_msg = "Configuration of chrony was changed by installer."

server_install = tasks.install_master(
Tiboris marked this conversation as resolved.
Show resolved Hide resolved
self.master, setup_dns=False,
extra_args=['--ntp-server=%s' % ntp_server1,
'--ntp-server=%s' % ntp_server2])
assert expected_msg in server_install.stderr_text
cmd = self.master.run_command(['cat', paths.CHRONY_CONF])
assert ntp_server1 in cmd.stdout_text
assert ntp_server2 in cmd.stdout_text

client_install = self.install_client('--ntp-server=%s' % ntp_server1,
Tiboris marked this conversation as resolved.
Show resolved Hide resolved
'--ntp-server=%s' % ntp_server2)
assert expected_msg in client_install.stderr_text
cmd = self.client.run_command(['cat', paths.CHRONY_CONF])
assert ntp_server1 in cmd.stdout_text
assert ntp_server2 in cmd.stdout_text

self.cleanup()
Tiboris marked this conversation as resolved.
Show resolved Hide resolved

def test_server_replica_client_install_with_pool_and_srv(self):
"""
test to verify that ipa-server, ipa-replica and ipa-client install
passes with options --ntp-pool and --ntp-server together
"""
ntp_pool = "pool.ntp.org"
ntp_server = "1.pool.ntp.org"
expected_msg = "Configuration of chrony was changed by installer."

server_install = tasks.install_master(
self.master, setup_dns=False,
extra_args=['--ntp-pool=%s' % ntp_pool,
'--ntp-server=%s' % ntp_server])
assert expected_msg in server_install.stderr_text
cmd = self.master.run_command(['cat', paths.CHRONY_CONF])
assert ntp_pool in cmd.stdout_text
assert ntp_server in cmd.stdout_text

replica_install = self.install_replica('--ntp-pool=%s' % ntp_pool,
'--ntp-server=%s' % ntp_server)
assert expected_msg in replica_install.stderr_text
cmd = self.replica.run_command(['cat', paths.CHRONY_CONF])
assert ntp_pool in cmd.stdout_text
assert ntp_server in cmd.stdout_text

client_install = self.install_client('--ntp-pool=%s' % ntp_pool,
'--ntp-server=%s' % ntp_server)
assert expected_msg in client_install.stderr_text
cmd = self.client.run_command(['cat', paths.CHRONY_CONF])
assert ntp_pool in cmd.stdout_text
assert ntp_server in cmd.stdout_text
tasks.uninstall_master(self.replica)

self.cleanup()

def test_server_client_install_mixed_options(self):
"""
test to verify that ipa-server and ipa-client install with
--ntp-server and -N options would fail
"""
ntp_server = "1.pool.ntp.org"
exp_str = ("error: --ntp-server cannot be used"
" together with --no-ntp")
exp_pool_str = ("error: --ntp-pool cannot be used"
" together with --no-ntp")

args1 = ['ipa-server-install', '-N', '--ntp-server=%s' % ntp_server]
server_install = self.master.run_command(args1, raiseonerr=False)
assert server_install.returncode == 2
assert exp_str in server_install.stderr_text

args2 = ['ipa-client-install', '-N', '--ntp-server=%s' % ntp_server]
client_install = self.client.run_command(args2, raiseonerr=False)
assert client_install.returncode == 2
assert exp_str in client_install.stderr_text

args3 = ['ipa-client-install', '-N',
'--ntp-pool=%s' % ntp_server.lstrip('1.')]
client_install = self.client.run_command(args3, raiseonerr=False)
assert client_install.returncode == 2
assert exp_pool_str in client_install.stderr_text

def test_replica_promotion_with_ntp_options(self):
"""
test to verify that replica promotion with ntp --ntp-server,
--ntp-pool and -N or --no-ntp option would fail
"""
ntp_server = "1.pool.ntp.org"
ntp_pool = "pool.ntp.org"
exp_str = "NTP configuration cannot be updated during promotion"

tasks.install_master(self.master, setup_dns=False)
tasks.install_client(self.master, self.replica)

try:
replica_install = self.replica.run_command(
['ipa-replica-install', '-N'], raiseonerr=False)
assert replica_install.returncode == 1
assert exp_str in replica_install.stderr_text

replica_install = self.replica.run_command(
['ipa-replica-install', '--ntp-server=%s' % ntp_server],
raiseonerr=False)
assert replica_install.returncode == 1
assert exp_str in replica_install.stderr_text

replica_install = self.replica.run_command(
['ipa-replica-install', '--ntp-pool=%s' % ntp_pool],
raiseonerr=False)
assert replica_install.returncode == 1
assert exp_str in replica_install.stderr_text

finally:
tasks.uninstall_master(self.replica)
self.cleanup()

def test_replica_promotion_without_ntp(self):
"""
test to verify that replica promotion without ntp options
- ipa-client install with ntp option
- ipa-replica without ntp option
will be successful
"""
Tiboris marked this conversation as resolved.
Show resolved Hide resolved
ntp_pool = "pool.ntp.org"
exp_str = "ipa-replica-install command was successful"

tasks.install_master(self.master, setup_dns=False)
tasks.install_client(self.master, self.replica,
extra_args=['--ntp-pool=%s' % ntp_pool])

replica_install = self.replica.run_command(
['ipa-replica-install'], raiseonerr=False)
assert exp_str in replica_install.stderr_text
cmd = self.replica.run_command(['cat', paths.CHRONY_CONF])
assert ntp_pool in cmd.stdout_text

tasks.uninstall_master(self.replica)

def cleanup(self):
"""
Uninstall ipa-server and ipa-client
"""
tasks.uninstall_client(self.client)
tasks.uninstall_master(self.master)
Copy link
Member

Choose a reason for hiding this comment

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

@varunmylaraiah what happens if we add replica uninstallation to cleanup as well?

Suggested change
tasks.uninstall_master(self.master)
tasks.uninstall_replica(self.replica)
tasks.uninstall_master(self.master)

Copy link
Member

Choose a reason for hiding this comment

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

The question is meant mostly for tests that are not using replica.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, all tests are not using replica install and replica uninstallation will take almost 45 seconds to 1 minute.
I think it's of no use for uninstalling replica every time.