1
""" testold_apt_features
2
Testing the former minimal apt features of curtin
7
from . import VMBaseClass
8
from .releases import base_vm_classes as relbase
10
from curtin import util
13
class TestOldAptAbs(VMBaseClass):
14
"""TestOldAptAbs - Basic tests for old apt features of curtin"""
19
collect_scripts = [textwrap.dedent("""
21
cat /etc/fstab > fstab
22
ls /dev/disk/by-dname > ls_dname
23
find /etc/network/interfaces.d > find_interfacesd
24
grep -A 3 "Name: debconf/priority" /var/cache/debconf/config.dat > debc
25
apt-config dump > aptconf
26
cp /etc/apt/apt.conf.d/90curtin-aptproxy .
27
cp /etc/apt/sources.list .
28
cp /etc/cloud/cloud.cfg.d/curtin-preserve-sources.cfg .
29
cp /etc/cloud/cloud.cfg.d/90_dpkg.cfg .
31
arch = util.get_architecture()
32
if arch in ['amd64', 'i386']:
33
conf_file = "examples/tests/test_old_apt_features.yaml"
34
exp_mirror = "http://us.archive.ubuntu.com/ubuntu"
35
exp_secmirror = "http://archive.ubuntu.com/ubuntu"
36
if arch in ['s390x', 'arm64', 'armhf', 'powerpc', 'ppc64el']:
37
conf_file = "examples/tests/test_old_apt_features_ports.yaml"
38
exp_mirror = "http://ports.ubuntu.com/ubuntu-ports"
39
exp_secmirror = "http://ports.ubuntu.com/ubuntu-ports"
41
def test_output_files_exist(self):
42
"""test_output_files_exist - Check if all output files exist"""
43
self.output_files_exist(
44
["debc", "aptconf", "sources.list", "90curtin-aptproxy",
45
"curtin-preserve-sources.cfg", "90_dpkg.cfg"])
47
def test_preserve_source(self):
48
"""test_preserve_source - no clobbering sources.list by cloud-init"""
49
self.check_file_regex("curtin-preserve-sources.cfg",
50
"apt_preserve_sources_list.*true")
52
def test_debconf(self):
53
"""test_debconf - Check if debconf is in place"""
54
self.check_file_strippedline("debc", "Value: low")
56
def test_aptconf(self):
57
"""test_aptconf - Check if apt conf for proxy is in place"""
58
# this gets configured by tools/launch and get_apt_proxy in
59
# tests/vmtests/__init__.py, so compare with those
60
rproxy = r"Acquire::http::Proxy \"" + re.escape(self.proxy) + r"\";"
61
self.check_file_regex("aptconf", rproxy)
62
self.check_file_regex("90curtin-aptproxy", rproxy)
64
def test_mirrors(self):
65
"""test_mirrors - Check for mirrors placed in source.list"""
67
self.check_file_strippedline("sources.list",
69
(self.exp_mirror, self.release) +
70
" main restricted universe multiverse")
71
self.check_file_strippedline("sources.list",
72
"deb %s %s-security" %
73
(self.exp_secmirror, self.release) +
74
" main restricted universe multiverse")
76
def test_cloudinit_seeded(self):
77
content = self.load_collect_file("90_dpkg.cfg")
78
# not the greatest test, but we seeded NoCloud as the only datasource
79
# in examples/tests/test_old_apt_features.yaml. Just verify that
80
# there are no others there.
81
self.assertIn("nocloud", content.lower())
82
self.assertNotIn("maas", content.lower())
85
class XenialTestOldApt(relbase.xenial, TestOldAptAbs):
87
Old apt features for Xenial