Wrap the inner loop code in an anonymous function to make sure that
defer calls are triggered for each iteration of the loop and join all
errors as needed.
Diff best viewed with whitespace changes hidden.
Fixes lint:
```
Error return value of `writer.Flush` is not checked (errcheck)
```
Fixes lints:
```
Error return value of `out.Close` is not checked (errcheck)
Error return value of `os.RemoveAll` is not checked (errcheck)
Error return value of `writer.Flush` is not checked (errcheck)
```
It's fine to take into account close errors here as those are unlikely
and in this case those are in tests, thus not a potential subtle change
in behavior.
We also setup the defer'ed close earlier, as soon as the file is opened.
Fixes lint:
```
tests/blackbox_test.go:136:20: Error return value of `os.RemoveAll` is not checked (errcheck)
tests/blackbox_test.go:151:20: Error return value of `os.RemoveAll` is not checked (errcheck)
```
Fixes lint:
```
tests/stubs/groupdel-stub/main.go:55:23: Error return value of `groupFile.Close` is not checked (errcheck)
tests/stubs/groupdel-stub/main.go:78:25: Error return value of `gshadowFile.Close` is not checked (errcheck)
tests/stubs/useradd-stub/main.go:98:24: Error return value of `passwdFile.Close` is not checked (errcheck)
tests/stubs/useradd-stub/main.go:112:23: Error return value of `groupFile.Close` is not checked (errcheck)
tests/stubs/useradd-stub/main.go:126:24: Error return value of `shadowFile.Close` is not checked (errcheck)
tests/stubs/useradd-stub/main.go:140:25: Error return value of `gshadowFile.Close` is not checked (errcheck)
tests/stubs/userdel-stub/main.go:59:24: Error return value of `passwdFile.Close` is not checked (errcheck)
tests/stubs/userdel-stub/main.go:82:23: Error return value of `groupFile.Close` is not checked (errcheck)
tests/stubs/userdel-stub/main.go:105:24: Error return value of `shadowFile.Close` is not checked (errcheck)
tests/stubs/userdel-stub/main.go:128:25: Error return value of `gshadowFile.Close` is not checked (errcheck)
tests/stubs/usermod-stub/main.go:113:24: Error return value of `passwdFile.Close` is not checked (errcheck)
```
Addresses the staticcheck lint error by replacing all instances of
strings.Replace(s, old, new, -1) with the more explicit
strings.ReplaceAll(s, old, new).
Fixes lint:
```
QF1004: could use strings.ReplaceAll instead (staticcheck)
```
The linter found staticcheck and errorcheck issues. Deferred statements now use join to combine any new error with an existing one, preventing error information from being lost. Other minor error checks, like for printing text and flushing data have also been addressed.
This commit introduces a new TMT tests and a GitHub Actions workflow to
run it.
TMT (Test Management Tool) is a tool for managing and executing tests
in a structured and efficient manner. It allows users to define test
plans, organize test cases, and execute them in a consistent manner. TMT is
particularly useful for testing software projects, as it provides a
framework for managing the entire testing process, from planning to
execution and reporting.
The workflow is set up to run on every push to the main branch and on
pull requests, providing continuous integration for the project.
The core test added is designed to verify the basic functionality of
the application using TMT, ensuring that it can successfully execute a
simple test case.
The smoke plan is defined in the `tests/tmt/plans/smoke.fmf` file and
is configure to run all tests with smoke tag.
The `tests/tmt/plans/main.fmf` file is the main plan that includes
common configurations and settings for the plans. Currently, it prepare
the test environment.
The workflow is defined in the `.github/workflows/tmt-tests.yml` file
and includes steps to set up the environment, install dependencies, and
run tests. It is allowed to execute on pull requests, pushes to the
main branch, and on demand. By default all tests are executed, but it
can be executed on demand with a TMT plan filter. As part of the
workflow, TMT will be executed inside a container.
JIRA: https://issues.redhat.com/browse/COS-2284
Signed-off-by: Tiago Bueno <tiago.bueno@gmail.com>
Add a field which can limit the max version of config generated from blackbox
testing. If left blank blackbox tests will act as they always have. The new
field simply limits the registration of tests to that version number. This
is for the odd case where we want to ensure functionality does not exist when
using older versions of configs.
Until now, the blackbox tests would not correctly cleanup after
running a test with a luks device. Now Luks devices can be tested
using blackbox test framework.
In the context of the test added in the previous patch, it's normal for
the first `sgdisk --zap-all` invocation to fail. Add a knob to allow the
harness to tolerate this and make use of it in the new test.
When `wipeTable` is enabled, we run `sgdisk --zap-all`. But if the table
was corrupted in the first place, `sgdisk` will exit with code 2 which
then breaks boot.
As a workaround, Ignition used to retry the invocation but the context
around it was lost in #544 and #1149 and the retry was removed and
the error-checking was added.
So this patch effectively re-applies 94c98bcb ("sgdisk: retry zap-all
operation on failure"), but now with a comment and a test to make sure
we don't regress again.
Closes: https://github.com/coreos/fedora-coreos-tracker/issues/1596
mkfs.xfs >= 5.19.0 refuses to create filesystems smaller than 300 MB
unless --unsupported is specified or some environment variables are set.
Apply workarounds for each affected test:
filesystem.create.multipledisks: Doesn't need XFS. Switch to ext4.
filesystem.create.zfs.xfs: Must use XFS and must use an existing test
fixture that has a small partition. Rather than reworking the fixture,
add --unsupported to storage.filesystems.options.
filesystem.create.xfs.wipe: The available default partitions are too
small. Ideally we'd resize one, but I haven't researched whether there
are implications for other tests. Just use --unsupported for now.
The use of --unsupported breaks the blackbox tests on xfsprogs < 5.19.
That doesn't affect CoreOS CI, but may affect anyone running them manually
on older systems.
Fixes https://github.com/coreos/ignition/issues/1583.
For services where FCOS ships a symlink in /etc, if the user tries
to disable the service via Ignition, systemd ignores the disablement
directive in the preset. Avoid this behavior by deleting the enablement
symlinks when disabling a unit, but continue to record the disablement
in the preset file. This is a short-term solution until the upstream
systemd PR (systemd/systemd#15205) is merged and widely deployed.
Fixes https://github.com/coreos/fedora-coreos-tracker/issues/392
The data URLs which are used are all in URL encoding, while users can
also use base64 encoded data URLs.
Add a test to make sure base64 decoding works as expected.
This originally called umount(8), and on failure, checked to see if the
unmount had succeeded anyway. A later refactor switched to umount(2) but
failed to update the error message, and also broke the retry loop so that
it no longer ignored a spurious error return if umount actually succeeded.
Reinstate the success return if the filesystem was umounted, regardless of
the umount(2) return value. Also clarify our error message on failure and
include the error we got from the syscall.
Fixes: 634508423b ("tests/filesystems: fix error handling")
If Ignition creates a directory within a user's home directory as a result
of creating a mountpoint, fix its permissions once the user exists.
Co-authored-by: Stephen Lowrie <slowrie@redhat.com>
Serialize a struct to a JSON file in /run at the end of each stage and load
it at the beginning of the next stage. This is intended to be an internal
mechanism that can change incompatibly without warning.