summaryrefslogtreecommitdiff
path: root/tests/cloud_tests/testcases/modules
diff options
context:
space:
mode:
authorRyan Harper <ryan.harper@canonical.com>2017-05-19 16:49:11 -0400
committerScott Moser <smoser@ubuntu.com>2017-05-19 16:55:08 -0400
commite11d3899d47ec5fcb545e0c7820af9d3995cb574 (patch)
treea36c05438254df94b410ff88fba2c672709b5673 /tests/cloud_tests/testcases/modules
parentafdddf8eea34866b43d1fc92624f9ac175802f36 (diff)
downloadvyos-cloud-init-e11d3899d47ec5fcb545e0c7820af9d3995cb574.tar.gz
vyos-cloud-init-e11d3899d47ec5fcb545e0c7820af9d3995cb574.zip
cc_ntp: write template before installing and add service restart
On systems which installed ntp and specified servers or pools in the config ntpd didn't notice the updated configuration file and didn't use the correct configuration. Resolve this by rendering the template first which allows the package install to use the existing configuration. Additionally add a service restart to handle the case where ntp does not need to be installed but it may not have started. Add an integration test to confirm that cc_ntp enables ntp to use the specific servers and pools in the cloud-config. LP: #1645644
Diffstat (limited to 'tests/cloud_tests/testcases/modules')
-rw-r--r--tests/cloud_tests/testcases/modules/ntp.py4
-rw-r--r--tests/cloud_tests/testcases/modules/ntp_pools.py18
-rw-r--r--tests/cloud_tests/testcases/modules/ntp_servers.py19
3 files changed, 28 insertions, 13 deletions
diff --git a/tests/cloud_tests/testcases/modules/ntp.py b/tests/cloud_tests/testcases/modules/ntp.py
index b1119257..82d32880 100644
--- a/tests/cloud_tests/testcases/modules/ntp.py
+++ b/tests/cloud_tests/testcases/modules/ntp.py
@@ -13,9 +13,9 @@ class TestNtp(base.CloudTestCase):
self.assertEqual(1, int(out))
def test_ntp_dist_entries(self):
- """Test dist config file has one entry"""
+ """Test dist config file is empty"""
out = self.get_data_file('ntp_conf_dist_empty')
- self.assertEqual(1, int(out))
+ self.assertEqual(0, int(out))
def test_ntp_entires(self):
"""Test config entries"""
diff --git a/tests/cloud_tests/testcases/modules/ntp_pools.py b/tests/cloud_tests/testcases/modules/ntp_pools.py
index d80cb673..ff6d8fa4 100644
--- a/tests/cloud_tests/testcases/modules/ntp_pools.py
+++ b/tests/cloud_tests/testcases/modules/ntp_pools.py
@@ -13,16 +13,22 @@ class TestNtpPools(base.CloudTestCase):
self.assertEqual(1, int(out))
def test_ntp_dist_entries(self):
- """Test dist config file has one entry"""
+ """Test dist config file is empty"""
out = self.get_data_file('ntp_conf_dist_pools')
- self.assertEqual(1, int(out))
+ self.assertEqual(0, int(out))
def test_ntp_entires(self):
"""Test config entries"""
out = self.get_data_file('ntp_conf_pools')
- self.assertIn('pool 0.pool.ntp.org iburst', out)
- self.assertIn('pool 1.pool.ntp.org iburst', out)
- self.assertIn('pool 2.pool.ntp.org iburst', out)
- self.assertIn('pool 3.pool.ntp.org iburst', out)
+ pools = self.cloud_config.get('ntp').get('pools')
+ for pool in pools:
+ self.assertIn('pool %s iburst' % pool, out)
+
+ def test_ntpq_servers(self):
+ """Test ntpq output has configured servers"""
+ out = self.get_data_file('ntpq_servers')
+ pools = self.cloud_config.get('ntp').get('pools')
+ for pool in pools:
+ self.assertIn(pool, out)
# vi: ts=4 expandtab
diff --git a/tests/cloud_tests/testcases/modules/ntp_servers.py b/tests/cloud_tests/testcases/modules/ntp_servers.py
index 4879bb6f..9ef270ee 100644
--- a/tests/cloud_tests/testcases/modules/ntp_servers.py
+++ b/tests/cloud_tests/testcases/modules/ntp_servers.py
@@ -13,13 +13,22 @@ class TestNtpServers(base.CloudTestCase):
self.assertEqual(1, int(out))
def test_ntp_dist_entries(self):
- """Test dist config file has one entry"""
+ """Test dist config file is empty"""
out = self.get_data_file('ntp_conf_dist_servers')
- self.assertEqual(1, int(out))
+ self.assertEqual(0, int(out))
def test_ntp_entires(self):
- """Test config entries"""
- out = self.get_data_file('ntp_conf_servers')
- self.assertIn('server pool.ntp.org iburst', out)
+ """Test config pools entries"""
+ out = self.get_data_file('ntp_conf_pools')
+ servers = self.cloud_config.get('ntp').get('servers')
+ for server in servers:
+ self.assertIn('server %s iburst' % server, out)
+
+ def test_ntpq_servers(self):
+ """Test ntpq output has configured servers"""
+ out = self.get_data_file('ntpq_servers')
+ servers = self.cloud_config.get('ntp').get('servers')
+ for server in servers:
+ self.assertIn(server, out)
# vi: ts=4 expandtab