673 Commits
Author SHA1 Message Date
William Douglas 6896d8f155 Rework output checking in test
The disk space check was trying to match exact number of download
attempt messages which was not working consistently.

Move to simply detecting the failure messages once.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-22 00:04:12 -08:00
William Douglas 98a3362ae9 Rework clear linux docker container for test runs
Also skips a few tests that do not run well with docker (changing date
and disk filling have a hard time). Adding comment for how to run
docker (needs the --cap-add LINUX_IMMUTABLE option passed).

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-22 00:04:12 -08:00
William Douglas a9608851ee Move packs to download synchronously
There are some problems with how we are using multiplexed curl causing
huge slowdowns (2-5 times slower).

For now rather than rework the multiplexed curl code, switch to using
the synchronous code path.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-21 23:26:19 -08:00
William Douglas 3338cb2c66 Rework clean-old-statedir test output checking
The order of files in this test aren't very completely stable so make
do with looking at output chunks that seem to be reasonably consistent
across different environments.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-17 12:58:05 -08:00
William Douglas 7f59817a43 Improve tests for container
Detect docker container usage when running test to handle cases where
systemd is unlikely to be running.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-17 12:58:05 -08:00
William Douglas 776f8c92b0 Update use bats setup and teardown features
Instead of relying on a custom global_setup and global_teardown
functions, migrate to the use of bats' setup_file and teardown_file
functions.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-17 12:58:05 -08:00
William Douglas eddf0dc2a4 Fix shellcheck SC2048 error
Correctly quote arrays.

Also improve some commands getting the array content (fixes space
issues with quoting).

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-17 12:58:05 -08:00
William Douglas 6a6a907b06 Move no space tests to CI only
These tests fill up the disk and can be quite annoying to run on a dev
system normally.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-17 12:58:05 -08:00
William Douglas e55e33afef Fix shellcheck SC2269 error
Remove useless assignment.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-17 12:58:05 -08:00
William Douglas ffb1590909 Update shellcheck exceptions
Shellcheck changed its detection for a few file sourcing errors from
1090 to 1091. Update the disables accordingly.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-17 12:58:05 -08:00
Brett T. Warden 0e0cc9b969 Update offline installation tests with URL override
Offline installation tests also override the installation URL, so we
must update the expected output to contain the new message about URL
override.
2022-10-05 11:08:47 -07:00
Brett T. Warden db4ceb85b8 Update tests for swupd mirror commands
Mirror tests specifically invoke the URL override options that trigger
the new text output I've added, so the tests' expected output needs to
be updated to match.
2022-10-05 11:08:47 -07:00
William Douglas 3d611782ab Move to a static pemfile
There is something going wrong with installing the generated pemfile.
The file is created but not yet valid, this is not a problem for
local testing for some reason. To work around this issue, use a static
pemfile that is already valid and force install it.

Signed-off-by: William Douglas <william.r.douglas@gmail.com>
2022-10-04 17:25:31 -07:00
William Douglas dbfce4b218 Skip the timesyncd stop and start
As these are CI only tests, the container image currently appears to
have the service masked so stop trying to modify it.

Signed-off-by: William Douglas <william.douglas@intel.com>
2022-10-04 17:25:31 -07:00
William Douglas 685ed470c4 Use regex match for size comparison
The exact size difference changed for some reason but shouldn't cause
the tests to fail as it isn't the point of this test.

Signed-off-by: William Douglas <william.douglas@intel.com>
2022-10-04 17:25:31 -07:00
William Douglas e778dc2ede Update test based on size
The test requires an exact size reporting, fix the size but consider
using a regex match instead.

Signed-off-by: William Douglas <william.douglas@intel.com>
2022-10-04 17:25:31 -07:00
Castulo Martinez 935053fdbe Testlib: refactoring setup to load correctly
The setup() function is run at the beginning of each test by the BATS
system, we leverage this function to implement a global_setup() and a
test_setup().

This commit refactors the function to make it easier to understand, also
makes sure it loads the environment variables correctly for tests.
2020-06-16 11:42:13 -07:00
Castulo Martinez 838022f36b Testlib: making variables available to all tests
Variables are available just after being exported, however variables are
not kept between tests since the process that orchestrate the tests of a
test file is a parent process and child processes cannot set variables
of a parent process. This is problematic because we were loosing some
variables (like all third party variables) when running multiple tests
using a global_setup().

