diff options
author | Chad Smith <chad.smith@canonical.com> | 2018-05-09 09:36:56 -0600 |
---|---|---|
committer | Chad Smith <chad.smith@canonical.com> | 2018-05-09 09:36:56 -0600 |
commit | 323eb30940cae2069daf74517089220fccc4afb9 (patch) | |
tree | d1ffd321afe20278c7bc4422a9715e55f5c20e0a /tests/cloud_tests/testcases/base.py | |
parent | 4c1af5c7eb8db67f51f35130e13157a735256d2b (diff) | |
download | vyos-cloud-init-323eb30940cae2069daf74517089220fccc4afb9.tar.gz vyos-cloud-init-323eb30940cae2069daf74517089220fccc4afb9.zip |
tests: fix package and ca_cert cloud_tests on bionic
package_update_upgrade_install was failing as htop is now included in
Bionic images. Switch this test to install 'sl' instead.
ca_certs integration test fails on cert_count test because bionic
update-ca-certificates on bionic generates less symlinks for a given cert.
Integration tests now collect dpkg-query --show output on every instance.
Add a new assertPackageInstalled helper method which finds the package or
package version installed on the instance.
Adapt existing byobu, package_update_upgrade_install, ntp and salt_minion
tests to use assertPackageInstalled method.
LP: #1769985
Diffstat (limited to 'tests/cloud_tests/testcases/base.py')
-rw-r--r-- | tests/cloud_tests/testcases/base.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/cloud_tests/testcases/base.py b/tests/cloud_tests/testcases/base.py index 0d1916b4..696db8dd 100644 --- a/tests/cloud_tests/testcases/base.py +++ b/tests/cloud_tests/testcases/base.py @@ -31,6 +31,27 @@ class CloudTestCase(unittest.TestCase): def is_distro(self, distro_name): return self.os_cfg['os'] == distro_name + def assertPackageInstalled(self, name, version=None): + """Check dpkg-query --show output for matching package name. + + @param name: package base name + @param version: string representing a package version or part of a + version. + """ + pkg_out = self.get_data_file('package-versions') + pkg_match = re.search( + '^%s\t(?P<version>.*)$' % name, pkg_out, re.MULTILINE) + if pkg_match: + installed_version = pkg_match.group('version') + if not version: + return # Success + if installed_version.startswith(version): + return # Success + raise AssertionError( + 'Expected package version %s-%s not found. Found %s' % + name, version, installed_version) + raise AssertionError('Package not installed: %s' % name) + def os_version_cmp(self, cmp_version): """Compare the version of the test to comparison_version. |