Define size of test environment

Sometimes is useful to be able to limit the size of a test environment
to validate some scenarios that are bound to disk size.

This commit adds a -s (size) option that can be used when creating test
environments so the user can control how much space is available in that
environment. If not used, the test environment works the same as before.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
This commit is contained in:
Castulo Martinez
2019-01-10 14:05:01 -08:00
committed by Otavio Pontes
parent 116a4c612e
commit 39e2d40127
13 changed files with 187 additions and 80 deletions
@@ -8,8 +8,8 @@ test_setup() {
create_bundle -n test-bundle -f /usr/bin/test-file "$TEST_NAME"
# set up state directory with bad hash file and pack hint
file_hash=$(get_hash_from_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle /usr/bin/test-file)
sudo sh -c "echo \"test file MODIFIED\" > $TEST_NAME/state/staged/$file_hash"
sudo touch "$TEST_NAME"/state/pack-test-bundle-from-0-to-10.tar
sudo sh -c "echo \"test file MODIFIED\" > $STATEDIR/staged/$file_hash"
sudo touch "$STATEDIR"/pack-test-bundle-from-0-to-10.tar
}
@@ -18,13 +18,13 @@ test_setup() {
# since one of the files needed to install the bundle is already in the state/staged
# directory, in theory this one should be used instead of downloading it again...
# however since the hash of this file is wrong it should be deleted and re-downloaded
hash_before=$(sudo "$SWUPD" hashdump "$TEST_NAME"/state/staged/"$file_hash")
hash_before=$(sudo "$SWUPD" hashdump "$STATEDIR"/staged/"$file_hash")
run sudo sh -c "$SWUPD bundle-add $SWUPD_OPTS test-bundle"
assert_status_is 0
hash_after=$(sudo "$SWUPD" hashdump "$TEST_NAME"/state/staged/"$file_hash")
assert_file_exists "$TEST_NAME"/target-dir/usr/bin/test-file
hash_after=$(sudo "$SWUPD" hashdump "$STATEDIR"/staged/"$file_hash")
assert_file_exists "$TARGETDIR"/usr/bin/test-file
assert_not_equal "$hash_before" "$hash_after"
expected_output=$(cat <<-EOM
Starting download of remaining update content. This may take a while...
+2 -3
View File
@@ -25,14 +25,13 @@ test_setup() {
# downloaded fullfile had a bad hash - immediately fatal with a 1 return code
assert_status_is 1
# the bad hash file should not exist on the system
assert_file_not_exists "$TEST_NAME"/target-dir/usr/bin/file1
assert_file_not_exists "$TARGETDIR"/usr/bin/file1
expected_output=$(cat <<-EOM
Starting download of remaining update content. This may take a while...
Finishing download of update content...
Error: File content hash mismatch for $TEST_DIRNAME/state/staged/e6d85023c5e619eb43d5cfbfdbdec784afef5a82ffa54e8c93bda3e0883360a3 (bad server data?)
Error: File content hash mismatch for $TEST_DIRNAME/testfs/state/staged/e6d85023c5e619eb43d5cfbfdbdec784afef5a82ffa54e8c93bda3e0883360a3 (bad server data?)
EOM
)
assert_is_output "$expected_output"
}
+1 -1
View File
@@ -15,7 +15,7 @@ test_setup() {
run sudo sh -c "$SWUPD bundle-add $SWUPD_OPTS test-bundle"
assert_status_is 0
assert_file_exists "$TEST_NAME/target-dir/usr/lib/kernel/test-file"
assert_file_exists "$TARGETDIR/usr/lib/kernel/test-file"
expected_output=$(cat <<-EOM
Starting download of remaining update content. This may take a while...
Finishing download of update content...
+1 -1
View File
@@ -15,7 +15,7 @@ test_setup() {
run sudo sh -c "$SWUPD bundle-add -b $SWUPD_OPTS test-bundle"
assert_status_is 0
assert_file_exists "$TEST_NAME/target-dir/usr/lib/kernel/test-file"
assert_file_exists "$TARGETDIR/usr/lib/kernel/test-file"
expected_output=$(cat <<-EOM
Starting download of remaining update content. This may take a while...
Finishing download of update content...
@@ -73,7 +73,7 @@ global_teardown() {
run sudo sh -c "$SWUPD bundle-add $SWUPD_OPTS test-bundle"
assert_status_is 0
assert_file_exists "$TEST_NAME"/target-dir/usr/bin/test-file
assert_file_exists "$TARGETDIR"/usr/bin/test-file
}
@test "ADD024: Try adding bundle over HTTPS with no client certificate" {
+3 -3
View File
@@ -8,7 +8,7 @@ test_setup() {
create_bundle -n test-bundle1 -f /foo/test-file1 "$TEST_NAME"
create_bundle -n test-bundle2 -f /bar/test-file2 "$TEST_NAME"
# add test-bundle2 as a dependency of test-bundle1
add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle1 test-bundle2
add_dependency_to_manifest "$WEBDIR"/10/Manifest.test-bundle1 test-bundle2
}
@@ -17,8 +17,8 @@ test_setup() {
run sudo sh -c "$SWUPD bundle-add $SWUPD_OPTS test-bundle1"
assert_status_is 0
assert_file_exists "$TEST_NAME"/target-dir/foo/test-file1
assert_file_exists "$TEST_NAME"/target-dir/bar/test-file2
assert_file_exists "$TARGETDIR"/foo/test-file1
assert_file_exists "$TARGETDIR"/bar/test-file2
expected_output=$(cat <<-EOM
Starting download of remaining update content. This may take a while...
Finishing download of update content...
+4 -4
View File
@@ -16,10 +16,10 @@ test_setup() {
run sudo sh -c "$SWUPD bundle-add $SWUPD_OPTS test-bundle1 test-bundle2"
assert_status_is 0
assert_dir_exists "$TEST_NAME/target-dir/usr/bin"
assert_dir_exists "$TEST_NAME/target-dir/media/lib"
assert_file_exists "$TEST_NAME/target-dir/usr/bin/10"
assert_file_exists "$TEST_NAME/target-dir/media/lib/file2"
assert_dir_exists "$TARGETDIR/usr/bin"
assert_dir_exists "$TARGETDIR/media/lib"
assert_file_exists "$TARGETDIR/usr/bin/10"
assert_file_exists "$TARGETDIR/media/lib/file2"
expected_output=$(cat <<-EOM
Downloading packs...
Extracting test-bundle1 pack for version 10
@@ -14,7 +14,7 @@ test_setup() {
run sudo sh -c "$SWUPD bundle-add --no-scripts $SWUPD_OPTS test-bundle"
assert_status_is 0
assert_file_exists "$TEST_NAME/target-dir/usr/lib/kernel/test-file"
assert_file_exists "$TARGETDIR/usr/lib/kernel/test-file"
expected_output=$(cat <<-EOM
Starting download of remaining update content. This may take a while...
Finishing download of update content...
@@ -10,12 +10,12 @@ test_setup() {
# bundles created with the testlib add all needed directories to the
# manifest by default, so we need to remove the directory from test-bundle1
# so its missing the path to the file.
remove_from_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle1 /foo
remove_from_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle1 /foo/bar
remove_from_manifest "$WEBDIR"/10/Manifest.test-bundle1 /foo
remove_from_manifest "$WEBDIR"/10/Manifest.test-bundle1 /foo/bar
# since test-bundle2 is already installed, both directories defined
# there already exist, so we need to delete one of the /foo/bar so it
# can be fixed using verify_fix_path
sudo rm -rf "$TEST_NAME"/target-dir/foo/bar
sudo rm -rf "$TARGETDIR"/foo/bar
}
@@ -27,7 +27,7 @@ test_setup() {
Starting download of remaining update content. This may take a while...
Finishing download of update content...
Installing bundle(s) files...
Update target directory does not exist: $TEST_DIRNAME/target-dir/foo/bar. Auto-fix disabled
Update target directory does not exist: $TEST_DIRNAME/testfs/target-dir/foo/bar. Auto-fix disabled
Path /foo/bar is missing on the file system ... fixing
Path /foo/bar/test-file1 is missing on the file system ... fixing
Calling post-update helper scripts.