This commit fixes the issue by making all the environment variables
available to all tests in a test file regardless of if they use
test_setup() o global_setup().

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-06-16 11:42:13 -07:00
Castulo Martinez 239376c425 Testlib: adding new setters for env variables
Unfortunatelly not all environment variables can be set in the same
place, since some values may depend on a specific function being run
before. However it is important to have easy to lacte places where env
variables are being set.

This commit adds a few more setter functions for envrionment variables
so they are easily identified.

Closes #1489

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-06-16 11:42:13 -07:00
Castulo Martinez da83141022 Testlib: set variables from a common place
Some env variables in testlib can be exported when the file is sourced,
but some other have to be exported only after the test environment has
been created because they depend on it and in values gotten from it.
However testlib should try to set env variables in as little places as
possible.

This commit moves the definition of variables that can be defined in
set_env_variables() to consolidate them there if possible.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-06-16 11:42:13 -07:00
Castulo Martinez 7dd6fc221a Testlib: renaming variables for consistency
Environment variables are used everywhere in testilb. This environment
variables are global variables that define the way testlib behaves.
However is was confusing to use the variables because they were
inconsistent between each other, for example some variables that define
paths would have absolute paths while other would have relative paths,
making it error prone while using them.

This commit makes the environment variables more consistent by following
a name convention for each type of variable, as an example, variables
that define absolute paths follow this convention ABS_<path_name>_DIR,
while variables that define relative paths are defined like this
<path_name>_DIR.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-06-16 11:42:13 -07:00
Castulo Martinez a48ff926f3 Testlib: adding one more env variable to the help
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-06-16 11:42:13 -07:00
Castulo Martinez ac837cb9fe Testlib: Replace zero_hash constant with ZERO_HASH
Global constants in testlib are just exported variables, so they should
be in all upper case so we know they were defined globally.

Closes #1484

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-06-16 11:42:13 -07:00
Castulo Martinez 47a2fc08d5 Testlib: adding info about BATS variables
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-06-16 11:42:13 -07:00
Castulo Martinez 04dfaa1db7 Allow paths that contain symlinks for cachedir
When the path provided by a user for the --statedir (or --cachedir)
contains a symlink swupd will fail to extrar tar files since
libarchive does not support extracting files through symlinks.

This commit fixes the issue allowing users to use symlinks in the
--statediri/--cachedir path.

Closes #1581

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-06-15 15:24:34 -07:00
Castulo Martinez cdf03c14d4 Testlib: include important env variables in help
After sourcing testlib, if the user runs testlib from the terminal,
the help of the library is displayed which includes the list of
commands provided by the library.

Testlib uses some environment variables to modify the way tests are
run. This commit adds information about those env variables to the
testlib help.

Closes #1479

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-06-10 12:11:02 -07:00
Castulo Martinez defd541061 Fixing a false positive in a "clean" test
When checking the output of the "clean --dry-run" command in the test,
we expect the output to be shown in a specific order, but the order can
change depending on the system since readdir doesn't warranty a specific
order when reading the content of a directory.

This commit fixes the test by only checking for the files we are
intereseted in, and it checks them with separate assertions to make sure
we don't have false positives due to the order.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-06-08 15:40:29 -07:00
Castulo Martinez 40472f5a21 Updating "clean" to remove new and old cache dirs
"Swupd clean" removes cache from certain pre-defined directories. This
commit udpdates the locations where clean looks for cache so it includes
the new locations where the cache is stored.

Swupd will continue looking at old cache locations until the bump to
format 31.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-06-08 12:10:39 -07:00
Castulo Martinez 8d54e6c995 Separating the cache from the data used by swupd
Currently there is only one location, known as "statedir", where swupd
stores data and cache. Normally it make sense to keep the data in a
path that is relative to the path prefix of the target system, since the
data is specific to that system, but cache can be independent of the
system, and that way it can be reused for other target systems if
desired.

