From e11d3899d47ec5fcb545e0c7820af9d3995cb574 Mon Sep 17 00:00:00 2001 From: Ryan Harper Date: Fri, 19 May 2017 16:49:11 -0400 Subject: 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 --- tests/cloud_tests/testcases/modules/ntp.py | 4 ++-- tests/cloud_tests/testcases/modules/ntp_pools.py | 18 ++++++++++++------ tests/cloud_tests/testcases/modules/ntp_servers.py | 19 ++++++++++++++----- 3 files changed, 28 insertions(+), 13 deletions(-) (limited to 'tests/cloud_tests/testcases/modules') 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 -- cgit v1.2.3 From 5375d9da344e84f496c54b253b42454e0888d101 Mon Sep 17 00:00:00 2001 From: Joshua Powers Date: Mon, 22 May 2017 11:58:06 -0700 Subject: Fixing wrong file name regression. --- tests/cloud_tests/testcases/modules/ntp_servers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/cloud_tests/testcases/modules') diff --git a/tests/cloud_tests/testcases/modules/ntp_servers.py b/tests/cloud_tests/testcases/modules/ntp_servers.py index 9ef270ee..419c8270 100644 --- a/tests/cloud_tests/testcases/modules/ntp_servers.py +++ b/tests/cloud_tests/testcases/modules/ntp_servers.py @@ -19,7 +19,7 @@ class TestNtpServers(base.CloudTestCase): def test_ntp_entires(self): """Test config pools entries""" - out = self.get_data_file('ntp_conf_pools') + out = self.get_data_file('ntp_conf_servers') servers = self.cloud_config.get('ntp').get('servers') for server in servers: self.assertIn('server %s iburst' % server, out) -- cgit v1.2.3 From 9fa17d4bc1ef2564e30ab655bf6de462296aecad Mon Sep 17 00:00:00 2001 From: Joshua Powers Date: Mon, 22 May 2017 12:43:31 -0700 Subject: function spelling & docstring update --- tests/cloud_tests/testcases/modules/ntp_servers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/cloud_tests/testcases/modules') diff --git a/tests/cloud_tests/testcases/modules/ntp_servers.py b/tests/cloud_tests/testcases/modules/ntp_servers.py index 419c8270..4010cf80 100644 --- a/tests/cloud_tests/testcases/modules/ntp_servers.py +++ b/tests/cloud_tests/testcases/modules/ntp_servers.py @@ -17,8 +17,8 @@ class TestNtpServers(base.CloudTestCase): out = self.get_data_file('ntp_conf_dist_servers') self.assertEqual(0, int(out)) - def test_ntp_entires(self): - """Test config pools entries""" + def test_ntp_entries(self): + """Test config server entries""" out = self.get_data_file('ntp_conf_servers') servers = self.cloud_config.get('ntp').get('servers') for server in servers: -- cgit v1.2.3 From 06a7f0afc4db3f8ba2a6b3b521274ee45a028ef2 Mon Sep 17 00:00:00 2001 From: Joshua Powers Date: Mon, 22 May 2017 12:13:55 -0700 Subject: tests: Apply workaround for snapd bug in test case. Snapd does not start on artful or on the versions in proposed. This changes the behavior of the test to confirm that snapd is installed, not that it is started, while the snap team fixes the issue (LP: ##1690880). --- tests/cloud_tests/configs/modules/snappy.yaml | 4 ++-- tests/cloud_tests/testcases/modules/snappy.py | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'tests/cloud_tests/testcases/modules') diff --git a/tests/cloud_tests/configs/modules/snappy.yaml b/tests/cloud_tests/configs/modules/snappy.yaml index 923bfe12..0e7dc852 100644 --- a/tests/cloud_tests/configs/modules/snappy.yaml +++ b/tests/cloud_tests/configs/modules/snappy.yaml @@ -6,8 +6,8 @@ cloud_config: | snappy: system_snappy: auto collect_scripts: - snap_version: | + snapd: | #!/bin/bash - snap --version + dpkg -s snapd # vi: ts=4 expandtab diff --git a/tests/cloud_tests/testcases/modules/snappy.py b/tests/cloud_tests/testcases/modules/snappy.py index 3e2f5924..b92271c1 100644 --- a/tests/cloud_tests/testcases/modules/snappy.py +++ b/tests/cloud_tests/testcases/modules/snappy.py @@ -9,10 +9,7 @@ class TestSnappy(base.CloudTestCase): def test_snappy_version(self): """Test snappy version output""" - out = self.get_data_file('snap_version') - self.assertIn('snap ', out) - self.assertIn('snapd ', out) - self.assertIn('series ', out) - self.assertIn('ubuntu ', out) + out = self.get_data_file('snapd') + self.assertIn('Status: install ok installed', out) # vi: ts=4 expandtab -- cgit v1.2.3