Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package yast2-storage-ng for 
openSUSE:Factory checked in at 2025-04-07 17:34:53
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-storage-ng (Old)
 and      /work/SRC/openSUSE:Factory/.yast2-storage-ng.new.1907 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yast2-storage-ng"

Mon Apr  7 17:34:53 2025 rev:172 rq:1267041 version:5.0.28

Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-storage-ng/yast2-storage-ng.changes        
2025-02-25 16:40:45.601795499 +0100
+++ 
/work/SRC/openSUSE:Factory/.yast2-storage-ng.new.1907/yast2-storage-ng.changes  
    2025-04-07 17:34:59.308736253 +0200
@@ -1,0 +2,8 @@
+Fri Apr  4 07:00:19 UTC 2025 - Ancor Gonzalez Sosa <an...@suse.com>
+
+- New environment variables YAST_STORAGE_TEST_MODE and
+  YAST_DEVICEGRAPH_FILE to ease development of YaST and Agama
+  (gh#yast/yast-storage-ng#1407).
+- 5.0.28
+
+-------------------------------------------------------------------

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

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

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

Other differences:
------------------
++++++ yast2-storage-ng.spec ++++++
--- /var/tmp/diff_new_pack.3ohlh7/_old  2025-04-07 17:34:59.868759677 +0200
+++ /var/tmp/diff_new_pack.3ohlh7/_new  2025-04-07 17:34:59.872759844 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-storage-ng
-Version:        5.0.27
+Version:        5.0.28
 Release:        0
 Summary:        YaST2 - Storage Configuration
 License:        GPL-2.0-only OR GPL-3.0-only

++++++ yast2-storage-ng-5.0.27.tar.bz2 -> yast2-storage-ng-5.0.28.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-5.0.27/package/yast2-storage-ng.changes 
new/yast2-storage-ng-5.0.28/package/yast2-storage-ng.changes
--- old/yast2-storage-ng-5.0.27/package/yast2-storage-ng.changes        
2025-02-24 16:18:28.000000000 +0100
+++ new/yast2-storage-ng-5.0.28/package/yast2-storage-ng.changes        
2025-04-04 09:16:44.000000000 +0200
@@ -1,4 +1,12 @@
 -------------------------------------------------------------------
+Fri Apr  4 07:00:19 UTC 2025 - Ancor Gonzalez Sosa <an...@suse.com>
+
+- New environment variables YAST_STORAGE_TEST_MODE and
+  YAST_DEVICEGRAPH_FILE to ease development of YaST and Agama
+  (gh#yast/yast-storage-ng#1407).
+- 5.0.28
+
+-------------------------------------------------------------------
 Mon Feb 24 15:11:04 UTC 2025 - Ancor Gonzalez Sosa <an...@suse.com>
 
 - Discarded RAM disks as candidate for installation
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-5.0.27/package/yast2-storage-ng.spec 
new/yast2-storage-ng-5.0.28/package/yast2-storage-ng.spec
--- old/yast2-storage-ng-5.0.27/package/yast2-storage-ng.spec   2025-02-24 
16:18:28.000000000 +0100
+++ new/yast2-storage-ng-5.0.28/package/yast2-storage-ng.spec   2025-04-04 
09:16:44.000000000 +0200
@@ -16,7 +16,7 @@
 #
 
 Name:           yast2-storage-ng
-Version:        5.0.27
+Version:        5.0.28
 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-5.0.27/src/lib/y2storage/clients/manual_test.rb 
new/yast2-storage-ng-5.0.28/src/lib/y2storage/clients/manual_test.rb
--- old/yast2-storage-ng-5.0.27/src/lib/y2storage/clients/manual_test.rb        
2025-02-24 16:18:28.000000000 +0100
+++ new/yast2-storage-ng-5.0.28/src/lib/y2storage/clients/manual_test.rb        
2025-04-04 09:16:44.000000000 +0200
@@ -143,11 +143,7 @@
 
       # @see #mock
       def load_devicegraph
-        if devicegraph_path =~ /.ya?ml$/
-          Y2Storage::StorageManager.instance(mode: 
:rw).probe_from_yaml(devicegraph_path)
-        else
-          Y2Storage::StorageManager.instance(mode: 
:rw).probe_from_xml(devicegraph_path)
-        end
+        Y2Storage::StorageManager.instance(mode: 
:rw).probe_from_file(devicegraph_path)
       end
 
       # @see #mock
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-storage-ng-5.0.27/src/lib/y2storage/device.rb 
new/yast2-storage-ng-5.0.28/src/lib/y2storage/device.rb
--- old/yast2-storage-ng-5.0.27/src/lib/y2storage/device.rb     2025-02-24 
16:18:28.000000000 +0100
+++ new/yast2-storage-ng-5.0.28/src/lib/y2storage/device.rb     2025-04-04 
09:16:44.000000000 +0200
@@ -20,6 +20,8 @@
 require "yast"
 require "yaml"
 require "y2storage/storage_class_wrapper"
+require "y2storage/storage_env"
+require "y2storage/resize_info"
 
 module Y2Storage
   # An abstract base class of storage devices and a vertex in the Devicegraph.
@@ -139,25 +141,8 @@
     #   @return [Boolean]
     storage_forward :exists_in_staging?
 
-    # @!method detect_resize_info
-    #   Information about the possibility of resizing a given device.
-    #   If the device has any children, they are also taken into account;
-    #   the result of this method is the combined information about this device
-    #   and all its children.
-    #
-    #   Note that the minimal and maximal are not aligned.
-    #
-    #   If the device already exists on the disk (i.e., in the probed
-    #   devicegraph), this operation can be expensive. Thus, consider using
-    #   {#resize_info} or any other caching mechanism.
-    #
-    #   @raise [Storage::Exception] if something goes wrong during the 
detection
-    #     (e.g. it fails to temporarily mount the corresponding filesystem)
-    #
-    #   @see can_resize?
-    #
-    #   @return [ResizeInfo]
-    storage_forward :detect_resize_info, as: "ResizeInfo"
+    storage_forward :storage_detect_resize_info, to: :detect_resize_info, as: 
"ResizeInfo"
+    private :storage_detect_resize_info
 
     storage_forward :storage_remove_descendants, to: :remove_descendants
     private :storage_remove_descendants
@@ -296,6 +281,35 @@
     end
 
     # Information about the possibility of resizing a given device.
+    # If the device has any children, they are also taken into account;
+    # the result of this method is the combined information about this device
+    # and all its children.
+    #
+    # Note that the minimal and maximal are not aligned.
+    #
+    # If the device already exists on the disk (i.e., in the probed
+    # devicegraph), this operation can be expensive. Thus, consider using
+    # {#resize_info} or any other caching mechanism.
+    #
+    # If Y2Storage is running in test mode (configured with an ENV variable)
+    # then the device is not checked and a fake result is returned.
+    #
+    # @raise [Storage::Exception] if something goes wrong during the detection
+    #   (e.g. it fails to temporarily mount the corresponding filesystem)
+    #
+    # @see can_resize?
+    #
+    # @return [ResizeInfo]
+    def detect_resize_info
+      if StorageEnv.instance.test_mode?
+        reasons = Storage::RB_FILESYSTEM_FULL | Storage::RB_MIN_MAX_ERROR
+        Y2Storage::ResizeInfo.new(Storage::ResizeInfo.new(false, reasons))
+      else
+        storage_detect_resize_info
+      end
+    end
+
+    # Information about the possibility of resizing a given device.
     #
     # This method relies on {#detect_resize_info}, caching the result for the
     # whole lifecycle of this object.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-5.0.27/src/lib/y2storage/device_finder.rb 
new/yast2-storage-ng-5.0.28/src/lib/y2storage/device_finder.rb
--- old/yast2-storage-ng-5.0.27/src/lib/y2storage/device_finder.rb      
2025-02-24 16:18:28.000000000 +0100
+++ new/yast2-storage-ng-5.0.28/src/lib/y2storage/device_finder.rb      
2025-04-04 09:16:44.000000000 +0200
@@ -20,6 +20,7 @@
 require "pathname"
 require "y2storage/storage_manager"
 require "y2storage/blk_device"
+require "y2storage/storage_env"
 
 module Y2Storage
   # Utility class to find devices in a devicegraph
@@ -61,7 +62,7 @@
     # * It uses a system lookup only when necessary (i.e. all the cheaper
     #   methods for finding the device have been unsuccessful).
     # * It avoids system lookup in potentially risky scenarios (like an 
outdated
-    #   {StorageManager#probed}).
+    #   {StorageManager#probed} or when running in test mode).
     #
     # In case of LUKSes and MDs, the device might be found by using an 
alternative name,
     # see {#alternative_names}.
@@ -173,6 +174,8 @@
     #
     # @return [Boolean]
     def udev_lookup_possible?
+      return false if StorageEnv.instance.test_mode?
+
       # Checking when the operation is safe is quite tricky, since we must
       # ensure than the list of block devices in #probed matches 1:1 the list
       # of block devices in the system.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-5.0.27/src/lib/y2storage/storage_env.rb 
new/yast2-storage-ng-5.0.28/src/lib/y2storage/storage_env.rb
--- old/yast2-storage-ng-5.0.27/src/lib/y2storage/storage_env.rb        
2025-02-24 16:18:28.000000000 +0100
+++ new/yast2-storage-ng-5.0.28/src/lib/y2storage/storage_env.rb        
2025-04-04 09:16:44.000000000 +0200
@@ -38,9 +38,14 @@
 
     ENV_NO_BLS_BOOT = "YAST_NO_BLS_BOOT".freeze
 
+    ENV_TEST_MODE = "YAST_STORAGE_TEST_MODE".freeze
+
+    ENV_DEVICEGRAPH = "YAST_DEVICEGRAPH_FILE".freeze
+
     private_constant :ENV_MULTIPATH, :ENV_BIOS_RAID, :ENV_ACTIVATE_LUKS
     private_constant :ENV_LIBSTORAGE_IGNORE_PROBE_ERRORS
     private_constant :ENV_REUSE_LVM, :ENV_NO_BLS_BOOT
+    private_constant :ENV_TEST_MODE, :ENV_DEVICEGRAPH
 
     def initialize
       reset_cache
@@ -74,6 +79,29 @@
       active?(ENV_BIOS_RAID)
     end
 
+    # Whether operations on the system should be avoided, including those for
+    # reading
+    #
+    # This implies creating a test instance of the libstorage-ng manager 
(instead
+    # of a regular one) and also avoiding queries to the system to search for
+    # devices or to analyze them.
+    #
+    # @return [Boolean]
+    def test_mode?
+      active?(ENV_TEST_MODE)
+    end
+
+    # Location of a file (XML or YAML) containing a devicegraph that must be
+    # used to mock the libstorage-ng probing.
+    #
+    # @return [String, nil]
+    def devicegraph_file
+      filename = read(ENV_DEVICEGRAPH)
+      return nil if filename&.strip&.empty?
+
+      filename
+    end
+
     # Whether LUKSes could be activated
     #
     # See bsc#1162545 for why this is needed and was added.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-5.0.27/src/lib/y2storage/storage_manager.rb 
new/yast2-storage-ng-5.0.28/src/lib/y2storage/storage_manager.rb
--- old/yast2-storage-ng-5.0.27/src/lib/y2storage/storage_manager.rb    
2025-02-24 16:18:28.000000000 +0100
+++ new/yast2-storage-ng-5.0.28/src/lib/y2storage/storage_manager.rb    
2025-04-04 09:16:44.000000000 +0200
@@ -182,6 +182,9 @@
     #
     # @param callbacks [Callbacks::Probe, nil]
     def probe!(callbacks = nil)
+      graph_file = StorageEnv.instance.devicegraph_file
+      return probe_from_file(graph_file) if graph_file
+
       probe_callbacks = Callbacks::Probe.new(user_callbacks: callbacks)
 
       begin
@@ -368,6 +371,15 @@
       manage_probing_issues
     end
 
+    # Probes from a file (XML or YAML) instead of doing a real probing
+    def probe_from_file(filename)
+      if filename =~ /.ya?ml$/i
+        probe_from_yaml(filename)
+      else
+        probe_from_xml(filename)
+      end
+    end
+
     # Access mode in which the storage system was initialized (read-only or 
read-write)
     #
     # @see StorageManager.setup
@@ -606,6 +618,8 @@
 
           raise AccessModeError,
             "Unexpected storage mode: current is #{@instance.mode}, requested 
is #{mode}"
+        elsif StorageEnv.instance.test_mode?
+          create_test_instance
         else
           read_only = mode == :ro
           create_instance(Storage::Environment.new(read_only), callbacks)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-5.0.27/test/y2storage/clients/manual_test_test.rb 
new/yast2-storage-ng-5.0.28/test/y2storage/clients/manual_test_test.rb
--- old/yast2-storage-ng-5.0.27/test/y2storage/clients/manual_test_test.rb      
2025-02-24 16:18:28.000000000 +0100
+++ new/yast2-storage-ng-5.0.28/test/y2storage/clients/manual_test_test.rb      
2025-04-04 09:16:44.000000000 +0200
@@ -31,7 +31,7 @@
       allow(Y2Storage::StorageManager).to receive(:instance).and_return 
storage_manager
     end
 
-    let(:storage_manager) { double("StorageManager", probe_from_yaml: nil, 
probe_from_xml: nil) }
+    let(:storage_manager) { double("StorageManager", probe_from_file: nil) }
     let(:partitioner_client) { double("Main", run: :next) }
     let(:proposal_client) { double("InstDiskProposal", run: :next) }
 
@@ -48,7 +48,7 @@
 
     RSpec.shared_examples "mock devicegraph" do
       it "mocks the devicegraph with the given file" do
-        expect(storage_manager).to receive(:probe_from_xml).with(args[1])
+        expect(storage_manager).to receive(:probe_from_file).with(args[1])
         described_class.run
       end
     end
@@ -97,7 +97,7 @@
       let(:args) { ["partitioner", "devicegraph.xml"] }
 
       it "mocks the devicegraph with the xml file" do
-        expect(storage_manager).to 
receive(:probe_from_xml).with("devicegraph.xml")
+        expect(storage_manager).to 
receive(:probe_from_file).with("devicegraph.xml")
         described_class.run
       end
 
@@ -111,7 +111,7 @@
       let(:args) { ["partitioner", "/path/to/devicegraph.yaml"] }
 
       it "mocks the devicegraph with the YAML file" do
-        expect(storage_manager).to 
receive(:probe_from_yaml).with("/path/to/devicegraph.yaml")
+        expect(storage_manager).to 
receive(:probe_from_file).with("/path/to/devicegraph.yaml")
         described_class.run
       end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-5.0.27/test/y2storage/device_test.rb 
new/yast2-storage-ng-5.0.28/test/y2storage/device_test.rb
--- old/yast2-storage-ng-5.0.27/test/y2storage/device_test.rb   2025-02-24 
16:18:28.000000000 +0100
+++ new/yast2-storage-ng-5.0.28/test/y2storage/device_test.rb   2025-04-04 
09:16:44.000000000 +0200
@@ -161,19 +161,43 @@
         reasons: 0, reason_texts: [])
     end
 
-    before { allow(device).to receive(:detect_resize_info).and_return 
resize_info }
+    before { allow(device).to receive(:storage_detect_resize_info).and_return 
resize_info }
 
-    context "if libstorage-nd reports that resizing is possible" do
+    context "if not in test mode and libstorage-ng reports that resizing is 
possible" do
       let(:resize_ok) { true }
 
+      it "invokes the corresponding libstorage-ng method" do
+        expect(device).to receive(:storage_detect_resize_info)
+        device.can_resize?
+      end
+
       it "returns true" do
         expect(device.can_resize?).to eq true
       end
     end
 
-    context "if libstorage-ng reports that resizing is not possible" do
+    context "if not in test mode and libstorage-ng reports that resizing is 
not possible" do
       let(:resize_ok) { false }
 
+      it "invokes the corresponding libstorage-ng method" do
+        expect(device).to receive(:storage_detect_resize_info)
+        device.can_resize?
+      end
+
+      it "returns false" do
+        expect(device.can_resize?).to eq false
+      end
+    end
+
+    context "if in test mode" do
+      before { allow(Y2Storage::StorageEnv.instance).to 
receive(:test_mode?).and_return(true) }
+      let(:resize_ok) { true }
+
+      it "does not check with libstorage-ng" do
+        expect(device).to_not receive(:storage_detect_resize_info)
+        device.can_resize?
+      end
+
       it "returns false" do
         expect(device.can_resize?).to eq false
       end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-5.0.27/test/y2storage/storage_env_test.rb 
new/yast2-storage-ng-5.0.28/test/y2storage/storage_env_test.rb
--- old/yast2-storage-ng-5.0.27/test/y2storage/storage_env_test.rb      
2025-02-24 16:18:28.000000000 +0100
+++ new/yast2-storage-ng-5.0.28/test/y2storage/storage_env_test.rb      
2025-04-04 09:16:44.000000000 +0200
@@ -100,4 +100,78 @@
       end
     end
   end
+
+  describe "#test_mode?" do
+    context "YAST_STORAGE_TEST_MODE is not set" do
+      let(:env_vars) do
+        {}
+      end
+
+      it "returns false" do
+        expect(Y2Storage::StorageEnv.instance.test_mode?).to be false
+      end
+    end
+
+    context "YAST_STORAGE_TEST_MODE is empty" do
+      let(:env_vars) do
+        { "YAST_STORAGE_TEST_MODE" => "" }
+      end
+
+      it "returns true" do
+        expect(Y2Storage::StorageEnv.instance.test_mode?).to be true
+      end
+    end
+
+    context "YAST_STORAGE_TEST_MODE is set to '1'" do
+      let(:env_vars) do
+        { "YAST_STORAGE_TEST_MODE" => "1" }
+      end
+
+      it "returns true" do
+        expect(Y2Storage::StorageEnv.instance.test_mode?).to be true
+      end
+    end
+
+    context "YAST_STORAGE_TEST_MODE is set to '0'" do
+      let(:env_vars) do
+        { "YAST_STORAGE_TEST_MODE" => "0" }
+      end
+
+      it "returns false" do
+        expect(Y2Storage::StorageEnv.instance.test_mode?).to be false
+      end
+    end
+  end
+
+  describe "#devicegraph_file" do
+    context "YAST_DEVICEGRAPH_FILE is not set" do
+      let(:env_vars) do
+        {}
+      end
+
+      it "returns nil" do
+        expect(Y2Storage::StorageEnv.instance.devicegraph_file).to be_nil
+      end
+    end
+
+    context "YAST_DEVICEGRAPH_FILE is empty" do
+      let(:env_vars) do
+        { "YAST_DEVICEGRAPH_FILE" => "" }
+      end
+
+      it "returns nil" do
+        expect(Y2Storage::StorageEnv.instance.devicegraph_file).to be_nil
+      end
+    end
+
+    context "YAST_DEVICEGRAPH_FILE contains a file path" do
+      let(:env_vars) do
+        { "YAST_DEVICEGRAPH_FILE" => "/tmp/mock.xml" }
+      end
+
+      it "returns the path" do
+        expect(Y2Storage::StorageEnv.instance.devicegraph_file).to eq 
"/tmp/mock.xml"
+      end
+    end
+  end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-storage-ng-5.0.27/test/y2storage/storage_manager_test.rb 
new/yast2-storage-ng-5.0.28/test/y2storage/storage_manager_test.rb
--- old/yast2-storage-ng-5.0.27/test/y2storage/storage_manager_test.rb  
2025-02-24 16:18:28.000000000 +0100
+++ new/yast2-storage-ng-5.0.28/test/y2storage/storage_manager_test.rb  
2025-04-04 09:16:44.000000000 +0200
@@ -783,6 +783,18 @@
     let(:devicegraph) { Y2Storage::Devicegraph.new(st_staging) }
     let(:proposal) { double("Y2Storage::GuidedProposal", devices: devicegraph, 
failed?: false) }
 
+    context "when a devicegraph file is set via environment variables" do
+      before do
+        allow(Y2Storage::StorageEnv.instance).to 
receive(:devicegraph_file).and_return(mock_path)
+      end
+      let(:mock_path) { File.join(DATA_PATH, "devicegraphs", 
"empty_disks.yml") }
+
+      it "does not execute a real probing" do
+        expect(manager.storage).to_not receive(:probe)
+        manager.probe!
+      end
+    end
+
     it "refreshes #probed" do
       expect(manager.probed.disks.size).to eq 6
       # Calling twice (or more) does not result in a refresh
@@ -1001,6 +1013,43 @@
     end
   end
 
+  describe "#probe_from_file" do
+    subject(:manager) { described_class.create_test_instance }
+
+    context "when called with a file name ending in .xml" do
+      let(:filename) { "devicegraph.xml" }
+
+      it "mocks the devicegraph using probe_from_xml" do
+        expect(manager).to receive(:probe_from_xml).with(filename)
+        expect(manager).to_not receive(:probe_from_yaml).with(filename)
+
+        manager.probe_from_file(filename)
+      end
+    end
+
+    context "when called with a file name ending in .yml" do
+      let(:filename) { "devicegraph.yml" }
+
+      it "mocks the devicegraph using probe_from_yaml" do
+        expect(manager).to receive(:probe_from_yaml).with(filename)
+        expect(manager).to_not receive(:probe_from_xml).with(filename)
+
+        manager.probe_from_file(filename)
+      end
+    end
+
+    context "when called with a file name ending in .YAML" do
+      let(:filename) { "devicegraph.YAML" }
+
+      it "mocks the devicegraph using probe_from_yaml" do
+        expect(manager).to receive(:probe_from_yaml).with(filename)
+        expect(manager).to_not receive(:probe_from_xml).with(filename)
+
+        manager.probe_from_file(filename)
+      end
+    end
+  end
+
   describe "#activate" do
     it "starts libstorage-ng activation using the default callbacks" do
       expect(manager.storage).to 
receive(:activate).with(Y2Storage::Callbacks::Activate)

Reply via email to