summaryrefslogtreecommitdiff
path: root/tests/cloud_tests
diff options
context:
space:
mode:
authorJoshua Powers <josh.powers@canonical.com>2017-06-26 10:16:56 -0700
committerScott Moser <smoser@brickies.net>2017-06-27 16:25:01 -0400
commitf0529559f9688a397f59f041dc6362e91faf96b6 (patch)
tree0399406af3a54e1531f37b1d92871141d31c05d1 /tests/cloud_tests
parentecb408afa1104fe49ce6eb1dc5708be56abd5cb2 (diff)
downloadvyos-cloud-init-f0529559f9688a397f59f041dc6362e91faf96b6.tar.gz
vyos-cloud-init-f0529559f9688a397f59f041dc6362e91faf96b6.zip
tests: update ntp tests after sntp added
Recent change to ntp in artful has added the sntp package whenever ntp is installed. The tests, rather poorly, did a dpkg -l instead of checking with `which`. This fixes the ntp tests to all use `which` over expecting a certain number of lines using dpkg and as a result make the tests OS independent.
Diffstat (limited to 'tests/cloud_tests')
-rw-r--r--tests/cloud_tests/configs/modules/ntp.yaml20
-rw-r--r--tests/cloud_tests/configs/modules/ntp_pools.yaml8
-rw-r--r--tests/cloud_tests/configs/modules/ntp_servers.yaml8
-rw-r--r--tests/cloud_tests/testcases/modules/ntp.py11
-rw-r--r--tests/cloud_tests/testcases/modules/ntp_pools.py2
-rw-r--r--tests/cloud_tests/testcases/modules/ntp_servers.py2
6 files changed, 15 insertions, 36 deletions
diff --git a/tests/cloud_tests/configs/modules/ntp.yaml b/tests/cloud_tests/configs/modules/ntp.yaml
index 0d07ef5a..fbef431b 100644
--- a/tests/cloud_tests/configs/modules/ntp.yaml
+++ b/tests/cloud_tests/configs/modules/ntp.yaml
@@ -1,31 +1,21 @@
#
# Emtpy NTP config to setup using defaults
#
-# NOTE: this should not require apt feature, use 'which' rather than 'dpkg -l'
-# NOTE: this should not require no_ntpdate feature, use 'which' to check for
-# installation rather than 'dpkg -l', as 'grep ntp' matches 'ntpdate'
-# NOTE: the verifier should check for any ntp server not 'ubuntu.pool.ntp.org'
-required_features:
- - apt
- - no_ntpdate
- - ubuntu_ntp
cloud_config: |
#cloud-config
ntp:
pools: {}
servers: {}
collect_scripts:
- ntp_installed_empty: |
+ ntp_installed: |
#!/bin/bash
- dpkg -l | grep ntp | wc -l
+ ntpd --version > /dev/null 2>&1
+ echo $?
ntp_conf_dist_empty: |
#!/bin/bash
ls /etc/ntp.conf.dist | wc -l
- ntp_conf_empty: |
+ ntp_conf_pool_list: |
#!/bin/bash
- grep '^pool' /etc/ntp.conf
- ntp_installed_list: |
- #!/bin/bash
- dpkg -l | grep ntp
+ grep 'pool.ntp.org' /etc/ntp.conf | grep -v ^#
# vi: ts=4 expandtab
diff --git a/tests/cloud_tests/configs/modules/ntp_pools.yaml b/tests/cloud_tests/configs/modules/ntp_pools.yaml
index 7561c7f3..3a93faa2 100644
--- a/tests/cloud_tests/configs/modules/ntp_pools.yaml
+++ b/tests/cloud_tests/configs/modules/ntp_pools.yaml
@@ -1,15 +1,10 @@
#
# NTP config using specific pools
#
-# NOTE: this should not require apt feature, use 'which' rather than 'dpkg -l'
-# NOTE: this should not require no_ntpdate feature, use 'which' to check for
-# installation rather than 'dpkg -l', as 'grep ntp' matches 'ntpdate'
# NOTE: lsb_release listed here because with recent cloud-init deb with
# (LP: 1628337) resolved, cloud-init will attempt to configure archives.
# this fails without lsb_release as UNAVAILABLE is used for $RELEASE
required_features:
- - apt
- - no_ntpdate
- lsb_release
cloud_config: |
#cloud-config
@@ -21,7 +16,8 @@ cloud_config: |
collect_scripts:
ntp_installed_pools: |
#!/bin/bash
- dpkg -l | grep ntp | wc -l
+ ntpd --version > /dev/null 2>&1
+ echo $?
ntp_conf_dist_pools: |
#!/bin/bash
ls /etc/ntp.conf.dist | wc -l
diff --git a/tests/cloud_tests/configs/modules/ntp_servers.yaml b/tests/cloud_tests/configs/modules/ntp_servers.yaml
index 9d1d65ef..d59d45a8 100644
--- a/tests/cloud_tests/configs/modules/ntp_servers.yaml
+++ b/tests/cloud_tests/configs/modules/ntp_servers.yaml
@@ -1,12 +1,7 @@
#
# NTP config using specific servers
#
-# NOTE: this should not require apt feature, use 'which' rather than 'dpkg -l'
-# NOTE: this should not require no_ntpdate feature, use 'which' to check for
-# installation rather than 'dpkg -l', as 'grep ntp' matches 'ntpdate'
required_features:
- - apt
- - no_ntpdate
- lsb_release
cloud_config: |
#cloud-config
@@ -17,7 +12,8 @@ cloud_config: |
collect_scripts:
ntp_installed_servers: |
#!/bin/sh
- dpkg -l | grep -c ntp
+ ntpd --version > /dev/null 2>&1
+ echo $?
ntp_conf_dist_servers: |
#!/bin/sh
cat /etc/ntp.conf.dist | wc -l
diff --git a/tests/cloud_tests/testcases/modules/ntp.py b/tests/cloud_tests/testcases/modules/ntp.py
index a4b8c3d8..b50e52fe 100644
--- a/tests/cloud_tests/testcases/modules/ntp.py
+++ b/tests/cloud_tests/testcases/modules/ntp.py
@@ -9,8 +9,8 @@ class TestNtp(base.CloudTestCase):
def test_ntp_installed(self):
"""Test ntp installed"""
- out = self.get_data_file('ntp_installed_empty')
- self.assertEqual(1, int(out))
+ out = self.get_data_file('ntp_installed')
+ self.assertEqual(0, int(out))
def test_ntp_dist_entries(self):
"""Test dist config file is empty"""
@@ -19,10 +19,7 @@ class TestNtp(base.CloudTestCase):
def test_ntp_entires(self):
"""Test config entries"""
- out = self.get_data_file('ntp_conf_empty')
- self.assertIn('pool 0.ubuntu.pool.ntp.org iburst', out)
- self.assertIn('pool 1.ubuntu.pool.ntp.org iburst', out)
- self.assertIn('pool 2.ubuntu.pool.ntp.org iburst', out)
- self.assertIn('pool 3.ubuntu.pool.ntp.org iburst', out)
+ out = self.get_data_file('ntp_conf_pool_list')
+ self.assertIn('pool.ntp.org iburst', out)
# vi: ts=4 expandtab
diff --git a/tests/cloud_tests/testcases/modules/ntp_pools.py b/tests/cloud_tests/testcases/modules/ntp_pools.py
index 336076df..152fd3f1 100644
--- a/tests/cloud_tests/testcases/modules/ntp_pools.py
+++ b/tests/cloud_tests/testcases/modules/ntp_pools.py
@@ -10,7 +10,7 @@ class TestNtpPools(base.CloudTestCase):
def test_ntp_installed(self):
"""Test ntp installed"""
out = self.get_data_file('ntp_installed_pools')
- self.assertEqual(1, int(out))
+ self.assertEqual(0, int(out))
def test_ntp_dist_entries(self):
"""Test dist config file is empty"""
diff --git a/tests/cloud_tests/testcases/modules/ntp_servers.py b/tests/cloud_tests/testcases/modules/ntp_servers.py
index 4010cf80..8d2a68b3 100644
--- a/tests/cloud_tests/testcases/modules/ntp_servers.py
+++ b/tests/cloud_tests/testcases/modules/ntp_servers.py
@@ -10,7 +10,7 @@ class TestNtpServers(base.CloudTestCase):
def test_ntp_installed(self):
"""Test ntp installed"""
out = self.get_data_file('ntp_installed_servers')
- self.assertEqual(1, int(out))
+ self.assertEqual(0, int(out))
def test_ntp_dist_entries(self):
"""Test dist config file is empty"""