Commit Graph

52 Commits

Author SHA1 Message Date
Colin Walters
ac42e29d66 os-init: Create a mount namespace
Today on anything using readonly sysroot `os-init` fails, because
we don't create a mount namespace if the `UNLOCKED` flag is specified
because we assume it's a readonly operation.

Since technically this is a mutation, let's just lock the sysroot
and use the tested path.
2023-08-02 14:32:22 -04:00
Colin Walters
6470429b2b tests/destructive: Turn off global sync()
Let's verify that things work with that off, as they should.

Previously:
cb73129483
"deploy: Add a 5s max timeout on global filesystem sync()"

But we may still have problems even with that, see
https://issues.redhat.com/browse/OCPBUGS-15917
where it might be that even a thread doesn't work because
we're locked in the kernel.
2023-07-28 17:59:28 -04:00
Colin Walters
64afbcdeb0 composefs: Use lowerdir in /run
I just noticed that this was another constant string duplicated
between prepare-root.c and libostree-1.so, and I went to make
it a common `#define` in libotcore.la.

But then I thought "it's ugly to have this directory mixed into
the deployment namespace" because in some theoretical world
it could also be in the ostree commit, which would cause weird
behavior.

I think this is transient state that is better in `/run`, so move
it there.
2023-07-22 16:46:17 -04:00
Colin Walters
93699cc546 prepare-root: Add metadata for composefs to /run/ostree-booted
Particularly for the signature case, having this metadata
acts as a reliable "proof of execution" of the signature verification
code (as opposed to parsing a log file or so).

Besides that, this is also just a stronger check for "we're using
composefs" instead of checking for "overlayfs on /".
2023-07-13 07:28:39 -04:00
Colin Walters
8bba482bc8 tests: Enable mtime test
I think this just accidentally was never enabled.

While looking at the code, add a sleep here to be resilient to
filesystems with only second mtime granularity.
2023-06-29 02:11:09 -04:00
Colin Walters
0b519c2573 tests: Drop unused alias 2023-06-29 02:09:51 -04:00
Colin Walters
54c731554e tests/transactionality: Port a bit to xshell
This will give us more useful error messages which should
help debug a flake.
2023-06-29 02:08:56 -04:00
Colin Walters
3c7e256cee tests: Add a sanity check for composefs
Prep for adding some coverage of this flow when booting with
composefs.
2023-06-19 19:02:20 -04:00
Colin Walters
88e8b671ce tests: A bit more xshell porting
Part of https://github.com/ostreedev/ostree/issues/2857
2023-05-18 08:14:50 -04:00
Colin Walters
dc23b9389b tests/inst: Add xshell and use it in one place
I've deprecated sh-inline; in the end I think it is better
to minimize the amount of bash code we have.  xshell solves
the core convenience problem of taking local variables and mapping
them to command arguments.

A full port would be nontrivial; this just starts the ball
rolling.
2023-05-10 14:02:09 -04:00
Colin Walters
cafe12cf1f treegen: Require at least one mutation
Since a later assertion would otherwise trigger.  We saw
this happen in CI.
2023-03-23 16:48:55 -04:00
Dan Nicholson
4fd36337b1 tests/inst: Update hyper-staticfile to 0.9.4
Due to some vulnerabilities[1][2], all versions prior to 0.9.4 have been
yanked from crates.io. There have been some API changes since 0.6.0, but
none of them affect the simple `hyper_staticfile::Static` usage here.

1. https://rustsec.org/advisories/RUSTSEC-2022-0069.html
2. https://rustsec.org/advisories/RUSTSEC-2022-0072.html
2023-01-24 13:20:10 -07:00
Colin Walters
2dc92b25cd tests/inst: Update sh-inline 2022-11-22 10:14:48 -05:00
Colin Walters
eadb8c3d58 tests/inst: Update cap-std-ext to 1.0 2022-11-22 10:14:17 -05:00
Colin Walters
c0beedbb48 tests/inst: Drop nix dependency
It has various semver bumps and we were literally just using
it to duplicate what's already in `libc`.
2022-11-22 10:13:42 -05:00
Colin Walters
180a1d8f0a tests/inst: Update to latest ostree-ext 2022-11-22 10:09:20 -05:00
Dan Nicholson
f3db79e7fa finalize-staged: Ensure /boot automount doesn't expire
If `/boot` is an automount, then the unit will be stopped as soon as the
automount expires. That's would defeat the purpose of using systemd to
delay finalizing the deployment until shutdown. This is not uncommon as
`systemd-gpt-auto-generator` will create an automount unit for `/boot`
when it's the EFI System Partition and there's no fstab entry.

