mirror of
https://github.com/clearlinux/swupd-client.git
synced 2026-09-02 19:51:36 +00:00
This commit does a major refactor of the bundle-remove command to include these improvements: - Adds a "--force" flag that can be used to remove a bundle that is required by other installed bundles along with all the bundles that depend on it - When attempting to remove a bundle which is required by other installed bundles, swupd used to show the list of dependencies in a tree view, this list was very large in some cases. This commit changes the output of such cases from a tree view to a simple deduplicated list of bundles that require the bundle to be removed. The user can still see the old tree view by including the --verbose when running the command - Stops notifying telemetry of user errors, like user trying to remove an invalid bundle, or a bundle that was not installed, etc - Consider all bundles provided in the bundle-remove command when checking for dependencies (required by) - Instead of removing each bundle in the command one by one, consolidate all bundles to be removed, validate them and remove them all at once. This will optimize the tasks to be executed for removing bundles. One change included in this commit for bundle-remove is propagated to bundle-list: - When using "bundle-list -D BUNDLE" to find what bundles depend on BUNDLE. The list will be presented in a simplified deduplicated list of dependencies by default instead of the tree view that used to be default. The user can still see the old tree view by running the command appending the --verbose flag Closes #891 Closes #732 Closes #674 Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
101 lines
3.5 KiB
Bash
Executable File
101 lines
3.5 KiB
Bash
Executable File
#!/usr/bin/env bats
|
|
|
|
# Author: Castulo Martinez
|
|
# Email: castulo.martinez@intel.com
|
|
|
|
load "../testlib"
|
|
|
|
test_setup() {
|
|
|
|
# create a test environment with 10 MB of space
|
|
create_test_environment -s 10 "$TEST_NAME"
|
|
|
|
# create a bundle (no matter its size since we'll be removing it)
|
|
create_bundle -L -n test-bundle -f /file_1 "$TEST_NAME"
|
|
|
|
# create the state version dirs ahead of time
|
|
sudo mkdir "$TEST_NAME"/testfs/state/10
|
|
|
|
}
|
|
|
|
@test "REM017: Removing a bundle with no disk space left (downloading the MoM)" {
|
|
|
|
# When removing a bundle, if we run out of disk space while downloading the
|
|
# MoM we should not retry the download since it will fail for sure
|
|
|
|
# fill up all the space in the disk
|
|
sudo dd if=/dev/zero of="$TEST_NAME"/testfs/dummy >& /dev/null || print "Using all space left in disk"
|
|
|
|
run sudo sh -c "$SWUPD bundle-remove $SWUPD_OPTS test-bundle"
|
|
|
|
assert_status_is "$SWUPD_COULDNT_LOAD_MOM"
|
|
expected_output=$(cat <<-EOM
|
|
Error: Curl - Error downloading to local file - 'file://$TEST_DIRNAME/web-dir/10/Manifest.MoM.tar'
|
|
Error: Curl - Check free space for $TEST_DIRNAME/testfs/state?
|
|
Error: Failed to retrieve 10 MoM manifest
|
|
Error: Unable to download/verify 10 Manifest.MoM
|
|
Failed to remove bundle(s)
|
|
EOM
|
|
)
|
|
assert_is_output "$expected_output"
|
|
|
|
}
|
|
|
|
@test "REM018: Removing a bundle with no disk space left (downloading other bundle manifests)" {
|
|
|
|
# When removing a bundle, if we run out of disk space while downloading the
|
|
# bundle manifests we should not retry the download since it will fail for sure
|
|
# bundle remove needs the manifest from all other bundles in the system to check
|
|
# for dependencies with the bundle to be removed
|
|
|
|
# let's replace the Manifest tar from os-core with a much larger file that will exceed
|
|
# the available space on disk
|
|
sudo rm "$WEBDIR"/10/Manifest.os-core
|
|
sudo rm "$WEBDIR"/10/Manifest.os-core.tar
|
|
big_manifest=$(create_file "$WEBDIR"/10 15MB)
|
|
sudo mv "$big_manifest" "$WEBDIR"/10/Manifest.os-core
|
|
sudo mv "$big_manifest".tar "$WEBDIR"/10/Manifest.os-core.tar
|
|
|
|
run sudo sh -c "$SWUPD bundle-remove $SWUPD_OPTS test-bundle"
|
|
|
|
assert_status_is "$SWUPD_RECURSE_MANIFEST"
|
|
expected_output=$(cat <<-EOM
|
|
Error: Curl - Error downloading to local file - 'file://$TEST_DIRNAME/web-dir/10/Manifest.os-core.tar'
|
|
Error: Curl - Check free space for $TEST_DIRNAME/testfs/state?
|
|
Error: Failed to retrieve 10 os-core manifest
|
|
Error: Cannot load MoM sub-manifests
|
|
Failed to remove bundle(s)
|
|
EOM
|
|
)
|
|
assert_is_output "$expected_output"
|
|
|
|
}
|
|
|
|
@test "REM019: Removing a bundle with no disk space left (downloading the bundle manifest)" {
|
|
|
|
# When removing a bundle, if we run out of disk space while downloading the
|
|
# bundle manifest we should not retry the download since it will fail for sure
|
|
|
|
# let's replace the Manifest tar from the bundle with a much larger file that will exceed
|
|
# the available space on disk
|
|
sudo rm "$WEBDIR"/10/Manifest.test-bundle
|
|
sudo rm "$WEBDIR"/10/Manifest.test-bundle.tar
|
|
big_manifest=$(create_file "$WEBDIR"/10 15MB)
|
|
sudo mv "$big_manifest" "$WEBDIR"/10/Manifest.test-bundle
|
|
sudo mv "$big_manifest".tar "$WEBDIR"/10/Manifest.test-bundle.tar
|
|
|
|
run sudo sh -c "$SWUPD bundle-remove $SWUPD_OPTS test-bundle"
|
|
|
|
assert_status_is "$SWUPD_RECURSE_MANIFEST"
|
|
expected_output=$(cat <<-EOM
|
|
Error: Curl - Error downloading to local file - 'file://$TEST_DIRNAME/web-dir/10/Manifest.test-bundle.tar'
|
|
Error: Curl - Check free space for $TEST_DIRNAME/testfs/state?
|
|
Error: Failed to retrieve 10 test-bundle manifest
|
|
Error: Cannot load MoM sub-manifests
|
|
Failed to remove bundle(s)
|
|
EOM
|
|
)
|
|
assert_is_output "$expected_output"
|
|
|
|
}
|