~curtin-dev/curtin/trunk

« back to all changes in this revision

Viewing changes to tests/vmtests/test_nvme.py

  • Committer: Scott Moser
  • Date: 2017-12-20 17:33:03 UTC
  • Revision ID: smoser@ubuntu.com-20171220173303-29gha5qb8wpqrd40
README: Mention move of revision control to git.

curtin development has moved its revision control to git.
It is available at
  https://code.launchpad.net/curtin

Clone with
  git clone https://git.launchpad.net/curtin
or
  git clone git+ssh://git.launchpad.net/curtin

For more information see
  http://curtin.readthedocs.io/en/latest/topics/development.html

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from . import VMBaseClass
2
 
from .releases import base_vm_classes as relbase
3
 
 
4
 
import os
5
 
import textwrap
6
 
 
7
 
 
8
 
class TestNvmeAbs(VMBaseClass):
9
 
    arch_skip = [
10
 
        "s390x",  # nvme is a pci device, no pci on s390x
11
 
    ]
12
 
    interactive = False
13
 
    conf_file = "examples/tests/nvme.yaml"
14
 
    extra_disks = []
15
 
    nvme_disks = ['4G', '4G']
16
 
    disk_to_check = [('main_disk', 1), ('main_disk', 2), ('main_disk', 15),
17
 
                     ('nvme_disk', 1), ('nvme_disk', 2), ('nvme_disk', 3),
18
 
                     ('second_nvme', 1)]
19
 
    collect_scripts = [textwrap.dedent("""
20
 
        cd OUTPUT_COLLECT_D
21
 
        ls /sys/class/ > sys_class
22
 
        ls /sys/class/nvme/ > ls_nvme
23
 
        ls /dev/nvme* > ls_dev_nvme
24
 
        ls /dev/disk/by-dname/ > ls_dname
25
 
        blkid -o export /dev/vda > blkid_output_vda
26
 
        blkid -o export /dev/vda1 > blkid_output_vda1
27
 
        blkid -o export /dev/vda2 > blkid_output_vda2
28
 
        cat /proc/partitions > proc_partitions
29
 
        ls -al /dev/disk/by-uuid/ > ls_uuid
30
 
        cat /etc/fstab > fstab
31
 
        mkdir -p /dev/disk/by-dname
32
 
        ls /dev/disk/by-dname/ > ls_dname
33
 
        find /etc/network/interfaces.d > find_interfacesd
34
 
 
35
 
        v=""
36
 
        out=$(apt-config shell v Acquire::HTTP::Proxy)
37
 
        eval "$out"
38
 
        echo "$v" > apt-proxy
39
 
        """)]
40
 
 
41
 
    def test_output_files_exist(self):
42
 
        self.output_files_exist(["ls_nvme", "ls_dname", "ls_dev_nvme"])
43
 
 
44
 
    def test_nvme_device_names(self):
45
 
        ls_nvme = self.collect_path('ls_nvme')
46
 
        # trusty and vivid do not have sys/class/nvme but
47
 
        # nvme devices do work
48
 
        if os.path.getsize(ls_nvme) > 0:
49
 
            self.check_file_strippedline("ls_nvme", "nvme0")
50
 
            self.check_file_strippedline("ls_nvme", "nvme1")
51
 
        else:
52
 
            self.check_file_strippedline("ls_dev_nvme", "/dev/nvme0")
53
 
            self.check_file_strippedline("ls_dev_nvme", "/dev/nvme1")
54
 
 
55
 
 
56
 
class TrustyTestNvme(relbase.trusty, TestNvmeAbs):
57
 
    __test__ = True
58
 
 
59
 
    # FIXME(LP: #1523037): dname does not work on trusty, so we cannot expect
60
 
    # sda-part2 to exist in /dev/disk/by-dname as we can on other releases
61
 
    # when dname works on trusty, then we need to re-enable by removing line.
62
 
    def test_dname(self):
63
 
        print("test_dname does not work for Trusty")
64
 
 
65
 
    def test_ptable(self):
66
 
        print("test_ptable does not work for Trusty")
67
 
 
68
 
 
69
 
class TrustyHWEXTestNvme(relbase.trusty_hwe_x, TestNvmeAbs):
70
 
    __test__ = True
71
 
 
72
 
    # FIXME(LP: #1523037): dname does not work on trusty, so we cannot expect
73
 
    # sda-part2 to exist in /dev/disk/by-dname as we can on other releases
74
 
    # when dname works on trusty, then we need to re-enable by removing line.
75
 
    def test_dname(self):
76
 
        print("test_dname does not work for Trusty")
77
 
 
78
 
    def test_ptable(self):
79
 
        print("test_ptable does not work for Trusty")
80
 
 
81
 
 
82
 
class XenialTestNvme(relbase.xenial, TestNvmeAbs):
83
 
    __test__ = True
84
 
 
85
 
 
86
 
