Skip to content

Commit

Permalink
Regression test for bsc#1166096
Browse files Browse the repository at this point in the history
  • Loading branch information
ancorgs committed Mar 25, 2020
1 parent 1d30f4e commit 4fd64ca
Show file tree
Hide file tree
Showing 2 changed files with 366 additions and 0 deletions.
342 changes: 342 additions & 0 deletions test/data/bug_1166096.xml
@@ -0,0 +1,342 @@
<?xml version="1.0"?>
<!-- generated by libstorage-ng version 4.2.65, install, 2020-03-03 06:00:31 GMT -->
<Devicegraph>
<Devices>
<Disk>
<sid>43</sid>
<name>/dev/vda</name>
<sysfs-name>vda</sysfs-name>
<sysfs-path>/devices/pci0000:00/0000:00:06.0/virtio3/block/vda</sysfs-path>
<region>
<length>41943040</length>
<block-size>512</block-size>
</region>
<topology/>
<udev-path>pci-0000:00:06.0</udev-path>
<range>256</range>
<rotational>true</rotational>
</Disk>
<Gpt>
<sid>51</sid>
</Gpt>
<Partition>
<sid>52</sid>
<name>/dev/vda1</name>
<sysfs-name>vda1</sysfs-name>
<sysfs-path>/devices/pci0000:00/0000:00:06.0/virtio3/block/vda/vda1</sysfs-path>
<region>
<start>2048</start>
<length>16384</length>
<block-size>512</block-size>
</region>
<topology/>
<udev-path>pci-0000:00:06.0-part1</udev-path>
<type>primary</type>
<id>65</id>
</Partition>
<Partition>
<sid>53</sid>
<name>/dev/vda2</name>
<sysfs-name>vda2</sysfs-name>
<sysfs-path>/devices/pci0000:00/0000:00:06.0/virtio3/block/vda/vda2</sysfs-path>
<region>
<start>18432</start>
<length>39047168</length>
<block-size>512</block-size>
</region>
<topology/>
<udev-path>pci-0000:00:06.0-part2</udev-path>
<type>primary</type>
<id>131</id>
</Partition>
<Btrfs>
<sid>54</sid>
<metadata-raid-level>DEFAULT</metadata-raid-level>
<data-raid-level>DEFAULT</data-raid-level>
</Btrfs>
<BtrfsSubvolume>
<sid>55</sid>
<id>5</id>
<path></path>
</BtrfsSubvolume>
<MountPoint>
<sid>56</sid>
<path>/</path>
<mount-by>uuid</mount-by>
<mount-type>btrfs</mount-type>
<active>true</active>
<in-etc-fstab>true</in-etc-fstab>
<freq>0</freq>
<passno>0</passno>
</MountPoint>
<BtrfsSubvolume>
<sid>57</sid>
<id>-1</id>
<path>@</path>
<default-btrfs-subvolume>true</default-btrfs-subvolume>
</BtrfsSubvolume>
<BtrfsSubvolume>
<sid>58</sid>
<id>-1</id>
<path>@/boot/grub2/powerpc-ieee1275</path>
</BtrfsSubvolume>
<MountPoint>
<sid>59</sid>
<path>/boot/grub2/powerpc-ieee1275</path>
<mount-by>uuid</mount-by>
<mount-options>subvol=/@/boot/grub2/powerpc-ieee1275</mount-options>
<mount-type>btrfs</mount-type>
<active>true</active>
<in-etc-fstab>true</in-etc-fstab>
<freq>0</freq>
<passno>0</passno>
</MountPoint>
<BtrfsSubvolume>
<sid>60</sid>
<id>-1</id>
<path>@/home</path>
</BtrfsSubvolume>
<MountPoint>
<sid>61</sid>
<path>/home</path>
<mount-by>uuid</mount-by>
<mount-options>subvol=/@/home</mount-options>
<mount-type>btrfs</mount-type>
<active>true</active>
<in-etc-fstab>true</in-etc-fstab>
<freq>0</freq>
<passno>0</passno>
</MountPoint>
<BtrfsSubvolume>
<sid>62</sid>
<id>-1</id>
<path>@/opt</path>
</BtrfsSubvolume>
<MountPoint>
<sid>63</sid>
<path>/opt</path>
<mount-by>uuid</mount-by>
<mount-options>subvol=/@/opt</mount-options>
<mount-type>btrfs</mount-type>
<active>true</active>
<in-etc-fstab>true</in-etc-fstab>
<freq>0</freq>
<passno>0</passno>
</MountPoint>
<BtrfsSubvolume>
<sid>64</sid>
<id>-1</id>
<path>@/root</path>
</BtrfsSubvolume>
<MountPoint>
<sid>65</sid>
<path>/root</path>
<mount-by>uuid</mount-by>
<mount-options>subvol=/@/root</mount-options>
<mount-type>btrfs</mount-type>
<active>true</active>
<in-etc-fstab>true</in-etc-fstab>
<freq>0</freq>
<passno>0</passno>
</MountPoint>
<BtrfsSubvolume>
<sid>66</sid>
<id>-1</id>
<path>@/srv</path>
</BtrfsSubvolume>
<MountPoint>
<sid>67</sid>
<path>/srv</path>
<mount-by>uuid</mount-by>
<mount-options>subvol=/@/srv</mount-options>
<mount-type>btrfs</mount-type>
<active>true</active>
<in-etc-fstab>true</in-etc-fstab>
<freq>0</freq>
<passno>0</passno>
</MountPoint>
<BtrfsSubvolume>
<sid>68</sid>
<id>-1</id>
<path>@/tmp</path>
</BtrfsSubvolume>
<MountPoint>
<sid>69</sid>
<path>/tmp</path>
<mount-by>uuid</mount-by>
<mount-options>subvol=/@/tmp</mount-options>
<mount-type>btrfs</mount-type>
<active>true</active>
<in-etc-fstab>true</in-etc-fstab>
<freq>0</freq>
<passno>0</passno>
</MountPoint>
<BtrfsSubvolume>
<sid>70</sid>
<id>-1</id>
<path>@/usr/local</path>
</BtrfsSubvolume>
<MountPoint>
<sid>71</sid>
<path>/usr/local</path>
<mount-by>uuid</mount-by>
<mount-options>subvol=/@/usr/local</mount-options>
<mount-type>btrfs</mount-type>
<active>true</active>
<in-etc-fstab>true</in-etc-fstab>
<freq>0</freq>
<passno>0</passno>
</MountPoint>
<BtrfsSubvolume>
<sid>72</sid>
<id>-1</id>
<path>@/var</path>
<nocow>true</nocow>
</BtrfsSubvolume>
<MountPoint>
<sid>73</sid>
<path>/var</path>
<mount-by>uuid</mount-by>
<mount-options>subvol=/@/var</mount-options>
<mount-type>btrfs</mount-type>
<active>true</active>
<in-etc-fstab>true</in-etc-fstab>
<freq>0</freq>
<passno>0</passno>
</MountPoint>
<Partition>
<sid>74</sid>
<name>/dev/vda3</name>
<sysfs-name>vda3</sysfs-name>
<sysfs-path>/devices/pci0000:00/0000:00:06.0/virtio3/block/vda/vda3</sysfs-path>
<region>
<start>39065600</start>
<length>2877407</length>
<block-size>512</block-size>
</region>
<topology/>
<udev-path>pci-0000:00:06.0-part3</udev-path>
<type>primary</type>
<id>130</id>
</Partition>
<Swap>
<sid>75</sid>
</Swap>
<MountPoint>
<sid>76</sid>
<path>swap</path>
<mount-by>uuid</mount-by>
<mount-type>swap</mount-type>
<active>true</active>
<in-etc-fstab>true</in-etc-fstab>
<freq>0</freq>
<passno>0</passno>
</MountPoint>
</Devices>
<Holders>
<User>
<source-sid>43</source-sid>
<target-sid>51</target-sid>
</User>
<Subdevice>
<source-sid>51</source-sid>
<target-sid>52</target-sid>
</Subdevice>
<Subdevice>
<source-sid>51</source-sid>
<target-sid>53</target-sid>
</Subdevice>
<Subdevice>
<source-sid>54</source-sid>
<target-sid>55</target-sid>
</Subdevice>
<FilesystemUser>
<source-sid>53</source-sid>
<target-sid>54</target-sid>
</FilesystemUser>
<User>
<source-sid>54</source-sid>
<target-sid>56</target-sid>
</User>
<Subdevice>
<source-sid>55</source-sid>
<target-sid>57</target-sid>
</Subdevice>
<Subdevice>
<source-sid>57</source-sid>
<target-sid>58</target-sid>
</Subdevice>
<User>
<source-sid>58</source-sid>
<target-sid>59</target-sid>
</User>
<Subdevice>
<source-sid>57</source-sid>
<target-sid>60</target-sid>
</Subdevice>
<User>
<source-sid>60</source-sid>
<target-sid>61</target-sid>
</User>
<Subdevice>
<source-sid>57</source-sid>
<target-sid>62</target-sid>
</Subdevice>
<User>
<source-sid>62</source-sid>
<target-sid>63</target-sid>
</User>
<Subdevice>
<source-sid>57</source-sid>
<target-sid>64</target-sid>
</Subdevice>
<User>
<source-sid>64</source-sid>
<target-sid>65</target-sid>
</User>
<Subdevice>
<source-sid>57</source-sid>
<target-sid>66</target-sid>
</Subdevice>
<User>
<source-sid>66</source-sid>
<target-sid>67</target-sid>
</User>
<Subdevice>
<source-sid>57</source-sid>
<target-sid>68</target-sid>
</Subdevice>
<User>
<source-sid>68</source-sid>
<target-sid>69</target-sid>
</User>
<Subdevice>
<source-sid>57</source-sid>
<target-sid>70</target-sid>
</Subdevice>
<User>
<source-sid>70</source-sid>
<target-sid>71</target-sid>
</User>
<Subdevice>
<source-sid>57</source-sid>
<target-sid>72</target-sid>
</Subdevice>
<User>
<source-sid>72</source-sid>
<target-sid>73</target-sid>
</User>
<Subdevice>
<source-sid>51</source-sid>
<target-sid>74</target-sid>
</Subdevice>
<FilesystemUser>
<source-sid>74</source-sid>
<target-sid>75</target-sid>
</FilesystemUser>
<User>
<source-sid>75</source-sid>
<target-sid>76</target-sid>
</User>
</Holders>
</Devicegraph>
24 changes: 24 additions & 0 deletions test/udev_mapping_test.rb
Expand Up @@ -71,6 +71,8 @@
context "and the udev name is not available for the mount by option in the mount point" do
let(:udev_name) { nil }

