Hello community, here is the log from the commit of package yast2 for openSUSE:Factory checked in at 2014-03-01 14:38:14 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2 (Old) and /work/SRC/openSUSE:Factory/.yast2.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2" Changes: -------- --- /work/SRC/openSUSE:Factory/yast2/yast2.changes 2014-02-21 13:48:11.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.yast2.new/yast2.changes 2014-03-01 14:38:15.000000000 +0100 @@ -1,0 +2,6 @@ +Thu Feb 27 09:56:16 UTC 2014 - vmora...@suse.com + +- Add systemd socket support (bnc#853300) +- 3.1.20 + +------------------------------------------------------------------- Old: ---- yast2-3.1.19.tar.bz2 New: ---- yast2-3.1.20.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2.spec ++++++ --- /var/tmp/diff_new_pack.3mv946/_old 2014-03-01 14:38:16.000000000 +0100 +++ /var/tmp/diff_new_pack.3mv946/_new 2014-03-01 14:38:16.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2 -Version: 3.1.19 +Version: 3.1.20 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build ++++++ yast2-3.1.19.tar.bz2 -> yast2-3.1.20.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.19/library/Makefile.am new/yast2-3.1.20/library/Makefile.am --- old/yast2-3.1.19/library/Makefile.am 2014-02-21 10:52:55.000000000 +0100 +++ new/yast2-3.1.20/library/Makefile.am 2014-02-27 10:56:49.000000000 +0100 @@ -1,3 +1,3 @@ # Makefile.am for yast2/library -SUBDIRS = types runlevel sequencer xml commandline desktop wizard control cwm log system packages cron network gpg general +SUBDIRS = types runlevel sequencer xml commandline desktop wizard control cwm log system packages cron network gpg general systemd diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.19/library/systemd/Makefile.am new/yast2-3.1.20/library/systemd/Makefile.am --- old/yast2-3.1.19/library/systemd/Makefile.am 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-3.1.20/library/systemd/Makefile.am 2014-02-27 10:56:49.000000000 +0100 @@ -0,0 +1 @@ +SUBDIRS = src test diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.19/library/systemd/src/Makefile.am new/yast2-3.1.20/library/systemd/src/Makefile.am --- old/yast2-3.1.19/library/systemd/src/Makefile.am 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-3.1.20/library/systemd/src/Makefile.am 2014-02-27 10:56:49.000000000 +0100 @@ -0,0 +1,11 @@ +module_DATA = \ + modules/systemd_socket.rb + +ylibdir = @ylibdir@/yast2 +ylib_DATA = \ + lib/yast2/systemctl.rb \ + lib/yast2/systemd_unit.rb + +EXTRA_DIST = $(module_DATA) $(ylib_DATA) + +include $(top_srcdir)/Makefile.am.common diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.19/library/systemd/src/lib/yast2/systemctl.rb new/yast2-3.1.20/library/systemd/src/lib/yast2/systemctl.rb --- old/yast2-3.1.19/library/systemd/src/lib/yast2/systemctl.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-3.1.20/library/systemd/src/lib/yast2/systemctl.rb 2014-02-27 10:56:49.000000000 +0100 @@ -0,0 +1,44 @@ +require "ostruct" + +module Yast + module Systemctl + CONTROL = "systemctl" + COMMAND_OPTIONS = " --no-legend --no-pager --no-ask-password " + ENV_VARS = " LANG=C TERM=dumb COLUMNS=1024 " + SYSTEMCTL = ENV_VARS + CONTROL + COMMAND_OPTIONS + + class << self + + def execute command + OpenStruct.new(SCR.Execute(Path.new(".target.bash_output"), SYSTEMCTL + command)) + end + + def socket_units + sockets_from_files = list_unit_files(:type=>:socket).lines.map do |line| + line[/\S+/] + end + + sockets_from_units = list_units(:type=>:socket).lines.map do |line| + line[/\S+/] + end + + ( sockets_from_files | sockets_from_units ).compact + end + + private + + def list_unit_files type: nil + command = " list-unit-files " + command << " --type=#{type} " if type + execute(command).stdout + end + + def list_units type: nil, all: true + command = " list-units " + command << " --all " if all + command << " --type=#{type} " if type + execute(command).stdout + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.19/library/systemd/src/lib/yast2/systemd_unit.rb new/yast2-3.1.20/library/systemd/src/lib/yast2/systemd_unit.rb --- old/yast2-3.1.19/library/systemd/src/lib/yast2/systemd_unit.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-3.1.20/library/systemd/src/lib/yast2/systemd_unit.rb 2014-02-27 10:56:49.000000000 +0100 @@ -0,0 +1,140 @@ +require 'yast2/systemctl' + +require 'ostruct' +require 'forwardable' + +module Yast + + ### + # Use this class always as a parent class for implementing various systemd units. + # Do not use it directly for add-hoc implemenation of systemd units. + # + # @example Create a systemd service unit + # + # class Service < Yast::SystemdUnit + # SUFFIX = ".service" + # PROPERTIES = { + # :before => "Before" + # } + # + # def initialize service_name, properties={} + # service_name += SUFFIX unless service_name.end_with?(SUFFIX) + # super(service_name, PROPERTIES.merge(properties)) + # end + # + # def before + # properties.before.split + # end + # end + # + # service = Service.new('sshd') + # + # service.before # ['shutdown.target', 'multi-user.target'] + # + ### + + class SystemdUnit + + SUPPORTED_TYPES = %w( service socket target ) + SUPPORTED_STATES = %w( enabled disabled ) + + DEFAULT_PROPERTIES = { + id: "Id", + pid: "MainPID", + description: "Description", + load_state: "LoadState", + active_state: "ActiveState", + sub_state: "SubState", + unit_file_state: "UnitFileState", + path: "FragmentPath" + } + + extend Forwardable + + def_delegators :@properties, :id, :path, + :active?, :enabled?, :running?, :loaded? + + attr_reader :unit_name, :unit_type, :input_properties, :errors, :properties + + def initialize full_unit_name, properties={} + @unit_name, @unit_type = full_unit_name.split(".") + raise "Missing unit type suffix" unless unit_type + raise "Unsupported unit type '#{unit_type}'" unless SUPPORTED_TYPES.member?(unit_type) + + @errors = "" + @input_properties = properties.merge!(DEFAULT_PROPERTIES) + @properties = show + end + + def show + Properties.new(self) + end + + def status + command("status", :options => "2>&1").stdout + end + + def start + run_command! { command("start") } + end + + def stop + run_command! { command("stop") } + end + + def enable + run_command! { command("enable") } + end + + def disable + run_command! { command("disable") } + end + + def command command_name, options={} + Systemctl.execute("#{command_name} #{unit_name}.#{unit_type} #{options[:options]}") + end + + private + + def run_command! + errors.clear + command_result = yield + errors << command_result.stderr + @properties = show + command_result.exit.zero? + end + + class Properties < OpenStruct + + def initialize systemd_unit + super() + self[:systemd_unit] = systemd_unit + raw_properties = load_systemd_properties + self[:raw] = raw_properties.stdout + self[:errors] = raw_properties.stderr + extract_properties + self[:active?] = active_state == "active" + self[:running?] = sub_state == "running" + self[:loaded?] = load_state == "loaded" + self[:not_found?] = load_state == "not-found" + self[:enabled?] = unit_file_state == "enabled" + self[:supported?] = SUPPORTED_STATES.member?(unit_file_state) + end + + private + + def extract_properties + systemd_unit.input_properties.each do |name, property| + self[name] = raw[/#{property}=(.+)/, 1] + end + end + + def load_systemd_properties + properties = systemd_unit.input_properties.map do |_, property_name| + " --property=#{property_name} " + end + systemd_unit.command("show", :options => properties.join) + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.19/library/systemd/src/modules/systemd_socket.rb new/yast2-3.1.20/library/systemd/src/modules/systemd_socket.rb --- old/yast2-3.1.19/library/systemd/src/modules/systemd_socket.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-3.1.20/library/systemd/src/modules/systemd_socket.rb 2014-02-27 10:56:49.000000000 +0100 @@ -0,0 +1,79 @@ +require 'yast2/systemd_unit' + +module Yast + ### + # Systemd.socket unit control API + # + # @example How to use it in other yast libraries + # + # require 'yast' + # + # Yast.import 'SystemdSocket' + # + # ## Get a socket unit by its name + # + # socket = Yast::SystemdSocket.find('iscsid') + # + # ## Get basic unit properties + # + # socket.unit_name # 'iscsid' + # socket.unit_type # 'socket' + # socket.id # 'iscsid.socket' + # socket.path # '/usr/lib/systemd/system/iscsid.socket' => unit file path + # socket.loaded? # true if it's loaded, false otherwise + # socket.listening? # true if it's listening, false otherwise + # socket.enabled? # true if enabled, false otherwise + # socket.disabled? # true if disabled, false otherwise + # socket.status # the same string output you get with `systemctl status iscsid.socket` + # socket.show # equivalent of calling `systemctl show iscsid.socket` + # + # ## Socket unit file commands + # + # # Unit file commands do modifications on the socket unit. Calling them triggers + # # socket properties reloading. In case a command fails, the error messages are available + # # through the method #errors as a string. + # + # socket.start # true if unit has been activated successfully + # socket.stop # true if unit has been deactivated successfully + # socket.enable # true if unit has been enabled successfully + # socket.disable # true if unit has been disabled successfully + # socket.errors # error string available if some of the actions above fails + # + # ## Extended socket properties + # + # # In case you need more details about the socket unit than the default ones, + # # you can extend the paramters when getting the socket. Those properties are + # # then available under the #properties instance method. To get an overview of + # # available socket properties, try e.g., `systemctl show iscsid.socket` + # + # socket = Yast::SystemdSocket.find('iscsid', :can_start=>'CanStart', :triggers=>'Triggers') + # socket.properties.can_start # 'yes' + # socket.properties.triggers # 'iscsid.service' + # + ## + + class SystemdSocketClass < Module + UNIT_SUFFIX = ".socket" + + def find socket_name, properties={} + socket_name += UNIT_SUFFIX unless socket_name.end_with?(UNIT_SUFFIX) + socket = Socket.new(socket_name, properties) + return nil if socket.properties.not_found? + socket + end + + def all properties={} + sockets = Systemctl.socket_units.map do |socket_unit| + Socket.new(socket_unit, properties) + end + sockets.select {|s| s.properties.supported?} + end + + class Socket < SystemdUnit + def listening? + properties.sub_state == "listening" + end + end + end + SystemdSocket = SystemdSocketClass.new +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.19/library/systemd/test/Makefile.am new/yast2-3.1.20/library/systemd/test/Makefile.am --- old/yast2-3.1.19/library/systemd/test/Makefile.am 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-3.1.20/library/systemd/test/Makefile.am 2014-02-27 10:56:49.000000000 +0100 @@ -0,0 +1,12 @@ +TESTS = \ + test_helper.rb \ + systemctl_test.rb \ + systemd_unit_test.rb \ + systemd_socket_test.rb + +TEST_EXTENSIONS = .rb +RB_LOG_COMPILER = rspec +VERBOSE = 1 + +EXTRA_DIST = $(TESTS) + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.19/library/systemd/test/data/iscsid_socket_properties new/yast2-3.1.20/library/systemd/test/data/iscsid_socket_properties --- old/yast2-3.1.19/library/systemd/test/data/iscsid_socket_properties 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-3.1.20/library/systemd/test/data/iscsid_socket_properties 2014-02-27 10:56:49.000000000 +0100 @@ -0,0 +1,119 @@ +Id=iscsid.socket +Names=iscsid.socket +Requires=sysinit.target +Wants=system.slice +Conflicts=shutdown.target +Before=iscsid.service sockets.target shutdown.target +After=sysinit.target system.slice +Triggers=iscsid.service +Documentation=man:iscsid(8) man:iscsiadm(8) +Description=Open-iSCSI iscsid Socket +LoadState=loaded +ActiveState=active +SubState=listening +FragmentPath=/usr/lib/systemd/system/iscsid.socket +UnitFileState=disabled +InactiveExitTimestamp=Tue 2014-02-18 11:24:48 CET +InactiveExitTimestampMonotonic=504143880115 +ActiveEnterTimestamp=Tue 2014-02-18 11:24:48 CET +ActiveEnterTimestampMonotonic=504143880115 +ActiveExitTimestampMonotonic=0 +InactiveEnterTimestampMonotonic=0 +CanStart=yes +CanStop=yes +CanReload=no +CanIsolate=no +StopWhenUnneeded=no +RefuseManualStart=no +RefuseManualStop=no +AllowIsolate=no +DefaultDependencies=yes +OnFailureIsolate=no +IgnoreOnIsolate=no +IgnoreOnSnapshot=no +NeedDaemonReload=no +JobTimeoutUSec=0 +ConditionTimestamp=Tue 2014-02-18 11:24:48 CET +ConditionTimestampMonotonic=504143880077 +ConditionResult=yes +Transient=no +Slice=system.slice +ControlGroup=/system.slice/iscsid.socket +BindIPv6Only=default +Backlog=128 +TimeoutUSec=1min 30s +ControlPID=0 +DirectoryMode=0755 +SocketMode=0666 +Accept=no +KeepAlive=no +Priority=-1 +ReceiveBuffer=0 +SendBuffer=0 +IPTOS=-1 +IPTTL=-1 +PipeSize=0 +FreeBind=no +Transparent=no +Broadcast=no +PassCredentials=no +PassSecurity=no +ListenStream=@ISCSIADM_ABSTRACT_NAMESPACE +Mark=-1 +MaxConnections=64 +NConnections=0 +NAccepted=0 +Result=success +ReusePort=no +UMask=0022 +LimitCPU=18446744073709551615 +LimitFSIZE=18446744073709551615 +LimitDATA=18446744073709551615 +LimitSTACK=18446744073709551615 +LimitCORE=18446744073709551615 +LimitRSS=18446744073709551615 +LimitNOFILE=4096 +LimitAS=18446744073709551615 +LimitNPROC=7770 +LimitMEMLOCK=65536 +LimitLOCKS=18446744073709551615 +LimitSIGPENDING=7770 +LimitMSGQUEUE=819200 +LimitNICE=0 +LimitRTPRIO=0 +LimitRTTIME=18446744073709551615 +OOMScoreAdjust=0 +Nice=0 +IOScheduling=0 +CPUSchedulingPolicy=0 +CPUSchedulingPriority=0 +TimerSlackNSec=50000 +CPUSchedulingResetOnFork=no +NonBlocking=no +StandardInput=null +StandardOutput=journal +StandardError=inherit +TTYReset=no +TTYVHangup=no +TTYVTDisallocate=no +SyslogPriority=30 +SyslogLevelPrefix=yes +SecureBits=0 +CapabilityBoundingSet=18446744073709551615 +MountFlags=0 +PrivateTmp=no +PrivateNetwork=no +SameProcessGroup=no +IgnoreSIGPIPE=yes +NoNewPrivileges=no +KillMode=control-group +KillSignal=15 +SendSIGKILL=yes +SendSIGHUP=no +CPUAccounting=no +CPUShares=1024 +BlockIOAccounting=no +BlockIOWeight=1000 +MemoryAccounting=no +MemoryLimit=18446744073709551615 +DevicePolicy=auto diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.19/library/systemd/test/systemctl_test.rb new/yast2-3.1.20/library/systemd/test/systemctl_test.rb --- old/yast2-3.1.19/library/systemd/test/systemctl_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-3.1.20/library/systemd/test/systemctl_test.rb 2014-02-27 10:56:49.000000000 +0100 @@ -0,0 +1,23 @@ +#!/usr/bin/env rspec + +require_relative 'test_helper' +require 'yast2/systemctl' + +module Yast + describe Systemctl do + include SystemctlStubs + + before do + stub_systemctl + end + + describe ".socket_units" do + it "returns a list of socket unit ids registered with systemd" do + socket_units = Systemctl.socket_units + expect(socket_units).to be_a(Array) + expect(socket_units).not_to be_empty + socket_units.each {|u| expect(u).to match(/.socket$/) } + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.19/library/systemd/test/systemd_socket_test.rb new/yast2-3.1.20/library/systemd/test/systemd_socket_test.rb --- old/yast2-3.1.19/library/systemd/test/systemd_socket_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-3.1.20/library/systemd/test/systemd_socket_test.rb 2014-02-27 10:56:49.000000000 +0100 @@ -0,0 +1,46 @@ +#!/usr/bin/env rspec + +require_relative "test_helper" + +module Yast + import 'SystemdSocket' + + describe SystemdSocket do + include SystemdSocketStubs + + before do + stub_sockets + end + + describe ".find" do + it "returns the unit object specified in parameter" do + socket = SystemdSocket.find "iscsid" + expect(socket).to be_a(SystemdUnit) + expect(socket.unit_type).to eq("socket") + expect(socket.unit_name).to eq("iscsid") + end + end + + describe ".all" do + it "returns all supported sockets found" do + sockets = SystemdSocket.all + expect(sockets).to be_a(Array) + expect(sockets).not_to be_empty + sockets.each {|s| expect(s.unit_type).to eq('socket')} + end + end + + describe "#listening?" do + it "returns true if the socket is accepting connections" do + socket = SystemdSocket.find "iscsid" + expect(socket.listening?).to be_true + end + + it "returns false if the socket is dead" do + socket = SystemdSocket.find "iscsid" + socket.properties.sub_state = "dead" + expect(socket.listening?).to be_false + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.19/library/systemd/test/systemd_unit_test.rb new/yast2-3.1.20/library/systemd/test/systemd_unit_test.rb --- old/yast2-3.1.19/library/systemd/test/systemd_unit_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-3.1.20/library/systemd/test/systemd_unit_test.rb 2014-02-27 10:56:49.000000000 +0100 @@ -0,0 +1,195 @@ +#!/usr/bin/env rspec + +require_relative 'test_helper' +require 'yast2/systemd_unit' + +module Yast + describe SystemdUnit do + include SystemdSocketStubs + + def trigger_reloading_properties command + unit = SystemdUnit.new("new.socket") + properties = unit.properties + unit.send(command) + expect(unit.properties).not_to equal(properties) + end + + before do + stub_sockets + end + + describe "#properties" do + it "always returns struct including default properties" do + unit = SystemdUnit.new("iscsi.socket") + expect(unit.properties.to_h.keys).to include(*SystemdUnit::DEFAULT_PROPERTIES.keys) + end + + it "provides status properties methods" do + unit = SystemdUnit.new("iscsid.socket") + expect(unit.properties[:enabled?]).not_to be_nil + expect(unit.properties[:active?]).not_to be_nil + expect(unit.properties[:running?]).not_to be_nil + expect(unit.properties[:loaded?]).not_to be_nil + expect(unit.properties[:supported?]).not_to be_nil + expect(unit.properties[:not_found?]).not_to be_nil + expect(unit.properties[:path]).not_to be_nil + expect(unit.properties[:errors]).not_to be_nil + expect(unit.properties[:raw]).not_to be_nil + end + + it "delegates the status properties onto the unit object" do + unit = SystemdUnit.new("iscsid.socket") + expect(unit).to respond_to(:enabled?) + expect(unit).to respond_to(:active?) + expect(unit).to respond_to(:running?) + expect(unit).to respond_to(:loaded?) + expect(unit).to respond_to(:path) + end + end + + describe ".new" do + it "creates a new SystemdUnit instance with unit name and type parsed from first parameter" do + instance = SystemdUnit.new("random.socket") + expect { SystemdUnit.new("random.socket") }.not_to raise_error + expect(instance.unit_name).to eq("random") + expect(instance.unit_type).to eq("socket") + end + + it "raises an exception if an incomplete unit name is passed" do + expect { SystemdUnit.new("sshd") }.to raise_error + end + + it "allows to create supported units" do + expect { SystemdUnit.new("my.socket") }.not_to raise_error + expect { SystemdUnit.new("default.target") }.not_to raise_error + expect { SystemdUnit.new("sshd.service") }.not_to raise_error + end + + it "raises an exception if unsupported unit name is passed" do + expect { SystemdUnit.new("random.unit") }.to raise_error + end + + it "accepts parameters to extend the default properties" do + unit = SystemdUnit.new("iscsid.socket", :requires => "Requires", :wants => "Wants") + expect(unit.properties.wants).not_to be_nil + expect(unit.properties.requires).not_to be_nil + end + end + + describe "#stop" do + it "returns true if unit has been stopped" do + stub_unit_command + unit = SystemdUnit.new("my.socket") + expect(unit.stop).to be_true + end + + it "returns false if failed" do + stub_unit_command(:success=>false) + unit = SystemdUnit.new("my.socket") + expect(unit.stop).to be_false + expect(unit.errors).not_to be_empty + end + + it "triggers reloading of unit properties" do + trigger_reloading_properties(:stop) + end + end + + describe "#start" do + it "returns true if starts (activates) the unit" do + stub_unit_command(:success=>true) + unit = SystemdUnit.new("my.socket") + expect(unit.start).to be_true + end + + it "returns false if failed to start the unit" do + stub_unit_command(:success=>false) + unit = SystemdUnit.new("my.socket") + expect(unit.start).to be_false + expect(unit.errors).not_to be_empty + end + + it "triggers reloading of unit properties" do + trigger_reloading_properties(:start) + end + end + + describe "#enable" do + it "returns true if the unit has been enabled successfully" do + stub_unit_command(:success=>true) + unit = SystemdUnit.new("your.socket") + expect(unit.enable).to be_true + end + + it "returns false if unit fails" do + stub_unit_command(:success=>false) + unit = SystemdUnit.new("your.socket") + expect(unit.enable).to be_false + end + + it "triggers reloading of unit properties" do + trigger_reloading_properties(:enable) + end + end + + describe "#disable" do + it "returns true if the unit has been disabled successfully" do + stub_unit_command(:success=>true) + unit = SystemdUnit.new("your.socket") + expect(unit.disable).to be_true + end + + it "returns false if unit disabling fails" do + stub_unit_command(:success=>false) + unit = SystemdUnit.new("your.socket") + expect(unit.disable).to be_false + end + + it "triggers reloading of unit properties" do + trigger_reloading_properties(:disable) + end + end + + describe "#show" do + it "always returns new unit properties object" do + unit = SystemdUnit.new("startrek.socket") + expect(unit.show).not_to equal(unit.show) + end + end + + describe "#errors" do + it "returns empty string if the unit commands succeed" do + stub_unit_command(:success=>true) + unit = SystemdUnit.new("your.socket") + unit.start + expect(unit.errors).to be_empty + + unit.stop + expect(unit.errors).to be_empty + + unit.enable + expect(unit.errors).to be_empty + + unit.disable + expect(unit.errors).to be_empty + end + + it "returns error string if the unit commands fail" do + stub_unit_command(:success=>false) + unit = SystemdUnit.new("your.socket") + unit.start + expect(unit.errors).not_to be_empty + + unit.stop + expect(unit.errors).not_to be_empty + + unit.enable + expect(unit.errors).not_to be_empty + + unit.disable + expect(unit.errors).not_to be_empty + end + end + + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.19/library/systemd/test/test_helper.rb new/yast2-3.1.20/library/systemd/test/test_helper.rb --- old/yast2-3.1.19/library/systemd/test/test_helper.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-3.1.20/library/systemd/test/test_helper.rb 2014-02-27 10:56:49.000000000 +0100 @@ -0,0 +1,91 @@ +require 'rspec' + +ENV["Y2DIR"] = File.expand_path("../../src", __FILE__) + +require "yast" + +module SystemctlStubs + + def stub_systemctl + stub_socket_unit_files + stub_socket_units + stub_execute + end + + + def stub_execute success: true + Yast::Systemctl.stub(:execute).and_return( + OpenStruct.new \ + :stdout => 'success', + :stderr => ( success ? '' : 'failure'), + :exit => ( success ? 0 : 1 ) + ) + end + + def stub_socket_unit_files + Yast::Systemctl.stub(:list_unit_files).and_return(<<LIST +iscsid.socket disabled +avahi-daemon.socket enabled +cups.socket enabled +dbus.socket static +dm-event.socket disabled +LIST + ) + end + + def stub_socket_units + Yast::Systemctl.stub(:list_units).and_return(<<LIST +iscsid.socket loaded active listening Open-iSCSI iscsid Socket +avahi-daemon.socket loaded active running Avahi mDNS/DNS-SD Stack Activation Socket +cups.socket loaded inactive dead CUPS Printing Service Sockets +dbus.socket loaded active running D-Bus System Message Bus Socket +dm-event.socket loaded inactive dead Device-mapper event daemon FIFOs +lvm2-lvmetad.socket loaded inactive dead LVM2 metadata daemon socket +pcscd.socket loaded active listening PC/SC Smart Card Daemon Activation Socket +LIST + ) + end + +end + +module SystemdUnitStubs + def stub_unit_command success: true + Yast::SystemdUnit + .any_instance + .stub(:command) + .and_return( + OpenStruct.new \ + :stdout => 'success', + :stderr => ( success ? '' : 'failure'), + :exit => ( success ? 0 : 1 ) + ) + end +end + +module SystemdSocketStubs + include SystemctlStubs + include SystemdUnitStubs + + def socket_properties + @properties ||= OpenStruct.new( + :stdout => File.read(File.join(__dir__, 'data', 'iscsid_socket_properties')), + :stderr => '', + :exit => 0 + ) + end + + def stub_sockets + stub_unit_command + stub_systemctl + stub_socket_properties + end + + def stub_socket_properties + Yast::SystemdUnit::Properties + .any_instance + .stub(:load_systemd_properties) + .and_return(socket_properties) + end + +end + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.19/package/yast2.changes new/yast2-3.1.20/package/yast2.changes --- old/yast2-3.1.19/package/yast2.changes 2014-02-21 10:52:55.000000000 +0100 +++ new/yast2-3.1.20/package/yast2.changes 2014-02-27 11:06:54.000000000 +0100 @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Thu Feb 27 09:56:16 UTC 2014 - vmora...@suse.com + +- Add systemd socket support (bnc#853300) +- 3.1.20 + +------------------------------------------------------------------- Mon Feb 10 13:18:52 UTC 2014 - lsle...@suse.cz - added memory detection code (gh#yast/yast-packager#33) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.19/package/yast2.spec new/yast2-3.1.20/package/yast2.spec --- old/yast2-3.1.19/package/yast2.spec 2014-02-21 10:52:55.000000000 +0100 +++ new/yast2-3.1.20/package/yast2.spec 2014-02-27 11:06:54.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2 -Version: 3.1.19 +Version: 3.1.20 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build -- To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org For additional commands, e-mail: opensuse-commit+h...@opensuse.org