forked from sonic-net/sonic-utilities
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sonic-package-manager] remove leftovers from featured on uninstall (s…
…onic-net#3305) - What I did Added code to remove leftover symlinks and directories created by featured. Featured creates a symlink to /dev/null when unit is masked and an auto restart configuration is left under corresponding service.d/ directory. - How I did it Added necessary changes and UT to cover it. - How to verify it Uninstall an extension and verify no leftovers from featured. Signed-off-by: Stepan Blyschak <[email protected]>
- Loading branch information
1 parent
673da6b
commit 804e053
Showing
3 changed files
with
55 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
from sonic_package_manager.metadata import Metadata | ||
from sonic_package_manager.package import Package | ||
from sonic_package_manager.service_creator.creator import * | ||
from sonic_package_manager.service_creator.creator import ETC_SYSTEMD_LOCATION | ||
from sonic_package_manager.service_creator.feature import FeatureRegistry | ||
|
||
|
||
|
@@ -106,6 +107,14 @@ def test_service_creator(sonic_fs, manifest, service_creator, package_manager): | |
assert sonic_fs.exists(os.path.join(SERVICE_MGMT_SCRIPT_LOCATION, 'test.sh')) | ||
assert sonic_fs.exists(os.path.join(SYSTEMD_LOCATION, 'test.service')) | ||
|
||
# Create symlinks and directory featured creates | ||
os.symlink('/dev/null', os.path.join(ETC_SYSTEMD_LOCATION, 'test.service')) | ||
os.symlink('/dev/null', os.path.join(ETC_SYSTEMD_LOCATION, '[email protected]')) | ||
os.symlink('/dev/null', os.path.join(ETC_SYSTEMD_LOCATION, '[email protected]')) | ||
os.mkdir(os.path.join(ETC_SYSTEMD_LOCATION, 'test.service.d')) | ||
os.mkdir(os.path.join(ETC_SYSTEMD_LOCATION, '[email protected]')) | ||
os.mkdir(os.path.join(ETC_SYSTEMD_LOCATION, '[email protected]')) | ||
|
||
def read_file(name): | ||
with open(os.path.join(ETC_SONIC_PATH, name)) as file: | ||
return file.read() | ||
|
@@ -118,6 +127,15 @@ def read_file(name): | |
assert generated_services_conf_content.endswith('\n') | ||
assert set(generated_services_conf_content.split()) == set(['test.service', '[email protected]']) | ||
|
||
service_creator.remove(package) | ||
|
||
assert not sonic_fs.exists(os.path.join(ETC_SYSTEMD_LOCATION, 'test.service')) | ||
assert not sonic_fs.exists(os.path.join(ETC_SYSTEMD_LOCATION, '[email protected]')) | ||
assert not sonic_fs.exists(os.path.join(ETC_SYSTEMD_LOCATION, '[email protected]')) | ||
assert not sonic_fs.exists(os.path.join(ETC_SYSTEMD_LOCATION, 'test.service.d')) | ||
assert not sonic_fs.exists(os.path.join(ETC_SYSTEMD_LOCATION, '[email protected]')) | ||
assert not sonic_fs.exists(os.path.join(ETC_SYSTEMD_LOCATION, '[email protected]')) | ||
|
||
|
||
def test_service_creator_with_timer_unit(sonic_fs, manifest, service_creator): | ||
entry = PackageEntry('test', 'azure/sonic-test') | ||
|