8000 ci: add nightly NFS and Docker lock tests (#324) by adityamukho · Pull Request #333 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@ jobs:
- name: Install tarpaulin
run: cargo install cargo-tarpaulin

- name: Build the pid_ns_helper example used by lock tests
# tarpaulin deletes target/debug/examples/ as part of its own
# instrumented build, regardless of when it was built, so this has to
# live in a target dir tarpaulin never touches. nfs_lock_test.rs and
# docker_lock_test.rs read MINIGRAF_PID_NS_HELPER for exactly this.
run: cargo build --examples --target-dir /tmp/minigraf-lock-test-examples

- name: Generate coverage
env:
MINIGRAF_PID_NS_HELPER: /tmp/minigraf-lock-test-examples/debug/examples/pid_ns_helper
run: cargo tarpaulin --out Xml --timeout 300 --fail-under 75 --exclude-files "src/main.rs"

- name: Upload coverage to Codecov
Expand Down
15 10BC8 9 changes: 159 additions & 0 deletions .github/workflows/nfs-lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
name: NFS/Docker lock tests (nightly)

# Tiers 2 and 3 of the kernel file-locking design
# (docs/superpowers/specs/2026-08-22-kernel-file-locking-design.md): the
# per-PR suite (tests/pid_namespace_test.rs) covers PID namespaces but cannot
# reach how `std::fs::File::try_lock` behaves on a network filesystem or in
# real containers. See #324.

on:
schedule:
- cron: "41 2 * * *"
workflow_dispatch:

permissions:
contents: read
issues: write

jobs:
nfs:
name: NFS lock suite
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- uses: actions/checkout@v4

- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable

- name: Install and start a loopback NFS server
run: |
sudo apt-get update -y
sudo apt-get install -y nfs-kernel-server nfs-common
sudo modprobe nfsd || true

sudo mkdir -p /srv/nfs/export
sudo chown "$(id -u)":"$(id -g)" /srv/nfs/export
echo "/srv/nfs/export 127.0.0.1(rw,sync,no_subtree_check,no_root_squash,insecure)" \
| sudo tee -a /etc/exports
sudo exportfs -ra
sudo systemctl restart nfs-kernel-server

- name: Mount the export as NFSv4 and as NFSv3 without lockd
run: |
sudo mkdir -p /mnt/nfs-v4 /mnt/nfs-v3-nolock
sudo mount -t nfs -o vers=4,proto=tcp 127.0.0.1:/srv/nfs/export /mnt/nfs-v4
sudo mount -t nfs -o vers=3,nolock 127.0.0.1:/srv/nfs/export /mnt/nfs-v3-nolock
sudo chown "$(id -u)":"$(id -g)" /mnt/nfs-v4 /mnt/nfs-v3-nolock

- name: Build the PID-namespace helper binary
run: cargo build --examples

- name: Run the NFS lock suite
shell: bash
env:
MINIGRAF_NFS_TEST_DIR_V4: /mnt/nfs-v4
MINIGRAF_NFS_TEST_DIR_V3_NOLOCK: /mnt/nfs-v3-nolock
RUST_BACKTRACE: 1
run: |
set -o pipefail
cargo test --test nfs_lock_test -- --nocapture 2>&1 | tee nfs-lock-output.txt

- name: Record NFS lock-suite failure
if: ${{ failure() }}
shell: bash
env:
GH_TOKEN: ${{ github.token }}
ISSUE_TITLE: "Nightly NFS lock-suite failure"
run: |
report_file="nfs-lock-failure.md"
{
echo "The nightly NFS lock suite failed."
echo
echo "- Run: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
echo "- Commit: $GITHUB_SHA"
echo "- Reproduce: needs a loopback NFS export mounted as vers=4 and as"
echo " vers=3,nolock; see the \"nfs\" job in .github/workflows/nfs-lock.yml"
echo
echo "## Test output"
echo
echo '```text'
tail -n 1000 nfs-lock-output.txt
echo '```'
} > "$report_file"

existing_issue="$(gh issue list \
--repo "$GITHUB_REPOSITORY" \
--state open \
--search "$ISSUE_TITLE in:title" \
--json number,title \
--limit 100 \
--jq '.[] | select(.title == "Nightly NFS lock-suite failure") | .number' \
| head -n 1)"

if [ -n "$existing_issue" ]; then
gh issue comment "$existing_issue" --repo "$GITHUB_REPOSITORY" --body-file "$report_file"
else
gh issue create --repo "$GITHUB_REPOSITORY" --title "$ISSUE_TITLE" --body-file "$report_file"
fi

docker:
name: Docker lock suite
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- uses: actions/checkout@v4

- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable

- name: Build the PID-namespace helper binary
run: cargo build --examples

- name: Run the Docker lock suite
shell: bash
env:
RUST_BACKTRACE: 1
run: |
set -o pipefail
cargo test --test docker_lock_test -- --nocapture 2>&1 | tee docker-lock-output.txt

- name: Record Docker lock-suite failure
if: ${{ failure() }}
shell: bash
env:
GH_TOKEN: ${{ github.token }}
ISSUE_TITLE: "Nightly Docker lock-suite failure"
run: |
report_file="docker-lock-failure.md"
{
echo "The nightly Docker lock suite failed."
echo
echo "- Run: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
echo "- Commit: $GITHUB_SHA"
echo "- Reproduce: needs a reachable Docker daemon; see the \"docker\" job"
echo " in .github/workflows/nfs-lock.yml"
echo
echo "## Test output"
echo
echo '```text'
tail -n 1000 docker-lock-output.txt
echo '```'
} > "$report_file"

existing_issue="$(gh issue list \
--repo "$GITHUB_REPOSITORY" \
--state open \
--search "$ISSUE_TITLE in:title" \
--json number,title \
--limit 100 \
--jq '.[] | select(.title == "Nightly Docker lock-suite failure") | .number' \
| head -n 1)"

if [ -n "$existing_issue" ]; then
gh issue comment "$existing_issue" --repo "$GITHUB_REPOSITORY" --body-file "$report_file"
else
gh issue create --repo "$GITHUB_REPOSITORY" --title "$ISSUE_TITLE" --body-file "$report_file"
fi
19 changes: 18 additions & 1 deletion examples/pid_ns_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,24 @@ fn main() {
// than an env var so it survives `sudo` -- see the note above.
let release_marker = args.get(3).map(std::path::PathBuf::from);

match minigraf::Minigraf::open(path) {
// Validate the mode up front rather than falling through to a plain open
// for anything unrecognized: a typo'd or not-yet-implemented mode must
// fail loudly, not silently behave like "open".
if !["hold", "open", "open-unlocked"].contains(&mode.as_str()) {
eprintln!("unknown mode: {mode}");
std::process::exit(2);
}

let open_result = if mode == "open-unlocked" {
minigraf::OpenOptions::default()
.allow_unlocked(true)
.path(path)
.open()
} else {
minigraf::Minigraf::open(path)
};

match open_result {
Ok(db) => {
db.execute(r#"(transact [[:a :name "A"]])"#).ok();
println!("OPEN_OK");
Expand Down
Loading
Loading
0