To ensure that systemd doesn't stop the service early when the `/boot`
automount expires, introduce a new unit that holds `/boot` open until
it's sent `SIGTERM`. This uses a new `--hold` option for
`finalize-staged` that loads but doesn't lock the sysroot. A separate
unit is used since we want the process to remain active throughout the
finalization run in `ExecStop`. That wouldn't work if it was specified
in `ExecStart` in the same unit since it would be killed before the
`ExecStop` action was run.

Fixes: #2543
2022-08-30 09:16:39 -06:00
Lukas Kalbertodt
02b162347c
Update to libtest-mimic 0.5.0 2022-08-13 16:41:34 +02:00
Colin Walters
e98988ba17 tests/inst: Port to cap-std
Part of an ongoing effort.
2022-06-24 16:23:05 -04:00
Jonathan Lebon
7814d9339e tests/inst/destructive: stop disabling fedora-coreos-pinger
It was removed from FCOS:
https://github.com/coreos/fedora-coreos-tracker/issues/770
2022-06-23 15:50:39 -04:00
Colin Walters
e65c8e72c8
Merge pull request #2643 from cgwalters/rust-2021
rust: Switch to 2021 edition, bump MSRV, a few `format!` updates
2022-06-13 09:10:36 -04:00
Colin Walters
93e3784b66 rust: Use inline format! variables in a few places
Since our MSRV now supports it.
2022-06-09 17:51:07 -04:00
Colin Walters
99c122d219 rust: Switch to 2021 edition
No real changes.

```
$ cargo fix --edition
note: Switching to Edition 2021 will enable the use of the version 2 feature resolver in Cargo.
This may cause some dependencies to be built with fewer features enabled than previously.
More information about the resolver changes may be found at https://doc.rust-lang.org/nightly/edition-guide/rust-2021/default-cargo-resolver.html
When building the following dependencies, the given features will no longer be used:

  libc v0.2.126 removed features: extra_traits

The following differences only apply when building with dev-dependencies:

  getrandom v0.2.6 removed features: std
```

which looks OK to me.
2022-06-09 15:55:41 -04:00
Colin Walters
2688d7d261 tests/inst: Bump the version of ostree-ext
In the interest of cross-testing and keeping things up to date.

Hmm, I think we need to set up dependabot here.
2022-06-09 14:52:04 -04:00
Colin Walters
ee2c31badd tests/inst: Add .gitignore
Need this now that it is it's own workspace.
2022-05-09 14:52:26 -04:00
Colin Walters
252060906b build-sys: Adjust for merge of ostree-rs
Fix up the paths for the crates now that the Rust bindings are in
`rust/`.

We can't today include the test suite because it depends on `ostree-rs-ext`
which would make everything circular.

(Building that now requires a separate `cd tests/inst && cargo build`)
2022-05-06 12:53:57 -04:00
Colin Walters
afdc84b97b Update to sh-inline 0.2
Syncing up with the latest.
2022-03-14 09:54:48 -04:00
Colin Walters
75ae283f23 Update to rand 0.8
Part of general crate updates.
2022-03-11 15:34:59 -05:00
Colin Walters
fba7efb6da Update to ostree-ext 0.6
Part of general crate updates.
2022-03-11 15:33:02 -05:00
Colin Walters
34d1bcc68a Update to nix 0.23
Part of general crate updates.
2022-03-11 15:32:27 -05:00
Colin Walters
b6d1119f91 tests: Stop using inventory crate
I was reading this thread
https://internals.rust-lang.org/t/from-life-before-main-to-common-life-in-main/16006/30
and that reminded me about this code, which it turns out actually
doesn't compile with my default local cargo config:
```
$ cat ~/.cargo/config
[target.x86_64-unknown-linux-gnu]
rustflags = ["-Ctarget-cpu=native", "-C", "link-arg=-fuse-ld=lld"]

[profile.release]
incremental = true
$ cargo b
...
error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-m64" "/var/srv/walters/src/github/ostreedev/ostree/target/debug/deps/ostree_test-4ca8e730f9dc6ffc.10325uqlhkyr5uol.rcgu.o" "/var/srv/walte"
  = note: ld.lld: error: undefined symbol: __start_linkme_NONDESTRUCTIVE_TESTS
          >>> referenced by 22nn09lfsklfqvyy
          >>>               /var/srv/walters/src/github/ostreedev/ostree/target/debug/deps/ostree_test-4ca8e730f9dc6ffc.22nn09lfsklfqvyy.rcgu.o:(ostree_tes)

```

For now let's just go back to having a static list of functions.
We don't have *too* many of those.
2022-03-11 14:53:29 -05:00
Colin Walters
0d020a7145 tmpfiles: Create /run/ostree
This is referenced by 9645cee4f2/lib/src/globals.rs (L16)
specifically used for the (container image) pull secret in
`/run/ostree/auth.json`.

