Skip to content

Commit f9e45fd

Browse files
Merge pull request #1421 from vojtechtrefny/main_vm-image-tests-remove
convert ImageBackedTestCase and VMBackedTestCase tests to StorageTestCase
2 parents 0dc7f29 + f28ee43 commit f9e45fd

File tree

14 files changed

+746
-1288
lines changed

14 files changed

+746
-1288
lines changed

tests/README.rst

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,6 @@ There are three separate test suites available:
1717
- *Storage tests* located in the `storage_tests` folder. These tests require
1818
root privileges and create block devices to run tests on. These tests can
1919
be run separately using `make storage-test`.
20-
- *VM tests* located in the `vmtests` folder. These test are not run by
21-
default and require a special virtual machine to run in.
22-
23-
Tests descending from :class:`~.imagebackedtestcase.ImageBackedTestCase` or
24-
:class:`~.loopbackedtestcase.LoopBackedTestCase` require root access on the
25-
system and will be skipped if you're running as non-root user.
26-
Tests descending from :class:`~.imagebackedtestcase.ImageBackedTestCase` will
27-
also be skipped if the environment variable JENKINS_HOME is not defined. If
28-
you'd like to execute them use the following commands (as root)::
29-
30-
# export JENKINS_HOME=`pwd`
31-
# make test
3220

3321
To execute the Pylint code analysis tool run::
3422

@@ -64,16 +52,12 @@ inherit from them.
6452
:class:`~tests.unit_tests.action_test.DeviceActionTestCase`;
6553

6654

67-
- :class:`~tests.storage_tests.loopbackedtestcase.LoopBackedTestCase`,
68-
:class:`~tests.storage_tests.imagebackedtestcase.ImageBackedTestCase` and
69-
:class:`~tests.storage_tests.storagetestcase.StorageTestCase` - all three classes
70-
represent actual storage space.
71-
:class:`~tests.storage_tests.imagebackedtestcase.ImageBackedTestCase` uses the same stacks
72-
as anaconda disk image installations. These mimic normal disks more closely
73-
than using loop devices directly. Usually
55+
- :class:`~tests.storage_tests.loopbackedtestcase.LoopBackedTestCase` and
56+
:class:`~tests.storage_tests.storagetestcase.StorageTestCase` - these classes
57+
represent actual storage space. Usually
7458
:class:`~tests.storage_tests.loopbackedtestcase.LoopBackedTestCase` is used for stacks of
7559
limited depth (eg: md array with two loop members) and
76-
:class:`~tests.storage_tests.imagebackedtestcase.ImageBackedTestCase` for stacks of greater
60+
:class:`~tests.storage_tests.storagetestcase.StorageTestCase` for stacks of greater
7761
or arbitrary depth.
7862
:class:`~tests.storage_tests.storagetestcase.StorageTestCase` uses `targetcli` to create
7963
virtual SCSI drives for full stack tests on "real" hardware.

tests/storage_tests/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
from .unsupported_disklabel_test import *
66

77
from .iscsi_test import *
8+
from .gpt_test import *
9+
from .reset_test import *
Lines changed: 42 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,97 @@
11
import unittest
22
from uuid import UUID
33

4-
from .vmbackedtestcase import VMBackedTestCase
4+
from .storagetestcase import StorageTestCase
55

66
from blivet.devicelibs import gpt
77
from blivet.devices import LUKSDevice
88
from blivet.flags import flags
99
from blivet import formats
10-
from blivet.formats import disklabel
10+
from blivet.formats import get_format
1111
from blivet import partitioning
1212
from blivet.size import Size
13-
from blivet.util import set_up_logging
1413

1514
import parted
1615

1716

18-
class GPTTestBase(VMBackedTestCase):
17+
class GPTTestBase(StorageTestCase):
18+
19+
_num_disks = 1
1920

2021
# Default parted GUID for "Linux Data" partition
2122
LINUX_DATA_GUID = UUID("0fc63daf-8483-4772-8e79-3d69d8477de4")
2223

23-
def __init__(self, *args, **kwargs):
24-
super(GPTTestBase, self).__init__(*args, **kwargs)
25-
26-
self.root = None
27-
self.home = None
28-
self.tmp = None
29-
self.srv = None
30-
self.etc = None
31-
self.swap = None
32-
self.usrluks = None
33-
self.usr = None
34-
35-
@classmethod
36-
def setUpClass(cls):
37-
super().setUpClass()
38-
39-
set_up_logging()
40-
41-
def set_up_disks(self):
42-
disklabel.DiskLabel.set_default_label_type("gpt")
24+
def setUp(self):
25+
super().setUp()
26+
self._blivet_setup()
27+
self._set_up_storage()
4328

