summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Falcon <TheRealFalcon@users.noreply.github.com>2021-03-19 08:35:16 -0500
committerGitHub <noreply@github.com>2021-03-19 09:35:16 -0400
commitc6726c2bbe82b738bd0a7fb308496a497c797d5f (patch)
tree44956648fcee7d37beb227b051e7b3203e2d06fe
parentdae45c3b0d285cbc7b8b22128b5ed295e2c374f8 (diff)
downloadvyos-cloud-init-c6726c2bbe82b738bd0a7fb308496a497c797d5f.tar.gz
vyos-cloud-init-c6726c2bbe82b738bd0a7fb308496a497c797d5f.zip
Fix apt default integration test (#845)
The apt default test wasn't ported over from cloud-tests correctly. uri should be specified in the test, but it was not, so the test failed on openstack (and likely other platforms) because without a specified uri, the default uri will vary by platform. I separated this uri test out into a separate test function. Also add openstack specific test for apt configuration with no uri. Other platform-specific tests should be added here over time.
-rw-r--r--tests/integration_tests/modules/test_apt.py33
-rw-r--r--tox.ini1
2 files changed, 28 insertions, 6 deletions
diff --git a/tests/integration_tests/modules/test_apt.py b/tests/integration_tests/modules/test_apt.py
index c0c8321c..54711fc0 100644
--- a/tests/integration_tests/modules/test_apt.py
+++ b/tests/integration_tests/modules/test_apt.py
@@ -200,29 +200,32 @@ class TestApt:
assert conf_exists is False
-DEFAULT_DATA = """\
+_DEFAULT_DATA = """\
#cloud-config
apt:
primary:
- arches:
- default
+ {uri}
security:
- arches:
- default
"""
+DEFAULT_DATA = _DEFAULT_DATA.format(uri='')
@pytest.mark.ubuntu
@pytest.mark.user_data(DEFAULT_DATA)
class TestDefaults:
- def test_primary(self, class_client: IntegrationInstance):
- """Test apt default primary sources.
+ @pytest.mark.openstack
+ def test_primary_on_openstack(self, class_client: IntegrationInstance):
+ """Test apt default primary source on openstack.
- Ported from
- tests/cloud_tests/testcases/modules/apt_configure_primary.py
+ When no uri is provided.
"""
+ zone = class_client.execute('cloud-init query v1.availability_zone')
sources_list = class_client.read_from_file('/etc/apt/sources.list')
- assert 'deb http://archive.ubuntu.com/ubuntu' in sources_list
+ assert '{}.clouds.archive.ubuntu.com'.format(zone) in sources_list
def test_security(self, class_client: IntegrationInstance):
"""Test apt default security sources.
@@ -239,6 +242,24 @@ class TestDefaults:
)
+DEFAULT_DATA_WITH_URI = _DEFAULT_DATA.format(
+ uri='uri: "http://something.random.invalid/ubuntu"'
+)
+
+
+@pytest.mark.user_data(DEFAULT_DATA_WITH_URI)
+def test_default_primary_with_uri(client: IntegrationInstance):
+ """Test apt default primary sources.
+
+ Ported from
+ tests/cloud_tests/testcases/modules/apt_configure_primary.py
+ """
+ sources_list = client.read_from_file('/etc/apt/sources.list')
+ assert 'archive.ubuntu.com' not in sources_list
+
+ assert 'something.random.invalid' in sources_list
+
+
DISABLED_DATA = """\
#cloud-config
apt:
diff --git a/tox.ini b/tox.ini
index 10efd190..3158ebd5 100644
--- a/tox.ini
+++ b/tox.ini
@@ -174,6 +174,7 @@ markers =
gce: test will only run on GCE platform
azure: test will only run on Azure platform
oci: test will only run on OCI platform
+ openstack: test will only run on openstack
lxd_config_dict: set the config_dict passed on LXD instance creation
lxd_container: test will only run in LXD container
lxd_use_exec: `execute` will use `lxc exec` instead of SSH