class ZestyTestNvme(relbase.zesty, TestNvmeAbs):
87
 
    __test__ = True
88
 
 
89
 
 
90
 
class ArtfulTestNvme(relbase.artful, TestNvmeAbs):
91
 
    __test__ = True
92
 
 
93
 
 
94
 
class BionicTestNvme(relbase.bionic, TestNvmeAbs):
95
 
    __test__ = True
96
 
 
97
 
 
98
 
class TestNvmeBcacheAbs(VMBaseClass):
99
 
    arch_skip = [
100
 
        "s390x",  # nvme is a pci device, no pci on s390x
101
 
    ]
102
 
    interactive = False
103
 
    conf_file = "examples/tests/nvme_bcache.yaml"
104
 
    extra_disks = ['10G']
105
 
    nvme_disks = ['6G']
106
 
    uefi = True
107
 
    disk_to_check = [('sda', 1), ('sda', 2), ('sda', 3)]
108
 
 
109
 
    collect_scripts = [textwrap.dedent("""
110
 
        cd OUTPUT_COLLECT_D
111
 
        ls /sys/class/ > sys_class
112
 
        ls /sys/class/nvme/ > ls_nvme
113
 
        ls /dev/nvme* > ls_dev_nvme
114
 
        ls /dev/disk/by-dname/ > ls_dname
115
 
        ls -al /dev/bcache/by-uuid/ > ls_bcache_by_uuid |:
116
 
        blkid -o export /dev/vda > blkid_output_vda
117
 
        blkid -o export /dev/vda1 > blkid_output_vda1
118
 
        blkid -o export /dev/vda2 > blkid_output_vda2
119
 
        bcache-super-show /dev/nvme0n1p1 > bcache_super_nvme0n1p1
120
 
        ls /sys/fs/bcache > bcache_ls
121
 
        cat /sys/block/bcache0/bcache/cache_mode > bcache_cache_mode
122
 
        cat /proc/partitions > proc_partitions
123
 
        ls -al /dev/disk/by-uuid/ > ls_uuid
124
 
        cat /etc/fstab > fstab
125
 
        mkdir -p /dev/disk/by-dname
126
 
        ls /dev/disk/by-dname/ > ls_dname
127
 
        find /etc/network/interfaces.d > find_interfacesd
128
 
 
129
 
        v=""
130
 
        out=$(apt-config shell v Acquire::HTTP::Proxy)
131
 
        eval "$out"
132
 
        echo "$v" > apt-proxy
133
 
        """)]
134
 
 
135
 
    def test_output_files_exist(self):
136
 
        self.output_files_exist(["ls_nvme", "ls_dname", "ls_dev_nvme"])
137
 
 
138
 
    def test_nvme_device_names(self):
139
 
        ls_nvme = self.collect_path('ls_nvme')
140
 
        # trusty and vivid do not have sys/class/nvme but
141
 
        # nvme devices do work
142
 
        if os.path.getsize(ls_nvme) > 0:
143
 
            self.check_file_strippedline("ls_nvme", "nvme0")
144
 
        else:
145
 
            self.check_file_strippedline("ls_dev_nvme", "/dev/nvme0")
146
 
            self.check_file_strippedline("ls_dev_nvme", "/dev/nvme0n1")
147
 
            self.check_file_strippedline("ls_dev_nvme", "/dev/nvme0n1p1")
148
 
 
149
 
    def test_bcache_output_files_exist(self):
150
 
        self.output_files_exist(["bcache_super_nvme0n1p1", "bcache_ls",
151
 
                                 "bcache_cache_mode"])
152
 
 
153
 
    def test_bcache_status(self):
154
 
        bcache_cset_uuid = None
155
 
        bcache_super = self.load_collect_file("bcache_super_nvme0n1p1")
156
 
        for line in bcache_super.splitlines():
157
 
            if line != "" and line.split()[0] == "cset.uuid":
158
 
                bcache_cset_uuid = line.split()[-1].rstrip()
159
 
        self.assertIsNotNone(bcache_cset_uuid)
160
 
        self.assertTrue(bcache_cset_uuid in
161
 
                        self.load_collect_file("bcache_ls").splitlines())
162
 
 
163
 
    def test_bcache_cachemode(self):
164
 
        self.check_file_regex("bcache_cache_mode", r"\[writeback\]")
165
 
 
166
 
 
167
 
class XenialTestNvmeBcache(relbase.xenial, TestNvmeBcacheAbs):
168
 
    __test__ = True
169
 
 
170
 
 
171
 
class ZestyTestNvmeBcache(relbase.zesty, TestNvmeBcacheAbs):
172
 
    __test__ = True
173
 
 
174
 
 
175
 
class ArtfulTestNvmeBcache(relbase.artful, TestNvmeBcacheAbs):
176
 
    __test__ = True
177
 
 
178
 
 
179
 
class BionicTestNvmeBcache(relbase.bionic, TestNvmeBcacheAbs):
180
 
    __test__ = True