~smoser/curtin/yakkety.lp1666986

« back to all changes in this revision

Viewing changes to tests/vmtests/test_old_apt_features.py

  • Committer: Scott Moser
  • Date: 2016-08-05 20:47:14 UTC
  • mto: (58.1.1 pkg)
  • mto: This revision was merged to the branch mainline in revision 56.
  • Revision ID: smoser@ubuntu.com-20160805204714-f6j1k61cli5uf614
Tags: upstream-0.1.0~bzr415
ImportĀ upstreamĀ versionĀ 0.1.0~bzr415

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
""" testold_apt_features
 
2
    Testing the former minimal apt features of curtin
 
3
"""
 
4
import re
 
5
import textwrap
 
6
 
 
7
from . import VMBaseClass
 
8
from .releases import base_vm_classes as relbase
 
9
 
 
10
from curtin import util
 
11
 
 
12
 
 
13
class TestOldAptAbs(VMBaseClass):
 
14
    """TestOldAptAbs - Basic tests for old apt features of curtin"""
 
15
    interactive = False
 
16
    extra_disks = []
 
17
    fstab_expected = {}
 
18
    disk_to_check = []
 
19
    collect_scripts = [textwrap.dedent("""
 
20
        cd OUTPUT_COLLECT_D
 
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 .
 
30
        """)]
 
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"
 
40
 
 
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"])
 
46
 
 
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")
 
51
 
 
52
    def test_debconf(self):
 
53
        """test_debconf - Check if debconf is in place"""
 
54
        self.check_file_strippedline("debc", "Value: low")
 
55
 
 
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)
 
63
 
 
64
    def test_mirrors(self):
 
65
        """test_mirrors - Check for mirrors placed in source.list"""
 
66
 
 
67
        self.check_file_strippedline("sources.list",
 
68
                                     "deb %s %s" %
 
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")
 
75
 
 
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())
 
83
 
 
84
 
 
85
class XenialTestOldApt(relbase.xenial, TestOldAptAbs):
 
86
    """ XenialTestOldApt
 
87
       Old apt features for Xenial
 
88
    """
 
89
    __test__ = True