summaryrefslogtreecommitdiff
path: root/tests/vmtests/test_bcache_ceph.py
blob: cb41fdaed250a881669c5664f7b0c315814c8d8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# This file is part of curtin. See LICENSE file for copyright and license info.

from . import VMBaseClass, skip_if_flag
from .releases import base_vm_classes as relbase

import glob
import textwrap


class TestBcacheCeph(VMBaseClass):
    arch_skip = [
        "s390x",  # lp:1565029
    ]
    test_type = 'storage'
    conf_file = "examples/tests/bcache-ceph-nvme.yaml"
    nr_cpus = 2
    uefi = True
    dirty_disks = True
    extra_disks = ['20G', '20G', '20G', '20G', '20G', '20G', '20G', '20G']
    nvme_disks = ['20G', '20G']
    extra_collect_scripts = [textwrap.dedent("""
        cd OUTPUT_COLLECT_D
        ls /sys/fs/bcache/ > bcache_ls
        ls -al /dev/bcache/by-uuid/ > ls_al_dev_bcache_by_uuid
        ls -al /dev/bcache/by-label/ > ls_al_dev_bcache_by_label
        ls -al /sys/class/block/bcache* > ls_al_sys_block_bcache
        for bcache in /sys/class/block/bcache*; do
            for link in $(find ${bcache}/slaves -type l); do
                kname=$(basename $(readlink $link))
                outfile="bcache-super-show.$kname"
                bcache-super-show /dev/${kname} > $outfile
            done
        done
        exit 0
        """)]

    @skip_if_flag('expected_failure')
    def test_bcache_output_files_exist(self):
        self.output_files_exist([
            "bcache-super-show.vda1",
            "bcache-super-show.vdc",
            "bcache-super-show.vdd",
            "bcache-super-show.vde",
            "bcache-super-show.vdf",
            "bcache-super-show.vdh",
            "bcache-super-show.nvme0n1p2",
            "bcache-super-show.nvme1n1p2"])

    @skip_if_flag('expected_failure')
    def test_bcache_devices_cset_found(self):
        sblocks = glob.glob("%s/bcache-super-show.*")
        for superblock in sblocks:
            bcache_cset_uuid = None
            for line in self.load_collect_file(superblock).splitlines():
                if line != "" and line.split()[0] == "cset.uuid":
                    bcache_cset_uuid = line.split()[-1].rstrip()
            self.assertIsNotNone(bcache_cset_uuid)
            self.assertTrue(bcache_cset_uuid in
                            self.load_collect_file("bcache_ls").splitlines())


class XenialGATestBcacheCeph(relbase.xenial_ga, TestBcacheCeph):
    __test__ = True


class XenialHWETestBcacheCeph(relbase.xenial_hwe, TestBcacheCeph):
    __test__ = True


class XenialEdgeTestBcacheCeph(relbase.xenial_edge, TestBcacheCeph):
    __test__ = True


class BionicTestBcacheCeph(relbase.bionic, TestBcacheCeph):
    __test__ = True


class FocalTestBcacheCeph(relbase.focal, TestBcacheCeph):
    __test__ = True


class TestBcacheCephLvm(TestBcacheCeph):
    test_type = 'storage'
    nr_cpus = 2
    uefi = True
    dirty_disks = True
    extra_disks = ['20G', '20G']
    nvme_disks = ['20G']
    conf_file = "examples/tests/bcache-ceph-nvme-simple.yaml"

    @skip_if_flag('expected_failure')
    def test_bcache_output_files_exist(self):
        self.output_files_exist([
            "bcache-super-show.vda3",
            "bcache-super-show.vdc",
            "bcache-super-show.nvme0n1",
        ])


class BionicTestBcacheCephLvm(relbase.bionic, TestBcacheCephLvm):
    __test__ = True


class FocalTestBcacheCephLvm(relbase.focal, TestBcacheCephLvm):
    __test__ = True


# vi: ts=4 expandtab syntax=python