Skip to content

Commit

Permalink
Merge branch '3.9-devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtechtrefny committed Nov 22, 2023
2 parents 6f7a76c + 793ec72 commit 548285f
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 7 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/blivetgui_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Blivet-GUI tests

on:
pull_request:
branches:
- 3.*-devel

jobs:
build:
name: blivetgui-tests
runs-on: ubuntu-22.04
env:
CI_CONTAINER: blivet-ci-blivetgui-tests
steps:
- name: Checkout blivet repository
uses: actions/checkout@v4

- name: Install podman
run: |
sudo apt -qq update
sudo apt -y -qq install podman
- name: Build the container
run: |
podman build --no-cache -t ${{ env.CI_CONTAINER }} -f misc/ci.Dockerfile .
- name: Start the container
run: |
podman run -d -t --name ${{ env.CI_CONTAINER }} --privileged --volume "$(pwd):/app" --workdir "/app" ${{ env.CI_CONTAINER }}
- name: Install Blivet-GUI test dependencies in the container
run: |
podman exec -it ${{ env.CI_CONTAINER }} bash -c "ansible-playbook -i "localhost," -c local /blivet-gui/misc/install-test-dependencies.yml"
- name: Remove Blivet from the container (we want to install from source)
run: |
podman exec -it ${{ env.CI_CONTAINER }} bash -c "dnf -y remove python3-blivet --noautoremove"
- name: Install Blivet build dependencies in the container
run: |
podman exec -it ${{ env.CI_CONTAINER }} bash -c "ansible-playbook -i "localhost," -c local misc/install-test-dependencies.yml"
- name: Build and install Blivet in the container
run: |
podman exec -it ${{ env.CI_CONTAINER }} bash -c "python3 setup.py install --prefix=/usr"
- name: Run Blivet-GUI static analysis in the container
run: |
podman exec -it ${{ env.CI_CONTAINER }} bash -c "cd /blivet-gui && make check"
- name: Run Blivet-GUI unit tests in the container
run: |
podman exec -it ${{ env.CI_CONTAINER }} bash -c "cd /blivet-gui && make gui-test"
3 changes: 3 additions & 0 deletions blivet/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ def __init__(self):
# backup metadata in /etc/lvm/{archive,backup}
self.lvm_metadata_backup = True

# set to False to not write new LVM PVs to /etc/lvm/devices/system.devices
self.lvm_devices_file = True

# whether to include nodev filesystems in the devicetree
self.include_nodev = False

Expand Down
5 changes: 5 additions & 0 deletions blivet/formats/lvmpv.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from . import DeviceFormat, register_device_format
from .. import udev
from ..static_data.lvm_info import pvs_info, vgs_info
from ..flags import flags

import logging
log = logging.getLogger("blivet")
Expand Down Expand Up @@ -136,6 +137,10 @@ def lvmdevices_add(self, force=True):
self.device, lvm.LVM_DEVICES_FILE)
return

if not flags.lvm_devices_file:
log.debug("Not adding %s to devices file: 'lvm_devices_file' flag is set to False", self.device)
return

try:
blockdev.lvm.devices_add(self.device)
except blockdev.LVMError as e:
Expand Down
9 changes: 8 additions & 1 deletion blivet/tasks/fsmkfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,18 @@ def do_task(self, options=None, label=False, set_uuid=False, nodiscard=False):
" is unacceptable for this filesystem."
% (self.fs.label, self.fs.type))

if self.fs.create_options:
create_options = shlex.split(self.fs.create_options)
else:
create_options = []
if options:
create_options += options

try:
bd_options = BlockDev.FSMkfsOptions(label=self.fs.label if label else None,
uuid=self.fs.uuid if set_uuid else None,
no_discard=self.fs._mkfs_nodiscard if nodiscard else False)
BlockDev.fs.mkfs(self.fs.device, self.fstype, bd_options, extra=options or [])
BlockDev.fs.mkfs(self.fs.device, self.fstype, bd_options, extra={k: '' for k in create_options})
except BlockDev.FSError as e:
raise FSError(str(e))

Expand Down
10 changes: 10 additions & 0 deletions misc/ci.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# latest fedora image for running some of our tests in GH actions

FROM registry.fedoraproject.org/fedora:latest

RUN set -e; \
dnf install -y ansible python3-pip git which dnf-plugins-core; \
git clone --depth 1 https://github.com/storaged-project/ci.git; \
git clone --depth 1 https://github.com/storaged-project/blivet-gui.git;

