Skip to content

Commit c21ad0a

Browse files
pb8owearyzen
authored andcommitted
test: add a test to check for correct internal links, and fix them
Add a test to check that internal links in markdown files are correct. Also restrict both markdown tests to only check for files within the git repo. Signed-off-by: Pablo Barbáchano <[email protected]>
1 parent 6bdc53d commit c21ad0a

File tree

5 files changed

+33
-17
lines changed

5 files changed

+33
-17
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ and this project adheres to
10071007
- Apache-2.0 license
10081008
- Docs:
10091009
- [charter](CHARTER.md)
1010-
- [contribution guildelines](CONTRIBUTE.md)
1010+
- [contribution guidelines](CONTRIBUTING.md)
10111011
- [design](docs/design.md)
10121012
- [getting started guide](docs/getting-started.md)
10131013
- [security policy](SECURITY.md)

docs/api_requests/block-vhost-user.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
> \[!WARNING\]
44
>
55
> Support is currently in **developer preview**. See
6-
> [this section](RELEASE_POLICY.md#developer-preview-features) for more info.
6+
> [this section](../RELEASE_POLICY.md#developer-preview-features) for more info.
77
88
As an alternative to [file-backed block device](block-io-engine.md) `Sync` and
99
`Async` engines, Firecracker supports a vhost-user block device.

docs/metrics.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,20 @@ present in each metrics json object emitted by Firecracker:
109109

110110
Below table explains where Firecracker metrics are defined :
111111

112-
| Metrics key | Device | Additional comments |
113-
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
114-
| balloon | [BalloonDeviceMetrics](../src/vmm/src/devices/virtio/balloon/metrics.rs) | Respresent metrics for the Balloon device. |
115-
| block | [BlockDeviceMetrics](../src/vmm/src/devices/virtio/virtio_block/metrics.rs) | Respresent aggregate metrics for Virtio Block device. |
116-
| block\_{block_drive_id} | [BlockDeviceMetrics](../src/vmm/src/devices/virtio/virtio_block/metrics.rs) | Respresent Virtio Block device metrics for the endpoint `"/drives/{drive_id}"` e.g. `"block_rootfs":` represent metrics for the endpoint `"/drives/rootfs"` |
117-
| i8042 | [I8042DeviceMetrics](../src/vmm/src/devices/legacy/i8042.rs) | Respresent Metrics specific to the i8042 device. |
118-
| net | [NetDeviceMetrics](../src/vmm/src/devices/virtio/net/metrics.rs) | Respresent aggregate metrics for Virtio Net device. |
119-
| net\_{iface_id} | [NetDeviceMetrics](../src/vmm/src/devices/virtio/net/metrics.rs) | Respresent Virtio Net device metrics for the endpoint `"/network-interfaces/{iface_id}"` e.g. `net_eth0` represent metrics for the endpoint `"/network-interfaces/eth0"` |
120-
| rtc | [RTCDeviceMetrics](../src/vmm/src/devices/legacy/serial.rs) | Respresent Metrics specific to the RTC device. `Note`: this is emitted only on `aarch64`. |
121-
| uart | [SerialDeviceMetrics](../src/vmm/src/devices/legacy/serial.rs) | Respresent Metrics specific to the serial device. |
122-
| vhost_user\_{dev}\_{dev_id} | [VhostUserDeviceMetrics](../src/vmm/src/devices/virtio/vhost_user_metrics.rs) | Respresent Vhost-user device metrics for the device `dev` and device id `dev_id`. e.g. `"vhost_user_block_rootfs":` represent metrics for vhost-user block device having the endpoint `"/drives/rootfs"` |
123-
| vsock | [VsockDeviceMetrics](../src/vmm/src/devices/virtio/vsock/metrics.rs) | Respresent Metrics specific to the vsock device. |
124-
| entropy | [EntropyDeviceMetrics](../src/vmm/src/devices/virtio/rng/metrics.rs) | Respresent Metrics specific to the entropy device. |
125-
| "api_server"<br>"deprecated_api"<br>"get_api_requests"<br>"latencies_us"<br>"logger"<br>"mmds"<br>"patch_api_requests"<br>"put_api_requests"<br>"seccomp"<br>"signals"<br>"vcpu"<br>"vmm" | [metrics.rs](../src/vmm/src/logger/metrics.rs) | Rest of the metrics are defined in the same file metrics.rs. |
112+
| Metrics key | Device | Additional comments |
113+
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
114+
| balloon | [BalloonDeviceMetrics](../src/vmm/src/devices/virtio/balloon/metrics.rs) | Represent metrics for the Balloon device. |
115+
| block | [BlockDeviceMetrics](../src/vmm/src/devices/virtio/block/virtio/metrics.rs) | Represent aggregate metrics for Virtio Block device. |
116+
| block\_{block_drive_id} | [BlockDeviceMetrics](../src/vmm/src/devices/virtio/block/virtio/metrics.rs) | Represent Virtio Block device metrics for the endpoint `"/drives/{drive_id}"` e.g. `"block_rootfs":` represent metrics for the endpoint `"/drives/rootfs"` |
117+
| i8042 | [I8042DeviceMetrics](../src/vmm/src/devices/legacy/i8042.rs) | Represent Metrics specific to the i8042 device. |
118+
| net | [NetDeviceMetrics](../src/vmm/src/devices/virtio/net/metrics.rs) | Represent aggregate metrics for Virtio Net device. |
119+
| net\_{iface_id} | [NetDeviceMetrics](../src/vmm/src/devices/virtio/net/metrics.rs) | Represent Virtio Net device metrics for the endpoint `"/network-interfaces/{iface_id}"` e.g. `net_eth0` represent metrics for the endpoint `"/network-interfaces/eth0"` |
120+
| rtc | [RTCDeviceMetrics](../src/vmm/src/devices/legacy/serial.rs) | Represent Metrics specific to the RTC device. `Note`: this is emitted only on `aarch64`. |
121+
| uart | [SerialDeviceMetrics](../src/vmm/src/devices/legacy/serial.rs) | Represent Metrics specific to the serial device. |
122+
| vhost_user\_{dev}\_{dev_id} | [VhostUserDeviceMetrics](../src/vmm/src/devices/virtio/vhost_user_metrics.rs) | Represent Vhost-user device metrics for the device `dev` and device id `dev_id`. e.g. `"vhost_user_block_rootfs":` represent metrics for vhost-user block device having the endpoint `"/drives/rootfs"` |
123+
| vsock | [VsockDeviceMetrics](../src/vmm/src/devices/virtio/vsock/metrics.rs) | Represent Metrics specific to the vsock device. |
124+
| entropy | [EntropyDeviceMetrics](../src/vmm/src/devices/virtio/rng/metrics.rs) | Represent Metrics specific to the entropy device. |
125+
| "api_server"<br>"deprecated_api"<br>"get_api_requests"<br>"latencies_us"<br>"logger"<br>"mmds"<br>"patch_api_requests"<br>"put_api_requests"<br>"seccomp"<br>"signals"<br>"vcpu"<br>"vmm" | [metrics.rs](../src/vmm/src/logger/metrics.rs) | Rest of the metrics are defined in the same file metrics.rs. |
126126

127127
Note: Firecracker emits all the above metrics regardless of the presense of that
128128
component i.e. even if `vsock` device is not attached to the Microvm,

docs/snapshotting/versioning.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ corresponding to the guest exposed features.
141141
## Implementation
142142

143143
The microVM state file format is implemented in the
144-
[snapshot module](../../src/vmm/src/snapshot/lib.rs) in the Firecracker
144+
[snapshot crate](../../src/vmm/src/snapshot/mod.rs) in the Firecracker
145145
repository. All Firecracker devices implement the
146146
[Persist](../../src/vmm/src/snapshot/persist.rs) trait which exposes an
147147
interface that enables creating from and saving to the microVM state.

tests/integration_tests/style/test_markdown.py

+16
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# SPDX-License-Identifier: Apache-2.0
33
"""Tests for markdown style checks."""
44

5+
import re
6+
57
from framework import utils, utils_repo
68

79

@@ -30,3 +32,17 @@ def test_markdown_style():
3032
assert (
3133
not needs_format
3234
), "Some markdown files need formatting. Either run `./tools/devtool sh mdformat .` in the repository root, or apply the above diffs manually."
35+
36+
37+
def test_markdown_internal_links():
38+
"""Make sure markdown internal links work"""
39+
40+
for md_file in utils_repo.git_repo_files(root="..", glob="*.md"):
41+
txt = md_file.read_text(encoding="utf-8")
42+
for link in re.findall(r"\[.+?\]\((?P<link>.+?)\)", txt, re.DOTALL):
43+
if not re.match("(mailto:|https?://)", link):
44+
# internal link, ignore anchors (#) and query (?)
45+
parts = link.split("#", maxsplit=1)
46+
parts = parts[0].split("?", maxsplit=1)
47+
path = md_file.parent / parts[0]
48+
assert path.exists(), f"{md_file} {link} {path}"

0 commit comments

Comments
 (0)