# This is likely not the right fallback, it should use the preferred mount_by.
# And, by definition, the preferred mount_by is always available
it "returns the kernel name as fallback" do
expect(subject.to_mountby_device(device.name)).to eq("/dev/sda3")
end
Expand Down Expand Up @@ -98,10 +100,32 @@
context "and the udev name is not available for the preferred mount by option" do
let(:udev_name) { nil }

# This fallback is nice to have as extra check, but in general makes no sense.
# The preferred mount_by should always be available by definition
it "returns the kernel name as fallback" do
expect(subject.to_mountby_device(device.name)).to eq("/dev/sda3")
end
end
end

# Regression test for bsc#1166096
context "for a regular PReP partition (contains no filesystem and is not mounted)" do
before do
# First, disable the general mocking
allow(Y2Storage::BlkDevice).to receive(:find_by_name).and_call_original

# Then, just stub the whole devicegraph to reproduce the scenario
devicegraph_stub("bug_1166096.xml")
end

# These mocks are not needed
let(:device) { nil }
let(:udev_name) { nil }
let(:mount_by) { nil }

it "returns an udev link if there is any available" do
expect(subject.to_mountby_device("/dev/vda1")).to eq "/dev/disk/by-path/pci-0000:00:06.0-part1"
end
end
end
end

0 comments on commit 4fd64ca

Please sign in to comment.