Let's pre-create the directory so users don't have to.

Motivated by https://github.com/openshift/machine-config-operator/pull/3007#discussion_r824172564
2022-03-11 13:08:23 -05:00
Colin Walters
bcc0ef7583 tests: Use ostree-ext 0.3.0
This updates to the modern glib 0.14 and paves the way for
some reverse dependency testing by using ostree-ext's code.
2021-09-30 13:38:25 -04:00
Timothée Ravier
a709d4f846 *: rename master branch to main (external repos) 2021-05-07 16:55:03 +02:00
Colin Walters
7310203ce9 tests/inst: Make nondestructive tests runnable as unit tests
Ideally in the future we change more of our unit tests to
support running installed; we've tried this in the past with
https://wiki.gnome.org/Initiatives/GnomeGoals/InstalledTests

I'd like to pick that back up again.  This takes a step
towards that by having our Rust tests.

To make this even easier, add a `tests/run-installed`
which runs the installed tests (uninstalled, confusingly
but conveniently for now).
2021-04-15 12:33:34 -04:00
Colin Walters
46a0911c6d build-sys: Add toplevel workspace Cargo.toml
rust-analyzer is happier with this because it understands
the project structure out of the box.

We aren't actually again adding a dependency on Rust/cargo in the core,
this is only used to make `cargo build` work out of the box to build
the Rust test code.
2021-04-15 12:33:34 -04:00
Colin Walters
4d9e6de46b tests/inst: Update tokio, hyper and nix 2021-04-07 18:00:57 +00:00
Colin Walters
2628637a78 tests/inst: Update rpm-ostree client 2021-04-07 18:00:57 +00:00
Colin Walters
642dcd10ef tests/inst: Update ostree crate 2021-04-07 18:00:57 +00:00
Colin Walters
35d4e657e7 tests: Drop openat override
No longer needed.
2021-04-07 18:00:57 +00:00
Colin Walters
b69a4180b8 tests/inst: Patch to use my PR for openat
Fixes the build.
2021-03-19 21:45:54 +00:00
Colin Walters
c52a2ff52e tests/inst: cargo fmt 2021-03-17 18:45:17 +00:00
Colin Walters
d11dd7a37b tests/inst: Fix lots of cargo clippy warnings
Prep for doing this in CI.
2021-03-17 17:13:52 +00:00
Colin Walters
dc10bdfb0c tests/inst: Switch to rpmostree-client from git
See discussion in https://github.com/coreos/rpm-ostree/pull/2569#issuecomment-780569188
Currently pinned to a hash, but after the next stable release let's switch to tags
2021-02-23 15:20:54 +00:00
Luca BRUNO
bf2c23ca06
tests/ext/destructive: enhance test logic
This enhances external-tests logic, ensuring that destructive tests
have retries and some context to pinpoint failures, and that failed-state
services are reset between iterations.
2021-02-03 12:25:02 +00:00
Colin Walters
ef55c2c981 tests/inst: Update to published sh-inline crate
And I made a few more API tweaks, such as supporting `Path`
objects directly and also not needing e.g. `commit = commit`, see

- cfa7c71126
- 679bce4cc7
2020-08-26 17:00:19 +00:00
Colin Walters
33e2d34ea5 tests/inst: Port to new sh-inline repo
I cleaned up my fork of commandspec (see git log) and am
planning to publish to crates.  Port to the new API in prep
for that.
2020-08-25 22:06:13 +00:00
Colin Walters
cc1b70d921 tests: Check the immutable bit
See https://bugzilla.redhat.com/show_bug.cgi?id=1867601

We really want an upstream test for this, even if (to my knowledge)
nothing is running ostree's upstream CI on !x86_64.
2020-08-21 17:39:39 +00:00
Colin Walters
9f8c3f4400 tests/inst: Bump to latest ostree and gtk-rs
Updating our tests to the latest ostree crate is so deliciously
circular.
2020-08-18 18:00:19 +00:00
Colin Walters
1101c02c2a tests/inst: Add destructive test framework
This adds infrastructure to the Rust test suite for destructive
tests, and adds a new `transactionality` test which runs
rpm-ostree in a loop (along with `ostree-finalize-staged`) and
repeatedly uses either `kill -9`, `reboot` and  `reboot -ff`.

The main goal here is to flush out any "logic errors".

So far I've validated that this passes a lot of cycles
using
```
$ kola run --qemu-image=fastbuild-fedora-coreos-ostree-qemu.qcow2 ext.ostree.destructive-rs.transactionality --debug --multiply 8 --parallel 4
```
a number of times.
2020-08-17 14:34:04 +00:00