This commit splits the cache and data into two different locations.
It also stores the cache in a path that is dependent of the mirror url
being used by swupd. The commit also makes all references to files in
the cache or data directories through getter functions thus removing the
hardcoded reference to the file's location, making it easier to move the
location in the future if needed. Lastly, this commit changes the read
permissions for the data directory and the manifest directories in the
cache to be user readable.
2020-06-08 12:10:39 -07:00
Otavio Pontes 5bb4ef2337 swupd.bash: Make swupd.bash POSIX compliant
Bash autocomplete scripts should be POSIX compliant, so fixing that and
adding a test to validate this.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-19 13:47:49 -07:00
Castulo Martinez 8e4c017365 Moving downloaded manifests to their own directory
When swupd downloads manifests to the statedir they are downloaded in
directories that represent the version of clear that the manifests
belong to. However those version directories are stored in the statedir,
root directory. This commit moves them into their own "manifest"
directory so there is more consistency with the downloaded files.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-15 11:47:33 -07:00
Otavio Pontes d5d3c599d2 Revert "Moving downloaded manifests to their own directory"
This reverts commit 336fee7a9d.
2020-05-15 08:18:37 -07:00
Otavio Pontes 24ecf6c913 delta: Improve message on delta errors
Print a more useful error when we fail to locate a file to apply a
delta. Add a suggestion for the user to run `swupd repair` and make
it clear that the problem is in their system and not in the update
content.

Fixes #1425

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-14 13:41:59 -07:00
Castulo Martinez 336fee7a9d Moving downloaded manifests to their own directory
When swupd downloads manifests to the statedir they are downloaded in
directories that represent the version of clear that the manifests
belong to. However those version directories are stored in the statedir,
root directory. This commit moves them into their own "manifest"
directory so there is more consistency with the downloaded files.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-14 11:03:51 -07:00
Otavio Pontes 7263b2d774 verify: Don't apply heuristic to os-install
Don't run heuristics for os-install or repair --quick.
On os-install we want all files to be always installed. On repair --quick
we don't process any do_not_update files

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-13 08:24:37 -07:00
Castulo Martinez bca38243d8 3rd-party: add bundle-remove --orphans flag
Implementing the --orphans option to remove bundles no longer required
by tracked bundles from 3rd-party repositories.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-08 09:30:50 -07:00
Castulo Martinez 4d0a6d29a1 Implement bundle-remove --orphans flag
This commit implements the --orphan flag for bundle-remove which can be
used to remove bundles that are no longer required by tracked bundles.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-08 09:30:50 -07:00
Castulo Martinez 0b47050848 3rd-party: add --orphans flag for bundle-list
Implementing the --orphans flag for 3rd-party bundle-list.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-05 10:37:44 -07:00
Castulo Martinez 4cd51ca5d8 Add --orphans flag to bundle-list
Adding the --orphans flag to bundle-list which shows those bundles that
are installed ut no longer required by any tracked bundle.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-05 10:37:44 -07:00
Otavio Pontes d29865f8a9 swupd.bash: Fixing tests
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-05 09:09:53 -07:00
Castulo Martinez 86ef6bfde5 Testlib: Fixing functions that use a test ID
Instead of relying on all tests of the same group to exist in the same
directory, testlib should assume those tests could be scattered across
multiple directories.

Closes #1485

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-01 13:02:21 -07:00
Castulo Martinez 67dd98a5f1 Test: Use global_setup for bundle-list tests
Use global_setup in all bundle-list tests so we can only generate the
test environment once and use it for multiple tests. The one exception
is if we need to modify the env for a specific test.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-30 14:01:16 -07:00
Otavio Pontes d2c053cdb3 test: Create test to validate if we can repair files that have type change
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-30 12:26:29 -07:00
Otavio Pontes 4436d33e43 target_root: Handle invalid directory or missing directory the same way
We don't need to handle directory missing or invalid differently, because
the staging function removes it if necessary, so making the if simple.

Fix #1509

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-30 12:26:29 -07:00
Otavio Pontes ce0943982a shellcheck: Error SC2119 doesn't apply to our use cases
Ignoring error SC2119 because they are false positives and I don't see cases
where that would return anything useful for us.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-30 08:50:48 -07:00
Castulo Martinez 766be95913 Test: show_target shellcheck warning
The show_target function shows a warning that is not applicable so this
commit ignores that warning wherever show_target is used.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-29 09:04:13 -07:00
Castulo Martinez e57b9e6948 Testlib: adding help with description for all funcs
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-28 10:56:39 -07:00
Castulo Martinez 8a6eb85efe Testlib: function to print help menus of commands
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-28 10:56:39 -07:00
Castulo Martinez 201950445a Reporting if a file was fixed or not with --quiet
When using --quiet, there was no way of knowing if a file had been
successfully repaired or not. This commit fixes that.

Closes #1504

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-28 09:13:45 -07:00
Castulo Martinez 8b9a2e8510 API: Do not validate error messages in API tests
The tests in test/functional/api are going to validate the --quiet
output is rarely changed, therefore only expected output should be
validated and not warnings or error messages.

Closes #1502

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-27 16:04:05 -07:00