Skip to content

Commit

Permalink
Merge pull request #413 from SUSE/fix-migration-with-service-plugin
Browse files Browse the repository at this point in the history
Skip service addition/removal it's a zypper plugin
  • Loading branch information
ikapelyukhin committed Apr 10, 2019
2 parents c54def1 + ad3b90e commit 1aca5e4
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 13 deletions.
10 changes: 8 additions & 2 deletions lib/suse/connect/migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,19 @@ def repositories
# @param [String] service_url the url from the service to add
# @param [String] service_name the name of the service to add
def add_service(service_url, service_name)
SUSE::Connect::Zypper.add_service(service_url, service_name)
# don't try to add the service if the plugin with the same name exists (bsc#1128969)
unless File.exist?("/usr/lib/zypp/plugins/services/#{service_name}")
SUSE::Connect::Zypper.add_service(service_url, service_name)
end
end

# Forwards the service names which should be removed with zypper
# @param [String] service_name the name of the service to remove
def remove_service(service_name)
SUSE::Connect::Zypper.remove_service(service_name)
# don't try to remove the service if the plugin with the same name exists (bsc#1128969)
unless File.exist?("/usr/lib/zypp/plugins/services/#{service_name}")
SUSE::Connect::Zypper.remove_service(service_name)
end
end

# Finds the solvable products available on the system
Expand Down
2 changes: 1 addition & 1 deletion lib/suse/connect/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module SUSE
module Connect
VERSION = '0.3.16'
VERSION = '0.3.17'
end
end
7 changes: 7 additions & 0 deletions package/SUSEConnect.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue Apr 2 12:33:41 UTC 2019 - Ivan Kapelyukhin <ikapelyukhin@suse.com>

- Update to 0.3.17
- Don't try to remove a service during migration if a zypper service
plugin already exists (bsc#1128969)

-------------------------------------------------------------------
Tue Feb 5 07:12:31 UTC 2019 - Stephan Kulow <coolo@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/SUSEConnect.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: SUSEConnect
Version: 0.3.16
Version: 0.3.17
Release: 0
%define mod_name suse-connect
%define mod_full_name %{mod_name}-%{version}
Expand Down
43 changes: 34 additions & 9 deletions spec/connect/migration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,21 +118,46 @@
end

describe '.add_service' do
it 'forwards to zypper add_service' do
service_url = 'http://bla.bla'
service_name = 'bla'
expect(SUSE::Connect::Zypper).to receive(:add_service).with(service_url, service_name)
context 'without zypper service plugin' do
it 'forwards to zypper add_service' do
service_url = 'http://bla.bla'
service_name = 'bla'
expect(SUSE::Connect::Zypper).to receive(:add_service).with(service_url, service_name)

described_class.add_service(service_url, service_name)
described_class.add_service(service_url, service_name)
end
end

context 'with zypper service plugin' do
it "doesn't forward to zypper add_service" do
service_url = 'http://bla.bla'
service_name = 'bla'
expect(File).to receive(:exist?).with("/usr/lib/zypp/plugins/services/#{service_name}").and_return(true)
expect(SUSE::Connect::Zypper).not_to receive(:add_service)

described_class.add_service(service_url, service_name)
end
end
end

describe '.remove_service' do
it 'forwards to zypper remove_service' do
service_name = 'bla'
expect(SUSE::Connect::Zypper).to receive(:remove_service).with(service_name)
context 'without zypper service plugin' do
it 'forwards to zypper remove_service' do
service_name = 'bla'
expect(SUSE::Connect::Zypper).to receive(:remove_service).with(service_name)

described_class.remove_service(service_name)
described_class.remove_service(service_name)
end
end

context 'with zypper service plugin' do
it "doesn't forward to zypper remove_service" do
service_name = 'bla'
expect(File).to receive(:exist?).with("/usr/lib/zypp/plugins/services/#{service_name}").and_return(true)
expect(SUSE::Connect::Zypper).not_to receive(:remove_service)

described_class.remove_service(service_name)
end
end
end

Expand Down

0 comments on commit 1aca5e4

Please sign in to comment.