Hello community,

here is the log from the commit of package yast2-storage-ng for 
openSUSE:Factory checked in at 2020-12-15 12:30:28
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-storage-ng (Old)
 and      /work/SRC/openSUSE:Factory/.yast2-storage-ng.new.2328 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yast2-storage-ng"

Tue Dec 15 12:30:28 2020 rev:95 rq:855710 version:4.3.29

Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-storage-ng/yast2-storage-ng.changes        
2020-12-12 20:27:22.533540414 +0100
+++ 
/work/SRC/openSUSE:Factory/.yast2-storage-ng.new.2328/yast2-storage-ng.changes  
    2020-12-15 12:32:42.808112903 +0100
@@ -1,0 +2,6 @@
+Thu Dec 10 16:45:41 UTC 2020 - Imobach Gonzalez Sosa <[email protected]>
+
+- AutoYaST: add support for Btrfs quotas (jsc#SLE-7742).
+- 4.3.29
+
+-------------------------------------------------------------------

Old:
----
  yast2-storage-ng-4.3.28.tar.bz2

New:
----
  yast2-storage-ng-4.3.29.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ yast2-storage-ng.spec ++++++
--- /var/tmp/diff_new_pack.FD6nmF/_old  2020-12-15 12:32:43.548113499 +0100
+++ /var/tmp/diff_new_pack.FD6nmF/_new  2020-12-15 12:32:43.552113502 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-storage-ng
-Version:        4.3.28
+Version:        4.3.29
 Release:        0
 Summary:        YaST2 - Storage Configuration
 License:        GPL-2.0-only OR GPL-3.0-only

++++++ yast2-storage-ng-4.3.28.tar.bz2 -> yast2-storage-ng-4.3.29.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.28/package/yast2-storage-ng.changes 
new/yast2-storage-ng-4.3.29/package/yast2-storage-ng.changes
--- old/yast2-storage-ng-4.3.28/package/yast2-storage-ng.changes        
2020-12-10 10:12:46.000000000 +0100
+++ new/yast2-storage-ng-4.3.29/package/yast2-storage-ng.changes        
2020-12-14 11:28:45.000000000 +0100
@@ -1,4 +1,10 @@
 -------------------------------------------------------------------
+Thu Dec 10 16:45:41 UTC 2020 - Imobach Gonzalez Sosa <[email protected]>
+
+- AutoYaST: add support for Btrfs quotas (jsc#SLE-7742).
+- 4.3.29
+
+-------------------------------------------------------------------
 Thu Dec 10 08:45:09 UTC 2020 - José Iván López González <[email protected]>
 
 - Partitioner: do not show summary when there are no actions to
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.28/package/yast2-storage-ng.spec 
new/yast2-storage-ng-4.3.29/package/yast2-storage-ng.spec
--- old/yast2-storage-ng-4.3.28/package/yast2-storage-ng.spec   2020-12-10 
10:12:46.000000000 +0100
+++ new/yast2-storage-ng-4.3.29/package/yast2-storage-ng.spec   2020-12-14 
11:28:45.000000000 +0100
@@ -16,7 +16,7 @@
 #
 
 Name:           yast2-storage-ng
-Version:        4.3.28
+Version:        4.3.29
 Release:        0
 Summary:        YaST2 - Storage Configuration
 License:        GPL-2.0-only OR GPL-3.0-only
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.28/src/lib/y2storage/autoinst_issues/missing_btrfs_quotas.rb
 
new/yast2-storage-ng-4.3.29/src/lib/y2storage/autoinst_issues/missing_btrfs_quotas.rb
--- 
old/yast2-storage-ng-4.3.28/src/lib/y2storage/autoinst_issues/missing_btrfs_quotas.rb
       1970-01-01 01:00:00.000000000 +0100
+++ 
new/yast2-storage-ng-4.3.29/src/lib/y2storage/autoinst_issues/missing_btrfs_quotas.rb
       2020-12-14 11:28:45.000000000 +0100
@@ -0,0 +1,60 @@
+# Copyright (c) [2020] SUSE LLC
+#
+# All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of version 2 of the GNU General Public License as published
+# by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, contact SUSE LLC.
+#
+# To contact SUSE LLC about this file by physical or electronic mail, you may
+# find current contact information at www.suse.com.
+require "installation/autoinst_issues/issue"
+
+module Y2Storage
+  module AutoinstIssues
+    # Represents an scenario where Btrfs quotas were not enabled for the 
filesystem
+    # but they are needed for a subvolume.
+    #
+    # @example
+    #   section = AutoinstProfile::PartitionSection.new_from_hashes({})
+    #   problem = MissingBtrfsQuotas.new(section)
+    class MissingBtrfsQuotas < ::Installation::AutoinstIssues::Issue
+      # @param section [#parent,#section_name] Section where it was detected
+      #                (see {AutoinstProfile})
+      # @param subvolumes [Array<SubvolSpecification>]
+      def initialize(section, subvolumes)
+        textdomain "storage"
+        @section = section
+        @subvolumes = subvolumes
+      end
+
+      # Return problem severity
+      #
+      # @return [Symbol] :warn
+      # @see Issue#severity
+      def severity
+        :warn
+      end
+
+      # Return the error message to be displayed
+      #
+      # @return [String] Error message
+      # @see Issue#message
+      def message
+        format(
+          _("Btrfs quotas will be automatically enabled because they are 
needed for the " \
+            "following subvolumes:\n%{subvol_names}."),
+          subvol_names: @subvolumes.map(&:path).join(", ")
+        )
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.28/src/lib/y2storage/autoinst_issues.rb 
new/yast2-storage-ng-4.3.29/src/lib/y2storage/autoinst_issues.rb
--- old/yast2-storage-ng-4.3.28/src/lib/y2storage/autoinst_issues.rb    
2020-12-10 10:12:46.000000000 +0100
+++ new/yast2-storage-ng-4.3.29/src/lib/y2storage/autoinst_issues.rb    
2020-12-14 11:28:45.000000000 +0100
@@ -40,6 +40,7 @@
 require "y2storage/autoinst_issues/exception"
 require "y2storage/autoinst_issues/invalid_encryption"
 require "y2storage/autoinst_issues/invalid_value"
+require "y2storage/autoinst_issues/missing_btrfs_quotas"
 require "y2storage/autoinst_issues/missing_reusable_device"
 require "y2storage/autoinst_issues/missing_reusable_filesystem"
 require "y2storage/autoinst_issues/missing_reuse_info"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.28/src/lib/y2storage/autoinst_profile/partition_section.rb
 
new/yast2-storage-ng-4.3.29/src/lib/y2storage/autoinst_profile/partition_section.rb
--- 
old/yast2-storage-ng-4.3.28/src/lib/y2storage/autoinst_profile/partition_section.rb
 2020-12-10 10:12:46.000000000 +0100
+++ 
new/yast2-storage-ng-4.3.29/src/lib/y2storage/autoinst_profile/partition_section.rb
 2020-12-14 11:28:45.000000000 +0100
@@ -79,7 +79,8 @@
         { name: :bcache_backing_for },
         { name: :bcache_caching_for },
         { name: :device },
-        { name: :btrfs_name }
+        { name: :btrfs_name },
+        { name: :quotas }
       ].freeze
       private_constant :ATTRIBUTES
 
@@ -171,6 +172,9 @@
       # @!attribute btrfs_name
       #   @return [String] Btrfs in which this partition will be included
 
+      # @!attribute quotas
+      #   @return [Boolean] Whether support for quotas is enabled or not
+
       def init_from_hashes(hash)
         super
 
@@ -192,7 +196,8 @@
       # @see PartitioningSection.new_from_storage for more details
       #
       # @param device [Device] a device that can be cloned into a <partition> 
section,
-      #   like a partition, an LVM logical volume, an MD RAID or a NFS 
filesystem.
+      #   like a partition, an LVM logical volume, an MD RAID, a NFS 
filesystem or a
+      #   Btrfs multi-device.
       # @return [PartitionSection]
       def self.new_from_storage(device, parent = nil)
         result = new(parent)
@@ -392,6 +397,7 @@
         @filesystem = filesystem.type.to_sym
         @label = filesystem.label unless filesystem.label.empty?
         @mkfs_options = filesystem.mkfs_options unless 
filesystem.mkfs_options.empty?
+        @quotas = filesystem.quota? if filesystem.respond_to?(:quota?)
         init_subvolumes(filesystem)
         init_mount_options(filesystem)
       end
@@ -457,13 +463,18 @@
 
       # Returns an array of hashes representing subvolumes
       #
-      # AutoYaST only uses a subset of subvolumes properties: 'path' and 
'copy_on_write'.
+      # AutoYaST only uses a subset of subvolumes properties: 'path', 
'copy_on_write'
+      # and 'referenced_limit'.
       #
       # @return [Array<Hash>] Array of hash-based representations of subvolumes
       def subvolumes_to_hashes
         subvolumes.map do |subvol|
           subvol_path = subvol.path.sub(/\A#{@subvolumes_prefix}\//, "")
-          { "path" => subvol_path, "copy_on_write" => subvol.copy_on_write }
+          hash = { "path" => subvol_path, "copy_on_write" => 
subvol.copy_on_write }
+          if subvol.referenced_limit && !subvol.referenced_limit.unlimited?
+            hash["referenced_limit"] = subvol.referenced_limit.to_s
+          end
+          hash
         end
       end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.28/src/lib/y2storage/disk_size.rb 
new/yast2-storage-ng-4.3.29/src/lib/y2storage/disk_size.rb
--- old/yast2-storage-ng-4.3.28/src/lib/y2storage/disk_size.rb  2020-12-10 
10:12:46.000000000 +0100
+++ new/yast2-storage-ng-4.3.29/src/lib/y2storage/disk_size.rb  2020-12-14 
11:28:45.000000000 +0100
@@ -364,6 +364,31 @@
         DiskSize.new(bytes)
       end
 
+      # Create a {DiskSize} from a parsed string but returns a fallback when 
the string is not valid
+      #
+      # The parse method raises an exception when the given string does not
+      # correspond to a valid size. This method returns a fallback value
+      # instead of raising an exception.
+      #
+      # @example
+      #   DiskSize.parse_or("42 GiB")                             #=> 
<DiskSize 42.00 GiB (45097156608)>
+      #   DiskSize.parse_or("GiB")                                #=> nil
+      #   DiskSize.parse_or("GiB", DiskSize.unlimited)            #=> 
<DiskSize <unlimited> -1>
+      #   DiskSize.parse_or("1GB", legacy_units: true)            #=> 
<DiskSize 1.00 GiB (1073741824)>
+      #
+      # @param str [String] String representing a size
+      # @param fallback [Object] Fallback value to return when parsing failed
+      # @param legacy_units [Boolean] if true, International System units
+      #   are considered as base 2 units, that is, MB is the same than MiB.
+      # @return [DiskSize]
+      #
+      # @see .parse
+      def parse_or(str, fallback = nil, legacy_units: false)
+        parse(str, legacy_units: legacy_units)
+      rescue TypeError
+        fallback
+      end
+
       alias_method :from_s, :parse
       alias_method :from_human_string, :parse
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.28/src/lib/y2storage/planned/can_be_formatted.rb 
new/yast2-storage-ng-4.3.29/src/lib/y2storage/planned/can_be_formatted.rb
--- old/yast2-storage-ng-4.3.28/src/lib/y2storage/planned/can_be_formatted.rb   
2020-12-10 10:12:46.000000000 +0100
+++ new/yast2-storage-ng-4.3.29/src/lib/y2storage/planned/can_be_formatted.rb   
2020-12-14 11:28:45.000000000 +0100
@@ -72,11 +72,16 @@
       # @return [String] Options to be passed to the mkfs tool
       attr_accessor :mkfs_options
 
+      # @return [Boolean] Whether quotas are enabled
+      attr_accessor :quota
+      alias_method :quota?, :quota
+
       # Initializations of the mixin, to be called from the class constructor.
       def initialize_can_be_formatted
         @subvolumes = []
         @reformat = false
         @snapshots = false
+        @quota = false
       end
 
       # See #subvolumes
@@ -104,6 +109,7 @@
         final_device.remove_descendants
         filesystem = final_device.create_blk_filesystem(filesystem_type)
         setup_filesystem(filesystem)
+        setup_quota(filesystem)
         btrfs_setup(filesystem)
 
         filesystem
@@ -191,6 +197,12 @@
         mount_point.mount_options = options unless options.empty?
       end
 
+      def setup_quota(filesystem)
+        return unless filesystem.respond_to?(:quota=)
+
+        filesystem.quota = quota?
+      end
+
       # Returns fstab options for the given mount point
       #
       # @param mount_point [MountPoint]
@@ -237,8 +249,8 @@
         else
           filesystem = final_device!(device).filesystem
           if filesystem
-            assign_mount_point(filesystem)
-            setup_fstab_options(filesystem.mount_point)
+            setup_quota(filesystem)
+            setup_mount_point(filesystem)
           end
         end
       end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.28/src/lib/y2storage/proposal/autoinst_drive_planner.rb
 
new/yast2-storage-ng-4.3.29/src/lib/y2storage/proposal/autoinst_drive_planner.rb
--- 
old/yast2-storage-ng-4.3.28/src/lib/y2storage/proposal/autoinst_drive_planner.rb
    2020-12-10 10:12:46.000000000 +0100
+++ 
new/yast2-storage-ng-4.3.29/src/lib/y2storage/proposal/autoinst_drive_planner.rb
    2020-12-14 11:28:45.000000000 +0100
@@ -239,6 +239,29 @@
           else
             []
           end
+
+        configure_btrfs_quotas(device, section)
+      end
+
+      # Sets the Btrfs quotas according to the section and the subvolumes
+      #
+      # @param device  [Planned::Device] Planned device
+      # @param section [AutoinstProfile::PartitionSection] AutoYaST 
specification
+      def configure_btrfs_quotas(device, section)
+        if section.quotas
+          device.quota = true
+          return
+        end
+
+        subvols_with_quotas = device.subvolumes.select do |subvol|
+          subvol.referenced_limit && !subvol.referenced_limit.unlimited?
+        end
+        return if subvols_with_quotas.empty? || device.quota?
+
+        device.quota = true
+        issues_list.add(
+          Y2Storage::AutoinstIssues::MissingBtrfsQuotas, section, 
subvols_with_quotas
+        )
       end
 
       # Return the default subvolume attributes for a given mount point
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.28/src/lib/y2storage/subvol_specification.rb 
new/yast2-storage-ng-4.3.29/src/lib/y2storage/subvol_specification.rb
--- old/yast2-storage-ng-4.3.28/src/lib/y2storage/subvol_specification.rb       
2020-12-10 10:12:46.000000000 +0100
+++ new/yast2-storage-ng-4.3.29/src/lib/y2storage/subvol_specification.rb       
2020-12-14 11:28:45.000000000 +0100
@@ -30,7 +30,7 @@
   class SubvolSpecification
     include Yast::Logger
 
-    attr_accessor :path, :copy_on_write, :archs
+    attr_accessor :path, :copy_on_write, :archs, :referenced_limit
 
     COW_SUBVOL_PATHS = [
       "home",
@@ -70,16 +70,18 @@
       "boot/grub2/s390x-emu"        => ["s390"]
     }
 
-    def initialize(path, copy_on_write: true, archs: nil)
+    def initialize(path, copy_on_write: true, archs: nil, referenced_limit: 
nil)
       @path = path
       @copy_on_write = copy_on_write
       @archs = archs
+      @referenced_limit = referenced_limit
     end
 
     def to_s
       text = "SubvolSpecification #{@path}"
       text += " (NoCOW)" unless @copy_on_write
       text += " (archs: #{@archs})" if arch_specific?
+      text += " (limit): #{@referenced_limit}" if @referenced_limit
       text
     end
 
@@ -159,6 +161,7 @@
       subvolume = filesystem.create_btrfs_subvolume(subvolume_path, 
!copy_on_write)
       return if subvolume.nil?
 
+      subvolume.referenced_limit = referenced_limit if referenced_limit
       subvolume.can_be_auto_deleted = true
       subvolume
     end
@@ -169,17 +172,17 @@
     #   or just a string (for subvolumes specified just as a path)
     # @return [SubvolSpecification] or nil if error
     def self.create_from_xml(xml)
-      return nil if xml.nil?
-
+      xml ||= {}
       xml = { "path" => xml } if xml.is_a?(String)
       return nil unless xml.key?("path")
 
-      path = xml["path"]
-      cow = true
-      cow = xml["copy_on_write"] if xml.key?("copy_on_write")
+      cow = xml.key?("copy_on_write") ? xml["copy_on_write"] : true
       archs = nil
       archs = xml["archs"].gsub(/\s+/, "").split(",") if xml.key?("archs")
-      planned_subvol = SubvolSpecification.new(path, copy_on_write: cow, 
archs: archs)
+      referenced_limit = DiskSize.parse_or(xml["referenced_limit"]) if 
xml["referenced_limit"]
+      planned_subvol = SubvolSpecification.new(
+        xml["path"], copy_on_write: cow, archs: archs, referenced_limit: 
referenced_limit
+      )
       log.info("Creating from XML: #{planned_subvol}")
       planned_subvol
     end
@@ -189,7 +192,11 @@
     # @param subvolume [BtrfsSubvolume] Btrfs subvolume
     # @return [SubvolSpecification]
     def self.create_from_btrfs_subvolume(subvolume)
-      subvol = SubvolSpecification.new(subvolume.path, copy_on_write: 
!subvolume.nocow?)
+      subvol = SubvolSpecification.new(
+        subvolume.path,
+        copy_on_write:    !subvolume.nocow?,
+        referenced_limit: subvolume.referenced_limit
+      )
       log.info "Creating from Btrfs subvolume: #{subvol}"
       subvol
     end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.28/test/y2storage/autoinst_issues/missing_btrfs_quotas_test.rb
 
new/yast2-storage-ng-4.3.29/test/y2storage/autoinst_issues/missing_btrfs_quotas_test.rb
--- 
old/yast2-storage-ng-4.3.28/test/y2storage/autoinst_issues/missing_btrfs_quotas_test.rb
     1970-01-01 01:00:00.000000000 +0100
+++ 
new/yast2-storage-ng-4.3.29/test/y2storage/autoinst_issues/missing_btrfs_quotas_test.rb
     2020-12-14 11:28:45.000000000 +0100
@@ -0,0 +1,49 @@
+# Copyright (c) [2020] SUSE LLC
+#
+# All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of version 2 of the GNU General Public License as published
+# by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, contact SUSE LLC.
+#
+# To contact SUSE LLC about this file by physical or electronic mail, you may
+# find current contact information at www.suse.com.
+
+require_relative "../../spec_helper"
+require "y2storage/autoinst_issues/missing_btrfs_quotas"
+require "y2storage/autoinst_profile/partition_section"
+
+describe Y2Storage::AutoinstIssues::MissingBtrfsQuotas do
+  subject(:issue) { described_class.new(section, subvolumes) }
+
+  let(:section) do
+    instance_double(Y2Storage::AutoinstProfile::PartitionSection)
+  end
+
+  let(:subvolumes) do
+    [
+      Y2Storage::SubvolSpecification.new("@/tmp"),
+      Y2Storage::SubvolSpecification.new("@/var/log")
+    ]
+  end
+
+  describe "#message" do
+    it "returns a description of the issue" do
+      expect(issue.message).to match(/automatically enabled.+@\/tmp, 
@\/var\/log/m)
+    end
+  end
+
+  describe "#severity" do
+    it "returns :warn" do
+      expect(issue.severity).to eq(:warn)
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.28/test/y2storage/autoinst_profile/partition_section_test.rb
 
new/yast2-storage-ng-4.3.29/test/y2storage/autoinst_profile/partition_section_test.rb
--- 
old/yast2-storage-ng-4.3.28/test/y2storage/autoinst_profile/partition_section_test.rb
       2020-12-10 10:12:46.000000000 +0100
+++ 
new/yast2-storage-ng-4.3.29/test/y2storage/autoinst_profile/partition_section_test.rb
       2020-12-14 11:28:45.000000000 +0100
@@ -535,6 +535,22 @@
           end
         end
       end
+
+      context "and quotas are enabled" do
+        before do
+          allow(filesystem).to receive(:quota?).and_return(true)
+        end
+
+        it "initializes the 'quotas' attribute to 'true'" do
+          expect(section.quotas).to eq(true)
+        end
+      end
+
+      context "and quotas are disabled" do
+        it "initializes the 'quotas' attribute to 'false'" do
+          expect(section.quotas).to eq(false)
+        end
+      end
     end
 
     context "given a block filesystem" do
@@ -979,6 +995,22 @@
         end
 
       end
+
+      context "when a subvolume has a referenced limit" do
+        before do
+          section.subvolumes = [
+            Y2Storage::SubvolSpecification.new(
+              "@/usr", copy_on_write: true, referenced_limit: 
Y2Storage::DiskSize.new("5 GiB")
+            )
+          ]
+        end
+
+        it "exports subvolumes as an array of hashes" do
+          expect(section.to_hashes["subvolumes"]).to include(
+            a_hash_including("referenced_limit" => "5 GiB")
+          )
+        end
+      end
     end
 
     context "when there are not subvolumes" do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.28/test/y2storage/disk_size_test.rb 
new/yast2-storage-ng-4.3.29/test/y2storage/disk_size_test.rb
--- old/yast2-storage-ng-4.3.28/test/y2storage/disk_size_test.rb        
2020-12-10 10:12:46.000000000 +0100
+++ new/yast2-storage-ng-4.3.29/test/y2storage/disk_size_test.rb        
2020-12-14 11:28:45.000000000 +0100
@@ -535,6 +535,20 @@
     end
   end
 
+  describe ".parse_or" do
+    it "parses the given value" do
+      size = described_class.parse_or("10GiB", Y2Storage::DiskSize.unlimited)
+      expect(size).to eq(described_class.new("10GiB"))
+    end
+
+    context "when an invalid value is given" do
+      it "returns the fallback" do
+        size = described_class.parse_or("GiB", Y2Storage::DiskSize.unlimited)
+        expect(size).to eq(Y2Storage::DiskSize.unlimited)
+      end
+    end
+  end
+
   describe "#ceil" do
     # Use 31337 bytes (prime) to ensure we don't success accidentally
     let(:rounding) { Y2Storage::DiskSize.new(31337) }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.28/test/y2storage/planned/can_be_formatted_test.rb 
new/yast2-storage-ng-4.3.29/test/y2storage/planned/can_be_formatted_test.rb
--- old/yast2-storage-ng-4.3.28/test/y2storage/planned/can_be_formatted_test.rb 
2020-12-10 10:12:46.000000000 +0100
+++ new/yast2-storage-ng-4.3.29/test/y2storage/planned/can_be_formatted_test.rb 
2020-12-14 11:28:45.000000000 +0100
@@ -44,12 +44,13 @@
   end
 
   subject(:planned) { FormattableDevice.new }
+  let(:scenario) { "windows-linux-free-pc" }
   let(:blk_device) { Y2Storage::BlkDevice.find_by_name(fake_devicegraph, 
device_name) }
   let(:mount_by) { Y2Storage::Filesystems::MountByType::DEVICE }
   let(:mount_point) { "/" }
 
   before do
-    fake_scenario("windows-linux-free-pc")
+    fake_scenario(scenario)
   end
 
   describe "#format!" do
@@ -102,6 +103,32 @@
         end
       end
     end
+
+    context "when quotas are planned to be enabled" do
+      before do
+        planned.quota = true
+      end
+
+      it "enables the quotas" do
+        planned.format!(blk_device)
+        expect(blk_device.filesystem.quota?).to eq(true)
+      end
+
+      context "but they are not supported" do
+        let(:filesystem_type) { Y2Storage::Filesystems::Type::EXT4 }
+
+        it "does not enable the quotas" do
+          expect { planned.format!(blk_device) }.to_not raise_error
+        end
+      end
+    end
+
+    context "when quotas are not enabled" do
+      it "does not enable the quotas" do
+        planned.format!(blk_device)
+        expect(blk_device.filesystem.quota?).to eq(false)
+      end
+    end
   end
 
   describe "#reuse_device!" do
@@ -173,5 +200,38 @@
         end
       end
     end
+
+    context "when quotas are planned to be enabled" do
+      let(:scenario) { "trivial_btrfs" }
+      let(:device_name) { "/dev/sda1" }
+
+      before do
+        planned.quota = true
+      end
+
+      it "enables the quotas" do
+        planned.reuse!(fake_devicegraph)
+        expect(blk_device.filesystem.quota?).to eq(true)
+      end
+
+      context "but they are not supported" do
+        let(:scenario) { "windows-linux-free-pc" }
+        let(:device_name) { "/dev/sda2" }
+
+        it "does not enable the quotas" do
+          expect { planned.reuse!(fake_devicegraph) }.to_not raise_error
+        end
+      end
+    end
+
+    context "when quotas are not enabled" do
+      let(:scenario) { "trivial_btrfs" }
+      let(:device_name) { "/dev/sda1" }
+
+      it "does not enable the quotas" do
+        planned.reuse!(fake_devicegraph)
+        expect(blk_device.filesystem.quota?).to eq(false)
+      end
+    end
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.28/test/y2storage/proposal/autoinst_disk_device_planner_test.rb
 
new/yast2-storage-ng-4.3.29/test/y2storage/proposal/autoinst_disk_device_planner_test.rb
--- 
old/yast2-storage-ng-4.3.28/test/y2storage/proposal/autoinst_disk_device_planner_test.rb
    2020-12-10 10:12:46.000000000 +0100
+++ 
new/yast2-storage-ng-4.3.29/test/y2storage/proposal/autoinst_disk_device_planner_test.rb
    2020-12-14 11:28:45.000000000 +0100
@@ -741,5 +741,82 @@
         end
       end
     end
+
+    context "specifying quotas support" do
+      let(:root_spec) do
+        { "mount" => "/", "filesystem" => "btrfs", "quotas" => quotas?, 
"subvolumes" => subvolumes }
+      end
+
+      let(:subvolumes) do
+        [{ "path" => "@/var" }]
+      end
+
+      let(:planned_root) do
+        disk = planner.planned_devices(drive).first
+        disk.partitions.first
+      end
+
+      context "when quotas are enabled" do
+        let(:quotas?) { true }
+
+        it "enables the quotas" do
+          expect(planned_root.quota?).to eq(true)
+        end
+      end
+
+      context "when quotas are disabled" do
+        let(:quotas?) { false }
+
+        it "does not plan for quotas" do
+          expect(planned_root.quota?).to eq(false)
+        end
+
+        context "but a subvolume requires quotas" do
+          let(:subvolumes) do
+            [{ "path" => "@/tmp", "referenced_limit" => "1GiB" }]
+          end
+
+          it "plans for quotas" do
+            expect(planned_root.quota?).to eq(true)
+          end
+
+          it "reports an issue" do
+            planner.planned_devices(drive)
+            issue = planner.issues_list.find do |i|
+              i.is_a?(Y2Storage::AutoinstIssues::MissingBtrfsQuotas)
+            end
+            expect(issue).to_not be_nil
+          end
+        end
+      end
+
+      context "when it not specified whether quotas must be enabled or not" do
+        let(:root_spec) do
+          { "mount" => "/", "filesystem" => "btrfs", "subvolumes" => 
subvolumes }
+        end
+
+        it "does not plan for quotas" do
+          expect(planned_root.quota?).to eq(false)
+        end
+
+        context "but a subvolume requires quotas" do
+          let(:subvolumes) do
+            [{ "path" => "@/tmp", "referenced_limit" => "1GiB" }]
+          end
+
+          it "plans for quotas" do
+            expect(planned_root.quota?).to eq(true)
+          end
+
+          it "reports an issue" do
+            planner.planned_devices(drive)
+            issue = planner.issues_list.find do |i|
+              i.is_a?(Y2Storage::AutoinstIssues::MissingBtrfsQuotas)
+            end
+            expect(issue).to_not be_nil
+          end
+        end
+      end
+    end
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-4.3.28/test/y2storage/subvol_specification_test.rb 
new/yast2-storage-ng-4.3.29/test/y2storage/subvol_specification_test.rb
--- old/yast2-storage-ng-4.3.28/test/y2storage/subvol_specification_test.rb     
2020-12-10 10:12:46.000000000 +0100
+++ new/yast2-storage-ng-4.3.29/test/y2storage/subvol_specification_test.rb     
2020-12-14 11:28:45.000000000 +0100
@@ -46,6 +46,37 @@
     end
   end
 
+  describe ".create_from_xml" do
+    it "returns a subvolume specification with the given path" do
+      subvol_spec = described_class.create_from_xml("path" => "/srv")
+      expect(subvol_spec.path).to eq("/srv")
+    end
+
+    it "sets the list of architectures" do
+      subvol_spec = described_class.create_from_xml("path" => "/srv", "archs" 
=> "x86,aarch64")
+      expect(subvol_spec.archs).to eq(["x86", "aarch64"])
+    end
+
+    context "when a string is given" do
+      it "is used as the subvolume path" do
+        subvol_spec = described_class.create_from_xml("/srv")
+        expect(subvol_spec.path).to eq("/srv")
+      end
+    end
+
+    context "when 'nil' is given" do
+      it "returns nil" do
+        expect(described_class.create_from_xml(nil)).to be_nil
+      end
+    end
+
+    context "when no 'path' is specified" do
+      it "returns nil" do
+        expect(described_class.create_from_xml({})).to be_nil
+      end
+    end
+  end
+
   describe "#current_arch?" do
 
     context "when 'archs' is an empty array" do
_______________________________________________
openSUSE Commits mailing list -- [email protected]
To unsubscribe, email [email protected]
List Netiquette: https://en.opensuse.org/openSUSE:Mailing_list_netiquette
List Archives: 
https://lists.opensuse.org/archives/list/[email protected]

Reply via email to