cloud-init-dev team mailing list archive
-
cloud-init-dev team
-
Mailing list archive
-
Message #04830
Re: [Merge] ~chad.smith/cloud-init:bug/cloud-tests-pkg-install into cloud-init:master
Your commit message is incorrect.
> package_update_upgrade_install was failing as htop is not included in
> Bionic images. Switch this test to install 'sl' instead.
Actually the problem is that htop *is* in the bionic images.
We were testing that 'packages: [htop]' caused apt installation, but
since htop is already present in the base bionic image that assertion
was failing.
Maybe for that test we could instead use
https://launchpad.net/~cloud-init-dev/+archive/ubuntu/test-archive
and install 'smello'.
Its probably a safer assumption that 'smello' is not installed
in the official images.
What you have is probably fine though.
Diff comments:
> diff --git a/tests/cloud_tests/testcases/base.py b/tests/cloud_tests/testcases/base.py
> index 0d1916b..da93ab2 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.match(
> + '.*\n%s\t(?P<version>[^\n]+)' % name, pkg_out, re.DOTALL)
nicer as below?
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 version in installed_version:
i dont know if this is being used or not, but if i passed in 'version=9'
I'd probably not expect that '1.09' was success.
or even '1.0-47-gabc9def'
> + 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.
>
--
https://code.launchpad.net/~chad.smith/cloud-init/+git/cloud-init/+merge/345256
Your team cloud-init commiters is requested to review the proposed merge of ~chad.smith/cloud-init:bug/cloud-tests-pkg-install into cloud-init:master.
References