4429
def _clean_up(self):
45-
super(GPTTestBase, self)._clean_up()
46-
47-
disklabel.DiskLabel.set_default_label_type(None)
30+
self._blivet_cleanup()
31+
return super()._clean_up()
4832

4933
def _set_up_storage(self):
34+
disk = self.storage.devicetree.get_device_by_path(self.vdevs[0])
35+
self.assertIsNotNone(disk)
36+
37+
self.storage.format_device(disk, get_format("disklabel", label_type="gpt"))
38+
5039
# A part whose UUID varies per architecture, without FS formatted
51-
self.root = self.blivet.new_partition(
40+
self.root = self.storage.new_partition(
5241
size=Size("10MiB"), maxsize=Size("50GiB"), grow=True,
53-
parents=self.blivet.disks, mountpoint="/")
54-
self.blivet.create_device(self.root)
42+
parents=[disk], mountpoint="/")
43+
self.storage.create_device(self.root)
5544

5645
# A part whose UUID is fixed per architecture, without FS formatted
57-
self.home = self.blivet.new_partition(
58-
size=Size("50MiB"), parents=self.blivet.disks,
46+
self.home = self.storage.new_partition(
47+
size=Size("50MiB"), parents=[disk],
5948
mountpoint="/home")
60-
self.blivet.create_device(self.home)
49+
self.storage.create_device(self.home)
6150

6251
# A part whose UUID is fixed per architecture, with FS formatted
63-
self.tmp = self.blivet.new_partition(
52+
self.tmp = self.storage.new_partition(
6453
fmt_type="ext4", size=Size("50MiB"),
65-
parents=self.blivet.disks, mountpoint="/tmp")
66-
self.blivet.create_device(self.tmp)
54+
parents=[disk], mountpoint="/tmp")
55+
self.storage.create_device(self.tmp)
6756

6857
# A part whose UUID specified explicitly, with FS formatted
69-
self.srv = self.blivet.new_partition(
58+
self.srv = self.storage.new_partition(
7059
fmt_type="ext4", size=Size("50MiB"),
71-
parents=self.blivet.disks, mountpoint="/srv",
60+
parents=[disk], mountpoint="/srv",
7261
part_type_uuid=gpt.gpt_part_uuid_for_mountpoint("/srv"))
73-
self.blivet.create_device(self.srv)
62+
self.storage.create_device(self.srv)
7463

7564
# A part with no special UUID assignment
76-
self.etc = self.blivet.new_partition(
77-
size=Size("20MiB"), parents=self.blivet.disks,
65+
self.etc = self.storage.new_partition(
66+
size=Size("20MiB"), parents=[disk],
7867
mountpoint="/etc")
79-
self.blivet.create_device(self.etc)
68+
self.storage.create_device(self.etc)
8069

8170
# A part whose UUID is based off fmt type
82-
self.swap = self.blivet.new_partition(
83-
fmt_type="swap", size=Size("20MiB"), parents=self.blivet.disks)
84-
self.blivet.create_device(self.swap)
71+
self.swap = self.storage.new_partition(
72+
fmt_type="swap", size=Size("20MiB"), parents=[disk])
73+
self.storage.create_device(self.swap)
8574

8675
# An encrypted part
87-
self.usrluks = self.blivet.new_partition(
76+
self.usrluks = self.storage.new_partition(
8877
fmt_type="luks", fmt_args={
8978
"passphrase": "123456",
9079
}, size=Size("100MiB"),
91-
parents=self.blivet.disks, mountpoint="/usr")
92-
self.blivet.create_device(self.usrluks)
80+
parents=[disk], mountpoint="/usr")
81+
self.storage.create_device(self.usrluks)
9382

9483
self.usr = LUKSDevice(
9584
name="luks-user", size=self.usrluks.size, parents=self.usrluks)
96-
self.blivet.create_device(self.usr)
85+
self.storage.create_device(self.usr)
9786

9887
extfs = formats.get_format(
9988
fmt_type="ext4", device=self.usr.path, mountpoint="/usr")
100-
self.blivet.format_device(self.usr, extfs)
89+
self.storage.format_device(self.usr, extfs)
10190

10291
# Allocate the partitions
103-
partitioning.do_partitioning(self.blivet)
92+
partitioning.do_partitioning(self.storage)
93+
94+
self.storage.do_it()
10495

10596

10697
class GPTDiscoverableTestCase(GPTTestBase):

tests/storage_tests/imagebackedtestcase.py

Lines changed: 0 additions & 117 deletions
This file was deleted.

0 commit comments

Comments
 (0)