WORKDIR /
14 changes: 8 additions & 6 deletions misc/install-test-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
---
- hosts: all
become: true
vars:
test_dependencies: true # whether to install test dependencies or not

tasks:
####### Fedora
Expand Down Expand Up @@ -53,7 +55,7 @@
- python3-paramiko
- targetcli
- iscsi-initiator-utils
when: ansible_distribution == 'Fedora'
when: ansible_distribution == 'Fedora' and test_dependencies|bool

####### CentOS 8/9
- name: Install basic build tools (CentOS)
Expand Down Expand Up @@ -104,15 +106,15 @@
- python3-pip
- targetcli
- iscsi-initiator-utils
when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '8'
when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '8' and test_dependencies|bool

- name: Install paramiko using pip (not available in EPEL yet) (CentOS 9)
pip: name=paramiko executable=pip3
when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '9'
when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '9' and test_dependencies|bool

- name: Install pocketlint using pip (CentOS)
pip: name=pocketlint executable=pip3
when: ansible_distribution == 'CentOS'
when: ansible_distribution == 'CentOS' and test_dependencies|bool

####### Debian/Ubuntu
- name: Update apt cache (Debian/Ubuntu)
Expand Down Expand Up @@ -159,7 +161,7 @@
- python3-pip
- targetcli-fb
- open-iscsi
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' and test_dependencies|bool

- name: Install libmount (Debian/Ubuntu)
block:
Expand All @@ -175,4 +177,4 @@

- name: Install pocketlint using pip (Debian/Ubuntu)
pip: name=pocketlint executable=pip3
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' and test_dependencies|bool
20 changes: 20 additions & 0 deletions tests/storage_tests/formats_test/fs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from blivet.formats import get_format
from blivet.devices import PartitionDevice, DiskDevice
from blivet.flags import flags
from blivet.util import capture_output

from .loopbackedtestcase import LoopBackedTestCase

Expand Down Expand Up @@ -67,6 +68,25 @@ def test_online_resize(self):

an_fs.unmount()

def test_create_options(self):
label = "root-test-label"
uuid = "c1b9d5a2-f162-11cf-9ece-0020afc76f16"

an_fs = self._fs_class()
if not an_fs.formattable:
self.skipTest("can not create filesystem %s" % an_fs.name)
an_fs.device = self.loop_devices[0]

# custom fs create options -- -L <label> and -U <uuid> for mke2fs
an_fs.create_options = "-L %s -U %s" % (label, uuid)
an_fs.create()

sys_label = an_fs.read_label()
self.assertEqual(sys_label, label)

out = capture_output(["blkid", "-sUUID", "-ovalue", self.loop_devices[0]])
self.assertEqual(out.strip(), uuid)


class FATFSTestCase(fstesting.FSAsRoot):
_fs_class = fs.FATFS
Expand Down
16 changes: 16 additions & 0 deletions tests/unit_tests/formats_tests/lvmpv_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import unittest

from blivet.formats.lvmpv import LVMPhysicalVolume
from blivet.flags import flags


class LVMPVNodevTestCase(unittest.TestCase):
Expand Down Expand Up @@ -71,3 +72,18 @@ def test_lvm_devices(self):
fmt._create()

mock["blockdev"].lvm.devices_add.assert_not_called()

with self.patches() as mock:
# LVM devices file enabled and devices file exists
# but flag set to false -> devices_add should not be called
mock["lvm"].HAVE_LVMDEVICES = True
mock["os"].path.exists.return_value = True
mock["vgs_info"].cache = {}
flags.lvm_devices_file = False

fmt._create()

mock["blockdev"].lvm.devices_add.assert_not_called()

# reset the flag back
flags.lvm_devices_file = True
1 change: 1 addition & 0 deletions tests/unit_tests/formats_tests/methods_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ class LVMPhysicalVolumeMethodsTestCase(FormatMethodsTestCase):
def set_patches(self):
super(LVMPhysicalVolumeMethodsTestCase, self).set_patches()
self.patchers["blockdev"] = patch("blivet.formats.lvmpv.blockdev")
self.patchers["vgs_info"] = patch("blivet.formats.lvmpv.vgs_info")

def _test_destroy_backend(self):
self.format.exists = True
Expand Down

0 comments on commit 548285f

Please sign in to comment.