Commit Graph

21314 Commits

Author SHA1 Message Date
Jelle van der Waa 9d30e976af HACKING: add information on how to use React Developer Tools 2024-04-24 15:42:36 +02:00
Allison Karlitskaya 85fb0a223f test/README.md: document TEST_BIND_GLOBAL=1
Fixes #20364
2024-04-24 15:21:07 +02:00
Marius Vollmer bd8e987f1d storage: Exclude eMMC "boot" non-partitions from multipath logic
eMMC devices can have "boot" sub-devices which should be excluded from
multipath considerations, just like partitions.

Fixes #20250
2024-04-24 12:02:49 +02:00
Martin Pitt 5debdd0673 systemd, storaged: Fix deprecated format_bytes() calls
Use the `base2` option instead of an explicit factor.

There are two places left where we pass an explicit unit. For these we need to
think harder about what to do there. Mark them with FIXME comments for now.
2024-04-24 09:37:20 +02:00
Martin Pitt 0f1010229f base1: Add format_bytes{,_per_sec}() unit tests for 0 value 2024-04-24 09:37:20 +02:00
dependabot[bot] e3eae5b36d Bump stylelint from 16.3.1 to 16.4.0 in the stylelint group
Bumps the stylelint group with 1 update: [stylelint](https://github.com/stylelint/stylelint).

Updates `stylelint` from 16.3.1 to 16.4.0
- [Release notes](https://github.com/stylelint/stylelint/releases)
- [Changelog](https://github.com/stylelint/stylelint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/stylelint/stylelint/compare/16.3.1...16.4.0)

---
updated-dependencies:
- dependency-name: stylelint
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: stylelint
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-24 07:06:27 +02:00
Martin Pitt 7ad70e4bfa base1: Fix format_bytes() B unit
For numbers < 1000 the unit should be "B" (bytes), not simply empty.

This is technically an API break, but most places which use that (like,
memory or storage device sizes) don't usually deal with such small
numbers (except "0"), and cockpit-files already has a hack for this [1].
As cockpit-files, -podman, etc. bundle cockpit.js, this can be fixed at
the time when updating cockpit lib, so it's not a sudden runtime
breakage.

Again, `format_bytes_per_sec()` already gets this right.

[1] https://github.com/cockpit-project/cockpit-files/blob/8e078434f5/src/sidebar.jsx#L80
2024-04-23 15:30:19 +02:00
Martin Pitt 597f701d10 base1: Fix format_bytes() kB unit
It's "kB", not "KB". `format_bytes_per_sec()` is already correct (just
the documentation was wrong).

Also add unit tests for a really small (5 B) number in decimal and
binary, and a corner case for "1023" in binary units.

Adjust the pixel tests which exposed "KB".
2024-04-23 15:30:19 +02:00
Martin Pitt ea473a5d8c kdump: Clean up formatting of reserved memory
- Put a plain number into the data store instead of a pre-formatted
   string. This makes it easier to determine if we have an actual value
   (it's an integer), and also if the value is exactly zero.

 - Format the number in the React component instead, and move to the
   current API of `base2: true`. This fixes a deprecation log message.

 - Stop repeating the `"error"` string comparison. Anything which isn't
   `undefined` or a number counts as "error, don't show".
2024-04-23 15:30:19 +02:00
dependabot[bot] 9b4a6b50fa Bump @typescript-eslint/eslint-plugin in the types group
Bumps the types group with 1 update: [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin).

Updates `@typescript-eslint/eslint-plugin` from 7.7.0 to 7.7.1
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v7.7.1/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: types
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-23 06:02:10 +02:00
Jelle van der Waa ea6846753b eslint: enable no-useless-fragment rule by default
This rule is not part of the standard ESLint recommends set but is
useful and can be auto-fixed.
2024-04-23 00:13:38 +02:00
Allison Karlitskaya d474bdca0a test/static-code: copy mypy setup from bots/
Move our list of static files out of test/static-code (which is shared
with other projects).  Add testlib to that list.

This reduces the cost of running mypy on a warm cache from 20s to ~0.3s,
while expanding checking to every single Python file in the source tree.

A overall `test/static-code` run (minus `node_modules`) decreases from
~24s to ~4s.  The majority of that time is now in the json validity
checking rule (since it runs a separate python invocation for each
file).
2024-04-23 00:13:10 +02:00
Allison Karlitskaya 4bdf01e366 various: many typing-related fixups
In addition to fixing some issues, testlib is now strictly typed.
2024-04-23 00:13:10 +02:00
Allison Karlitskaya 6b590189d6 testlib: drop todoPybridge decorator
We no longer gate tests on this, so it's safe to drop.

We leave the todoPybridgeRHEL8 decorator in place, since we plan to
bring back a scenario that involves running the Python bridge on RHEL8,
but for now, we make it a non-op.
2024-04-23 00:13:10 +02:00
Allison Karlitskaya b2c4b07b48 test/common/__init__.py: drop this file
test/common is in the Python Path, which means that it's not a module.
Drop this file.
2024-04-23 00:13:10 +02:00
Allison Karlitskaya cb2b61553c tap-cdp: fix a case of module shadowing
We `import cdp` and later set `cdp = cdp.CDP()`.  That might confuse
people who think that they could call other things from the `cdp`
module.

Just do `from cdp import CDP` and then `cdp = CD()` to avoid the issue.
2024-04-23 00:13:10 +02:00
Allison Karlitskaya 60d54b8a31 tools: rename vulture(- → _)suppressions
We are about to ask mypy to run on the entire source tree, and it
doesn't like having `-` in module names.  Use a `_` instead.
2024-04-23 00:13:10 +02:00
Allison Karlitskaya bdae67c4e6 pywrap: simplify bots python path
We no longer need to have `machine` in the path — we refer to everything
in bots with its fully-qualified name, the same way it's now done in the
bots repository itself.
2024-04-23 00:13:10 +02:00
Allison Karlitskaya 740047ab2a test/static-code: speed up JSON validation
After mypy (addressed in #20342) the slowest thing in test/static-code
is... JSON validation.  This is caused by the fact that `json.tool`
doesn't support multiple filenames, so we have to invoke it separately
for every single JSON file (and we have many).

Replace that with a small script which runs in a single Python
invocation and improves the output by printing the name of the file
containing the failure (which `json.tool` doesn't do).  This saves us a
sed invocation after the fact.
2024-04-23 00:10:26 +02:00
Jelle van der Waa 40fab56cba lib: initial typing for cockpit.spawn
Implements some rough typing for cockpit.spawn, this is already useful
to lint `cockpit.spawn`'s options in our codebase and found instances
where we pass a boolean to `superuser`.
2024-04-22 12:42:49 +02:00
Jelle van der Waa 61e5addb28 playground: superuser option is a string not a bool
While the bridge converts it from true to "require", it does not convert
false and our protocol documentation states that it should be a string.
2024-04-19 13:41:28 +02:00
Jelle van der Waa f881405c00 systemd: superuser option is a string not a bool
While the bridge converts it from true to "require", it does not convert
false and our protocol documentation states that it should be a string.
2024-04-19 13:41:28 +02:00
Jelle van der Waa d93e816acd sosreport: superuser option is a string not a bool
While the bridge converts it from true to "require", it does not convert
false and our protocol documentation states that it should be a string.
2024-04-19 13:41:28 +02:00
Jelle van der Waa c586ec8de4 lib: superuser option is a string not a bool
While the bridge converts it from true to "require", it does not convert
false and our protocol documentation states that it should be a string.
2024-04-19 13:41:28 +02:00
Jelle van der Waa 669f28539d selinux: superuser option is a string not a bool
While the bridge converts it from true to "require", it does not convert
false and our protocol documentation states that it should be a string.
2024-04-19 13:41:28 +02:00
Jelle van der Waa 9f93271115 storaged: superuser option is a string not a bool
While the bridge converts it from true to "require", it does not convert
false and our protocol documentation states that it should be a string.
2024-04-19 13:41:28 +02:00
Jelle van der Waa c43b3289d8 lib: add typing for dbus related variant and bytearray functions 2024-04-19 11:29:21 +02:00
dependabot[bot] 9b843c89d6 Bump the patternfly group with 6 updates
Bumps the patternfly group with 6 updates:

| Package | From | To |
| --- | --- | --- |
| [@patternfly/patternfly](https://github.com/patternfly/patternfly) | `5.2.1` | `5.3.0` |
| [@patternfly/react-core](https://github.com/patternfly/patternfly-react) | `5.2.3` | `5.3.0` |
| [@patternfly/react-icons](https://github.com/patternfly/patternfly-react) | `5.2.1` | `5.3.0` |
| @patternfly/react-styles | `5.2.1` | `5.3.0` |
| [@patternfly/react-table](https://github.com/patternfly/patternfly-react) | `5.2.4` | `5.3.0` |
| [@patternfly/react-tokens](https://github.com/patternfly/patternfly-react) | `5.2.1` | `5.3.0` |

Updates `@patternfly/patternfly` from 5.2.1 to 5.3.0
- [Release notes](https://github.com/patternfly/patternfly/releases)
- [Changelog](https://github.com/patternfly/patternfly/blob/main/release.config.js)
- [Commits](https://github.com/patternfly/patternfly/compare/patch-v5.2.1...v5.3.0)

Updates `@patternfly/react-core` from 5.2.3 to 5.3.0
- [Release notes](https://github.com/patternfly/patternfly-react/releases)
- [Commits](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-core@5.2.3...@patternfly/react-core@5.3.0)

Updates `@patternfly/react-icons` from 5.2.1 to 5.3.0
- [Release notes](https://github.com/patternfly/patternfly-react/releases)
- [Commits](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-icons@5.2.1...@patternfly/react-icons@5.3.0)

Updates `@patternfly/react-styles` from 5.2.1 to 5.3.0

Updates `@patternfly/react-table` from 5.2.4 to 5.3.0
- [Release notes](https://github.com/patternfly/patternfly-react/releases)
- [Commits](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-table@5.2.4...@patternfly/react-table@5.3.0)

Updates `@patternfly/react-tokens` from 5.2.1 to 5.3.0
- [Release notes](https://github.com/patternfly/patternfly-react/releases)
- [Commits](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-tokens@5.2.1...@patternfly/react-tokens@5.3.0)

---
updated-dependencies:
- dependency-name: "@patternfly/patternfly"
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: patternfly
- dependency-name: "@patternfly/react-core"
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: patternfly
- dependency-name: "@patternfly/react-icons"
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: patternfly
- dependency-name: "@patternfly/react-styles"
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: patternfly
- dependency-name: "@patternfly/react-table"
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: patternfly
- dependency-name: "@patternfly/react-tokens"
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: patternfly
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-19 11:19:56 +02:00
Allison Karlitskaya 850feb23be test: port test-format to typescript
This was pretty much completely pain-free, with a minor exception: the
test overrides the `cockpit.language` attribute, which we would
otherwise probably declare as `const`.
2024-04-19 10:45:07 +02:00
Allison Karlitskaya ef5fa2d0ac cockpit.js: add new number formatting API style
Add a new simplified style for all of the units-based number formatting
APIs (bytes, bytes/sec, bits/sec).  Keep loose versions of the old APIs
around in `cockpit.d.ts`, but mark them deprecated.

Make sure we test the new API variant from test-format.js.
2024-04-19 10:45:07 +02:00
Allison Karlitskaya a49d9e33de storage: add a testcase for format_fsys_usage()
Let's make sure we don't regress this with changes to
`cockpit.format_units()`.
2024-04-19 10:45:07 +02:00
Allison Karlitskaya 5ea8c3e60b test: use f-strings in asserts in test-format
Use our fancy new tagged templates to name our assertions in
test-format.  In addition to being a lot easier (and shorter) to write,
it means we see `{"precision": 2}` instead of `[object Object]`.

Also, leave out the value that we're comparing it equal to.  This value
is already displayed on assertion failures, and having it shown twice
only makes the output harder to read.
2024-04-19 10:45:07 +02:00
Allison Karlitskaya 2a9d5bf31b test: add f`` tagged template string helper
Add a small function called f() to qunit-tests.ts.  It is intended to be
used as a tagged template string format function.

The default formatting for template strings passes each argument to
String(), which means that objects get formatted like:

  [object Object]

This function formats them using JSON, so you can see the actual object
value.

It can be imported into any QUnit test and used like:

  f`format_bytes_per_sec(${checks[i][0]}, ${checks[i][1]}, ${checks[i][2]})`

which produces output like:

  ok 121 - format_bytes_per_sec: format_bytes_per_sec(25555678, "kB/s", {"precision":2})
2024-04-19 10:45:07 +02:00
Allison Karlitskaya 577afa3600 storaged: simplify utils.get_byte_units()
Thanks to Martin for some ideas there.
2024-04-19 10:45:07 +02:00
Allison Karlitskaya e0c65de407 base1: drop cockpit.get_byte_units() API
This has a single user (in storaged) and is more general than it needs
to be to support that user.  Hardcode it to SI-based units and move it
into storaged/utils.js, so we can keep the unit tests.

The unit tests themselves only test the 1024 case (which is the opposite
of what is actually used in practice) so adjust them for SI (mostly by
renaming variables and changing `1024`s to `1000`s).
2024-04-19 10:45:07 +02:00
Martin Pitt 4d7fcbfebb tools: Depend on kdumpctl binary
`kdumpctl` moved from the kexec-tools to the kdump-utils package in
Fedora Rawhide, and the former does not require the latter. To make sure
we get the one we want, depend on the program path directly.

https://bugzilla.redhat.com/show_bug.cgi?id=2275385
2024-04-19 09:42:10 +02:00
Martin Pitt ae44e9457f test: Adjust special cases for CentOS/RHEL 10
- Generalize the nginx skip (it's also not installed on
   centos-9-stream, we just never have started to test it there on our
   CI)
 - vdo and wireguard are not currently available in RHEL 10
 - NM team devices are not supported, see
   https://issues.redhat.com/browse/RHEL-33026
2024-04-19 09:27:41 +02:00
Martin Pitt a41a3ca54c test: Unbreak half of podman on RHEL 10
Add workaround for https://bugzilla.redhat.com/show_bug.cgi?id=2273078

(The other half is https://issues.redhat.com/browse/RHEL-32905 -- user
containers are still doomed).
2024-04-19 09:27:41 +02:00
Martin Pitt 58f7d6a9c9 test: Make encrypt_root()'s old root fs destruction less aggressive
Completely wiping the currently running root partition is too
aggressive: During shutdown, recent versions of systemd-shutdown [1]
re-executes itself to free all open fds on the root fs (so that it can
be unmounted cleanly), which doesn't work if /usr/sbin/systemd-shutdown
is gone. This leads to reboot hanging at

```
[  OK  ] Reached target reboot.target - System Reboot.
[!!!!!!] Failed to execute shutdown binary.
```

Instead, make the partition unbootable by cleaning /etc (i.e. allowed
SSH keys, boot targets, etc.) Even that is redundant, as post reboot the
test already checks that it booted from the encrypted partition. But
let's keep the belt and suspenders.

[1] https://github.com/systemd/systemd/blob/main/src/shutdown/shutdown.c
2024-04-19 09:27:41 +02:00
Jelle van der Waa 9d94d911f2 test: stop using deprecated cgi module for multipart post parsing
Python 3.13 removes the cgi module and recommends using EmailMessage for
parsing a multipart section. This is a bit trickier as it needs a full
message with original Content-Type header and boundary.

As this runs inside our testvm we can't rely on for example the
`multipart` module.
2024-04-18 14:53:00 +02:00
Jelle van der Waa 41ed7872c6 test: testIdentifierReloading is not destructive
The test inserts messages in the journal, we do not clean up the journal
but other non-destructive tests circumvent showing old test messages
from a retry by starting the log since the start time of the test.
2024-04-18 14:32:21 +02:00
Jelle van der Waa 7f0a48efc0 test: testBridgeCLI is not destructive
This tests the CLI output of cockpit-bridge.
2024-04-18 14:32:21 +02:00
Martin Pitt 5516784bc7 test: Use `nft` instead of `iptables`
`iptables` has been a backwards compatibility shim for nftables for a
long time now, and finally does not work on CentOS/RHEL 10 any more.

The first case in TestConnection.testBasic takes the socket away on the
login page with a TCP reset reply. We can get the same effect by just
stopping the socket.

The second case silently drops the packets to cover the "reply timeout"
functionality of the shell. Replace `iptables` with the corresponding
`nft` commands. It would be nice to use firewalld for that, but that has
a default rule to always allow packets on established connections -- but
severing that is exactly the goal of this test.
2024-04-17 13:59:28 +02:00
Martin Pitt ef77aee7f7 test: Clean up systemd units after erasing packages
CentOS 10's rpm scripts don't properly reload systemd any more after
uninstalling a package, so that `pmlogger.service` still exists in
systemd's brain afterwards (as loaded/inactive). The same is true for
stratisd.service and others, so this is not pcp specific.

Explicitly reload systemd to purge units which don't exist on disk any
more from systemd's brain. This fixes TestClient.testBeibootNoBridge on
CentOS 10, which checks the case that `pcp.service` does not exist.
2024-04-17 13:59:28 +02:00
Martin Pitt 5f959822fd test: Less aggressive pmlogger log cleaning in TestGrafanaClient
Don't remove the /var/log/pcp/pmlogger directory itself, just its
content, like we do in all other tests. Latest pcp version fails to
start up if the directory isn't present. This is a regression [1], but
also there's no need to be that demanding.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=2275408

Fixes #20327
2024-04-17 10:19:54 +02:00
dependabot[bot] 454126a086 Bump @types/react from 18.2.78 to 18.2.79 in the types group
Bumps the types group with 1 update: [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react).

Updates `@types/react` from 18.2.78 to 18.2.79
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react)

---
updated-dependencies:
- dependency-name: "@types/react"
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: types
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-17 07:20:38 +02:00
GitHub Workflow 9e187dce58 po: Update from Fedora Weblate
Closes #20325
2024-04-17 07:18:27 +02:00
Allison Karlitskaya 18ec3fa7f0 test: support typescript on qunit tests
Rename qunit-tests.js to .ts and stop hanging our functions on the main
QUnit object (which isn't typesafe).  We can just export them from our
module.  Adjust the users accordingly.

Add explicit file extensions to the list of tests in files.js (removing
the hardcoded '.js' from build.js) and add our first .ts case.

This new case tests that `cockpit.assert()` works properly in the
positive and negative cases and also verifies that it can be used for
type narrowing (otherwise tsc would complain).
2024-04-16 18:21:36 +02:00
Allison Karlitskaya bfc4186b2a bridge: fix a `(a and b) or c` case
...this got merged in parallel to the ruff work, so it slipped through
the cracks.
2024-04-16 17:17:40 +02:00
Jelle van der Waa 59276ed5ef lib: type all format related functions 2024-04-16 14:38:40 +02:00